/* Nexa Ads Command, dark trading terminal design system.
   No em dashes anywhere. Cyan primary, gold for money and warnings, red critical. */

:root {
  --bg: #0b0f14;
  --bg-2: #0e141b;
  --surface: #121a23;
  --surface-2: #16202b;
  --surface-3: #1b2734;
  --line: #1f2c3a;
  --line-2: #27384a;
  --text: #e6edf3;
  --text-dim: #9fb0c0;
  --text-faint: #6b7d8f;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --gold: #EEB027;
  --gold-dim: #7a5c15;
  --red: #f2545b;
  --red-dim: #5c1f24;
  --green: #34d399;
  --green-dim: #14532d;
  --amber: #f59e0b;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 0 rgba(255,255,255,0.03), 0 10px 30px rgba(0,0,0,0.35);
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Chart.js reads these via NAC.chartColors() so charts re-theme with the page. */
  --chart-grid: #1a2430;
  --chart-tick: #6b7d8f;
  --chart-legend: #9fb0c0;
  --chart-tooltip-bg: #0e141b;
  --chart-tooltip-border: #27384a;
  --spark: #22d3ee;
  /* Page background glow, softened per theme. */
  --glow-1: rgba(34,211,238,0.06);
  --glow-2: rgba(238,176,39,0.04);
  --topbar-bg: rgba(11,15,20,0.7);
}

/* Light theme. Dark stays the default and is untouched. Same cyan/gold/red
   semantics with darkened variants for WCAG-ish contrast on white. */
:root[data-theme="light"] {
  --bg: #f2f5f8;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --surface-3: #e2e8f0;
  --line: #dbe3ec;
  --line-2: #c4cfdb;
  --text: #0f172a;
  --text-dim: #475569;
  --text-faint: #64748b;
  --cyan: #0e7490;
  --cyan-dim: #cffafe;
  --gold: #9a6d00;
  --gold-dim: #f4e6bd;
  --red: #c0392b;
  --red-dim: #f6d5d2;
  --green: #0f8a5f;
  --green-dim: #d1efe1;
  --amber: #b45309;
  --shadow: 0 1px 0 rgba(255,255,255,0.6), 0 10px 26px rgba(15,23,42,0.10);
  --chart-grid: #e2e8f0;
  --chart-tick: #64748b;
  --chart-legend: #475569;
  --chart-tooltip-bg: #ffffff;
  --chart-tooltip-border: #cbd5e1;
  --spark: #0e7490;
  --glow-1: rgba(34,211,238,0.10);
  --glow-2: rgba(238,176,39,0.08);
  --topbar-bg: rgba(255,255,255,0.78);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--glow-1), transparent 60%),
    radial-gradient(900px 500px at -5% 10%, var(--glow-2), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--cyan), #0891b2);
  display: grid; place-items: center;
  font-weight: 800; color: #04141a; font-size: 15px;
  box-shadow: 0 0 18px rgba(34,211,238,0.35);
}
.brand .name { font-weight: 700; letter-spacing: 0.2px; line-height: 1.1; }
.brand .name small { display: block; color: var(--text-faint); font-weight: 500; font-size: 11px; }

.nav-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500;
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--cyan); }
.nav-link .pill { font-size: 11px; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--text-faint); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 26px; border-bottom: 1px solid var(--line);
  background: var(--topbar-bg); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: 0.2px; }
