/* 4all Monitor · Kult — sistema visual
   Tokens em OKLCH; tema claro por padrão, escuro via prefers-color-scheme ou [data-theme]. */
:root {
  color-scheme: light;
  --bg: oklch(0.972 0.004 165);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.958 0.006 165);
  --surface-3: oklch(0.93 0.008 165);
  --border: oklch(0.885 0.01 165);
  --border-strong: oklch(0.8 0.014 165);
  --text: oklch(0.23 0.02 165);
  --text-2: oklch(0.38 0.02 165);
  --muted: oklch(0.47 0.018 165);
  --brand: oklch(0.52 0.15 138);
  --brand-strong: oklch(0.86 0.19 130);
  --on-brand: oklch(0.2 0.03 140);
  --ok: oklch(0.5 0.14 150);
  --warn: oklch(0.54 0.13 65);
  --crit: oklch(0.52 0.2 25);
  --info: oklch(0.5 0.14 255);
  --chart: oklch(0.6 0.12 175);
  --chart-2: oklch(0.62 0.15 140);
  --grid: oklch(0.9 0.008 165);
  --focus: oklch(0.55 0.18 255);
  --shadow: 0 1px 2px oklch(0.2 0.02 165 / 0.06), 0 4px 16px oklch(0.2 0.02 165 / 0.05);
  --tint: 14%;

  --font: Inter, "Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;   /* 12 */
  --fs-sm: 0.8125rem; /* 13 */
  --fs-md: 0.9375rem; /* 15 */
  --fs-lg: 1.125rem;  /* 18 */
  --fs-xl: 1.375rem;  /* 22 */
  --fs-kpi: clamp(1.6rem, 1.2rem + 0.9vw, 2.25rem);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --gap: clamp(12px, 0.6rem + 0.6vw, 20px);
  --ease: cubic-bezier(.2,.7,.2,1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: oklch(0.165 0.012 165);
    --surface: oklch(0.205 0.013 165);
    --surface-2: oklch(0.24 0.015 165);
    --surface-3: oklch(0.28 0.016 165);
    --border: oklch(0.31 0.016 165);
    --border-strong: oklch(0.4 0.02 165);
    --text: oklch(0.95 0.01 165);
    --text-2: oklch(0.85 0.014 165);
    --muted: oklch(0.73 0.018 165);
    --brand: oklch(0.86 0.18 130);
    --ok: oklch(0.8 0.16 148);
    --warn: oklch(0.83 0.14 78);
    --crit: oklch(0.72 0.18 22);
    --info: oklch(0.77 0.12 250);
    --chart: oklch(0.78 0.12 175);
    --chart-2: oklch(0.84 0.17 132);
    --grid: oklch(0.29 0.014 165);
    --focus: oklch(0.8 0.14 250);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.3);
    --tint: 18%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.165 0.012 165);
  --surface: oklch(0.205 0.013 165);
  --surface-2: oklch(0.24 0.015 165);
  --surface-3: oklch(0.28 0.016 165);
  --border: oklch(0.31 0.016 165);
  --border-strong: oklch(0.4 0.02 165);
  --text: oklch(0.95 0.01 165);
  --text-2: oklch(0.85 0.014 165);
  --muted: oklch(0.73 0.018 165);
  --brand: oklch(0.86 0.18 130);
  --ok: oklch(0.8 0.16 148);
  --warn: oklch(0.83 0.14 78);
  --crit: oklch(0.72 0.18 22);
  --info: oklch(0.77 0.12 250);
  --chart: oklch(0.78 0.12 175);
  --chart-2: oklch(0.84 0.17 132);
  --grid: oklch(0.29 0.014 165);
  --focus: oklch(0.8 0.14 250);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.3);
  --tint: 18%;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 var(--fs-md)/1.5 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.num, td, .kpi-value, .chart-tick em { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--border); }
.skip:focus { top: 8px; }

