:root {
  --bg: #131313;
  --surface: #1c1b1b;
  --surface2: #201f1f;
  --surface3: #2a2a2a;
  --surface-lowest: #0e0e0e;
  --surface-highest: #353534;
  --border: rgba(86, 67, 57, 0.35);
  --border2: rgba(164, 140, 128, 0.4);
  --text: #e5e2e1;
  --text2: #dcc1b4;
  --text3: #a48c80;
  --accent: #e87d3e;
  --accent-bright: #ffb690;
  --accent-soft: rgba(232, 125, 62, 0.12);
  --green: #e9c349;
  --green-soft: rgba(233, 195, 73, 0.12);
  --red: #ffb4ab;
  --red-soft: rgba(255, 180, 171, 0.12);
  --yellow: #ffe088;
  --yellow-soft: rgba(255, 224, 136, 0.12);
  --orange: #ffb690;
  --orange-soft: rgba(255, 182, 144, 0.14);
  --font-display: 'Syne', sans-serif;
  --font-body: 'Be Vietnam Pro', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}
.light {
  --bg: #f3ede7;
  --surface: #ffffff;
  --surface2: #faf5f0;
  --surface3: #f0e6dc;
  --surface-lowest: #ffffff;
  --surface-highest: #e4d5c6;
  --border: rgba(180, 140, 100, 0.25);
  --border2: rgba(140, 100, 70, 0.35);
  --text: #2a1d12;
  --text2: #5c4530;
  --text3: #8a7360;
  --accent: #c2600f;
  --accent-bright: #a24b00;
  --accent-soft: rgba(194, 96, 15, 0.1);
  --green: #96730a;
  --green-soft: rgba(150, 115, 10, 0.1);
  --red: #b3261e;
  --red-soft: rgba(179, 38, 30, 0.08);
  --yellow: #a67c00;
  --yellow-soft: rgba(166, 124, 0, 0.1);
  --orange: #c2600f;
  --orange-soft: rgba(194, 96, 15, 0.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 13px; min-height: 100vh; transition: background 0.3s, color 0.3s; position: relative; overflow-x: hidden; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20; vertical-align: middle; font-size: 18px; line-height: 1; }

/* ── AMBIENT BACKGROUND ── */
.ambient-bg { position: fixed; inset: 0; z-index: -2; background: var(--bg); overflow: hidden; }
.mist {
  position: absolute; width: 150%; height: 150%; top: -25%; left: -25%;
  background:
    radial-gradient(circle at 20% 30%, rgba(232, 125, 62, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(233, 195, 73, 0.05) 0%, transparent 40%);
  filter: blur(80px);
  animation: drift 22s ease-in-out infinite alternate;
}
.light .mist { opacity: 0.5; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(2%, 2%) scale(1.1); } }
.cursor-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(500px circle at var(--mx, 50%) var(--my, 50%), rgba(232, 125, 62, 0.06), transparent 45%);
}

