:root {
  --o:   #FAA61A;
  --o2:  rgba(250,166,26,0.12);
  --o3:  rgba(250,166,26,0.35);
  --bg:  #111111;
  --bg2: #1A1A1A;
  --bg3: #222222;
  --bg4: #2A2A2A;
  --t1:  #F2F2F2;
  --t2:  #888888;
  --t3:  #4A4A4A;
  --red:    #FF4D2E;
  --red2:   rgba(255,77,46,0.10);
  --red3:   rgba(255,77,46,0.30);
  --green:  #3DD68C;
  --green2: rgba(61,214,140,0.10);
  --green3: rgba(61,214,140,0.30);
  --r: 8px; --r2: 12px; --r3: 16px;

  --cf:    #6366f1;
  --ads:   #FAA61A;
  --ecom:  #3DD68C;
  --total: #4f6bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--t1);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--o); text-decoration: none; }

/* ── PASSWORD SCREEN ── */
#password-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#password-screen.hidden { display: none; }

.password-card {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  background: var(--bg2);
  border: 1px solid var(--bg4);
  border-radius: var(--r3);
  text-align: center;
}

.password-card .logo-mark { height: 36px; margin-bottom: 18px; }
.password-card .logo-mark img { height: 100%; }
.password-card .logo-fallback { font-size: 28px; font-weight: 800; color: var(--o); letter-spacing: 0.02em; }

.password-card h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--t1);
  margin: 0 0 4px;
}

.password-card p.subtitle {
  font-size: 12px;
  color: var(--t2);
  margin: 0 0 24px;
}

.password-card input[type="password"] {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--bg4);
  border-radius: var(--r);
  color: var(--t1);
  font-family: inherit;
  font-size: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s ease;
}

.password-card input[type="password"]:focus { border-color: var(--o3); }

.btn-primary {
  width: 100%;
  background: var(--o);
  color: #1a1100;
  border: none;
  border-radius: var(--r);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 14px;
  cursor: pointer;
  transition: opacity .15s ease;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.password-error {
  margin-top: 12px;
  font-size: 12px;
  color: var(--red);
  min-height: 14px;
}

/* ── APP SHELL ── */
#app { display: none; }
#app.visible { display: block; }

.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
  background: var(--bg2);
  border-bottom: 1px solid rgba(250,166,26,0.2);
}

.header-inner {
  height: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo { display: flex; align-items: center; gap: 10px; height: 26px; }
.header-logo img { height: 24px; display: block; }
.header-logo .logo-fallback { font-size: 18px; font-weight: 800; color: var(--o); letter-spacing: 0.02em; }

.header-badge {
  background: var(--o2);
  border: 1px solid var(--o3);
  color: var(--o);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 999px;
}

/* ── TABS ── */
.tabs {
  position: sticky;
  top: 60px;
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--bg4);
}

.tabs-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 28px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--t2);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease;
}

.tab-btn:hover { color: var(--t1); }

.tab-btn.active {
  color: var(--o);
  border-bottom-color: var(--o);
}

/* ── MAIN ── */
main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── LOADING / ERROR STATES ── */
.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 120px 24px;
  text-align: center;
  color: var(--t2);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg4);
  border-top-color: var(--o);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.state-screen .error-title { color: var(--red); font-size: 14px; font-weight: 700; }
.state-screen .error-detail { font-size: 12px; color: var(--t2); max-width: 420px; }

.btn-retry {
  background: var(--bg3);
  border: 1px solid var(--bg4);
  color: var(--t1);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 18px;
  border-radius: var(--r);
  cursor: pointer;
}

.btn-retry:hover { border-color: var(--o3); color: var(--o); }

/* ── GRID / LAYOUT ── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.section { margin-bottom: 28px; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t1);
  margin: 0 0 14px;
}

/* ── CARDS ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--bg4);
  border-radius: var(--r2);
  padding: 20px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t2);
  margin: 0 0 16px;
}

.chart-wrap { position: relative; height: 320px; }
.chart-wrap.short { height: 240px; }

/* ── STAT BOXES ── */
.stat-box {
  background: var(--bg3);
  border: 1px solid var(--bg4);
  border-radius: var(--r);
  padding: 16px;
}

.stat-box.highlight { background: var(--o2); border-color: var(--o3); }
.stat-box.danger { background: var(--red2); border-color: var(--red3); }
.stat-box.success { background: var(--green2); border-color: var(--green3); }

.stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--t3);
  margin: 0 0 8px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--t1);
  margin: 0;
}

.stat-sub {
  font-size: 11px;
  color: var(--t2);
  margin-top: 6px;
}

.stat-delta { font-size: 11px; font-weight: 700; margin-top: 6px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ── PROGRESS BARS ── */
.progress-track {
  background: var(--bg3);
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.progress-fill {
  background: var(--o);
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}

.progress-fill.over { background: var(--green); }

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--t2);
}

/* ── TABLES ── */
table { width: 100%; border-collapse: collapse; font-size: 12px; }

th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--bg4);
}

td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--bg3);
  color: var(--t1);
}

tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
td.muted { color: var(--t2); }

.table-wrap { overflow-x: auto; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge.green { background: var(--green2); color: var(--green); border: 1px solid var(--green3); }
.badge.amber { background: var(--o2); color: var(--o); border: 1px solid var(--o3); }
.badge.red { background: var(--red2); color: var(--red); border: 1px solid var(--red3); }
.badge.gray { background: var(--bg3); color: var(--t2); border: 1px solid var(--bg4); }

/* ── LEGEND ── */
.legend-list { display: flex; flex-direction: column; gap: 12px; }

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.legend-key { display: flex; align-items: center; gap: 8px; color: var(--t1); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-val { color: var(--t2); display: flex; gap: 10px; }
.legend-val strong { color: var(--t1); font-weight: 700; }

/* ── MISC ── */
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted-note { font-size: 11px; color: var(--t3); margin-top: 4px; }

.partial-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--t2);
  background: var(--bg4);
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}
