/* ═══════════════════════════════════════════════════════════
   PERFORMANCEMAX V5 — DARK ANALYTICS TERMINAL AESTHETIC
   Bloomberg meets modern SaaS — with Light Mode support
═══════════════════════════════════════════════════════════ */

/* ─── DARK THEME (default) ─── */
:root, [data-theme="dark"] {
  --bg-base:       #0b0f14;
  --bg-card:       #151d28;
  --bg-card-hover: #1a2535;
  --bg-elevated:   #1f2d3d;
  --border:        #1a2535;
  --border-subtle: #0f1923;
  --border-bright: #253348;
  --text-primary:   #e8edf3;
  --text-secondary: #8ba0b8;
  --text-muted:     #4a6380;
  --text-dim:       #2a3f55;
  --green:  #10b981;
  --red:    #ef4444;
  --amber:  #f59e0b;
  --blue:   #3b82f6;
  --purple: #8b5cf6;
  --cyan:   #06b6d4;
  --pink:   #ec4899;
  --green-bg:  rgba(16, 185, 129, 0.12);
  --red-bg:    rgba(239, 68, 68, 0.12);
  --amber-bg:  rgba(245, 158, 11, 0.12);
  --blue-bg:   rgba(59, 130, 246, 0.12);
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --header-h:  56px;
  --datebar-h: 52px;
  --nav-h:     48px;
  --radius:    8px;
  --radius-sm: 5px;
  --radius-lg: 12px;
  --scanline-opacity: 0.025;
  --modal-bg: rgba(0,0,0,0.7);
}

/* ─── LIGHT THEME ─── */
[data-theme="light"] {
  --bg-base:       #f5f7fa;
  --bg-card:       #ffffff;
  --bg-card-hover: #f0f2f5;
  --bg-elevated:   #ffffff;
  --border:        #e2e5ea;
  --border-subtle: #edf0f3;
  --border-bright: #d1d5db;
  --text-primary:   #1a1d21;
  --text-secondary: #5a6371;
  --text-muted:     #9ca3af;
  --text-dim:       #d1d5db;
  --green-bg:  rgba(16, 185, 129, 0.08);
  --red-bg:    rgba(239, 68, 68, 0.08);
  --amber-bg:  rgba(245, 158, 11, 0.08);
  --blue-bg:   rgba(59, 130, 246, 0.08);
  --scanline-opacity: 0;
  --modal-bg: rgba(0,0,0,0.3);
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: var(--blue); text-decoration: none; }

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,var(--scanline-opacity)) 2px, rgba(0,0,0,var(--scanline-opacity)) 4px);
  pointer-events: none;
  z-index: 1000;
}

/* ═══ HEADER ═══════════════════════════════════════════════ */
.app-header {
  position: sticky; top: 0; z-index: 200;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg-base) 95%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; gap: 1rem;
}
.header-left, .header-right { display: flex; align-items: center; gap: 0.75rem; }
.logo { display: flex; align-items: center; gap: 0.6rem; }
.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }

.live-indicator {
  display: flex; align-items: center; gap: 5px;
  background: var(--green-bg); border: 1px solid rgba(16,185,129,0.2);
  border-radius: 20px; padding: 3px 10px;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse-live 2s infinite; }
.live-label { font-size: 10px; font-weight: 700; font-family: var(--font-mono); letter-spacing: 0.12em; color: var(--green); }
@keyframes pulse-live { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.client-selector-wrap { position: relative; }
.client-selector {
  display: flex; align-items: center; gap: 0.5rem; height: 34px; padding: 0 0.75rem;
  background: var(--bg-card); border: 1px solid var(--border-bright); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px; font-weight: 500;
  transition: border-color 0.15s, background 0.15s; min-width: 0; max-width: 220px;
}
.client-selector:hover { border-color: var(--blue); background: var(--bg-elevated); }
.client-icon { color: var(--text-secondary); flex-shrink: 0; }
.client-selector span:not(.client-icon) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: var(--text-muted); flex-shrink: 0; transition: transform 0.2s; }
.client-selector-wrap.open .chevron { transform: rotate(180deg); }

