/* ═══════════════════════════════════════════
   Federal Expenses Dashboard — Design System
   ═══════════════════════════════════════════ */

:root {
  /* Color palette — Dark finance theme */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1f2a42;
  --bg-controls: #0f1520;
  --bg-input: #151d2e;

  --text-primary: #f0f4fc;
  --text-secondary: #8b95b0;
  --text-muted: #5a6580;

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;
  --accent-pink: #ec4899;

  --positive: #10b981;
  --negative: #f43f5e;

  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ═══════════ Header ═══════════ */
.header {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, rgba(10, 14, 23, 0.98) 100%);
  border-bottom: 1px solid var(--border);
  /* Header scrolls away — NOT sticky */
}

.header-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f0f4fc 0%, #8bb8f8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.data-status.loaded {
  color: var(--positive);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hobo-link {
  display: inline-block;
  transition: all 0.3s ease;
}

.hobo-link:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.hobo-img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-light);
  transition: border-color 0.3s ease;
}

.hobo-link:hover .hobo-img {
  border-color: var(--accent-blue);
}

.canada-flag {
  font-size: 1rem;
  -webkit-text-fill-color: initial;
  background: none;
  -webkit-background-clip: unset;
}

/* ═══════════ Controls Bar ═══════════ */
.controls-bar {
  background: var(--bg-controls);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.controls-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.controls-row {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  z-index: 50;
  position: relative;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 250px;
}

.control-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Custom Dropdown Styles */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-trigger {
  padding: 12px 16px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  user-select: none;
}

.dropdown-trigger:hover,
.custom-dropdown.open .dropdown-trigger {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dropdown-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.dropdown-arrow {
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.2s ease;
}

.custom-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

.custom-dropdown.open .dropdown-menu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.dropdown-search {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
}

.dropdown-search input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
}

.dropdown-search input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.dropdown-options {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
}

.dropdown-list {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
}

.dropdown-list::-webkit-scrollbar {
  width: 6px;
}

.dropdown-list::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Hierarchy Items */
.dd-item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  transition: background 0.15s ease;
  user-select: none;
}

.dd-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dd-item.selected {
  background: rgba(59, 130, 246, 0.1);
}

.dd-item.is-parent {
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.dd-item.is-parent .dd-icon {
  color: var(--accent-blue);
  font-size: 1.1rem;
}

.dd-item.is-child {
  padding-left: 38px;
  color: var(--text-secondary);
}

.dd-item.is-child:hover {
  color: var(--text-primary);
}

/* Checkboxes for multi-select */
.dd-checkbox {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.dd-item.selected .dd-checkbox {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='10' height='8' viewBox='0 0 10 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4L3.5 6.5L9 1' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

/* Buttons */
.quick-btn {
  padding: 6px 12px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.quick-btn:hover {
  color: white;
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

/* Slicer Row */
.slicer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.slicer-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slicer-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.slicer-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.slicer-btn {
  padding: 8px 14px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.slicer-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.slicer-btn.active {
  background: linear-gradient(135deg, var(--accent-blue), #2563eb);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.slicer-color-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.7;
}

.slicer-btn.active .slicer-color-indicator {
  opacity: 1;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Combine Toggle Switch */
.toggle-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.toggle-group label:first-child {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
}

input:checked+.slider {
  background: linear-gradient(135deg, var(--accent-blue), #2563eb);
  border-color: transparent;
}

input:checked+.slider:before {
  background-color: white;
  transform: translateX(22px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.slider.round {
  border-radius: 26px;
}

.slider.round:before {
  border-radius: 50%;
}

/* ═══════════ Main Content ═══════════ */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ═══════════ Summary Cards ═══════════ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card:hover::before {
  opacity: 1;
}

.card-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.card-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ═══════════ Chart Container ═══════════ */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  min-height: 480px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-wrapper {
  position: relative;
  height: 440px;
  display: none;
}

.chart-wrapper.active {
  display: block;
}

.chart-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}

.chart-empty-state p {
  font-size: 1rem;
  font-weight: 500;
}

.chart-empty-state .hint {
  font-size: 0.82rem;
  font-weight: 400;
  opacity: 0.6;
}

.chart-empty-state.hidden {
  display: none;
}

/* ═══════════ Footer ═══════════ */
.footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 32px 32px;
  text-align: center;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 900px) {
  .controls-row {
    flex-direction: column;
    gap: 16px;
  }

  .control-group {
    min-width: 100%;
  }

  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .slicer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .toggle-group {
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  html {
    font-size: 14px;
  }

  .header-content {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
  }

  .header h1 {
    font-size: 1rem;
  }

  .controls-content {
    padding: 0 16px;
  }

  .main-content {
    padding: 16px;
  }

  .summary-cards {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .card {
    padding: 14px 16px;
  }

  .card-value {
    font-size: 1.3rem;
  }

  .chart-container {
    padding: 16px;
    min-height: 350px;
  }

  .chart-wrapper {
    height: 300px;
  }

  .chart-empty-state {
    height: 260px;
  }

  .slicer-buttons {
    gap: 6px;
  }

  .slicer-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
  }

  .dropdown-menu {
    max-height: 300px;
  }

  .footer {
    padding: 16px;
  }
}

@media (max-width: 400px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .header h1 {
    font-size: 0.9rem;
  }

  .hobo-img {
    width: 32px;
    height: 32px;
  }
}