:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --good-ink: #0ca30c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --good-ink: #0ca30c;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; padding: 20px clamp(16px, 2.5vw, 32px) 32px; }
button { font: inherit; color: inherit; }

header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 18px; }
header h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
header .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
header .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
.live.off .dot { background: var(--critical); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { padding: 14px 16px 14px; min-height: 112px; display: flex; flex-direction: column; gap: 6px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; font-weight: 500; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.tile .value small { font-size: 15px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.tile .foot { color: var(--muted); font-size: 12px; margin-top: auto; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: auto; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--s1); transition: width .4s ease; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 7px 2px 5px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip svg { width: 12px; height: 12px; flex: none; }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; }
@media (max-width: 1100px) { .span-8, .span-4, .span-6 { grid-column: span 12; } }

.panel { padding: 14px 16px 10px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 6px; }
.panel-head h2 { font-size: 14px; font-weight: 650; margin: 0; }
.panel-head .unit { color: var(--muted); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-left: auto; }
.legend button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 3px 6px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.legend button:hover { background: var(--surface-2); }
.legend button[aria-pressed="false"] { opacity: .45; }
.legend button[aria-pressed="false"] .sw { background: transparent !important; outline: 2px solid var(--muted); outline-offset: -2px; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .08; }
.chart .dlabel { font-size: 11.5px; font-weight: 600; fill: var(--ink); }
.chart .dlabel tspan.v { fill: var(--ink-2); font-weight: 500; }
.chart .xhair { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: 12.5px; min-width: 160px; }
.tip .tt { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.tip .row { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.tip .row .n { color: var(--ink-2); flex: 1; }
.tip .row .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.fans { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 12px 0 6px; margin-top: 8px; border-top: 1px solid var(--grid); }
.fan { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.fan .top { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12.5px; }
.fan .rpm { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.fan .rpm small { font-size: 12px; color: var(--ink-2); font-weight: 500; margin-left: 2px; }
.fan .duty { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }
.fan .duty .meter { flex: 1; margin: 0; height: 4px; }
.fan .duty .meter > i { background: var(--ink-2); }
.fan.idle { opacity: .55; }
.fan svg.spin { width: 16px; height: 16px; color: var(--ink-2); }

details.readings { margin-top: 12px; }
details.readings summary { cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.readings summary::-webkit-details-marker { display: none; }
details.readings summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(-45deg); transition: transform .15s; }
details.readings[open] summary::before { transform: rotate(45deg); }
.table-wrap { overflow-x: auto; padding: 0 16px 14px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.grp { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding-top: 14px; }
footer { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ===== FS-API-MON additions (same tokens) ===== */
a { color: inherit; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; box-shadow: var(--shadow); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--s1); border-color: var(--s1); color: #fff; }
.btn.danger { color: var(--critical); }
.btn.icon { padding: 6px 9px; }
header form { margin: 0; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--s1) 45%, transparent); outline-offset: 1px; }
.muted { color: var(--muted); }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 0; }
.login-card { padding: 28px; width: 340px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 20px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.login-card input { width: 100%; padding: 9px 12px; }
.login-card .btn { padding: 9px; }
.error { color: var(--critical); margin: 0; font-size: 13px; }

/* overview */
.filters { margin-bottom: 16px; flex-wrap: wrap; }
.filters button small { color: var(--muted); margin-left: 5px; font-weight: 500; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.group-title:first-child { margin-top: 0; }
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.ws { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; transition: border-color .15s; min-width: 0; }
.ws:hover { border-color: color-mix(in srgb, var(--s1) 55%, transparent); }
.ws.offline { opacity: .62; }
.ws-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ws-head b { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-head .chip { margin-left: auto; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--critical); flex: none; }
.sdot.on { background: var(--good); }
.ws-sub { color: var(--ink-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: -6px; }
.ws-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ws-stat .k { color: var(--muted); font-size: 11.5px; display: flex; align-items: center; gap: 4px; }
.ws-stat .v { font-size: 20px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.ws-stat .v small { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-left: 1px; }
.ws-stat .meter { margin-top: 4px; height: 4px; }
.spark svg { display: block; width: 100%; height: 44px; overflow: visible; }
.spark .line { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.ws-foot { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.ws-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { text-align: center; color: var(--ink-2); padding: 70px 20px; }
.empty-state img { width: 72px; height: 72px; opacity: .9; }
.st-good { color: var(--good-ink); } .st-warning { color: #b07d00; } .st-serious { color: var(--serious); } .st-critical { color: var(--critical); }
:root[data-theme="dark"] .st-warning { color: var(--warning); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-warning { color: var(--warning); } }

/* machine page extras */
.back { color: var(--ink-2); text-decoration: none; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.back:hover { color: var(--ink); }
.client-pick { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.notice { padding: 10px 14px; margin-bottom: 12px; border-left: 3px solid var(--warning); font-size: 13px; color: var(--ink-2); }
h2.section { font-size: 14px; font-weight: 650; margin: 18px 0 10px; }
.drives { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.drive { padding: 14px 16px; }
.drive-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; min-width: 0; }
.drive-head b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-head .chip { margin-left: auto; }
.kind { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); border-radius: 4px; padding: 2px 6px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.fact span { display: block; color: var(--muted); font-size: 11.5px; }
.fact b { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.drive .foot { color: var(--muted); font-size: 12px; margin-top: 8px; }
.vol { margin-bottom: 10px; }
.vol-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.vol-top span { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 28px; }
.kv div { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.kv div span:first-child { color: var(--muted); }
.panel table td, .panel table th { padding: 5px 8px; }
dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,.25); max-width: 720px; width: 92vw; padding: 20px 22px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin: 0 0 12px; font-size: 16px; }
dialog ol { padding-left: 20px; line-height: 1.7; }
dialog .row { display: flex; gap: 8px; margin-bottom: 12px; }
dialog .row input { flex: 1; }
dialog .actions { display: flex; justify-content: flex-end; margin-top: 14px; }
pre.cmd { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