.client-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; width: 220px;
  background: var(--bg-elevated); border: 1px solid var(--border-bright);
  border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  z-index: 300; display: none; overflow: hidden;
}
.client-selector-wrap.open .client-dropdown { display: block; }
.dropdown-header { padding: 0.6rem 0.85rem; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.dropdown-client-item { width: 100%; padding: 0.6rem 0.85rem; text-align: left; color: var(--text-primary); font-size: 13px; transition: background 0.1s; display: flex; align-items: center; justify-content: space-between; }
.dropdown-client-item:hover { background: var(--bg-card-hover); }
.dropdown-client-item.active { color: var(--blue); }
.dropdown-divider { border-top: 1px solid var(--border); }
.dropdown-add-btn { width: 100%; padding: 0.6rem 0.85rem; text-align: left; color: var(--blue); font-size: 13px; display: flex; align-items: center; gap: 0.5rem; transition: background 0.1s; }
.dropdown-add-btn:hover { background: var(--bg-card-hover); }

.icon-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text-secondary);
  background: var(--bg-card); transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--border-bright); background: var(--bg-elevated); }
.settings-btn.active { color: var(--blue); border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.1); }

/* Theme toggle */
.theme-toggle-btn { position: relative; }

/* ═══ DATE BAR ══════════════════════════════════════════════ */
.date-bar {
  position: sticky; top: var(--header-h); z-index: 190;
  background: color-mix(in srgb, var(--bg-base) 95%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); height: var(--datebar-h);
}
.date-bar-inner { height: 100%; display: flex; align-items: center; gap: 0.75rem; padding: 0 1.25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.date-bar-inner::-webkit-scrollbar { display: none; }
.date-quick-btns { display: flex; gap: 4px; flex-shrink: 0; }
.date-btn {
  height: 28px; padding: 0 0.7rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12px; font-weight: 500; background: transparent;
  transition: all 0.15s; white-space: nowrap; min-height: 28px;
}
.date-btn:hover { border-color: var(--border-bright); color: var(--text-primary); }
.date-btn.active { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.35); color: var(--blue); }
.date-custom { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.date-input { height: 28px; padding: 0 0.5rem; border-radius: var(--radius-sm); border: 1px solid var(--border-bright); background: var(--bg-card); color: var(--text-primary); font-size: 12px; font-family: var(--font-mono); }
.date-sep { color: var(--text-muted); font-size: 12px; }
.date-apply-btn { height: 28px; padding: 0 0.75rem; background: var(--blue); color: white; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; }
.compare-toggle-wrap { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; flex-shrink: 0; }
.compare-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border-bright); border-radius: 20px; cursor: pointer; transition: background 0.2s; }
.toggle-slider::before { content: ''; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: transform 0.2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--blue); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ═══ MAIN NAV ══════════════════════════════════════════════ */
.main-nav {
  position: sticky; top: calc(var(--header-h) + var(--datebar-h)); z-index: 180;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg-base) 95%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.25rem; gap: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-tab {
  display: flex; align-items: center; gap: 0.4rem; height: 34px; padding: 0 0.875rem;
  border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px; font-weight: 500;
  transition: color 0.15s, background 0.15s; white-space: nowrap; flex-shrink: 0; min-height: 44px;
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-tab.active { color: var(--text-primary); background: rgba(59,130,246,0.1); border-bottom: 2px solid var(--blue); }

/* ═══ MAIN CONTENT ══════════════════════════════════════════ */
.app-main { padding: 1.25rem; max-width: 1600px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.product-sub-tabs { display: flex; gap: 8px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.pill-tab {
  height: 32px; padding: 0 1rem; border-radius: 20px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); border: 1px solid var(--border); background: transparent;
  transition: all 0.15s; min-height: 44px; display: flex; align-items: center;
}
.pill-tab:hover { color: var(--text-primary); border-color: var(--border-bright); }
.pill-tab.active { color: var(--blue); border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.08); }

.product-panel { display: none; }
.product-panel.active { display: block; animation: fadeIn 0.15s ease; }

/* ─── MINI KPI ROW ─── */
.mini-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.mini-kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.875rem 1rem; transition: border-color 0.15s; }
.mini-kpi:hover { border-color: var(--border-bright); }
.mini-kpi-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.mini-kpi-value { font-size: 20px; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); line-height: 1.2; }
.mini-kpi-delta { font-size: 11px; font-family: var(--font-mono); margin-top: 3px; display: flex; align-items: center; gap: 3px; }
.delta-up { color: var(--green); } .delta-down { color: var(--red); }

