/* ==========================================================================
   RESPIRA ORIAN - Enterprise Sales Intelligence Design System
   Modern, Professional, Minimal, Zero-Overlap, Optimized Compact Table
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  /* Color Palette - Restrained Enterprise Theme */
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #eff6ff;
  
  --color-target: #2563eb;
  --color-cn: #64748b;
  --color-effective: #4f46e5;
  --color-online: #16a34a;
  --color-apollo: #9333ea;
  --color-trade: #ea580c;
  --color-total-bkg: #1d4ed8;
  --color-remain: #d97706;
  --color-today: #db2777;

  /* Theme: Light */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: #3b82f6;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --bg-hover: #1f293d;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-disabled: #64748b;

  --border-color: #1e293b;
  --border-subtle: #162032;
  --border-focus: #60a5fa;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

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

html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ==========================================================================
   App Header & Modern Enterprise Navigation
   ========================================================================== */
.app-header {
  background-color: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.02);
  width: 100%;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] .app-header {
  background-color: rgba(15, 23, 42, 0.92);
  border-bottom-color: rgba(30, 41, 59, 0.8);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
}

.header-container {
  max-width: 1720px;
  margin: 0 auto;
  padding: 8px 18px;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Branding Section */
.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.brand-group:hover {
  opacity: 0.92;
}

.brand-logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo-badge {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.28);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#app-header-logo {
  max-height: 40px;
  max-width: 140px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  transition: transform 0.2s ease;
}

.brand-group:hover #app-header-logo {
  transform: scale(1.02);
}

.brand-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.15;
  margin: 0;
}

.brand-zone-tag {
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: #ffffff;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}

.brand-subtitle {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
  margin: 0;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  flex-grow: 1;
  justify-content: center;
}

.nav-tabs-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.nav-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .nav-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  background: var(--bg-surface);
  color: var(--color-primary);
  border-color: rgba(37, 99, 235, 0.15);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
  font-weight: 700;
}

[data-theme="dark"] .nav-tab-btn.active {
  background: #1e293b;
  border-color: rgba(96, 165, 250, 0.3);
  color: #60a5fa;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.nav-tab-icon {
  font-size: 12px;
  line-height: 1;
}

.dropdown-caret {
  font-size: 8px;
  transition: transform 0.15s ease;
  opacity: 0.7;
}

