/* Design tokens follow shadcn/ui's semantic scheme (background, card, muted, border, primary, destructive, chart-N, ring)
   in OKLCH; the original variable names below are aliases onto them. Themes: light (white), dark, green. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --background: oklch(0.985 0 0); --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0); --secondary: oklch(0.97 0 0); --muted-foreground: oklch(0.556 0 0);
  --border: oklch(0.922 0 0); --ring: oklch(0.708 0 0);
  --primary: oklch(0.205 0 0); --primary-foreground: oklch(0.985 0 0); --link: oklch(0.488 0.2 264);
  --ok: oklch(0.6 0.16 150); --warn: oklch(0.7 0.16 70); --destructive: oklch(0.577 0.245 27.325); --info: oklch(0.56 0.15 250);
  --chart-1: oklch(0.646 0.222 41.116); --chart-2: oklch(0.6 0.118 184.704); --chart-3: oklch(0.398 0.07 227.392); --chart-4: oklch(0.828 0.189 84.429);
  --shadow: 0 1px 2px oklch(0 0 0 / 5%);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #11171b; --foreground: oklch(0.985 0 0);
  --card: #181f25; --secondary: #202931; --muted-foreground: oklch(0.708 0 0);
  --border: oklch(1 0 0 / 10%); --ring: oklch(0.556 0 0);
  --primary: oklch(0.922 0 0); --primary-foreground: oklch(0.205 0 0); --link: oklch(0.75 0.13 255);
  --ok: oklch(0.72 0.17 155); --warn: oklch(0.769 0.188 70); --destructive: oklch(0.704 0.191 22.216); --info: oklch(0.72 0.12 245);
  --chart-1: oklch(0.488 0.243 264.376); --chart-2: oklch(0.696 0.17 162.48); --chart-3: oklch(0.769 0.188 70.08); --chart-4: oklch(0.627 0.265 303.9);
  --shadow: none;
}
/* green: built from the logo's greens: its background (#10523d) is the surface colour, its ring green is the primary */
:root[data-theme="green"] {
  color-scheme: dark;
  --background: #0b3a2c; --foreground: #e9fff4;
  --card: #10523d; --secondary: #17634b; --muted-foreground: #9fd6bd;
  --border: #23775a; --ring: #14be72;
  --primary: #14be72; --primary-foreground: #04261a; --link: #5fe3a2;
  --ok: oklch(0.8 0.18 155); --warn: oklch(0.84 0.15 85); --destructive: oklch(0.74 0.18 25); --info: oklch(0.8 0.1 230);
  --chart-1: #14be72; --chart-2: oklch(0.82 0.11 195); --chart-3: oklch(0.86 0.15 95); --chart-4: oklch(0.78 0.11 245);
  --shadow: 0 1px 2px oklch(0 0 0 / 25%);
}
:root {
  --bg: var(--background); --panel: var(--card); --panel2: var(--secondary); --text: var(--foreground); --muted: var(--muted-foreground);
  --line: var(--border); --accent: var(--primary); --accent-fg: var(--primary-foreground); --bad: var(--destructive);
  --ok-bg: color-mix(in oklab, var(--ok) 15%, transparent); --warn-bg: color-mix(in oklab, var(--warn) 18%, transparent);
  --bad-bg: color-mix(in oklab, var(--bad) 14%, transparent); --info-bg: color-mix(in oklab, var(--info) 14%, transparent);
  --grey-bg: var(--secondary);
  --c-cpu: var(--chart-1); --c-mem: var(--chart-2); --c-rx: var(--chart-3); --c-tx: var(--chart-4);
  --radius: .625rem; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 15px; margin: 0 0 12px; } h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); } .right { text-align: right; } .nowrap { white-space: nowrap; }

/* shell */
header.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 9px; } .brand img { border-radius: 50%; display: block; } .brand:hover { text-decoration: none; }
nav.main { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
nav.main a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; transition: background .12s, color .12s; }
nav.main a:hover { background: var(--panel2); text-decoration: none; } nav.main a.on { background: var(--panel2); color: var(--text); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.badge:empty { display: none; }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }
main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card.flush { padding: 0; overflow: hidden; } .card.flush > h2 { padding: 14px 18px 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 14px; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.span2 { grid-column: 1 / -1; } .grid > * { min-width: 0; }
.tile { padding: 14px 16px; } .tile .n { font-size: 28px; font-weight: 700; line-height: 1.1; } .tile .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tile.ok .n { color: var(--ok); } .tile.bad .n { color: var(--bad); } .tile.warn .n { color: var(--warn); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click:hover { background: var(--panel2); cursor: pointer; }
.tablewrap { overflow-x: auto; }
dl.kv { display: grid; grid-template-columns: minmax(110px, 36%) 1fr; gap: 7px 14px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.info { background: var(--info-bg); color: var(--info); } .pill.grey { background: var(--grey-bg); color: var(--muted); }
.sev-critical { color: var(--bad); font-weight: 600; } .sev-warning { color: var(--warn); font-weight: 600; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--grey-bg); color: var(--muted); font-size: 12px; }

/* forms */
button, .btn { font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
button:hover:not(:disabled) { background: var(--panel2); } button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); } button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; } button.danger:hover:not(:disabled) { background: var(--bad-bg); }
button.small { padding: 3px 10px; font-size: 12.5px; }
input, select, textarea { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); max-width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
label.f { display: block; margin-bottom: 12px; } label.f > span { display: block; font-weight: 600; margin-bottom: 4px; }
label.f small { display: block; color: var(--muted); margin-top: 3px; font-weight: 400; }
label.f input:not([type=checkbox]), label.f select { width: 100%; max-width: 420px; }
label.chk { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 600; } label.chk input { width: 16px; height: 16px; }
.formrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; } .toolbar input[type=search] { min-width: 240px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; } .tabs a.on { color: var(--text); border-color: var(--accent); } .tabs a:hover { text-decoration: none; }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--info-bg); margin-bottom: 14px; } .notice.warn { background: var(--warn-bg); } .notice.bad { background: var(--bad-bg); }
.cmd { position: relative; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 6px 0 12px; overflow-x: auto; }
.cmd code { white-space: pre-wrap; word-break: break-all; display: block; padding-right: 60px; } .cmd button { position: absolute; top: 6px; right: 6px; }