/* ─── DATA TABLE ─── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-lg); border: 1px solid var(--border); margin-bottom: 0.75rem; background: var(--bg-card); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.data-table th { padding: 0.65rem 0.875rem; text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg-base) 60%, transparent); white-space: nowrap; }
.data-table th.num-col { text-align: right; }
.data-table th.cf-col { color: var(--cyan); }
.data-table td { padding: 0.7rem 0.875rem; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; white-space: nowrap; }
.data-table td.num-col { text-align: right; font-family: var(--font-mono); font-size: 12.5px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-card-hover); cursor: pointer; }
.data-table tbody tr.expanded { background: rgba(59, 130, 246, 0.04); }
.data-table tbody tr.expanded td:first-child { border-left: 3px solid var(--blue); }

.product-name-cell { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.product-expand-icon { width: 18px; height: 18px; border-radius: 4px; background: var(--bg-elevated); border: 1px solid var(--border-bright); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s, border-color 0.15s, transform 0.2s; color: var(--text-muted); }
.product-expand-icon.open { transform: rotate(90deg); background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.4); color: var(--blue); }

.cf-green { background: rgba(16,185,129,0.1); color: var(--green); border-radius: var(--radius-sm); }
.cf-amber { background: rgba(245,158,11,0.1); color: var(--amber); border-radius: var(--radius-sm); }
.cf-red   { background: rgba(239,68,68,0.1);  color: var(--red);   border-radius: var(--radius-sm); }
td.cf-cell { padding: 0 !important; }
.cf-pill { display: inline-block; padding: 0.3rem 0.6rem; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 12px; font-weight: 600; min-width: 60px; text-align: right; }

.delta-badge { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: 10px; font-weight: 600; margin-left: 4px; vertical-align: middle; }
.delta-badge.up { color: var(--green); } .delta-badge.down { color: var(--red); }

/* ─── DRILL-DOWN ─── */
.drill-row { background: color-mix(in srgb, var(--bg-base) 80%, transparent) !important; }
.drill-row td { padding: 0 !important; }
.drill-content { padding: 1rem 1.25rem; animation: fadeIn 0.2s ease; }
.drill-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 0.25rem; }
.drill-kpi-grid .kpi-card { padding: 0.75rem 1rem; }
.drill-kpi-grid .kpi-value { font-size: 18px; }
.drill-section-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.75rem; margin-top: 0.5rem; display: flex; align-items: center; gap: 0.4rem; }
.drill-section-title::before { content: ''; display: block; width: 3px; height: 12px; background: var(--blue); border-radius: 2px; }
.drill-sub-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 1rem; min-width: 600px; overflow-x: auto; display: block; }
.drill-sub-table th { padding: 0.5rem 0.75rem; text-align: left; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg-base) 40%, transparent); white-space: nowrap; }
.drill-sub-table th.num-col { text-align: right; }
.drill-sub-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.drill-sub-table td.num-col { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.drill-sub-table tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 3px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-family: var(--font-mono); flex-shrink: 0; }
.badge--green { background: rgba(16,185,129,0.15); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.badge--red   { background: rgba(239,68,68,0.15);  color: var(--red);   border: 1px solid rgba(239,68,68,0.25); }
.badge--amber { background: rgba(245,158,11,0.15); color: var(--amber); border: 1px solid rgba(245,158,11,0.25); }
.badge--blue  { background: rgba(59,130,246,0.15); color: var(--blue);  border: 1px solid rgba(59,130,246,0.25); }

.funnel-path { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }

.cf-legend { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 0; flex-wrap: wrap; }
.cf-legend-title { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.cf-legend-items { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.cf-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-secondary); }
.cf-dot { width: 8px; height: 8px; border-radius: 50%; }
.cf-dot.cf-green { background: var(--green); } .cf-dot.cf-amber { background: var(--amber); } .cf-dot.cf-red { background: var(--red); }

/* ═══ OVERVIEW ═══════════════════════════════════════════════ */
.overview-product-filter { display: flex; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.875rem; margin-bottom: 1.5rem; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; transition: border-color 0.2s, transform 0.15s; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; opacity: 0; transition: opacity 0.2s; }
.kpi-card:hover { border-color: var(--border-bright); transform: translateY(-1px); }
.kpi-card:hover::before { opacity: 1; }
.kpi-card[data-color="green"]::before  { background: var(--green); }
.kpi-card[data-color="blue"]::before   { background: var(--blue); }
.kpi-card[data-color="red"]::before    { background: var(--red); }
.kpi-card[data-color="amber"]::before  { background: var(--amber); }
.kpi-card[data-color="cyan"]::before   { background: var(--cyan); }
.kpi-card[data-color="purple"]::before { background: var(--purple); }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5rem; }
.kpi-value { font-size: 28px; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); line-height: 1.1; letter-spacing: -0.02em; }
.kpi-delta { margin-top: 0.5rem; font-size: 12px; font-family: var(--font-mono); display: flex; align-items: center; gap: 4px; }
.kpi-sub { margin-top: 0.25rem; font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.charts-row { display: grid; grid-template-columns: 1fr 360px; gap: 0.875rem; }
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; }
.chart-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.chart-badge { font-size: 10px; font-weight: 700; font-family: var(--font-mono); padding: 2px 7px; border-radius: 3px; background: rgba(59,130,246,0.1); color: var(--blue); letter-spacing: 0.06em; }
.chart-container { height: 280px; }
.chart-container--donut { height: 280px; }

