:root {
  --bg: #060b16;
  --panel: #0b1426;
  --line: #1c2a44;
  --text: #e3e9f3;
  --muted: #8293ad;
  --blue: #4f8fe0;
  --gold: #c9a24a;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--text); background: var(--bg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
code { font-size: .92em; color: var(--gold); }

.top {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--gold);
  background: linear-gradient(#0a1224, var(--bg));
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.crest { font-weight: 700; letter-spacing: 3px; font-size: 17px; }
.brand .sub { color: var(--gold); font-size: 13px; letter-spacing: .5px; text-transform: uppercase; }
.ranges { display: flex; gap: 4px; flex-wrap: wrap; }
.ranges a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; }
.ranges a.on { color: var(--bg); background: var(--gold); border-color: var(--gold); font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 8px 24px 40px; }
h1 { font-size: 24px; margin: 8px 0 14px; }
h1.sec { font-size: 19px; margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.period { color: var(--text); margin: 14px 0; font-size: 13px; }
.back { font-size: 14px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi .v { display: block; font-size: 26px; font-weight: 650; line-height: 1.1; }
.kpi .l { display: block; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.kpi em { display: block; font-style: normal; color: var(--gold); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.cols .panel { margin-bottom: 0; }
.cols + .panel { margin-top: 14px; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
td.n, th.n { text-align: right; }
td.lbl { white-space: normal; word-break: break-all; min-width: 170px; }
tbody tr:hover { background: #0f1b33; }

.legend { text-transform: none; letter-spacing: 0; font-weight: 400; display: inline-flex; gap: 6px; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.legend .k1 { background: var(--blue); }
.legend .k2 { background: var(--gold); }

svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
svg.chart .s1 { fill: var(--blue); }
svg.chart .s2 { fill: var(--gold); }
svg.chart rect:hover { opacity: .75; }

footer { margin-top: 30px; color: var(--muted); font-size: 13px; }
footer dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 12px 0; }
footer dt { color: var(--text); }
footer dd { margin: 0; }
@media (max-width: 600px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  footer dl { grid-template-columns: 1fr; }
  footer dd { margin-bottom: 6px; }
}

/* ===================================================================== Archon
   Navigation, forms, auth pages, tenant charts and logs. Still no script:
   every interaction is a link or a form. */
.top { position: sticky; top: 0; z-index: 2; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav.main a:hover { color: var(--text); background: #0f1b33; text-decoration: none; }
nav.main a.on { color: var(--text); background: #13213d; box-shadow: inset 0 -2px 0 var(--gold); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who a.on { color: var(--gold); }
.subnav { display: flex; gap: 18px; max-width: 1120px; margin: 0 auto; padding: 12px 24px 0; font-size: 14px; }
.subnav a { color: var(--muted); }
.subnav a:hover { color: var(--text); }

.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin: 14px 0 10px; }
h1.page { margin: 0; font-size: 22px; }
h1.page .muted, h1 .muted { font-weight: 400; }
a.back { color: var(--muted); }
.small { font-size: 12.5px; }
.inline { display: inline; margin: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: 14px; border: 1px solid; }
.flash.ok { background: #0d2a1e; border-color: #1f6b47; color: #b7f0d2; }
.flash.err { background: #2b1015; border-color: #8a2d3a; color: #ffc7cf; }
.flash.warn { background: #2a230d; border-color: #806a1f; color: #f5e3a8; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.tag.good { color: #9ee6c0; border-color: #1f6b47; }
.tag.bad { color: #ffb3bf; border-color: #8a2d3a; }

/* ---- forms ---- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, textarea, select {
  font: inherit; font-size: 14px; color: var(--text); background: #08101f;
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; min-width: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: transparent; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }
button, .button {
  font: inherit; font-size: 13.5px; cursor: pointer; color: var(--text); background: #13213d;
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 14px; display: inline-block;
}
button:hover, .button:hover { border-color: var(--blue); text-decoration: none; }
button.primary, .button.primary { background: var(--gold); border-color: var(--gold); color: #0a1224; font-weight: 600; }
button.danger { color: #ffb3bf; }
button.danger:hover { border-color: #8a2d3a; }
button.link { background: none; border: none; color: var(--muted); padding: 0; }
button.link:hover { color: var(--text); }
form.stack { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
form.stack button { align-self: flex-start; }
form.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin: 6px 0; }
form.row .grow { flex: 1 1 260px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { margin-left: 4px; }
tr.keyrow td { padding-top: 0; background: #0a1324; }
.reveal { border-color: var(--gold); }
code.secret { font-size: 15px; letter-spacing: 1px; color: var(--text); background: #08101f; padding: 3px 8px; border-radius: 6px; word-break: break-all; }

/* ---- sign-in, enrolment ---- */
.auth { max-width: 420px; margin: 48px auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px; }
.auth.wide { max-width: 560px; }
.auth h1 { margin-top: 0; }
.auth ol { padding-left: 20px; }
img.qr { display: block; margin: 8px 0 6px; border-radius: 8px; background: #fff; padding: 8px; }
ol.codes { columns: 2; padding-left: 26px; font-size: 16px; line-height: 1.9; }
ol.codes code { color: var(--text); }

/* ---- tenant charts ---- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 14px; }
.grid2 .panel { margin-bottom: 0; }
.grid2 + .panel { margin-top: 14px; }
svg.chart path.ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .c0 { stroke: #4f8fe0; } svg.chart .c1 { stroke: #c9a24a; } svg.chart .c2 { stroke: #5fc4a0; } svg.chart .c3 { stroke: #d9738c; }
svg.chart .c4 { stroke: #a58bea; } svg.chart .c5 { stroke: #e39a55; } svg.chart .c6 { stroke: #7fc8e8; } svg.chart .c7 { stroke: #b4c06a; }
ul.legend-list { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
ul.legend-list b { color: var(--text); font-weight: 600; margin-left: 4px; }
i.sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
i.sw.c0 { background: #4f8fe0; } i.sw.c1 { background: #c9a24a; } i.sw.c2 { background: #5fc4a0; } i.sw.c3 { background: #d9738c; }
i.sw.c4 { background: #a58bea; } i.sw.c5 { background: #e39a55; } i.sw.c6 { background: #7fc8e8; } i.sw.c7 { background: #b4c06a; }
.kpi .v a { color: var(--blue); }

/* ---- logs ---- */
form.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin: 10px 0; }
form.filters label:nth-child(3) { flex: 1 1 240px; }
table.logs { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
table.logs td { vertical-align: top; padding: 4px 8px; }
table.logs td.ts { color: var(--muted); white-space: nowrap; }
table.logs td.src { color: var(--gold); white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
table.logs td.line { white-space: pre-wrap; word-break: break-word; }

@media (max-width: 760px) {
  .top { position: static; }
  nav.main { order: 3; width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  ol.codes { columns: 1; }
  .auth { margin: 20px auto; padding: 20px; }
}

/* Archon users / activity */
td.nowrap, .nowrap { white-space: nowrap; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.btnrow { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.subnav .muted { margin-left: auto; }