/* ── GLASS PANEL ── */
.glass-panel {
  background: rgba(32, 31, 31, 0.7);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.light .glass-panel { background: rgba(255, 255, 255, 0.75); }
.glow-copper { box-shadow: 0 0 16px rgba(232, 125, 62, 0.25); }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.reveal-once { animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* ── HEADER ── */
.header { position: sticky; top: 0; z-index: 200; border-bottom: 1px solid var(--border); border-left: none; border-right: none; border-top: none; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; height: 56px; flex-wrap: wrap; gap: 8px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 32px; height: 32px; background: linear-gradient(135deg, var(--accent), var(--green)); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #1a1206; box-shadow: 0 0 16px rgba(232, 125, 62, 0.35); }
.logo-icon .material-symbols-outlined { font-size: 18px; font-variation-settings: 'FILL' 1; }
.logo-text { font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.logo-sub { font-size: 10px; color: var(--text3); font-family: var(--font-mono); }
.header-right { display: flex; align-items: center; gap: 6px; }
.nav-tabs { display: flex; background: var(--surface3); border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--border); }
.nav-tab { padding: 6px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 12px; font-weight: 600; font-family: var(--font-body); transition: all 0.15s; background: transparent; color: var(--text2); display: flex; align-items: center; gap: 5px; }
.nav-tab .material-symbols-outlined { font-size: 16px; }
.nav-tab.active { background: var(--accent); color: #1a0e04; box-shadow: 0 0 14px rgba(232, 125, 62, 0.35); }
.nav-tab:not(.active):hover { color: var(--text); }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-size: 12px; font-weight: 600; font-family: var(--font-body); transition: all 0.15s; white-space: nowrap; }
.btn .material-symbols-outlined { font-size: 16px; }
.btn-primary { background: var(--accent); color: #1a0e04; }
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 0 14px rgba(232, 125, 62, 0.4); }
.btn-outline { background: transparent; color: var(--text2); border: 1px solid var(--border2); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.spin .material-symbols-outlined, .spin { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sync-status { font-size: 10px; color: var(--text3); font-family: var(--font-mono); display: flex; align-items: center; gap: 5px; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; box-shadow: 0 0 8px var(--green); }
.sync-dot.err { background: var(--red); box-shadow: 0 0 8px var(--red); }
.sync-dot.loading { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.systems-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); border: 1px solid rgba(232,125,62,0.25); }
.label-caps { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--text3); text-transform: uppercase; }
.systems-count { font-family: var(--font-mono); font-weight: 700; color: var(--accent-bright); text-shadow: 0 0 8px rgba(232,125,62,0.5); }
.systems-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }

.section-label { font-family: var(--font-display); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text3); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-label .material-symbols-outlined { color: var(--accent); font-size: 18px; }

select, input[type="text"] { font-family: var(--font-body); }
.filter-bar { position: sticky; top: 56px; z-index: 100; display: flex; align-items: center; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--border); border-left: none; border-right: none; border-top: none; flex-wrap: wrap; }
.filter-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text3); font-family: var(--font-mono); }
.filter-select { background: var(--surface-lowest); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12px; color: var(--text); font-family: var(--font-body); cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--accent); }
.search-wrap { display: flex; align-items: center; gap: 6px; background: var(--surface-lowest); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 6px 10px; }
.search-wrap .material-symbols-outlined { font-size: 16px; color: var(--text3); }
.search-inp { background: transparent; border: none; font-size: 12px; color: var(--text); font-family: var(--font-body); width: 200px; }
.search-inp:focus { outline: none; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table { border-collapse: collapse; width: max-content; min-width: 100%; table-layout: auto; }
th { font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text3); padding: 10px 12px; text-align: left; background: var(--surface3); border-bottom: 2px solid var(--border2); white-space: nowrap; position: sticky; top: var(--thead-top, 111px); z-index: 50; cursor: pointer; user-select: none; }
th:hover { color: var(--accent-bright); }
th.num { text-align: right; }
th.ctr { text-align: center; }
td { padding: 6px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
td.num { text-align: right; font-family: var(--font-mono); font-size: 12px; }
td.ctr { text-align: center; }
td.campaign-cell { white-space: normal; max-width: 280px; }
tr:hover td { background: var(--accent-soft); }
.row-account td { background: var(--surface2) !important; border-top: 2px solid var(--accent); scroll-margin-top: 170px; }
.row-account-label { font-family: var(--font-display); font-size: 13px; font-weight: 700; color: var(--text); }
.row-channel td { background: var(--surface3) !important; border-top: 1px solid var(--border2); border-bottom: 1px solid var(--border2); }
.row-channel-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); font-family: var(--font-mono); }
.row-ch-total td { background: var(--surface2) !important; border-top: 1px solid var(--border2); border-bottom: 1px solid var(--border2); }
.row-acc-total td { background: var(--surface3) !important; border-top: 2px solid var(--border2); border-bottom: 2px solid var(--border2); }
.total-label { font-family: var(--font-display); font-size: 11px; font-weight: 700; }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; font-family: var(--font-mono); border: 1px solid transparent; }
.badge-green { background: var(--green-soft); color: var(--green); border-color: rgba(233,195,73,0.25); }
.badge-red { background: var(--red-soft); color: var(--red); border-color: rgba(255,180,171,0.25); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(255,224,136,0.25); }
.badge-orange { background: var(--orange-soft); color: var(--orange); border-color: rgba(255,182,144,0.25); }
.badge-blue { background: var(--accent-soft); color: var(--accent-bright); border-color: rgba(232,125,62,0.25); }