/* ═══ AD / SECTION HEADERS ═══════════════════════════════════ */
.section-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.section-badge { font-size: 10px; font-weight: 700; font-family: var(--font-mono); padding: 2px 7px; border-radius: 3px; background: rgba(139,92,246,0.1); color: var(--purple); letter-spacing: 0.06em; }
.roas-great { color: var(--green); font-weight: 700; }
.roas-good  { color: #34d399; font-weight: 600; }
.roas-ok    { color: var(--amber); }
.roas-bad   { color: var(--red); }

/* ═══ SETTINGS LAYOUT ════════════════════════════════════════ */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem; min-height: 600px; }
@media (max-width: 768px) { .settings-layout { grid-template-columns: 1fr; } }
.settings-nav { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem; height: fit-content; }
.settings-nav-item { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.7rem 0.875rem; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--text-secondary); transition: color 0.15s, background 0.15s; text-align: left; min-height: 44px; }
.settings-nav-item:hover { color: var(--text-primary); background: var(--bg-elevated); }
.settings-nav-item.active { color: var(--blue); background: rgba(59,130,246,0.1); }
.settings-content { min-width: 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeIn 0.15s ease; }
.settings-panel-header { margin-bottom: 1.5rem; }
.settings-panel-header h3 { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem; }
.settings-panel-header p { font-size: 13px; color: var(--text-secondary); }

.integrations-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.integration-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; transition: border-color 0.2s; }
.integration-card:hover { border-color: var(--border-bright); }
.integration-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.integration-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.integration-status { font-size: 10px; font-weight: 700; font-family: var(--font-mono); padding: 2px 8px; border-radius: 10px; letter-spacing: 0.08em; }
.integration-status.connected { background: rgba(16,185,129,0.1); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.integration-status.disconnected { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }

.form-section { max-width: 600px; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.4rem; letter-spacing: 0.02em; }
.form-hint { color: var(--text-muted); font-weight: 400; }
.form-input { width: 100%; height: 36px; padding: 0 0.75rem; background: var(--bg-base); border: 1px solid var(--border-bright); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; transition: border-color 0.15s; -webkit-appearance: none; }
.form-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.form-input--readonly { background: color-mix(in srgb, var(--bg-base) 60%, transparent); color: var(--text-muted); cursor: not-allowed; }
.form-select { width: 100%; height: 36px; padding: 0 0.75rem; background: var(--bg-base); border: 1px solid var(--border-bright); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; transition: border-color 0.15s; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%234a6380' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }
.form-select:focus { outline: none; border-color: var(--blue); }

.input-with-unit { display: flex; align-items: center; gap: 0px; background: var(--bg-card); border: 1px solid var(--border-bright); border-radius: var(--radius-sm); overflow: hidden; height: 34px; }
.input-with-unit span { padding: 0 0.5rem; font-size: 12px; color: var(--text-muted); background: rgba(128,128,128,0.05); height: 100%; display: flex; align-items: center; border-right: 1px solid var(--border); flex-shrink: 0; }
.input-with-unit span:last-child { border-right: none; border-left: 1px solid var(--border); }
.cf-input { height: 100% !important; border: none !important; background: transparent !important; border-radius: 0 !important; flex: 1; min-width: 0; padding: 0 0.5rem !important; box-shadow: none !important; }
.cf-input:focus { outline: none !important; box-shadow: none !important; }

.alert-rule-card { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.alert-rule-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; gap: 0.5rem; }
.alert-rule-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-left: 0.5rem; }
.alert-rule-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 0.875rem; }
.cf-input-group { display: flex; flex-direction: column; gap: 0.35rem; min-width: 120px; }
.cf-input-group label { font-size: 12px; color: var(--text-secondary); }

/* Buttons */
.btn-primary { height: 36px; padding: 0 1.25rem; background: var(--blue); color: white; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; transition: background 0.15s, transform 0.1s; min-height: 44px; display: inline-flex; align-items: center; }
.btn-primary:hover { background: #2563eb; } .btn-primary:active { transform: scale(0.98); }
.btn-ghost { height: 36px; padding: 0 1.25rem; background: transparent; color: var(--text-secondary); border-radius: var(--radius-sm); border: 1px solid var(--border-bright); font-size: 13px; font-weight: 500; transition: color 0.15s, border-color 0.15s; min-height: 44px; display: inline-flex; align-items: center; }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-bright); }
.btn-danger { height: 36px; padding: 0 1rem; background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.25); border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; transition: background 0.15s; }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.form-status { margin-top: 0.75rem; font-size: 12px; min-height: 20px; }
.form-status.success { color: var(--green); } .form-status.error { color: var(--red); }