/* Management Nav Dropdown */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 5px;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  min-width: 250px;
  z-index: 1100;
  padding: 6px;
  animation: dropdownSlide 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .nav-dropdown-menu {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

@keyframes dropdownSlide {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.nav-dropdown-menu.show {
  display: block;
}

.dropdown-header-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 6px 10px 4px;
  text-transform: uppercase;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.12s ease;
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

[data-theme="dark"] .dropdown-item:hover {
  background: #334155;
}

.dropdown-item.active-item {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

[data-theme="dark"] .dropdown-item.active-item {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.3);
}

.dropdown-item-icon {
  font-size: 16px;
  line-height: 1;
  width: 22px;
  text-align: center;
}

.dropdown-item-info {
  display: flex;
  flex-direction: column;
}

.dropdown-item-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.dropdown-item.active-item .dropdown-item-title {
  color: var(--color-primary);
}

[data-theme="dark"] .dropdown-item.active-item .dropdown-item-title {
  color: #60a5fa;
}

.dropdown-item-desc {
  font-size: 9.5px;
  color: var(--text-muted);
  line-height: 1.2;
  margin-top: 1px;
}

/* Header Actions & Profile */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 4px 10px 4px 5px;
  border-radius: 9999px;
  transition: all 0.15s ease;
}

.user-profile-badge:hover {
  border-color: rgba(37, 99, 235, 0.3);
}

.user-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.user-profile-details {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-profile-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.user-profile-role {
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme="dark"] .user-profile-role {
  background: rgba(96, 165, 250, 0.2);
  color: #93c5fd;
}

/* Action Buttons */
.theme-toggle-btn,
.mobile-menu-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover,
.mobile-menu-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.mobile-menu-btn {
  display: none;
}

.btn-signout {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 6px 11px;
  border-radius: var(--radius-md);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-signout:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-signout:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* ==========================================================================
   Page Header Banner & Breadcrumbs
   ========================================================================== */
.page-header-banner {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.page-header-container {
  max-width: 1720px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-breadcrumb {
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  margin-bottom: 1px;
}

.breadcrumb-root {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb-separator {
  margin: 0 5px;
  color: var(--border-focus);
  opacity: 0.4;
}

.breadcrumb-category {
  color: var(--text-muted);
  font-weight: 600;
}

.breadcrumb-current {
  color: var(--color-primary);
  font-weight: 700;
}

[data-theme="dark"] .breadcrumb-current {
  color: #60a5fa;
}

.page-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-main-title {
  font-family: 'Outfit', sans-serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0;
}

.page-period-chip {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.page-main-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.3;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Responsive Header Media Queries (Desktop, Tablet, Mobile)
   ========================================================================== */
@media (max-width: 1180px) {
  .header-container {
    padding: 8px 12px;
    gap: 10px;
  }
  .nav-tab-btn {
    padding: 5px 9px;
    font-size: 11px;
  }
  .brand-subtitle {
    display: none;
  }
}

@media (max-width: 960px) {
  .mobile-menu-btn {
    display: flex;
  }

  .nav-tabs {
    display: none;
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    bottom: auto;
    background: var(--bg-surface);
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    z-index: 999;
  }

  .nav-tabs.mobile-open {
    display: block;
    animation: mobileDrawerSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes mobileDrawerSlide {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .nav-tabs-inner {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    gap: 6px;
  }

  .nav-tab-btn {
    width: 100%;
    padding: 10px 14px;
    font-size: 12.5px;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
  }

  .nav-tab-btn.active {
    background: rgba(37, 99, 235, 0.08);
    border-color: var(--color-primary);
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: 1px dashed var(--border-color);
    margin-top: 6px;
    width: 100%;
  }
}

@media (max-width: 580px) {
  .user-profile-details {
    display: none;
  }
  .signout-text {
    display: none;
  }
  .btn-signout {
    padding: 6px 8px;
  }
  .page-header-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .page-header-actions {
    width: 100%;
  }
}

/* ==========================================================================
   Main Wrapper & Page Header
   ========================================================================== */
.main-wrapper {
  max-width: 1680px;
  margin: 0 auto;
  padding: 12px 16px;
  width: 100%;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-title-group h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-title-group p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border: 1px solid #bfdbfe;
  padding: 3px 8px;
  border-radius: var(--radius-md);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

[data-theme="dark"] .scope-badge {
  background: rgba(37, 99, 235, 0.15);
  color: #93c5fd;
  border-color: rgba(37, 99, 235, 0.3);
}

/* Financial Unit Banner */
.unit-rule-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 10.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

[data-theme="dark"] .unit-rule-banner {
  background: rgba(22, 163, 74, 0.1);
  border-color: rgba(22, 163, 74, 0.25);
  color: #86efac;
}

/* ==========================================================================
   Modern Responsive KPI Cards (10 Cards Grid)
   ========================================================================== */
.kpi-ribbon {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 7px 8px;
  box-shadow: var(--shadow-xs);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-top: 2.5px solid var(--card-accent, #3b82f6);
  min-width: 0;
  overflow: hidden;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.kpi-title {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 1px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.kpi-val {
  font-family: 'Outfit', sans-serif;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.kpi-sub {
  font-size: 8.5px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* ==========================================================================
   Control Cards, Segmented View Hierarchy & Filter Panel
   ========================================================================== */
.control-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
  width: 100%;
}

.dimension-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.dim-label {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  margin-right: 4px;
  flex-shrink: 0;
}

.dim-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.dim-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.dim-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.25);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
  gap: 6px;
  align-items: flex-end;
  width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.form-group label {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-control {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 7px;
  border-radius: var(--radius-md);
  font-size: 10.5px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.filter-actions {
  display: flex;
  gap: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-md);
  font-size: 10.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--color-primary); color: #ffffff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--bg-subtle); border-color: var(--border-color); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--border-color); color: var(--text-primary); }
.btn-success { background: #16a34a; color: #ffffff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }

/* ==========================================================================
   Analytics Charts Section
   ========================================================================== */
.charts-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
  width: 100%;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

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

.chart-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-canvas-wrapper {
  position: relative;
  height: 180px;
  width: 100%;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 3px;
}

.leader-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 7px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  font-size: 10.5px;
}

.leader-name { font-weight: 600; color: var(--text-primary); }
.leader-val { font-weight: 700; font-family: 'Outfit', sans-serif; }

/* ==========================================================================
   Booking Analysis Data Table (Sticky Header, Sticky Col 1, Space-Optimized)
   ========================================================================== */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
  width: 100%;
  overflow: hidden;
}

.table-toolbar {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.table-search-box {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px 7px;
  width: 220px;
  max-width: 100%;
}

.table-search-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 10.5px;
  color: var(--text-primary);
  width: 100%;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* Dedicated Scroll Container with Sticky Vertical & Horizontal Freeze */
.table-scroll-container,
.table-responsive,
.table-wrapper {
  width: 100%;
  max-height: 65vh;
  min-height: 250px;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  position: relative;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 10.5px;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  text-align: right;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Sticky Header Rows */
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  z-index: 15;
  border-bottom: 2px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  min-width: 60px;
}

/* Column 1: Responsive Space-Optimized & Sticky Left */
.data-table thead th:first-child,
.data-table tbody td:first-child,
.data-table tfoot td:first-child {
  position: sticky;
  left: 0;
  text-align: left;
  width: clamp(180px, 18vw, 240px);
  min-width: 160px;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

/* Corner Intersection: Top-Left Header Cell (Highest z-index) */
.data-table thead th:first-child {
  top: 0;
  left: 0;
  z-index: 25;
  background: var(--bg-subtle);
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.08);
}

/* Data Row Sticky Column 1 */
.data-table tbody td:first-child {
  z-index: 10;
  background: var(--bg-surface);
}

.data-table tbody tr:hover td:first-child {
  background: var(--bg-hover);
}

.data-table tbody tr {
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

/* Hierarchical Subtotal Row Styling for Sticky Column 1 */
tr.row-zone td:first-child { background: #eff6ff !important; }
tr.row-region td:first-child { background: #f8fafc !important; }
tr.row-area td:first-child { background: #ffffff !important; }

[data-theme="dark"] tr.row-zone td:first-child { background: #1e293b !important; }
[data-theme="dark"] tr.row-region td:first-child { background: #182234 !important; }
[data-theme="dark"] tr.row-area td:first-child { background: #111827 !important; }

/* Hierarchical Subtotal Badges (Ultra Compact) */
.badge-zone {
  display: inline-flex;
  align-items: center;
  background: #1e3a8a;
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.badge-region {
  display: inline-flex;
  align-items: center;
  background: #dbeafe;
  color: #1e40af;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  flex-shrink: 0;
}

.badge-area {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 1px 3px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Sticky Footer Summary Row */
.data-table tfoot td {
  background: var(--bg-subtle);
  font-weight: 800;
  color: var(--text-primary);
  border-top: 2px solid var(--color-primary);
  position: sticky;
  bottom: 0;
  z-index: 12;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.04);
}

.data-table tfoot td:first-child {
  bottom: 0;
  left: 0;
  z-index: 22;
  background: var(--bg-subtle);
  box-shadow: 2px -2px 5px rgba(0, 0, 0, 0.07);
}

.pagination-bar {
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 6px;
}

/* ==========================================================================
   Modals & Dropzones
   ========================================================================== */
.upload-card-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  width: 100%;
}

.dropzone-box {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-app);
  transition: all 0.15s ease;
}

.dropzone-box:hover,
.dropzone-box.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.dropzone-icon { font-size: 20px; margin-bottom: 3px; }

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.modal-close-btn { background: transparent; border: none; font-size: 15px; color: var(--text-muted); cursor: pointer; }

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 2000;
  max-width: 90vw;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: 10.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 5px;
  animation: slideIn 0.2s ease forwards;
}

.toast-success { border-left: 4px solid #16a34a; }
.toast-error { border-left: 4px solid #dc2626; }
.toast-info { border-left: 4px solid var(--color-primary); }
.toast-warning { border-left: 4px solid #d97706; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Full Responsive Media Queries (Mobile, Tablet, Laptop, Desktop)
   ========================================================================== */
@media (max-width: 1400px) {
  .kpi-ribbon {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 1024px) {
  .charts-section {
    grid-template-columns: 1fr;
  }
  .kpi-ribbon {
    grid-template-columns: repeat(5, 1fr);
  }
  .data-table thead th:first-child,
  .data-table tbody td:first-child,
  .data-table tfoot td:first-child {
    width: clamp(150px, 20vw, 190px);
    min-width: 140px;
    max-width: 200px;
  }
}

@media (max-width: 768px) {
  .header-container {
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .brand-group {
    justify-content: space-between;
    width: 100%;
  }

  .nav-tabs {
    width: 100%;
    overflow-x: auto;
    padding: 2px;
  }

  .header-actions {
    justify-content: space-between;
    width: 100%;
  }

  .main-wrapper {
    padding: 10px 8px;
  }

  .page-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

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

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

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .table-search-box {
    width: 100%;
  }

  .table-actions {
    width: 100%;
  }

  .table-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Compact First Column on Mobile */
  .data-table thead th:first-child,
  .data-table tbody td:first-child,
  .data-table tfoot td:first-child {
    width: clamp(130px, 35vw, 160px);
    min-width: 125px;
    max-width: 170px;
  }
}

@media (max-width: 480px) {
  .kpi-ribbon {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .data-table thead th:first-child,
  .data-table tbody td:first-child,
  .data-table tfoot td:first-child {
    width: clamp(120px, 40vw, 150px);
    min-width: 115px;
    max-width: 155px;
  }
}
