:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --s-blue: #2a78d6;      /* received, CPU */
  --s-blue-track: #cde2fb;
  --s-orange: #eb6834;    /* sent */
  --s-aqua: #1baf7a;
  --s-violet: #4a3aa7;    /* memory */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #09090b;
    --surface: #141416;
    --surface-2: #1d1d20;
    --ink: #f4f4f2;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.08);
    --s-blue: #3987e5;
    --s-blue-track: #1c2a3d;
    --s-orange: #d95926;
    --s-aqua: #199e70;
    --s-violet: #9085e9;
    --good-ink: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #09090b; --surface: #141416; --surface-2: #1d1d20; --ink: #f4f4f2; --ink-2: #c3c2b7;
  --muted: #898781; --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.08);
  --s-blue: #3987e5; --s-blue-track: #1c2a3d; --s-orange: #d95926; --s-aqua: #199e70; --s-violet: #9085e9; --good-ink: #0ca30c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body { -webkit-font-smoothing: antialiased; }
#root { max-width: 1280px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px 32px; }
h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 13px; margin: 0 0 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.err { color: var(--critical); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  background: var(--ink); color: var(--page); text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button.ghost, .btn.ghost { background: var(--surface-2); color: var(--ink); }
button.icon { padding: 8px; }
button.icon svg { width: 18px; height: 18px; fill: currentColor; }
button:disabled { opacity: .5; cursor: default; }
input { font: inherit; font-size: 16px; width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--ring); background: var(--surface-2); color: var(--ink); margin-bottom: 10px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 14px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 22px; height: 22px; fill: var(--s-blue); }
.top-right { display: flex; align-items: center; gap: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); padding: 3px 9px 3px 7px; border-radius: 99px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: beat 2s infinite; }
.live.stale i { background: var(--muted); animation: none; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.5); } 70% { box-shadow: 0 0 0 6px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }

.card { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 16px; min-width: 0; }
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.traffic { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.hosts { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.signin { max-width: 420px; margin: 40px auto; }
.signin form { margin-top: 14px; }
.signin button { width: 100%; justify-content: center; padding: 12px; }
.menu { margin-bottom: 12px; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.menu-row:last-child { border-bottom: 0; }
.menu-row p { margin: 2px 0 0; font-size: 13px; }

/* Alerts: status color + icon + words, never color alone. */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--ring); border-left: 4px solid var(--warning); }
.alert.critical { border-left-color: var(--critical); }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert.critical svg { fill: var(--critical); }
.alert.warning svg { fill: var(--warning); }
.alert b { display: block; font-size: 15px; }
.alert span { font-size: 13px; color: var(--ink-2); }
.alert small { margin-left: auto; color: var(--muted); white-space: nowrap; font-size: 12px; }
.allgood { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; color: var(--ink-2); }
.allgood svg { width: 18px; height: 18px; fill: var(--good); }

/* Monthly traffic */
.tr-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tr-value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin: 6px 0 2px; }
.tr-value small { font-size: 15px; font-weight: 500; color: var(--muted); }
.meter { position: relative; height: 10px; border-radius: 5px; background: var(--s-blue-track); margin: 12px 0 8px; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--s-blue); }
.meter.warn > i { background: var(--warning); }
.meter.crit > i { background: var(--critical); }
.meter > b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-2); border-radius: 1px; }
.tr-note { font-size: 13px; color: var(--ink-2); }