/* ═══ MODAL ══════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: var(--modal-bg); backdrop-filter: blur(4px); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-elevated); border: 1px solid var(--border-bright); border-radius: var(--radius-lg); width: 100%; max-width: 440px; animation: scaleIn 0.15s ease; }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem 0; }
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.modal-close { color: var(--text-muted); font-size: 16px; padding: 4px; border-radius: 4px; transition: color 0.15s; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer { padding: 0 1.5rem 1.5rem; display: flex; gap: 0.75rem; justify-content: flex-end; }

.drill-overlay { display: none; position: fixed; inset: 0; z-index: 50; }

/* ═══ SCROLLBAR ══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ═══ SORTABLE HEADERS ═══════════════════════════════════════ */
.sortable-th { cursor: pointer; user-select: none; transition: color 0.15s, background 0.15s; white-space: nowrap; }
.sortable-th:hover { color: var(--text-primary); background: rgba(59,130,246,0.06); }
.sort-indicator { display: inline-block; margin-left: 4px; font-size: 9px; color: var(--text-dim); vertical-align: middle; transition: color 0.15s; }
.sort-indicator.active { color: var(--blue); font-size: 10px; }

/* ═══ CAMPAIGN DRILL ═════════════════════════════════════════ */
.camp-expand-arrow { display: inline-flex; align-items: center; justify-content: center; font-size: 8px; color: var(--text-muted); transition: transform 0.2s, color 0.15s; flex-shrink: 0; cursor: pointer; }
.camp-expand-arrow.open { transform: rotate(90deg); color: var(--blue); }
.camp-drill-row { cursor: pointer; transition: background 0.1s; }
.camp-drill-row:hover { background: rgba(59,130,246,0.06); }
.camp-drill-row.camp-expanded { background: rgba(59,130,246,0.04); }
.camp-drill-row.camp-expanded td:first-child { border-left: 2px solid var(--blue); }

.kw-sub-drill-row td { padding: 0 !important; background: color-mix(in srgb, var(--bg-base) 70%, transparent); }
.kw-sub-drill-content { padding: 0.75rem 1.25rem 0.75rem 2.5rem; border-left: 2px solid rgba(59,130,246,0.25); animation: fadeIn 0.18s ease; }
.kw-sub-drill-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.kw-sub-drill-title { font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--cyan); }

.tcpa-input-wrap { display: inline-flex; align-items: center; background: var(--bg-base); border: 1px solid var(--border-bright); border-radius: var(--radius-sm); overflow: hidden; height: 26px; min-width: 80px; }
.tcpa-prefix { padding: 0 4px 0 6px; font-size: 11px; color: var(--text-muted); background: rgba(128,128,128,0.05); border-right: 1px solid var(--border); height: 100%; display: flex; align-items: center; flex-shrink: 0; }
.tcpa-input { border: none !important; background: transparent !important; outline: none !important; box-shadow: none !important; width: 60px; height: 100%; padding: 0 0.4rem; font-size: 12px; font-family: var(--font-mono); color: var(--text-primary); text-align: right; -moz-appearance: textfield; }
.tcpa-input::-webkit-outer-spin-button, .tcpa-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tcpa-input-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.btn-save-bids { height: 26px; padding: 0 0.75rem; background: rgba(16,185,129,0.12); color: var(--green); border: 1px solid rgba(16,185,129,0.3); border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; font-family: var(--font-mono); letter-spacing: 0.04em; transition: background 0.15s; cursor: pointer; }
.btn-save-bids:hover { background: rgba(16,185,129,0.2); }