/* ---------- Shell ---------- */
.shell { width: 100%; max-width: 2400px; margin: 0 auto; padding-inline: clamp(16px, 2.4vw, 56px); }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in oklch, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-row { display: flex; align-items: center; gap: var(--sp-3); min-height: 64px; }
.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; margin-right: auto; }
.mark { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-strong); color: var(--on-brand); font-weight: 800; font-size: 18px; letter-spacing: -0.04em; }
.brand-text { min-width: 0; }
.brand h1 { font-size: var(--fs-md); font-weight: 700; white-space: nowrap; }
.brand p { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live[data-kind="fresh"] .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklch, var(--ok) 25%, transparent); }
.live[data-kind="delayed"] .dot, .live[data-kind="api_error"] .dot { background: var(--warn); }
.icon-btn { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 10px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); gap: 6px; }
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.btn-text { display: inline-flex; align-items: center; gap: 6px; }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-bottom: -1px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; min-height: 44px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }
.tab svg { width: 16px; height: 16px; opacity: .8; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text); }
.badge.crit { background: var(--crit); color: oklch(0.99 0 0); }
.badge.warn { background: var(--warn); color: oklch(0.18 0.02 70); }

main.shell { padding-block: var(--sp-6) var(--sp-8); }
.view { display: grid; gap: var(--gap); }
.view-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--sp-3); }
.view-head h2 { font-size: var(--fs-xl); font-weight: 700; }
.view-head p { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: clamp(14px, 0.8rem + 0.4vw, 22px); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h3 { font-size: var(--fs-md); font-weight: 650; }
.card-head .sub { color: var(--muted); font-size: var(--fs-xs); }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.foot, .note { font-size: var(--fs-xs); color: var(--muted); }
.note { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--sp-3); }
.note svg { flex: none; width: 14px; height: 14px; margin-top: 2px; }
.link-btn { background: none; border: 0; padding: 6px 0; color: var(--brand); font-weight: 600; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.link-btn:hover { text-decoration: underline; }
.link-btn svg { width: 14px; height: 14px; }

.grid { display: grid; gap: var(--gap); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
@media (max-width: 640px) { .g-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); } .chart-x.alt { display: none; } }
.g-auto-lg { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .g-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .g-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.g-2 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Overview */
.ov-top { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
.machines { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) { .machines { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .ov-top { grid-template-columns: minmax(0, 2.1fr) minmax(340px, 1fr); } }
.ov-bottom { align-items: start; display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 900px) { .ov-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .ov-bottom { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); } }

.machine { display: flex; flex-direction: column; gap: var(--sp-4); position: relative; overflow: hidden; }
.machine::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--muted); }
.machine[data-status="online"]::before { background: var(--ok); }
.machine[data-status="stale"]::before { background: var(--warn); }
.machine[data-status="offline"]::before { background: var(--crit); }
.machine-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.machine-title { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.machine-icon { flex: none; width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.machine-icon svg { width: 20px; height: 20px; }
.machine h3 { font-size: var(--fs-lg); font-weight: 700; }
.machine-state { font-size: var(--fs-kpi); font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
.machine-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.meta dt { font-size: var(--fs-xs); color: var(--muted); }
.meta dd { margin: 2px 0 0; font-weight: 600; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.machine-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: auto; }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--ok); background: color-mix(in oklch, var(--ok) var(--tint), transparent); border-color: color-mix(in oklch, var(--ok) 35%, transparent); }
.status.warn { color: var(--warn); background: color-mix(in oklch, var(--warn) var(--tint), transparent); border-color: color-mix(in oklch, var(--warn) 35%, transparent); }
.status.crit { color: var(--crit); background: color-mix(in oklch, var(--crit) var(--tint), transparent); border-color: color-mix(in oklch, var(--crit) 35%, transparent); }
.status.info { color: var(--info); background: color-mix(in oklch, var(--info) var(--tint), transparent); border-color: color-mix(in oklch, var(--info) 35%, transparent); }
.status.plain::before { display: none; }

.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--chart); border-radius: inherit; transition: width .4s var(--ease); }
.progress.warn > i { background: var(--warn); }
.progress.crit > i { background: var(--crit); }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: var(--fs-kpi); font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
.kpi-value small { font-size: 0.5em; font-weight: 600; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-foot { font-size: var(--fs-xs); color: var(--muted); }
.kpi .tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: var(--r-pill); color: var(--warn); background: color-mix(in oklch, var(--warn) var(--tint), transparent); }
.tone-ok { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-crit { color: var(--crit); } .tone-muted { color: var(--muted); }

/* Section with header row above a grid of KPIs */
.section-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); }
.section-row h3 { font-size: var(--fs-md); font-weight: 650; }