/* Server cards */
.host-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.host-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
.host-head .sub { font-size: 12px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.pill.off i { background: var(--critical); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 12px; min-width: 0; }
.tile .lbl { font-size: 12px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 6px; }
.tile .val { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin: 2px 0 0; white-space: nowrap; }
.tile .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.tile .note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .meter { margin: 8px 0 4px; height: 6px; }
.spark { display: block; width: 100%; height: 34px; margin-top: 6px; }
.spark path.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.cores { display: flex; gap: 3px; margin-top: 8px; height: 22px; align-items: flex-end; }
.cores i { flex: 1; background: var(--s-blue); border-radius: 3px 3px 0 0; min-height: 2px; }
.units { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.unit { font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 5px 8px; display: inline-flex; gap: 6px; align-items: center; }
.unit i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.unit.bad i { background: var(--critical); }
.unit span { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Lists */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row .k { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .k a { color: inherit; text-decoration: none; }
.row .v { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.dot.bad { background: var(--critical); }
.dot.warn { background: var(--warning); }
.dot.idle { background: var(--muted); }
.big { font-size: 22px; font-weight: 650; }
.sub-h { margin-top: 18px; }

/* History */
.history-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.history-head h2 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { background: transparent; color: var(--ink-2); padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px 22px; margin-top: 8px; }
.chart h4 { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.chart .cap { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.legend i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; vertical-align: middle; margin-right: 5px; }
.plot { position: relative; }
.plot svg { display: block; width: 100%; height: 150px; overflow: visible; }
.plot .gridl { stroke: var(--grid); stroke-width: 1; }
.plot .base { stroke: var(--axis); stroke-width: 1; }
.plot text { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.plot .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .cross { stroke: var(--axis); stroke-width: 1; }
.plot .mark { stroke: var(--surface); stroke-width: 2; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--page); font-size: 12px; padding: 7px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -100%); top: 0; z-index: 2; }
.tip b { display: block; font-weight: 600; margin-bottom: 2px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.empty { font-size: 13px; color: var(--muted); padding: 30px 0; text-align: center; }
.foot { font-size: 12px; text-align: center; margin-top: 18px; }
.log .row .v { font-size: 12px; }

/* ---------------------------------------------------------------- wall display (tablet) */
body.wall #root { max-width: none; padding: 20px 26px; height: 100vh; display: flex; flex-direction: column; transition: transform 2s ease; }
body.wall .top { padding-bottom: 12px; }
body.wall h1 { font-size: 22px; }
body.wall #clock { font-size: 26px; font-weight: 600; color: var(--ink); }
body.wall #history, body.wall #alertLog, body.wall #menuBtn, body.wall .foot { display: none; }
body.wall main { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto minmax(0, 1fr); gap: 12px; min-height: 0; overflow: hidden; }
body.wall main > * { margin: 0; }
body.wall #alerts { grid-column: 1 / -1; }
body.wall #alerts:empty { display: none; }
body.wall #traffic { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
body.wall #hosts { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
body.wall .three { grid-column: 1 / -1; grid-template-columns: 1fr 1fr 1fr; align-items: stretch; }
body.wall .tile .val { font-size: 26px; }
body.wall .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
body.wall .tile { padding: 10px; }
body.wall .tile .note { display: none; }
body.wall .cores { display: none; }
body.wall .card { padding: 14px; }
body.wall .host-head { margin-bottom: 10px; }
body.wall .units { margin-top: 8px; }
body.wall .three .card { overflow: hidden; }
body.wall .row { padding: 6px 0; }
body.wall .tr-note { display: none; }
body.wall .meter { margin: 10px 0 2px; }
body.wall .tr-value { font-size: 30px; }
body.wall .alert { padding: 16px 18px; }
body.wall .alert b { font-size: 20px; }
body.wall .alert.critical { animation: flash 1.6s ease-in-out infinite; }
@keyframes flash { 50% { background: color-mix(in srgb, var(--critical) 22%, var(--surface)); } }
body.wall .spark { height: 30px; }
@media (orientation: portrait) {
  body.wall main, body.wall #traffic, body.wall #hosts, body.wall .three { grid-template-columns: 1fr; }
}
#dim { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 3s; }
body.night #dim { opacity: .6; }
@media (max-width: 420px) {
  .tile .val { font-size: 22px; }
  .hosts { grid-template-columns: 1fr; }
}
@media (forced-colors: active) {
  .meter > i, .cores i, .dot, .pill i, .unit i { forced-color-adjust: none; }
}