.match-type-badge { display: inline-block; font-size: 9.5px; font-weight: 700; font-family: var(--font-mono); letter-spacing: 0.06em; padding: 1px 6px; border-radius: 3px; text-transform: uppercase; }
.match-type-exact  { background: rgba(59,130,246,0.12); color: var(--blue);   border: 1px solid rgba(59,130,246,0.2); }
.match-type-phrase { background: rgba(139,92,246,0.12); color: var(--purple); border: 1px solid rgba(139,92,246,0.2); }
.match-type-broad  { background: rgba(245,158,11,0.12); color: var(--amber);  border: 1px solid rgba(245,158,11,0.2); }
.match-type-auto   { background: rgba(107,114,128,0.12); color: #9ca3af;       border: 1px solid rgba(107,114,128,0.2); }

/* ═══ LIVE SALES TRACKER ═════════════════════════════════════ */
.live-sales-wrapper { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; margin-top: 1.25rem; align-items: start; }
@media (max-width: 900px) { .live-sales-wrapper { grid-template-columns: 1fr; } }
.live-sales-card { background: linear-gradient(135deg, #0d1a12 0%, #0b1520 60%, #0c1118 100%); border: 1px solid rgba(16,185,129,0.2); border-radius: var(--radius-lg); overflow: hidden; }
[data-theme="light"] .live-sales-card { background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 60%, #f0fdf4 100%); }
.live-sales-header { display: flex; align-items: center; justify-content: space-between; padding: 0.875rem 1.25rem; border-bottom: 1px solid rgba(16,185,129,0.12); background: rgba(16,185,129,0.04); }
.live-sales-title-row { display: flex; align-items: center; gap: 0.5rem; }
.live-sales-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(16,185,129,0.6); animation: pulse-live 2s infinite; }
.live-sales-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.live-sales-badge { font-size: 9px; font-weight: 800; font-family: var(--font-mono); letter-spacing: 0.15em; color: var(--green); background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); border-radius: 3px; padding: 2px 6px; }
.live-sales-feed { padding: 0.5rem 0; max-height: 260px; overflow-y: auto; }
.sale-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1.25rem; transition: background 0.1s; border-bottom: 1px solid rgba(16,185,129,0.05); }
.sale-item:last-child { border-bottom: none; }
.sale-item:hover { background: rgba(16,185,129,0.04); }
.sale-emoji { font-size: 14px; flex-shrink: 0; }
.sale-product { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; min-width: 0; }
.sale-amount { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: var(--green); flex-shrink: 0; }
.sale-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); flex-shrink: 0; text-align: right; min-width: 70px; }
.live-sales-footer { padding: 0.6rem 1.25rem; font-size: 11px; color: var(--text-muted); border-top: 1px solid rgba(16,185,129,0.08); background: rgba(0,0,0,0.1); display: flex; align-items: center; gap: 0.5rem; }
[data-theme="light"] .live-sales-footer { background: rgba(0,0,0,0.02); }

.ls-filter-group { display: flex; gap: 2px; flex-shrink: 0; }
.ls-filter-btn { height: 24px; padding: 0 0.55rem; border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); font-size: 10.5px; font-weight: 600; background: transparent; transition: all 0.15s; white-space: nowrap; font-family: var(--font-body); }
.ls-filter-btn:hover { border-color: var(--border-bright); color: var(--text-secondary); }
.ls-filter-btn.active { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.35); color: var(--green); }

.sale-type-tag { display: inline-flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 800; font-family: var(--font-mono); letter-spacing: 0.08em; padding: 1px 5px; border-radius: 3px; flex-shrink: 0; min-width: 22px; text-align: center; }
.sale-type-new { background: rgba(16,185,129,0.12); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.sale-type-ret { background: rgba(139,92,246,0.12); color: var(--purple); border: 1px solid rgba(139,92,246,0.2); }

.live-sales-rev-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.rev-summary-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg-base) 60%, transparent); }
.rev-summary-label { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.4rem; }
.rev-summary-total { display: block; font-size: 26px; font-weight: 700; font-family: var(--font-mono); color: var(--green); line-height: 1.1; letter-spacing: -0.02em; }
.rev-summary-orders { display: block; font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); margin-top: 0.25rem; }
.rev-summary-list { padding: 0.5rem 0; }
.rev-summary-row { display: flex; align-items: center; padding: 0.45rem 1.25rem; gap: 0.5rem; transition: background 0.1s; border-bottom: 1px solid var(--border-subtle); }
.rev-summary-row:last-child { border-bottom: none; }
.rev-summary-row:hover { background: rgba(16,185,129,0.03); }
.rev-summary-product { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; min-width: 0; }
.rev-summary-count { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); flex-shrink: 0; }
.rev-summary-amount { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--green); flex-shrink: 0; min-width: 80px; text-align: right; }

/* ═══ TOAST ══════════════════════════════════════════════════ */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 1rem; background: var(--bg-elevated); border: 1px solid var(--border-bright); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.4); font-size: 13px; font-weight: 500; color: var(--text-primary); opacity: 0; transform: translateY(8px); transition: opacity 0.25s ease, transform 0.25s ease; pointer-events: none; min-width: 200px; max-width: 320px; }
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--hiding { opacity: 0; transform: translateY(4px); }
.toast--success { border-left: 3px solid var(--green); }
.toast--error   { border-left: 3px solid var(--red); }
.toast-icon { font-size: 14px; font-weight: 700; flex-shrink: 0; }
.toast--success .toast-icon { color: var(--green); }
.toast--error   .toast-icon { color: var(--red); }
.toast-msg { flex: 1; }

