:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1c1b19; --muted: #6d6a64; --line: #e6e3dd;
  --brand: #e8701f; --brand-ink: #ffffff; --good: #1f8a4c; --warn: #b7791f; --bad: #c53b30; --info: #2f6fcb;
  --soft: #f1efea; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312; --panel: #1d1c1a; --ink: #f1efea; --muted: #a29e96; --line: #2f2d2a;
    --brand: #f08a3f; --good: #4cc27f; --warn: #e2a748; --bad: #ef6f63; --info: #6aa1ef;
    --soft: #262421; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px; }
.brand small { font-weight: 500; color: var(--muted); }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { text-decoration: none; padding: 8px 10px; border-radius: 8px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
nav a:hover { background: var(--soft); color: var(--ink); }
nav a.active { background: var(--soft); color: var(--ink); font-weight: 600; }
.who { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; word-break: break-all; }
.main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 12px; }
.two { grid-template-columns: 1.4fr 1fr; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.up { color: var(--good); } .down { color: var(--bad); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.link { cursor: pointer; } tr.link:hover td { background: var(--soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.pro { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.pill.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.pill.info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
button:hover { background: var(--soft); }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover { filter: brightness(.95); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button:disabled { opacity: .55; cursor: default; }
.tabs { display: inline-flex; background: var(--soft); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 5px 11px; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.form { display: grid; gap: 8px; }
.form .row { display: flex; gap: 8px; flex-wrap: wrap; }
.form .row > * { flex: 1 1 120px; }
.form label { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.section { margin-top: 12px; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart .line { stroke: var(--brand); fill: none; stroke-width: 2.5; }
.chart .area { fill: color-mix(in srgb, var(--brand) 12%, transparent); }
.chart .bar { fill: color-mix(in srgb, var(--info) 70%, transparent); }
.chart .bar.bad { fill: color-mix(in srgb, var(--bad) 70%, transparent); }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .dot { fill: var(--brand); }
.convo { display: grid; gap: 10px; margin-bottom: 14px; }
.msg { border-radius: 10px; padding: 10px 12px; max-width: 80%; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: var(--soft); }
.msg.admin { background: color-mix(in srgb, var(--brand) 12%, transparent); margin-left: auto; }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 360px; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; }
.back { text-decoration: none; color: var(--muted); font-size: 13px; }
.note { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .who { display: none; }
  .two { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .table-wrap { overflow-x: auto; }
}
.center-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.signin { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.signin h1 { font-size: 19px; }
.signin .form { gap: 12px; }
.signin input { width: 100%; }
.secret { background: var(--soft); border-radius: 8px; padding: 12px; font-size: 15px; letter-spacing: .5px; word-spacing: 6px; text-align: center; user-select: all; }
.error { color: var(--bad); margin: 0; }
.side .signout { margin: 0 8px; }
.side .signout + .signout { margin-top: -10px; font-size: 12px; }
.reauth { max-width: 360px; width: calc(100% - 32px); color: var(--ink); }
.reauth::backdrop { background: rgba(0,0,0,.35); }
.role { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
