/* nhmon -- shared styling.
   Palette roles, not raw hex, in the body below: light/dark swap in one place.
   Dark is declared under BOTH the media query and the data-theme scope so a
   viewer's explicit choice wins over the OS setting either way. */

:root {
  color-scheme: light;
  --plane:    #f9f9f7;
  --surface:  #fcfcfb;
  --ink:      #0b0b0b;
  --ink-2:    #52514e;
  --muted:    #898781;
  --grid:     #e1e0d9;
  --axis:     #c3c2b7;
  --ring:     rgba(11,11,11,.10);
  --fill:     #2a78d6;   /* sequential blue: ONU occupancy is a magnitude */
  --track:    #e1e0d9;
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:   #0d0d0d;
    --surface: #1a1a19;
    --ink:     #ffffff;
    --ink-2:   #c3c2b7;
    --muted:   #898781;
    --grid:    #2c2c2a;
    --axis:    #383835;
    --ring:    rgba(255,255,255,.10);
    --fill:    #3987e5;
    --track:   #2c2c2a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:   #0d0d0d;
  --surface: #1a1a19;
  --ink:     #ffffff;
  --ink-2:   #c3c2b7;
  --muted:   #898781;
  --grid:    #2c2c2a;
  --axis:    #383835;
  --ring:    rgba(255,255,255,.10);
  --fill:    #3987e5;
  --track:   #2c2c2a;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }

header {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  padding: 12px 18px; background: var(--surface);
  border-bottom: 1px solid var(--grid); position: sticky; top: 0; z-index: 5;
}
header h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .01em; }
header .right { margin-left: auto; display: flex; gap: 14px; align-items: center;
  color: var(--ink-2); font-size: 12px; }
.crumb { color: var(--muted); text-decoration: none; font-size: 12px; }
.crumb:hover { color: var(--ink); }

main { padding: 18px; max-width: 1500px; margin: 0 auto; }
h2 { font-size: 12px; color: var(--muted); text-transform: uppercase;
     letter-spacing: .08em; margin: 24px 0 10px; font-weight: 600; }
h2:first-child { margin-top: 0; }

/* ---- stat tiles: hero numbers stay in ink, never in a series color ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
         gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--ring);
        border-radius: 10px; padding: 12px 14px; }
.tile .k { color: var(--muted); font-size: 11px; text-transform: uppercase;
           letter-spacing: .06em; }
.tile .v { font-size: 26px; font-weight: 600; margin-top: 2px; line-height: 1.1; }
.tile .s { color: var(--ink-2); font-size: 12px; margin-top: 2px; }

/* ---- OLT cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
         gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--ring);
        border-radius: 12px; padding: 14px; text-decoration: none; color: inherit;
        display: block; transition: border-color .12s ease; }
.card:hover { border-color: var(--fill); }
.card .top { display: flex; align-items: baseline; gap: 8px; }
.card .nm { font-size: 15px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 11px; margin-left: auto;
             font-variant-numeric: tabular-nums; }
.card .head { display: flex; align-items: flex-end; gap: 10px; margin: 10px 0 4px; }
.card .big { font-size: 28px; font-weight: 600; line-height: 1; }
.card .of { color: var(--ink-2); font-size: 13px; }
.card .meta { color: var(--ink-2); font-size: 12px; margin-bottom: 10px; }

/* ---- per-PON occupancy: magnitude on a neutral track ---- */
.pons { display: flex; flex-direction: column; gap: 4px; }
.pline { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px;
         align-items: center; font-size: 11px; }
.pline .lbl { color: var(--ink-2); font-variant-numeric: tabular-nums;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pline .num { color: var(--ink-2); font-variant-numeric: tabular-nums;
              white-space: nowrap; }
.track { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--fill); border-radius: 4px; }
.track.down i { background: var(--critical); }
.track.idle { opacity: .5; }
/* Capacity thresholds. The fill changes color AND the row gains a word --
   the color never carries the meaning on its own. */
.track.near i { background: var(--serious); }
.track.full i { background: var(--critical); }
/* The capacity ceiling, drawn on the track so "how full" is readable without
   doing arithmetic. */
.track { position: relative; }
.track.over::after { content: ""; position: absolute; top: -2px; bottom: -2px;
  right: 0; width: 2px; background: var(--critical); opacity: .75; }

/* ---- status: never color alone. Always an icon and a word. ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
         font-weight: 600; padding: 2px 8px; border-radius: 999px;
         border: 1px solid currentColor; }
.badge.crit  { color: var(--critical); }
.badge.warn  { color: var(--serious); }
.badge.ok    { color: var(--good); }
.badge.idle  { color: var(--muted); font-weight: 500; }
.badge .ico  { font-size: 12px; line-height: 1; }
/* Motion only at the hard ceiling, and never for anyone who has asked for
   less of it. A page where two things blink is a page nobody reads. */
@keyframes nh-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.badge.full { color: var(--critical); animation: nh-pulse 1.8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .badge.full { animation: none; } }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---- tables ---- */
.wrap { background: var(--surface); border: 1px solid var(--ring);
        border-radius: 10px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--grid);
         white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase;
     letter-spacing: .05em; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
td.bar { width: 34%; min-width: 120px; }

.note { background: var(--surface); border: 1px solid var(--ring);
        border-left: 3px solid var(--critical); border-radius: 8px;
        padding: 10px 14px; margin-bottom: 12px; }
.note.warn { border-left-color: var(--serious); }
.note b { font-weight: 600; }
.muted { color: var(--muted); }

/* ---- login ---- */
.login { max-width: 330px; margin: 14vh auto; background: var(--surface);
         border: 1px solid var(--ring); border-radius: 12px; padding: 24px; }
.login h1 { margin: 0 0 16px; font-size: 17px; }
.login input { width: 100%; padding: 10px 12px; margin-bottom: 10px;
               border-radius: 8px; border: 1px solid var(--axis);
               background: var(--plane); color: var(--ink); font: inherit; }
.login button { width: 100%; padding: 10px; border-radius: 8px; border: 0;
                background: var(--fill); color: #fff; font: inherit;
                font-weight: 600; cursor: pointer; }
.err { background: var(--critical); color: #fff; padding: 10px 14px;
       border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

@media (max-width: 560px) {
  main { padding: 12px; }
  .cards { grid-template-columns: 1fr; }
}