.integration-help-text { font-size: 11px; color: var(--text-muted); margin-top: 0.5rem; padding: 0.5rem 0.75rem; background: rgba(59,130,246,0.06); border-left: 2px solid rgba(59,130,246,0.3); border-radius: 0 4px 4px 0; line-height: 1.4; }

.refresh-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-sm); color: var(--text-secondary); background: transparent; transition: color 0.15s, background 0.15s; flex-shrink: 0; }
.refresh-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.refresh-btn svg { transition: transform 0.6s ease; }
.refresh-btn.spinning svg { animation: spin360 0.6s linear forwards; }
@keyframes spin360 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.source-label { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: 0.02em; }

.ad-account-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 32px; align-items: center; }
.ad-account-chip { display: flex; align-items: center; gap: 6px; background: var(--bg-elevated); border: 1px solid var(--border-bright); border-radius: 20px; padding: 4px 10px; font-size: 12px; color: var(--text-primary); font-family: var(--font-mono); }
.ad-account-chip button { display: flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--border-bright); color: var(--text-secondary); font-size: 12px; line-height: 1; transition: background 0.15s, color 0.15s; padding: 0; }
.ad-account-chip button:hover { background: var(--red-bg); color: var(--red); }

.add-account-btn { background: var(--bg-elevated); border: 1px solid var(--border-bright); border-radius: var(--radius-sm); color: var(--blue); font-size: 12px; padding: 5px 12px; transition: background 0.15s, border-color 0.15s; white-space: nowrap; }
.add-account-btn:hover { background: var(--blue-bg); border-color: var(--blue); }

.campaign-mapping-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.campaign-mapping-table th { text-align: left; padding: 8px 10px; color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.campaign-mapping-table td { padding: 7px 10px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); vertical-align: middle; }
.campaign-mapping-table td:first-child { color: var(--text-primary); font-size: 12px; }
.campaign-mapping-table tr:last-child td { border-bottom: none; }
.campaign-mapping-table .form-select, .campaign-mapping-table select { background: var(--bg-elevated); border: 1px solid var(--border-bright); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 11px; }

.auto-badge { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; color: var(--cyan); background: rgba(6,182,212,0.12); border: 1px solid rgba(6,182,212,0.3); border-radius: 3px; padding: 1px 5px; vertical-align: middle; margin-left: 4px; font-family: var(--font-mono); }

.hourly-chart-section { margin-bottom: 1rem; }
.hourly-chart-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 6px; }
.hourly-chart-wrap { height: 200px; width: 100%; background: var(--bg-base); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 8px; box-sizing: border-box; }
.hourly-chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ═══ UTILITY ═══════════════════════════════════════════════ */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-amber  { color: var(--amber); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--text-muted); }
.text-mono   { font-family: var(--font-mono); }
.hidden { display: none !important; }