/* Segmented control */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: none; padding: 6px 12px; min-height: 34px; border-radius: 7px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button:disabled { opacity: .5; cursor: progress; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 38px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.field input { padding: 6px 10px; min-height: 38px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 100%; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }

/* Alertas: linha clicável + drawer de andamento (<dialog>) */
tr.row-open { cursor: pointer; }
.t-alerts { min-width: 720px; }
.only-sm { display: none; margin-top: var(--sp-2); }
@media (max-width: 640px) { .t-min.t-alerts { min-width: 0; } .hide-sm { display: none; } .only-sm { display: block; } }
.row-btn { background: none; border: 0; padding: 0; text-align: left; font-weight: 600; color: var(--text); cursor: pointer; border-radius: var(--r-sm); overflow-wrap: anywhere; }
.row-btn:hover { color: var(--brand); text-decoration: underline; }
.btn-solid { background: var(--brand-strong); color: var(--on-brand); border-color: transparent; }
.btn-solid:hover:not(:disabled) { background: var(--brand-strong); filter: brightness(1.05); }
.adialog { position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; width: min(480px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-left: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: -8px 0 32px oklch(0 0 0 / 0.25); overflow: hidden; }
.adialog:not([open]) { display: none; }
.adialog::backdrop { background: oklch(0 0 0 / 0.5); }
.adrawer { display: flex; flex-direction: column; height: 100%; min-width: 0; }
.adrawer-head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.adrawer-head .grow { min-width: 0; }
.adrawer-head h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); overflow-wrap: anywhere; }
.adrawer-pills { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.adrawer-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-4) var(--sp-5) var(--sp-6); display: grid; gap: var(--sp-5); align-content: start; min-width: 0; }
.adrawer-body h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); max-height: 240px; overflow-y: auto; }
.notes li { padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); min-width: 0; }
.notes-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); color: var(--muted); }
.notes-meta b { color: var(--text); font-size: var(--fs-sm); }
.notes p { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.adrawer-form { display: grid; gap: var(--sp-3); }
.fld { display: grid; gap: 4px; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; min-width: 0; }
.fld small { font-weight: 400; }
.fld select, .fld input, .fld textarea { width: 100%; min-height: 40px; padding: 8px 10px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 400; }
.fld textarea { resize: vertical; min-height: 84px; }
.fld select:focus-visible, .fld input:focus-visible, .fld textarea:focus-visible, .row-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.form-msg { margin: 0; font-size: var(--fs-sm); font-weight: 600; }
.adrawer-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 720px) {
  .adialog { width: 100vw; border-left: 0; }
  .adrawer-actions .btn { flex: 1 1 100%; justify-content: center; min-height: 44px; }
  .adrawer-head, .adrawer-body { padding-inline: var(--sp-4); }
}

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); min-width: 0; }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.list .desc { color: var(--muted); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.list .end { flex: none; text-align: right; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.sev-dot { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--warn); }
.sev-dot.crit { background: var(--crit); box-shadow: 0 0 0 3px color-mix(in oklch, var(--crit) 25%, transparent); }
.sev-dot.info { background: var(--info); }
.sev-dot.ok { background: var(--ok); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px var(--sp-4); margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }

.meter { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--sp-3); align-items: center; margin-bottom: var(--sp-3); font-size: var(--fs-sm); }
.meter .progress { grid-column: 1 / -1; }
.meter b { font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow-x: auto; margin-inline: calc(-1 * var(--sp-1)); padding-inline: var(--sp-1); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th { text-align: left; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding: 0 var(--sp-3) var(--sp-2); white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: top; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in oklch, var(--surface-2) 60%, transparent); }
td.strong { color: var(--text); font-weight: 600; }
td.r, th.r { text-align: right; }
td.wrap { overflow-wrap: anywhere; min-width: 160px; }
.t-min { min-width: 520px; }