.topbar .sub { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

.content { padding: 22px 26px 60px 26px; }

/* ---------- badges, pills ---------- */
.mode-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 4px 9px; border-radius: 6px;
}
.mode-demo { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(238,176,39,0.35); }
.mode-live { background: var(--green-dim); color: var(--green); border: 1px solid rgba(52,211,153,0.35); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line-2); color: var(--text-dim); background: var(--surface);
  white-space: nowrap;
}
.pill.active { color: var(--green); border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.08); }
.pill.paused { color: var(--text-faint); }
.pill.rejected, .pill.disapproved { color: var(--red); border-color: rgba(242,84,91,0.4); background: rgba(242,84,91,0.08); }
.pill.learning { color: var(--gold); border-color: rgba(238,176,39,0.4); background: rgba(238,176,39,0.08); }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.sev { padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.sev-critical { background: rgba(242,84,91,0.14); color: var(--red); border: 1px solid rgba(242,84,91,0.4); }
.sev-warn { background: rgba(238,176,39,0.14); color: var(--gold); border: 1px solid rgba(238,176,39,0.4); }
.sev-info { background: rgba(34,211,238,0.12); color: var(--cyan); border: 1px solid rgba(34,211,238,0.35); }

.fatigue { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.f-Fresh { background: rgba(52,211,153,0.12); color: var(--green); border: 1px solid rgba(52,211,153,0.4); }
.f-Watch { background: rgba(238,176,39,0.12); color: var(--gold); border: 1px solid rgba(238,176,39,0.4); }
.f-Fatigued { background: rgba(242,84,91,0.14); color: var(--red); border: 1px solid rgba(242,84,91,0.4); }

/* ---------- cards, kpis ---------- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; opacity: 0.7; }
.kpi.k-spend::after { background: var(--cyan); }
.kpi.k-results::after { background: var(--green); }
.kpi.k-cpl::after { background: var(--gold); }
.kpi.k-accounts::after { background: var(--text-faint); }
.kpi .label { color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 8px; font-family: var(--mono); letter-spacing: -0.5px; }
.kpi .value.money { color: var(--gold); }
.kpi .sub { color: var(--text-faint); font-size: 12px; margin-top: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.grid thead th {
  text-align: right; padding: 11px 14px; color: var(--text-faint);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
  background: var(--bg-2); border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
table.grid thead th:first-child { text-align: left; }
table.grid tbody td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line); font-family: var(--mono); }
table.grid tbody td:first-child { text-align: left; font-family: var(--sans); }
table.grid tbody tr:hover { background: var(--surface); }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid .money { color: var(--gold); }
.num-dim { color: var(--text-dim); }
.up { color: var(--green); }
.down { color: var(--red); }

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 15px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #26d7f0, #0891b2); border-color: #0e7490; color: #04141a; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.gold { background: linear-gradient(180deg, #f5bd3f, #d3971a); border-color: #a97812; color: #1a1204; }
.btn.danger { background: rgba(242,84,91,0.12); border-color: rgba(242,84,91,0.4); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.xs { padding: 4px 9px; font-size: 11px; border-radius: 6px; }

input, select {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-family: var(--sans);
  outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,0.14); }
label { font-size: 12px; color: var(--text-dim); font-weight: 600; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.spacer { flex: 1 1 auto; }

/* range picker */
.rangepick { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.rangepick a { padding: 7px 13px; color: var(--text-dim); font-weight: 600; font-size: 12.5px; border-right: 1px solid var(--line); }
.rangepick a:last-child { border-right: none; }
.rangepick a:hover { background: var(--surface-2); text-decoration: none; }
.rangepick a.active { background: var(--cyan); color: #04141a; }

/* ---------- attention queue ---------- */
.attn { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.attn-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); border-left-width: 3px;
}
.attn-item.s-critical { border-left-color: var(--red); }
.attn-item.s-warn { border-left-color: var(--gold); }
.attn-item.s-info { border-left-color: var(--cyan); }
.attn-item .msg { flex: 1 1 auto; }
.attn-empty { color: var(--text-faint); padding: 14px 16px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); }

/* ---------- creative grid ---------- */
.crea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.crea-card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer; transition: border-color 0.12s, transform 0.08s;
}
.crea-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.crea-thumb { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-3); display: block; }
.crea-body { padding: 13px 15px; display: flex; flex-direction: column; gap: 10px; }
.crea-name { font-weight: 600; font-size: 13px; line-height: 1.35; min-height: 34px; }
.crea-acct { font-size: 11px; color: var(--text-faint); }
.crea-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.crea-metrics .m .k { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.4px; }
.crea-metrics .m .v { font-size: 14px; font-weight: 700; font-family: var(--mono); margin-top: 2px; }
.crea-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- tree (account drilldown) ---------- */
.tree-row {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: 26px minmax(220px, 1.6fr) 108px repeat(5, minmax(74px, 1fr)) 150px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.tree-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .metric { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.tree-row.head { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; background: var(--bg-2); }
.tree-row.lvl-campaign { background: var(--surface-2); }
.tree-row.lvl-adset { background: rgba(22,32,43,0.5); }
.tree-row.lvl-ad { }
.indent-1 { padding-left: 18px; }
.indent-2 { padding-left: 38px; }
.caret { cursor: pointer; color: var(--text-faint); width: 20px; text-align: center; user-select: none; transition: transform 0.12s; display: inline-block; }
.caret.open { transform: rotate(90deg); color: var(--cyan); }
.actions-cell { display: flex; gap: 6px; justify-content: flex-end; }

.budget-edit { display: inline-flex; align-items: center; gap: 5px; }
.budget-edit input { width: 78px; padding: 5px 8px; font-size: 12px; font-family: var(--mono); text-align: right; }

/* sparkline */
.spark { display: inline-block; vertical-align: middle; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,8,12,0.72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; padding: 24px;
}
.modal {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px;
  width: 100%; max-width: 720px; box-shadow: 0 24px 80px rgba(0,0,0,0.6); overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; }
.modal-x { cursor: pointer; color: var(--text-faint); font-size: 20px; line-height: 1; background: none; border: none; }
.confirm-modal { max-width: 440px; }
.confirm-modal .modal-body p { color: var(--text-dim); line-height: 1.55; }

/* ---------- misc ---------- */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); font-weight: 700; margin: 26px 0 12px; }
.chart-box { height: 300px; position: relative; }
.mini-chart { height: 150px; position: relative; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.hint { color: var(--text-faint); font-size: 12px; line-height: 1.5; }
.digest-pre { font-family: var(--mono); font-size: 13px; line-height: 1.7; white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--text); }
.toast { position: fixed; bottom: 22px; right: 22px; z-index: 200; padding: 13px 18px; border-radius: var(--radius-sm); font-weight: 600; box-shadow: var(--shadow); border: 1px solid var(--line-2); background: var(--surface-2); }
.toast.ok { border-color: rgba(52,211,153,0.5); color: var(--green); }
.toast.err { border-color: rgba(242,84,91,0.5); color: var(--red); }
.flags { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.flag { font-size: 10.5px; padding: 2px 7px; border-radius: 5px; font-weight: 700; }
.flag.rej { background: rgba(242,84,91,0.14); color: var(--red); }
.flag.lrn { background: rgba(238,176,39,0.14); color: var(--gold); }
.flag.zero { background: rgba(148,163,184,0.14); color: var(--text-dim); }
.flag.pay { background: rgba(242,84,91,0.2); color: var(--red); }
.flag.ok { background: rgba(52,211,153,0.12); color: var(--green); }

.pace-bar { width: 88px; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; display: inline-block; vertical-align: middle; }
.pace-fill { height: 100%; border-radius: 4px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card .brand { justify-content: center; border-bottom: none; margin: 0 0 20px; padding-bottom: 0; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.login-card input { text-align: center; padding: 12px; }
.login-err { color: var(--red); font-size: 13px; margin-top: 4px; }

/* ========== V2: winners, tags, journal, deep-dive ========== */
[x-cloak] { display: none !important; }

/* state badges (Winner, Solid, Watch, Underperformer) */
.badge-state { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.s-Winner { background: rgba(52,211,153,0.16); color: var(--green); border: 1px solid rgba(52,211,153,0.5); }
.s-Solid { background: rgba(34,211,238,0.12); color: var(--cyan); border: 1px solid rgba(34,211,238,0.4); }
.s-Watch { background: rgba(238,176,39,0.12); color: var(--gold); border: 1px solid rgba(238,176,39,0.4); }
.s-Underperformer { background: rgba(242,84,91,0.14); color: var(--red); border: 1px solid rgba(242,84,91,0.45); }
.s-Fatigued { background: rgba(242,84,91,0.14); color: var(--red); border: 1px solid rgba(242,84,91,0.45); }
.s-Nodata { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--line-2); }

.delta { font-size: 11px; font-weight: 700; font-family: var(--mono); }
.delta.good, .delta-line.good { color: var(--green); }
.delta.bad, .delta-line.bad { color: var(--red); }
.delta.neutral, .delta-line.neutral { color: var(--text-faint); }
.delta-line { font-size: 11.5px; font-weight: 600; font-family: var(--mono); margin-top: 5px; }

/* ranking chips: compact Q E C badges from Meta diagnostics */
.rank-chips { display: inline-flex; gap: 4px; align-items: center; }
.rank-chip { font-size: 10px; font-weight: 800; letter-spacing: 0.3px; padding: 2px 6px;
  border-radius: 5px; border: 1px solid var(--line-2); }
.rank-chip.good { color: var(--green); border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.08); }
.rank-chip.mid { color: var(--text-dim); background: var(--surface-2); }
.rank-chip.bad { color: var(--red); border-color: rgba(242,84,91,0.45); background: rgba(242,84,91,0.1); }

/* compare battle card */
.battle-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.battle { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
table.battle th, table.battle td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: right; font-family: var(--mono); }
table.battle th:first-child, table.battle td:first-child { text-align: left; font-family: var(--sans);
  color: var(--text-dim); font-weight: 600; }
table.battle thead th { background: var(--bg-2); color: var(--text); font-family: var(--sans);
  font-weight: 700; position: sticky; top: 0; }
table.battle td.best { color: var(--cyan); font-weight: 800; background: rgba(34,211,238,0.08); }
.verdict-list { display: flex; flex-direction: column; gap: 10px; }
.verdict { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.verdict.decisive { border-left: 3px solid var(--green); }
.verdict.tooclose { border-left: 3px solid var(--gold); }
.verdict.lowdata { border-left: 3px solid var(--text-faint); }
.verdict .vpair { font-size: 12px; color: var(--text-faint); }
.verdict .vtext { font-weight: 600; }

/* compare picker */
.checklist { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.checklist label { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 6px;
  cursor: pointer; font-weight: 500; color: var(--text); }
.checklist label:hover { background: var(--surface-2); }
.compare-float { position: fixed; bottom: 24px; right: 24px; z-index: 60; }

/* test scoreboard, learnings, budget */
.scoreboard { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.conf-bar { width: 120px; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; display: inline-block; }
.conf-fill { height: 100%; background: var(--cyan); }
.learn-card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, var(--surface), var(--bg-2)); padding: 16px 18px; margin-bottom: 14px; }
.learn-card .lc-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.learn-card .lc-body { color: var(--text-dim); line-height: 1.55; white-space: pre-wrap; font-size: 13px; }
.learn-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.budget-card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, var(--surface), var(--bg-2)); padding: 18px 20px; margin-bottom: 16px; }
.proj-bar { height: 12px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin: 10px 0; }
.proj-fill { height: 100%; border-radius: 6px; }
.sug-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line); }
.sug-item:first-of-type { border-top: none; }
.sug-actions { display: flex; gap: 6px; }
.status-chip { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; padding: 3px 8px; border-radius: 5px; }
.st-running { background: rgba(34,211,238,0.12); color: var(--cyan); }
.st-called { background: rgba(52,211,153,0.14); color: var(--green); }
.st-archived { background: var(--surface-2); color: var(--text-faint); }

