/* WhyItChanged: warm ink + ember. Palette adapted from heydamir.design (ink #151413, cream #efe9de, ember/flame). */
:root {
  --ink: #151413;
  --bg: #121110;
  --surface: #1a1917;
  --surface-2: #211f1d;
  --surface-3: #2a2825;
  --text: #efe9de;
  --muted: color-mix(in srgb, var(--text) 64%, transparent);
  --faint: color-mix(in srgb, var(--text) 40%, transparent);
  --line: #ece4d414;
  --line-2: #ece4d426;
  --ember: #ff7d38;
  --flame: #ffb470;
  --glow: #e2b383;
  --core: #fff4e4;
  --good: #7fd6a4;
  --bad: #ff8a7a;
  --warn: #ffc56e;
  --info: #9cc3ff;
  --demo: #c9a7ff;
  --grad: linear-gradient(100deg, #f7dcb8 0%, #e3a06a 22%, #f6cfa6 40%, #c97f58 58%, #f2c79b 76%, #f7dcb8 100%);
  --btn: linear-gradient(180deg, #ffb470, #ff7d38);
  --shadow: 0 1px 0 #ffffff08 inset, 0 10px 30px -12px #000000aa;
  --radius: 14px;
  --font: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink: #f6f1e8; --bg: #f3eee5; --surface: #fbf8f2; --surface-2: #f4efe6; --surface-3: #ebe4d8;
    --text: #1d1a17; --line: #2a20140f; --line-2: #2a20141f;
    --ember: #e8621d; --flame: #d9873f; --glow: #b9763f; --core: #3a2a1c;
    --good: #23935a; --bad: #d4443a; --warn: #b7791f; --info: #2f6fd1; --demo: #7b4fd6;
    --grad: linear-gradient(100deg, #9a4f22 0%, #d9732f 30%, #b45a26 60%, #e08a45 100%);
    --shadow: 0 1px 2px #2a201410, 0 8px 24px -14px #2a201433;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --ink: #f6f1e8; --bg: #f3eee5; --surface: #fbf8f2; --surface-2: #f4efe6; --surface-3: #ebe4d8;
  --text: #1d1a17; --line: #2a20140f; --line-2: #2a20141f;
  --ember: #e8621d; --flame: #d9873f; --glow: #b9763f; --core: #3a2a1c;
  --good: #23935a; --bad: #d4443a; --warn: #b7791f; --info: #2f6fd1; --demo: #7b4fd6;
  --grad: linear-gradient(100deg, #9a4f22 0%, #d9732f 30%, #b45a26 60%, #e08a45 100%);
  --shadow: 0 1px 2px #2a201410, 0 8px 24px -14px #2a201433;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--flame); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 15px; letter-spacing: -0.01em; }
h3 { font-size: 13px; }
p { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.glow-text {
  color: transparent;
  background-image: var(--grad);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--flame) 30%, transparent)) drop-shadow(0 0 22px color-mix(in srgb, var(--ember) 18%, transparent));
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer { to { background-position: -250% 0; } }
@media (prefers-reduced-motion: reduce) { .glow-text { animation: none; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, var(--bg));
  padding: 18px 12px; display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: radial-gradient(circle at 30% 30%, var(--core), var(--flame) 40%, var(--ember) 75%); box-shadow: 0 0 18px color-mix(in srgb, var(--ember) 45%, transparent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.nav svg { width: 16px; height: 16px; opacity: 0.85; flex: none; }
.nav .count { margin-left: auto; font-size: 11px; color: var(--bad); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 6px; color: var(--faint); font-size: 12px; }
.app-switch { width: 100%; }

.main { min-width: 0; padding: 22px 28px 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); margin-top: 4px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .hint { color: var(--faint); font-size: 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1fr) 340px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.kpi { background: var(--surface); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.kpi .value { font-size: 24px; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; }
.kpi .delta { font-size: 12px; margin-top: 2px; color: var(--faint); }
.up { color: var(--good) !important; }
.down { color: var(--bad) !important; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.01em; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-demo { color: var(--demo); border-color: color-mix(in srgb, var(--demo) 40%, transparent); background: color-mix(in srgb, var(--demo) 10%, transparent); }
.b-ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.b-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.b-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.b-est { color: var(--warn); border-style: dashed; }
.b-meas { color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.b-prov { color: var(--faint); border-style: dashed; }

/* ---------- forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px; border: 0; cursor: pointer;
  font: 600 13px/1 var(--font); color: #1b1006; background: var(--btn);
  box-shadow: 0 0 0 1px #ffffff1a inset, 0 6px 18px -8px color-mix(in srgb, var(--ember) 80%, transparent);
  transition: transform .16s cubic-bezier(.2,.8,.2,1), filter .15s;
}
.btn:hover { filter: brightness(1.06); color: #1b1006; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 40%, transparent); }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font: 13px/1.4 var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { font-family: var(--mono); font-size: 12px; min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: color-mix(in srgb, var(--ember) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ember) 18%, transparent); }
.field { margin-bottom: 12px; }
.field .help { color: var(--faint); font-size: 12px; margin-top: 4px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }
select.compact, input.compact { width: auto; padding: 6px 10px; border-radius: 999px; font-size: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* ---------- charts ---------- */
.chart { position: relative; height: 320px; }
.chart.sm { height: 220px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- markers / lists ---------- */
.mk { display: inline-flex; width: 20px; height: 20px; border-radius: 6px; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; color: #140c05; }
.mk-release { background: var(--flame); }
.mk-deploy { background: var(--info); }
.mk-ad_change { background: var(--good); }
.mk-push { background: var(--demo); }
.mk-note { background: var(--faint); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; cursor: default; }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; border-radius: 8px; }
.list-item.clickable:hover { background: var(--surface-2); }
.list-item .meta { color: var(--faint); font-size: 12px; }
.empty { color: var(--faint); padding: 20px; text-align: center; border: 1px dashed var(--line-2); border-radius: 12px; }

.callout { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); color: var(--text); }
.callout.bad { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); color: var(--text); }
.callout.demo { border-color: color-mix(in srgb, var(--demo) 35%, transparent); background: color-mix(in srgb, var(--demo) 7%, var(--surface)); color: var(--text); }
.callout strong { color: var(--text); }

.ba-table td:first-child { color: var(--muted); }
.steps { margin: 0; padding-left: 18px; color: var(--muted); }
.steps li { margin-bottom: 6px; }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.conn { display: flex; flex-direction: column; gap: 8px; }
.conn .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conn p { color: var(--muted); font-size: 13px; margin: 0; flex: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth::before { content: ""; position: absolute; width: 900px; height: 900px; left: 50%; top: -420px; transform: translateX(-50%); background: radial-gradient(closest-side, color-mix(in srgb, var(--ember) 22%, transparent), transparent 70%); pointer-events: none; }
.auth-box { width: 100%; max-width: 400px; position: relative; }
.auth h1 { font-size: 34px; margin: 18px 0 6px; }
.auth .lede { color: var(--muted); margin-bottom: 22px; }
.err { color: var(--bad); font-size: 13px; margin-bottom: 10px; }
.ok-msg { color: var(--good); font-size: 13px; margin-bottom: 10px; }

.secret-once { font-family: var(--mono); padding: 10px 12px; border-radius: 10px; background: var(--surface-3); border: 1px dashed var(--flame); word-break: break-all; }
details summary { cursor: pointer; color: var(--muted); }
.drawer { position: fixed; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); z-index: 50; display: none; }
.drawer.open { display: block; animation: rise .22s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.theme-toggle { background: none; border: 1px solid var(--line-2); color: var(--muted); border-radius: 999px; padding: 4px 10px; cursor: pointer; font: 12px var(--font); }

@media (max-width: 1100px) { .g-main { grid-template-columns: 1fr; } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; }
  .nav-label, .side-foot { display: none; }
  .nav a { white-space: nowrap; }
  .main { padding: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .chart { height: 260px; }
}
.est { color: var(--warn); text-decoration: underline dashed color-mix(in srgb, var(--warn) 50%, transparent); text-underline-offset: 3px; }
.btn[aria-busy="true"] { opacity: .6; cursor: progress; }