/* Charts (HTML/CSS) */
.chart { margin: 0; display: grid; gap: 4px; }
.chart-plot { position: relative; height: 200px; margin-left: 44px; border-bottom: 1px solid var(--border-strong); }
.chart-compact .chart-plot { height: 96px; margin-left: 0; }
.chart-tick { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--grid); }
.chart-tick em { position: absolute; right: calc(100% + 8px); top: -0.7em; font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart-cols { position: absolute; inset: 0; display: flex; align-items: stretch; gap: clamp(2px, 0.6%, 8px); }
.chart-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; position: relative; }
.chart-bar-wrap { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { display: block; width: min(100%, 56px); background: var(--chart); border-radius: 4px 4px 0 0; transition: filter .15s; }
.chart-bar.is-zero { height: 0 !important; }
.chart-col:hover .chart-bar { filter: brightness(1.12); }
.chart-x { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart { padding-bottom: 22px; }
.chart-unit { order: -1; font-size: 11px; color: var(--muted); margin: 0 0 6px; }
.chart.alt .chart-bar { background: var(--chart-2); }
.chart-empty { display: grid; place-items: center; min-height: 120px; color: var(--muted); font-size: var(--fs-sm); border: 1px dashed var(--border-strong); border-radius: var(--r-md); padding-bottom: 0; }

/* States */
.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: var(--sp-6) var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--r-md); color: var(--muted); font-size: var(--fs-sm); }
.empty svg { width: 28px; height: 28px; color: var(--muted); }
.empty strong { color: var(--text); font-size: var(--fs-md); }
.empty.ok svg { color: var(--ok); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid color-mix(in oklch, var(--warn) 40%, transparent); background: color-mix(in oklch, var(--warn) 10%, var(--surface)); font-size: var(--fs-sm); }
.banner svg { flex: none; width: 18px; height: 18px; color: var(--warn); }
.banner .grow { flex: 1; min-width: 200px; }
.banner.info { border-color: color-mix(in oklch, var(--info) 35%, transparent); background: color-mix(in oklch, var(--info) 8%, var(--surface)); }
.banner.info svg { color: var(--info); }
.banner.crit { border-color: color-mix(in oklch, var(--crit) 40%, transparent); background: color-mix(in oklch, var(--crit) 9%, var(--surface)); }
.banner.crit svg { color: var(--crit); }

.skel { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel.h-l { height: 2.2rem; width: 60%; } .skel.h-m { height: 1rem; width: 80%; } .skel.h-s { height: .75rem; width: 45%; } .skel.h-chart { height: 200px; width: 100%; }
.skel-stack { display: grid; gap: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.site-foot { padding-block: var(--sp-6); color: var(--muted); font-size: var(--fs-xs); border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); justify-content: space-between; }

@media (max-width: 640px) {
  .topbar-row { min-height: 56px; gap: var(--sp-2); }
  .brand p { display: none; }
  .live .live-text { display: none; }
  .live { padding: 8px; }
  .btn-label { display: none; }
  .chart-plot { height: 160px; margin-left: 36px; }
  .machine-state { font-size: 1.6rem; }
}
@media (min-width: 1800px) {
  :root { --fs-md: 1rem; --fs-sm: 0.875rem; --fs-xs: 0.8125rem; }
  .chart-plot { height: 240px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Login ---------- */
.login-page { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
.login-side { display: none; }
.login-main { display: grid; place-items: center; padding: var(--sp-6) var(--sp-4); }
.login-box { width: 100%; max-width: 400px; display: grid; gap: var(--sp-4); }
.login-box .brand { margin: 0 0 var(--sp-2); }
.login-box h2 { font-size: var(--fs-xl); font-weight: 700; }
.login-box label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 6px; }
.login-box input { width: 100%; padding: 12px 14px; min-height: 46px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 1rem; }
.login-box input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.btn-primary { width: 100%; min-height: 46px; border: 0; border-radius: var(--r-md); background: var(--brand-strong); color: var(--on-brand); font-weight: 700; font-size: 1rem; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.err { min-height: 20px; color: var(--crit); font-size: var(--fs-sm); font-weight: 600; }
.login-theme { position: absolute; top: 16px; right: 16px; }
@media (min-width: 1000px) {
  .login-page { grid-template-columns: minmax(0, 1.1fr) minmax(420px, 1fr); }
  .login-side { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(32px, 4vw, 80px); background: oklch(0.2 0.02 160); color: oklch(0.95 0.01 160); position: relative; overflow: hidden; }
  .login-side::after { content: ""; position: absolute; inset: auto -20% -40% auto; width: 80%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(closest-side, oklch(0.86 0.19 130 / .22), transparent); }
  .login-side h2 { font-size: clamp(1.8rem, 1rem + 1.6vw, 3rem); max-width: 18ch; letter-spacing: -0.02em; }
  .login-side p { color: oklch(0.8 0.02 160); max-width: 46ch; margin-top: var(--sp-4); }
  .login-side .mark { width: 44px; height: 44px; font-size: 22px; }
  .login-feats { display: grid; gap: var(--sp-3); list-style: none; padding: 0; margin: 0; position: relative; z-index: 1; }
  .login-feats li { display: flex; gap: var(--sp-3); align-items: center; color: oklch(0.88 0.015 160); }
  .login-feats svg { width: 18px; height: 18px; color: oklch(0.86 0.19 130); }
}