.card { border-radius: var(--radius); padding: 18px 20px; }
.kpi-card { flex: 1; min-width: 170px; }
.kpi-card-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 8px; font-family: var(--font-mono); }
.kpi-card-value { font-family: var(--font-mono); font-size: 23px; font-weight: 600; letter-spacing: -0.02em; }
.kpi-card-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

.insight-card { border-radius: var(--radius); padding: 13px 15px; display: flex; gap: 11px; align-items: flex-start; margin-bottom: 8px; border: 1px solid; }
.insight-icon { flex-shrink: 0; margin-top: 1px; width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.insight-title { font-size: 12px; font-weight: 700; }
.insight-desc { font-size: 11px; color: var(--text2); margin-top: 2px; line-height: 1.55; }
.insight-red { background: var(--red-soft); border-color: rgba(255,180,171,0.3); animation: pulseRed 2.4s infinite; }
.insight-red .insight-icon { background: rgba(255,180,171,0.15); color: var(--red); }
.insight-yellow { background: var(--yellow-soft); border-color: rgba(255,224,136,0.3); animation: pulseYellow 2.4s infinite; }
.insight-yellow .insight-icon { background: rgba(255,224,136,0.15); color: var(--yellow); }
.insight-green { background: var(--green-soft); border-color: rgba(233,195,73,0.3); }
.insight-green .insight-icon { background: rgba(233,195,73,0.15); color: var(--green); }
.insight-orange { background: var(--orange-soft); border-color: rgba(255,182,144,0.3); }
.insight-orange .insight-icon { background: rgba(255,182,144,0.15); color: var(--orange); }
@keyframes pulseRed { 0%{box-shadow:0 0 0 0 rgba(255,180,171,0.25)} 70%{box-shadow:0 0 0 8px rgba(255,180,171,0)} 100%{box-shadow:0 0 0 0 rgba(255,180,171,0)} }
@keyframes pulseYellow { 0%{box-shadow:0 0 0 0 rgba(255,224,136,0.2)} 70%{box-shadow:0 0 0 8px rgba(255,224,136,0)} 100%{box-shadow:0 0 0 0 rgba(255,224,136,0)} }

.bar-chart-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar-chart-label { font-size: 11px; color: var(--text); width: 100px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); }
.bar-chart-track { flex: 1; height: 9px; border-radius: 5px; background: var(--surface-highest); overflow: hidden; position: relative; }
.bar-chart-budget { position: absolute; height: 100%; border-radius: 5px; background: var(--surface3); }
.bar-chart-cost { position: absolute; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--green)); transition: width 0.6s cubic-bezier(0.16,1,0.3,1); box-shadow: 0 0 8px rgba(232,125,62,0.4); }

.empty { text-align: center; padding: 60px 20px; color: var(--text3); }

.page { display: none; }
.page.active { display: block; }
.page-content { padding: 0 0 60px 0; }

.summary-kpis { display: flex; gap: 14px; flex-wrap: wrap; padding: 18px 20px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 20px 20px; }
.summary-insights { padding: 0 20px 20px; }
@media (max-width: 768px) { .summary-grid { grid-template-columns: 1fr; } }

.error-box { margin: 16px 20px; border: 1px solid rgba(255,180,171,0.3); border-radius: var(--radius); padding: 14px 16px; font-size: 12px; }

.toast { position: fixed; bottom: 20px; right: 20px; z-index: 999; padding: 10px 16px; border-radius: var(--radius); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 7px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.toast-success { background: var(--green); color: #241a00; }
.toast-error { background: var(--red); color: #690005; }