/* meters & charts */
meter { width: 100%; height: 10px; border-radius: 5px; vertical-align: middle; background: var(--panel2); }
meter::-webkit-meter-bar { background: var(--panel2); border-radius: 5px; height: 10px; border: 0; }
meter::-webkit-meter-optimum-value { background: var(--ok); border-radius: 5px; }
meter::-webkit-meter-suboptimum-value { background: var(--warn); border-radius: 5px; }
meter::-webkit-meter-even-less-good-value { background: var(--bad); border-radius: 5px; }
meter::-moz-meter-bar { background: var(--ok); border-radius: 5px; } meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--warn); } meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--bad); }
.big { font-size: 30px; font-weight: 700; line-height: 1; } .bigsub { color: var(--muted); margin: 4px 0 10px; }
.vol { margin-bottom: 14px; } .vol:last-child { margin-bottom: 0; } .vol .row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; } svg.chart text { fill: var(--muted); font-size: 10px; }
svg.chart .ln { fill: none; stroke-width: 1.6; stroke-linejoin: round; } svg.chart .ar { stroke: none; opacity: .14; }
.s-cpu { stroke: var(--c-cpu); fill: var(--c-cpu); } .s-mem { stroke: var(--c-mem); fill: var(--c-mem); } .s-rx { stroke: var(--c-rx); fill: var(--c-rx); } .s-tx { stroke: var(--c-tx); fill: var(--c-tx); }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin-top: 4px; } .legend i { display: inline-block; width: 10px; height: 3px; margin-right: 5px; vertical-align: middle; border-radius: 2px; }
.legend .s-cpu { background: var(--c-cpu); } .legend .s-mem { background: var(--c-mem); } .legend .s-rx { background: var(--c-rx); } .legend .s-tx { background: var(--c-tx); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; } .seg button { border: 0; border-radius: 0; padding: 4px 11px; font-size: 12.5px; } .seg button.on { background: var(--accent); color: var(--accent-fg); }
.empty { text-align: center; padding: 38px 20px 42px; color: var(--muted); } .empty h2 { color: var(--text); margin: 10px 0 4px; font-size: 16px; }
.empty .art { display: block; margin: 0 auto; width: 96px; height: 96px; border-radius: 50%; filter: drop-shadow(0 6px 14px color-mix(in oklab, var(--primary) 30%, transparent)); }
.authlogo { display: block; margin: 0 auto 8px; width: 96px; height: 96px; border-radius: 50%; }
#app { min-height: 100vh; display: flex; flex-direction: column; } #app > main { flex: 1; width: 100%; } #app > .authwrap { flex: 1; min-height: 0; }
footer.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; background: var(--panel); }
footer.foot .fl { display: flex; align-items: center; gap: 8px; } footer.foot .fl img { border-radius: 50%; } footer.foot b { color: var(--text); font-weight: 600; }
footer.foot .ver { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--grey-bg); }

/* login */
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.authcard { width: 100%; max-width: 380px; } .authcard h1 { text-align: center; margin-bottom: 4px; } .authcard .sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.authcard label.f input { max-width: none; } .authcard button.primary { width: 100%; padding: 10px; }
.err { color: var(--bad); min-height: 20px; margin: 8px 0; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.bad { background: var(--bad); color: #fff; }
.themes { padding: 0; } .themes button { padding: 3px 9px; font-size: 12px; background: transparent; }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; }
@media (max-width: 720px) {
  header.top { gap: 8px; padding: 0 10px; } .userbox .u { display: none; } main { padding: 14px 10px 50px; }
  .grid { grid-template-columns: minmax(0, 1fr); } td, th { padding: 9px 10px; }
}
@media (prefers-reduced-motion: no-preference) { .empty .art { animation: sway 6s ease-in-out infinite; transform-origin: 50% 90%; } @keyframes sway { 50% { transform: rotate(3deg) translateY(-2px); } } .toast { animation: pop .18s ease-out; } @keyframes pop { from { transform: translateY(6px); opacity: 0; } } }
footer.foot .copy::before { content: "·"; margin-right: 8px; }