.app-header, .date-bar, .main-nav, .app-main { animation: pageLoad 0.3s ease both; }
.date-bar { animation-delay: 0.05s; }
.main-nav { animation-delay: 0.1s; }
.app-main { animation-delay: 0.15s; }
@keyframes pageLoad { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ RESPONSIVE ═════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .live-sales-wrapper { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .integrations-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root, [data-theme="dark"], [data-theme="light"] { --header-h: 50px; --datebar-h: auto; --nav-h: 44px; }
  .app-main { padding: 0.75rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .kpi-value { font-size: 20px; }
  .kpi-card { padding: 0.875rem; }
  .logo-text { display: none; }
  .live-label { display: none; }
  .date-bar { height: auto; }
  .date-bar-inner { flex-wrap: wrap; padding: 0.5rem 0.75rem; gap: 0.5rem; }
  .compare-toggle-wrap { width: 100%; justify-content: space-between; margin-left: 0; padding-top: 0.25rem; border-top: 1px solid var(--border-subtle); }
  .main-nav { gap: 0; padding: 0 0.5rem; }
  .nav-tab { font-size: 11.5px; padding: 0 0.65rem; min-height: 40px; gap: 0.3rem; }
  .nav-tab svg { width: 13px; height: 13px; }
  .product-sub-tabs { gap: 6px; margin-bottom: 0.875rem; }
  .pill-tab { font-size: 12px; padding: 0 0.75rem; min-height: 36px; height: 36px; }
  .data-table { font-size: 12px; min-width: 700px; }
  .data-table th { padding: 0.5rem 0.6rem; font-size: 9.5px; }
  .data-table td { padding: 0.55rem 0.6rem; }
  .data-table td.num-col { font-size: 11.5px; }
  .table-wrap { border-radius: var(--radius); }
  .mini-kpi-row { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .mini-kpi { padding: 0.65rem 0.75rem; } .mini-kpi-value { font-size: 17px; } .mini-kpi-label { font-size: 9.5px; }
  .live-sales-wrapper { grid-template-columns: 1fr; gap: 0.75rem; }
  .live-sales-header { flex-wrap: wrap; gap: 0.4rem; padding: 0.65rem 0.875rem; }
  .live-sales-title { font-size: 12px; }
  .ls-filter-group { width: 100%; order: 3; }
  .ls-filter-btn { flex: 1; text-align: center; font-size: 10px; height: 28px; }
  .sale-item { padding: 0.4rem 0.875rem; gap: 0.35rem; }
  .sale-product { font-size: 12px; } .sale-amount { font-size: 11.5px; } .sale-time { font-size: 10px; min-width: 55px; }
  .rev-summary-total { font-size: 22px; }
  .settings-layout { grid-template-columns: 1fr; gap: 0.75rem; min-height: auto; }
  .settings-nav { display: flex; overflow-x: auto; gap: 2px; padding: 0.35rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav-item { white-space: nowrap; flex-shrink: 0; padding: 0.5rem 0.75rem; min-height: 36px; font-size: 12px; }
  .integrations-grid { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .chart-container, .chart-container--donut { height: 220px; }
  .app-header { padding: 0 0.75rem; }
  .client-selector { max-width: 160px; height: 32px; font-size: 12px; padding: 0 0.6rem; }
  .icon-btn { width: 32px; height: 32px; }
  .drill-content { padding: 0.75rem; }
  .drill-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .drill-sub-table { font-size: 11.5px; min-width: 500px; }
  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .app-main { padding: 0.5rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .kpi-card { padding: 0.75rem; border-radius: var(--radius); }
  .kpi-value { font-size: 18px; } .kpi-label { font-size: 9.5px; margin-bottom: 0.3rem; }
  .mini-kpi-row { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .mini-kpi { padding: 0.5rem 0.6rem; border-radius: 6px; } .mini-kpi-value { font-size: 15px; } .mini-kpi-label { font-size: 9px; }
  .data-table { min-width: 600px; font-size: 11px; }
  .data-table th { padding: 0.4rem 0.5rem; font-size: 9px; }
  .data-table td { padding: 0.45rem 0.5rem; }
  .product-sub-tabs { gap: 4px; }
  .pill-tab { font-size: 11px; padding: 0 0.6rem; min-height: 32px; height: 32px; }
  .date-quick-btns { gap: 3px; }
  .date-btn { padding: 0 0.5rem; font-size: 11px; height: 26px; min-height: 26px; }
  .badge { font-size: 8px; padding: 1px 5px; }
  .cf-pill { font-size: 11px; padding: 0.2rem 0.4rem; min-width: 50px; }
  .nav-tab { font-size: 11px; padding: 0 0.5rem; }
  .nav-tab svg { display: none; }
  .client-selector { max-width: 130px; font-size: 11px; }
  .btn-primary, .btn-ghost { min-height: 40px; font-size: 12px; }
  .form-section { max-width: 100%; }
}

@media (max-width: 375px) {
  .app-main { padding: 0.35rem; }
  .kpi-value { font-size: 16px; }
  .mini-kpi-value { font-size: 14px; }
}

@media (pointer: coarse) {
  .date-btn, .pill-tab, .nav-tab, .ls-filter-btn, .settings-nav-item, .btn-primary, .btn-ghost, .btn-danger, .dropdown-client-item, .dropdown-add-btn { min-height: 44px; }
  .data-table tbody tr { min-height: 44px; }
  .data-table td, .data-table th { padding-top: 0.65rem; padding-bottom: 0.65rem; }
  .toggle-switch { width: 40px; height: 22px; }
  .toggle-slider::before { width: 16px; height: 16px; }
  .toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
  .ad-account-chip button { width: 22px; height: 22px; font-size: 14px; }
  .refresh-btn { width: 36px; height: 36px; }
}

/* KPI source badge */
.kpi-source {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  background: rgba(59,130,246,0.15);
  color: #5b9cf6;
}
[data-theme="light"] .kpi-source {
  background: rgba(59,130,246,0.1);
  color: #2563eb;
}

/* Overview campaign table */
.overview-campaign-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.overview-campaign-table .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