/* tag chips */
.tag-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.2px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-dim); }
.t-language { color: #7dd3fc; border-color: rgba(125,211,252,0.3); }
.t-angle { color: #c4b5fd; border-color: rgba(196,181,253,0.3); }
.t-format { color: #6ee7b7; border-color: rgba(110,231,183,0.3); }
.t-cta { color: #fcd34d; border-color: rgba(252,211,77,0.3); }
.tag-pencil { background: none; border: 1px dashed var(--line-2); color: var(--text-faint); font-size: 10.5px;
  padding: 2px 8px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.tag-pencil:hover { color: var(--cyan); border-color: var(--cyan); }

.crea-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.crea-linkwrap { display: block; }
.crea-name a { color: var(--text); }
.crea-name a:hover { color: var(--cyan); text-decoration: none; }
.crea-metrics { grid-template-columns: repeat(3, 1fr); }

.tag-editor { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); background: var(--bg); }
.tag-editor.inline { flex-flow: row wrap; align-items: flex-end; }
.te-row { display: flex; flex-direction: column; gap: 4px; }
.te-row select { padding: 6px 8px; font-size: 12px; }

/* What is working panel */
.work-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 8px; }
.work-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint);
  font-weight: 700; margin-bottom: 12px; }
.work-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line); }
.work-row:first-of-type { border-top: none; }
.work-row.static { grid-template-columns: auto 1fr auto; }
.work-row .work-rank { font-family: var(--mono); color: var(--text-faint); font-weight: 700; }
.work-row .work-name { font-size: 12.5px; font-weight: 600; overflow: hidden; }
.work-row .work-name .hint { font-weight: 400; display: block; }
.work-row .work-metric { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
a.work-row:hover { text-decoration: none; }
a.work-row:hover .work-name { color: var(--cyan); }

.ci-list { display: flex; flex-direction: column; gap: 10px; }
.ci-item { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
  border-left-width: 3px; }
.ci-winner { border-left-color: var(--green); }
.ci-loser { border-left-color: var(--red); }
.ci-tag_trend { border-left-color: var(--cyan); }
.ci-headline { font-size: 12.5px; font-weight: 600; line-height: 1.4; }

/* journal */
.journal-panel { display: flex; flex-direction: column; gap: 16px; }
.journal-add { display: flex; flex-direction: column; gap: 10px; }
.journal-add textarea { width: 100%; background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--sans); font-size: 13px; resize: vertical; }
.journal-add textarea:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 0 3px rgba(34,211,238,0.14); }
.journal-add-row { display: flex; gap: 10px; align-items: center; }
.journal-list { display: flex; flex-direction: column; }
.journal-item { display: grid; grid-template-columns: 74px 1fr auto; gap: 12px; align-items: start;
  padding: 11px 0; border-top: 1px solid var(--line); }
