:root {
  color-scheme: dark;
  --page-plane: #12141c;
  --sidebar-bg: #1a1d29;
  --surface-1: #1e2130;
  --surface-2: #262a3c;
  --text-primary: #f5f6fa;
  --text-secondary: #b3b7c6;
  --text-muted: #7d8194;
  --gridline: #2e3244;
  --baseline: #3a3f57;
  --border: rgba(255, 255, 255, 0.08);
  --success-text: #34d399;

  --series-1: #3987e5; /* blue */
  --series-2: #d95926; /* orange */
  --series-3: #199e70; /* aqua */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

#root {
  min-height: 100vh;
}
/* Shell layout */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0 12px;
  margin-bottom: 32px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: start;
  font-family: inherit;
}

.sidebar-nav-item:hover {
  background: var(--surface-1);
  color: var(--text-primary);
}

.sidebar-nav-icon {
  display: inline-flex;
  color: var(--series-1);
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-user {
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

/* Main content */
.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.main-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main-header h1 {
  font-size: 24px;
  margin: 0;
  color: var(--text-primary);
}

.mobile-nav-toggle {
  display: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
}

/* Login screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  background: var(--page-plane);
}

.login-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin-bottom: 8px;
}

.login-screen h1 {
  font-size: 22px;
  line-height: 1.4;
  margin: 0;
}

.login-button {
  background: var(--series-1);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
}

.auth-error {
  color: var(--series-2);
  font-size: 13px;
  max-width: 400px;
}

.logout-button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Filters bar */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
}

.filter-field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.date-range-inputs input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--surface-2);
  color: var(--text-primary);
  color-scheme: dark;
}

.date-range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.date-preset-combobox {
  position: relative;
}

.date-preset-toggle {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

.date-preset-toggle:hover {
  color: var(--text-primary);
}

.date-preset-dropdown {
  position: absolute;
  z-index: 10;
  top: 100%;
  margin-top: 4px;
  min-width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 6px;
  display: flex;
  flex-direction: column;
}

.date-preset-option {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: start;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.date-preset-option:hover {
  background: var(--surface-1);
  color: var(--text-primary);
}

.campaign-combobox {
  position: relative;
  width: 320px;
  max-width: 100%;
}

.campaign-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}

.campaign-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.campaign-chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 6px;
}

.campaign-search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14px;
}

.campaign-dropdown {
  position: absolute;
  z-index: 10;
  top: 100%;
  margin-top: 4px;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 6px;
}

.campaign-dropdown-empty {
  padding: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.campaign-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.campaign-option:hover {
  background: var(--surface-1);
}

.clear-selection {
  background: none;
  border: none;
  color: var(--series-1);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

/* Sections */
.dashboard-section {
  scroll-margin-top: 24px;
}

.dashboard-section h2 {
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.dashboard-section .section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

/* Executive summary layout */
.summary-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
}

.summary-layout .kpi-row {
  flex: 1;
  min-width: 280px;
}

/* KPI tiles */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.kpi-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  text-align: center;
}

.kpi-tile .kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-tile .kpi-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ROI ring */
.roi-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  flex-shrink: 0;
}

.roi-ring-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.roi-ring-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.roi-ring-caption {
  font-size: 12px;
  color: var(--text-muted);
}

/* Data tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-1);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: start;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

.data-table td {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.data-table td:first-child {
  color: var(--text-primary);
  font-variant-numeric: normal;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  position: sticky;
  top: 0;
  background: var(--surface-2);
}

.data-table tbody tr:hover td {
  background: var(--surface-2);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.state-message {
  padding: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.unmatched-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.video-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.video-tabs button {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
}

.video-tabs button.active {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}

@media (max-width: 900px) {
  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 260px;
    max-width: 80vw;
    z-index: 30;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  }

  .sidebar-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 20;
  }

  .main {
    padding: 20px;
  }
}