.journal-item:first-child { border-top: none; }
.journal-item.pinned { background: rgba(238,176,39,0.05); border-radius: var(--radius-sm); padding: 11px 10px; }
.journal-item.event { opacity: 0.72; }
.journal-item.event .journal-body { font-style: italic; color: var(--text-dim); }
.journal-main { min-width: 0; }
.journal-body { font-size: 13px; line-height: 1.5; }
.journal-meta { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.journal-actions { display: flex; gap: 5px; }
.note-type { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 3px 8px; border-radius: 5px; text-align: center; }
.nt-note { background: rgba(34,211,238,0.12); color: var(--cyan); }
.nt-change { background: rgba(238,176,39,0.14); color: var(--gold); }
.nt-test { background: rgba(167,139,250,0.16); color: #c4b5fd; }
.nt-idea { background: rgba(52,211,153,0.14); color: var(--green); }
.nt-event { background: var(--surface-2); color: var(--text-faint); }

/* ad deep-dive */
.ad-header { display: grid; grid-template-columns: 180px 1fr auto; gap: 20px; align-items: start; margin-bottom: 20px; }
.ad-thumb { width: 180px; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-3); }
.ad-head-main { min-width: 0; }
.ad-breadcrumbs { margin-bottom: 6px; }
.ad-breadcrumbs a { color: var(--text-dim); }
.ad-title { font-size: 19px; margin: 0 0 10px; font-weight: 700; }
.ad-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ad-tags-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ad-head-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

.kpi-strip { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; margin-bottom: 20px; }
.kpi-mini { background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 13px; }
.kpi-mini .label { color: var(--text-faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kpi-mini .value { font-size: 18px; font-weight: 800; margin-top: 6px; font-family: var(--mono); }
.kpi-mini .value.money { color: var(--gold); }
.kpi-mini .sub { color: var(--text-faint); font-size: 11px; margin-top: 3px; }

table.grid tbody tr.top-key { background: rgba(34,211,238,0.06); }
table.grid tbody tr.top-key td:first-child { box-shadow: inset 2px 0 0 var(--cyan); font-weight: 700; }

/* ========== V5: identity, role chips, theme toggle, users, connect guide ========== */
.identity { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.identity .who { min-width: 0; }
.identity .who .dn { font-weight: 700; color: var(--text); font-size: 13px; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity .who .un { font-size: 11px; color: var(--text-faint); }
.role-chip { font-size: 9.5px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 5px; }
.role-boss { background: rgba(238,176,39,0.16); color: var(--gold); border: 1px solid rgba(238,176,39,0.5); }
.role-admin { background: rgba(34,211,238,0.14); color: var(--cyan); border: 1px solid rgba(34,211,238,0.45); }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-dim);
  cursor: pointer; font-size: 14px; line-height: 1; }
.theme-toggle:hover { color: var(--cyan); border-color: var(--cyan); }
.readonly-hint { font-size: 11px; color: var(--text-faint); font-style: italic; }

table.users-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.users-tbl th { text-align: left; padding: 9px 10px; color: var(--text-faint); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--line); }
table.users-tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.acct-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.acct-checks label { display: flex; align-items: center; gap: 7px; font-weight: 500; color: var(--text); }

.connect-steps { counter-reset: step; display: flex; flex-direction: column; gap: 7px; margin: 6px 0 4px; }
.connect-steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.45;
  color: var(--text-dim); list-style: none; }
.connect-steps li::before { counter-increment: step; content: counter(step); flex: 0 0 auto;
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface-3); color: var(--text);
  font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.checklist-status { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.check-item { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.check-dot { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; flex: 0 0 auto; }
.check-dot.on { background: rgba(52,211,153,0.16); color: var(--green); border: 1px solid rgba(52,211,153,0.5); }
.check-dot.off { background: var(--surface-3); color: var(--text-faint); border: 1px solid var(--line-2); }
.check-item .cl { color: var(--text); font-weight: 600; }
.check-item .cd { color: var(--text-faint); }

@media (max-width: 1200px) {
  .kpi-strip { grid-template-columns: repeat(4, 1fr); }
  .work-panel { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .ad-header { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
