/* =========================================================
   TractionTherm — Train Motor Temperature Monitoring UI
   Shared stylesheet (all pages)
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #e2e7ee;
  --border-strong: #cfd7e2;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;

  --primary: #1f5fbf;
  --primary-hover: #194f9f;
  --primary-soft: #e8f0fc;
  --primary-ink: #ffffff;

  --sidebar: #0d1726;
  --sidebar-2: #13213a;
  --sidebar-text: #b8c4d6;
  --sidebar-muted: #7486a0;

  /* status (fixed roles: always paired with icon + label) */
  --ok: #0ca30c;      --ok-text: #006300;   --ok-bg: #e7f6e7;
  --warn: #fab219;    --warn-text: #7a5000; --warn-bg: #fff4d9;
  --crit: #d03b3b;    --crit-text: #a92828; --crit-bg: #fcebeb;
  --off: #94a3b8;     --off-text: #475569;  --off-bg: #eef2f6;

  /* chart series: Probe 1, Probe 2, Ambient */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --heat: #d9480f;   /* heatmap ramp end (mixed toward surface) */

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px -6px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .25);

  --sidebar-w: 256px;
  --topbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a111d;
    --surface: #111a29;
    --surface-2: #152033;
    --surface-3: #1b2840;
    --border: #22304a;
    --border-strong: #2e3e5c;
    --text: #e7ecf3;
    --text-2: #a9b5c7;
    --muted: #8593a8;
    --primary: #4b8df0;
    --primary-hover: #6aa1f3;
    --primary-soft: rgba(75, 141, 240, .14);
    --sidebar: #070d18;
    --sidebar-2: #0f1a2d;
    --ok-text: #3ccf3c;  --ok-bg: rgba(12, 163, 12, .16);
    --warn-text: #fab219; --warn-bg: rgba(250, 178, 25, .14);
    --crit-text: #f07c7c; --crit-bg: rgba(208, 59, 59, .18);
    --off-text: #a9b5c7; --off-bg: rgba(148, 163, 184, .12);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2c2c2a;
    --axis: #383835;
    --heat: #ff7a3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px -8px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a111d;
  --surface: #111a29;
  --surface-2: #152033;
  --surface-3: #1b2840;
  --border: #22304a;
  --border-strong: #2e3e5c;
  --text: #e7ecf3;
  --text-2: #a9b5c7;
  --muted: #8593a8;
  --primary: #4b8df0;
  --primary-hover: #6aa1f3;
  --primary-soft: rgba(75, 141, 240, .14);
  --sidebar: #070d18;
  --sidebar-2: #0f1a2d;
  --ok-text: #3ccf3c;  --ok-bg: rgba(12, 163, 12, .16);
  --warn-text: #fab219; --warn-bg: rgba(250, 178, 25, .14);
  --crit-text: #f07c7c; --crit-bg: rgba(208, 59, 59, .18);
  --off-text: #a9b5c7; --off-bg: rgba(148, 163, 184, .12);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #2c2c2a;
  --axis: #383835;
  --heat: #ff7a3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px -8px rgba(0, 0, 0, .5);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
svg[aria-hidden="true"] { width: 1.15em; height: 1.15em; flex: none; }

button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: flex; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: #fff;
}
.brand-mark {
  width: 36px; height: 36px; flex: none;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2a78d6, #1baf7a);
  color: #fff;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); text-transform: uppercase; letter-spacing: .08em; }

.nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--sidebar-muted); padding: 14px 12px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a[aria-current="page"] { background: #1f5fbf; color: #fff; }
.nav a[aria-current="page"] svg { opacity: 1; }
.nav .count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px;
  background: rgba(208, 59, 59, .9); color: #fff;
}
.sidebar-foot {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: 12px; color: var(--sidebar-muted);
}
.sys-status { display: flex; align-items: center; gap: 8px; color: var(--sidebar-text); font-weight: 500; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs { font-size: 12px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.clock { font-size: 13px; color: var(--text-2); padding: 0 8px; white-space: nowrap; }

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--crit); box-shadow: 0 0 0 2px var(--surface);
}
.menu-btn { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.user-chip:hover { text-decoration: none; background: var(--surface-3); }
.avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #1f5fbf, #6250d6);
}
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 600; }
.user-chip .who span { font-size: 11px; color: var(--muted); }

.content { padding: 28px; display: flex; flex-direction: column; gap: 24px; max-width: 1600px; width: 100%; }

.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(2, 6, 23, .5);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head p { color: var(--text-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 20px; }

.grid-devices { grid-template-columns: repeat(auto-fill, minmax(min(100%, 540px), 1fr)); }
.grid-device-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title h3 { font-size: 16px; }
.section-title span { font-size: 12px; color: var(--muted); }

.slot-list { list-style: none; margin: 0; padding: 6px 20px; flex: 1; }
.slot-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.slot-list li:last-child { border-bottom: 0; }
.slot-list li > div { min-width: 0; flex: 1; }
.slot-list li b { display: block; font-size: 13px; }
.slot-list li span:not(.badge):not(.device-ico) { font-size: 12px; color: var(--muted); }
.slot-list .device-ico svg { width: 16px; height: 16px; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge svg { width: 13px; height: 13px; }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.crit { background: var(--crit-bg); color: var(--crit-text); }
.badge.off { background: var(--off-bg); color: var(--off-text); }

.pulse {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(12, 163, 12, .6);
  animation: pulse 2s infinite;
}
.pulse.off { background: var(--off); animation: none; box-shadow: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, .55); }
  70% { box-shadow: 0 0 0 8px rgba(12, 163, 12, 0); }
  100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); }
}
.live-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--ok-text);
  padding: 6px 12px; border-radius: 999px; background: var(--ok-bg);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600; font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--crit-text); }
.btn-danger:hover { background: var(--crit-bg); border-color: var(--crit); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; height: 44px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select {
  width: 100%; height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--muted); }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 38px; }
.input-icon .trail {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); cursor: pointer;
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px;
}
.input-icon .trail svg { width: 16px; height: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.segmented {
  display: inline-flex; padding: 3px; gap: 3px;
  border-radius: 10px; background: var(--surface-3);
  border: 1px solid var(--border);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  padding: 6px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
}
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + label { outline: 2px solid var(--primary); }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1 1 240px; }

.fieldset {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px 16px; margin: 0;
  display: grid; gap: 12px;
}
.fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.fieldset[disabled] { opacity: .5; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  padding: 12px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; white-space: nowrap; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }

/* ---------- Device / motor panels ---------- */
.device-card { display: flex; flex-direction: column; }
.device-card .card-head { align-items: flex-start; }
.device-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.device-ico {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.device-ico svg { width: 20px; height: 20px; }
.device-title h3 { font-size: 15px; }
.device-title .sub { font-size: 12px; color: var(--muted); }

.motor-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 20px; }

.motor-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.motor-panel.is-warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.motor-panel.is-crit { border-color: color-mix(in srgb, var(--crit) 55%, var(--border)); }
.motor-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.motor-panel-head b { font-size: 14px; }
.motor-panel-head .slot { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: block; }

.t-warn { color: var(--warn-text); }
.t-crit { color: var(--crit-text); }
.motor-panel-foot { margin-top: auto; padding: 10px 14px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); gap: 8px; }

.empty-slot {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--muted); min-height: 160px;
  gap: 6px; font-size: 13px;
}
.empty-slot svg { width: 24px; height: 24px; margin: 0 auto; }

.offline-mask { padding: 32px 20px; text-align: center; color: var(--muted); }
.offline-mask svg { width: 28px; height: 28px; margin: 0 auto 8px; }

.meta-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 13px; }
.meta-list dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.meta-list dd { margin: 2px 0 0; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.signal i { width: 3px; background: var(--border-strong); border-radius: 1px; }
.signal i:nth-child(1) { height: 4px; } .signal i:nth-child(2) { height: 7px; }
.signal i:nth-child(3) { height: 10px; } .signal i:nth-child(4) { height: 14px; }
.signal i.on { background: var(--ok); }

/* ---------- Readings: large digital values ---------- */
.readings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.reading { padding: 14px 14px 12px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reading + .reading { border-left: 1px solid var(--border); }
.reading.amb { background: color-mix(in srgb, var(--surface-3) 45%, transparent); }
.r-label { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; line-height: 1.3; }
.r-label small { display: block; font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 6px; font-family: var(--mono); }
.r-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; font-family: var(--font); }
.r-sub { font-size: 12px; font-weight: 600; color: var(--text-2); }
.readings.lg { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.readings.lg .reading { padding: 22px 24px 18px; }
.readings.lg .r-value { font-size: 48px; }
.readings.lg .r-value small { font-size: 18px; }
.readings.lg .r-sub { font-size: 14px; }
.motor-panel .readings { grid-template-columns: minmax(0, 1fr); border-bottom: 1px solid var(--border); background: var(--surface); }
.modal-body .readings { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }

.verdict-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.verdict-pill svg { width: 15px; height: 15px; }
.verdict-pill.ok { background: var(--ok); color: #fff; }
.verdict-pill.warn { background: var(--warn); color: #0b0b0b; }
.verdict-pill.crit { background: var(--crit); color: #fff; }
.verdict-pill.off { background: var(--off-bg); color: var(--off-text); }

/* alarm banner: only motors that need action */
.alarm-bar { display: grid; gap: 8px; }
.alarm-row { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); color: var(--text); text-decoration: none; border: 1px solid; }
.alarm-row:hover { text-decoration: none; filter: brightness(.98); }
.alarm-row svg { width: 20px; height: 20px; }
.alarm-row.crit { background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit) 45%, transparent); }
.alarm-row.crit svg, .alarm-row.crit em { color: var(--crit-text); }
.alarm-row.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.alarm-row.warn svg, .alarm-row.warn em { color: var(--warn-text); }
.alarm-row b { font-size: 15px; }
.alarm-where { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.alarm-reason { font-size: 13px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alarm-row em { font-style: normal; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }

/* motor page header */
.motor-hero-card { overflow: hidden; }
.mh-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 24px; flex-wrap: wrap; }
.mh-top h2 { font-size: 24px; font-family: var(--mono); letter-spacing: -.01em; }
.mh-verdict { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 420px; text-align: right; font-size: 13px; color: var(--text-2); }
.mh-verdict .verdict-pill { font-size: 16px; padding: 8px 16px; }
.mh-verdict .verdict-pill svg { width: 18px; height: 18px; }
.mh-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 14px 24px; font-size: 13px; color: var(--text-2); }
.mh-foot b { color: var(--text); }
.mh-limits { flex: 1 1 320px; color: var(--muted); }
.mh-actions { display: flex; gap: 8px; }

/* ---------- Summary strip ---------- */

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.summary-strip > div { padding: 18px 20px; border-right: 1px solid var(--border); }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.summary-strip b { font-size: 26px; display: block; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- Dialog ---------- */
dialog.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(2, 6, 23, .55); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: pop .18s ease-out; display: flex; flex-direction: column; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 20px 24px; overflow-y: auto; min-height: 0; flex: 1 1 auto; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- CRUD: dialogs, details, actions ---------- */
[hidden] { display: none !important; }
dialog.modal.small { width: min(420px, calc(100vw - 32px)); }
.confirm-box { margin: 0; padding: 28px 24px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.confirm-box h3 { font-size: 17px; }
.confirm-box p { color: var(--text-2); font-size: 13.5px; }
.confirm-ico { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 4px; }
.confirm-ico svg { width: 24px; height: 24px; }
.confirm-ico.crit { background: var(--crit-bg); color: var(--crit-text); }
.confirm-ico.warn { background: var(--warn-bg); color: var(--warn-text); }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 10px; }
.btn-danger-solid { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger-solid:hover { background: #b32f2f; border-color: #b32f2f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.btn-danger:disabled:hover { background: transparent; border-color: transparent; }

.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 0; }
.detail-list dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.detail-list dd { margin: 3px 0 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.detail-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.detail-slots { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.detail-slots li { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 14px; font-size: 13px; }
.detail-slots li + li { border-top: 1px solid var(--border); }

.avatar.lg { width: 52px; height: 52px; font-size: 17px; }

.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--primary); text-decoration: underline; }
.slot-link { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; min-width: 0; flex: 1; color: inherit; }
.slot-link b { display: block; font-size: 13px; }
.slot-link span { font-size: 12px; color: var(--muted); }
.slot-link:hover b { color: var(--primary); text-decoration: underline; }

.table tr.is-active { background: var(--primary-soft); }
.table tr.is-active:hover { background: var(--primary-soft); }
.empty-state { padding: 40px 20px; text-align: center; display: grid; justify-items: center; gap: 8px; color: var(--text-2); }
.empty-state > svg { width: 36px; height: 36px; color: var(--muted); }
.empty-state h3 { font-size: 16px; color: var(--text); }
.empty-state .btn { margin-top: 6px; }
.input-unit { position: relative; }
.input-unit .input { padding-right: 44px; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
.switch-row { height: 40px; }
.card-head .toolbar .input-icon { width: 220px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  background: #0f172a; color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform .2s, opacity .2s;
}
.toast.show { transform: none; opacity: 1; }
.toast svg { width: 18px; height: 18px; color: #3ccf3c; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-visual {
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 600px at 10% 0%, #1f5fbf 0%, transparent 60%),
              radial-gradient(800px 500px at 100% 100%, #0f6e57 0%, transparent 55%),
              #0b1424;
  color: #e7ecf3;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.auth-visual .brand { padding: 0; height: auto; border: 0; }
.auth-visual h2 { font-size: clamp(26px, 3vw, 38px); font-weight: 700; letter-spacing: -.02em; max-width: 520px; }
.auth-visual p.lead { color: #b8c4d6; font-size: 15px; max-width: 480px; margin-top: 14px; }
.auth-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; max-width: 560px; }
.auth-stats div { padding: 16px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); }
.auth-stats b { font-size: 22px; display: block; color: #fff; }
.auth-stats span { font-size: 12px; color: #9fb0c8; }
.auth-preview {
  max-width: 560px;
  padding: 18px; border-radius: 14px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.auth-preview .pv span { font-size: 11px; color: #9fb0c8; display: block; }
.auth-preview .pv b { font-size: 22px; color: #fff; font-variant-numeric: tabular-nums; }
.auth-preview .pv i { display: block; height: 4px; border-radius: 4px; margin-top: 8px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.auth-preview .pv i::after { content: ""; display: block; height: 100%; width: var(--w, 50%); background: var(--c, #2a78d6); border-radius: 4px; }
.auth-preview .hd { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #b8c4d6; }
.auth-foot { font-size: 12px; color: #7f91ab; }

.auth-form-wrap { display: grid; place-items: center; padding: 48px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.auth-form h1 { font-size: 26px; }
.auth-form .lead { color: var(--text-2); margin-top: 6px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-error { display: none; padding: 10px 12px; border-radius: 10px; background: var(--crit-bg); color: var(--crit-text); font-size: 13px; font-weight: 500; }
.form-error.show { display: block; }
.mobile-brand { display: none; align-items: center; gap: 10px; }
.mobile-brand .brand-name { color: var(--text); }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1200px) {

  .clock { display: none; }
}

/* Tablet: off-canvas sidebar */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 20px; }
  .content { padding: 24px 20px; }
  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .mobile-brand { display: flex; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-strip > div:nth-child(2) { border-right: 0; }
  .summary-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 860px) {

  .user-chip .who { display: none; }
  .user-chip { padding: 3px; }

}

/* Phone */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar .crumbs { display: none; }
  .topbar-actions .hide-sm { display: none; }
  .content { padding: 20px 16px; gap: 20px; }
  .grid { gap: 16px; }

  .card-foot { padding: 12px 16px; }
  .device-card .card-foot .btn { flex: 1 1 auto; }
  .device-card .card-foot .btn-ghost { border-color: var(--border-strong); }

  .detail-list { grid-template-columns: minmax(0, 1fr); }
  .detail-slots li { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .detail-slots li > .num { grid-column: 2 / -1; grid-row: 2; font-size: 12px; color: var(--text-2); }
  .card-head .toolbar, .card-head .toolbar .input-icon { width: 100%; }
  .card-head .toolbar .input-icon { flex: 1 1 160px; }

  .confirm-actions .btn { width: 100%; }

  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .motor-slots { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .meta-list { padding: 14px 16px; }

  .page-head h2 { font-size: 19px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-foot .btn { flex: 1; }
  .toast { left: 16px; right: 16px; }

  /* tables become stacked cards */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table.responsive tr:last-child { border-bottom: 0; }
  .table.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; flex: none; }
  .table.responsive td.lead-cell { padding-bottom: 10px; justify-content: flex-start; text-align: left; }
  .table.responsive td.lead-cell::before { display: none; }
  .table.responsive td .row-actions { justify-content: flex-end; }
  .summary-strip b { font-size: 22px; }

}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .sidebar, .topbar, .page-head .actions, .toolbar, .toast, .viz-tip { display: none !important; }
  .main { margin-left: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- Readings / alarms on small screens ---------- */
@media (max-width: 860px) {
  .readings.lg .r-value { font-size: 38px; }
  .readings.lg .reading { padding: 18px 16px 14px; }
  .alarm-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .alarm-where { display: none; }
}
@media (max-width: 640px) {
  .reading { padding: 12px 10px 10px; }
  .r-label { font-size: 11px; }
  .r-label small { display: none; }
  .r-value { font-size: 22px; }
  .r-value small { font-size: 11px; margin-left: 1px; }
  .r-sub { font-size: 11px; }
  .readings.lg .reading { padding: 14px 10px 12px; }
  .readings.lg .r-value { font-size: 26px; }
  .readings.lg .r-value small { font-size: 12px; }
  .readings.lg .r-sub { font-size: 12px; }
  .mh-top, .mh-foot { padding-left: 16px; padding-right: 16px; }
  .mh-verdict { align-items: flex-start; text-align: left; max-width: none; }
  .mh-actions { width: 100%; }
  .mh-actions .btn { flex: 1; }
  .alarm-row { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 2px; padding: 10px 12px; }
  .alarm-reason { grid-column: 2 / -1; white-space: normal; font-size: 12px; }

}
@media (max-width: 360px) {
  .r-value { font-size: 19px; }
  .readings.lg .r-value { font-size: 22px; }
}

/* motor cards on the dashboard: readings stacked as meter rows (label left, value right) */
.motor-panel .reading { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "sub value"; align-items: center; column-gap: 12px; padding: 10px 14px; }
.motor-panel .reading + .reading { border-left: 0; border-top: 1px solid var(--border); }
.motor-panel .r-label { grid-area: label; }
.motor-panel .r-label small { display: none; }
.motor-panel .r-value { grid-area: value; margin: 0; font-size: 26px; text-align: right; }
.motor-panel .r-sub { grid-area: sub; }
@media (max-width: 640px) {
  .motor-panel .r-value { font-size: 24px; }
  .motor-panel .r-value small { font-size: 12px; }
}

/* motor register: keep IDs on one line; drop secondary columns on tablet / phone */
#motorTable .lead-cell b { white-space: nowrap; }
.col-alt { display: none; }
@media (max-width: 1100px) {
  .col-opt { display: none !important; }
  .col-alt { display: inline; }
}

/* phone alarm rows: icon · motor · result on the first line, reason underneath */
@media (max-width: 640px) {
  .alarm-row > svg { grid-column: 1; grid-row: 1; }
  .alarm-row > b { grid-column: 2; grid-row: 1; }
  .alarm-row > em { grid-column: 3; grid-row: 1; }
  .alarm-row > .alarm-reason { grid-column: 2 / -1; grid-row: 2; }
}

/* =========================================================
   Graphs
   ========================================================= */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { height: 0; border-top: 2px dashed var(--crit); background: none; }

/* line chart */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end-label { font-size: 11px; font-weight: 600; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart .limit { stroke: var(--crit); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart .limit-warn { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart .limit-label { font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.chart .limit-t { fill: var(--crit-text); }
.chart .limit-warn-t { fill: var(--warn-text); }
.chart .crosshair { stroke: var(--text-2); stroke-width: 1; opacity: .5; }
.chart .hover-dot { stroke: var(--surface); stroke-width: 2; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 170px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12px; opacity: 0; transition: opacity .12s; }
.chart-tip.show { opacity: 1; }
.chart-tip .t { font-weight: 600; margin-bottom: 6px; color: var(--text); }
.chart-tip .r { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.chart-tip .r b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip .sw { width: 10px; height: 3px; border-radius: 2px; }

/* shared hover tooltip */
.viz-tip { position: fixed; z-index: 70; pointer-events: none; min-width: 140px; max-width: 260px; padding: 9px 12px; border-radius: 10px; background: var(--surface); color: var(--text-2); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; opacity: 0; transition: opacity .1s; }
.viz-tip.show { opacity: 1; }
.viz-tip b { display: block; color: var(--text); margin-bottom: 2px; }

/* run-trend line in each dashboard motor card */
.panel-trend { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.panel-trend > span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
svg.spark { flex: 1; height: 32px; width: 100%; display: block; overflow: visible; }
svg.spark path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.spark .spark-fail { stroke: var(--crit); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }

/* rise-by-motor grouped bars */
.rb { display: grid; gap: 4px; }
.rb-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 96px; gap: 14px; align-items: center; padding: 6px 4px; border-radius: 8px; color: inherit; text-decoration: none; }
a.rb-row:hover { background: var(--surface-2); text-decoration: none; }
.rb-label { min-width: 0; line-height: 1.25; }
.rb-label b { display: block; font-size: 14px; font-family: var(--mono); }
.rb-label span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.rb-track { position: relative; display: grid; gap: 3px; padding: 4px 0; }
.rb-bar { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; transition: width .6s ease; }
.rb-mark { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 2px dashed; }
.rb-mark.warn { border-color: var(--warn); }
.rb-mark.fail { border-color: var(--crit); }
.rb-val { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rb-head, .rb-axis { padding-top: 0; padding-bottom: 0; }
.rb-labels, .rb-ticks { height: 16px; display: block; font-size: 11px; color: var(--muted); }
.rb-labels span, .rb-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rb-labels span { color: var(--warn-text); font-weight: 600; }
.rb-labels span.fail { color: var(--crit-text); }
.rb-ticks span:first-child { transform: none; }
.rb-unit { font-size: 11px; color: var(--muted); text-align: right; }
.v-dot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; }
.v-dot svg { width: 13px; height: 13px; }
.v-dot.ok { background: var(--ok-bg); color: var(--ok-text); }
.v-dot.warn { background: var(--warn-bg); color: var(--warn-text); }
.v-dot.crit { background: var(--crit-bg); color: var(--crit-text); }



@media (max-width: 860px) {
  .rb-row { grid-template-columns: 110px minmax(0, 1fr) 76px; gap: 10px; }
}
@media (max-width: 640px) {
  .rb-row { grid-template-columns: 76px minmax(0, 1fr) 64px; gap: 8px; padding: 6px 0; }
  .rb-label b { font-size: 12px; }
  .rb-label span { display: none; }
  .rb-val { font-size: 12px; gap: 4px; }
  .v-dot { width: 16px; height: 16px; }
  .rb-ticks span:nth-child(even) { display: none; }
  .rb-labels span { font-size: 10px; }
  .rb-labels span:not(.fail) { display: none; }

  .panel-trend { padding: 8px 10px; }
}
@media print {
  .chart-tip, .viz-tip { display: none !important; }
}

@media (max-width: 420px) { .hide-xs { display: none; } }

/* =========================================================
   Condition analysis graphics
   ========================================================= */
.grid-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-pair > [hidden] { display: none; }
.grid-pair:has(> #cmpCard[hidden]) { grid-template-columns: minmax(0, 1fr); }

/* predicted lines + now marker in line charts */
.chart .line.predicted { stroke-dasharray: 5 4; opacity: .85; }
.chart .now-line { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; }
.chart .now-label { font-size: 11px; font-weight: 600; fill: var(--muted); }
.legend i.pred { height: 0; border-top: 2px dashed var(--text-2); background: none; }

/* progress ring */
svg.ring { display: block; flex: none; }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 7; }
.ring-arc { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring-val { font-size: 17px; font-weight: 700; fill: var(--text); font-variant-numeric: tabular-nums; }
.ring-sub { font-size: 10px; fill: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
svg.ring[width="58"] .ring-val { font-size: 13px; }
svg.ring[width="58"] .ring-sub { display: none; }
svg.ring[width="58"] .ring-track, svg.ring[width="58"] .ring-arc { stroke-width: 6; }

/* bars with predicted-final outline (dashboard + condition card) */
.rb-lane { position: relative; display: block; height: 10px; }
.rb-lane .rb-bar { position: relative; height: 10px; }
.rb-ghost { position: absolute; left: 0; top: 0; bottom: 0; border: 1.5px dashed; border-left: 0; border-radius: 0 4px 4px 0; opacity: .75; }

/* dashboard motor card: heating row */
.panel-heat { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.ph-text { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.ph-text span { font-size: 12px; color: var(--text-2); }
.ph-text b { font-size: 14px; }
.ph-text small { font-size: 11px; color: var(--muted); }
.panel-heat a { align-self: flex-end; font-size: 13px; white-space: nowrap; }

/* dashboard summary: condition split bar under the tiles */
.summary-strip .cond-split { grid-column: 1 / -1; display: flex; gap: 2px; height: 8px; padding: 0; margin: 0 20px 16px; border: 0; border-radius: 4px; overflow: hidden; }
.cond-split span { display: block; height: 100%; }
.cond-split .ok { background: var(--ok); } .cond-split .warn { background: var(--warn); } .cond-split .crit { background: var(--crit); }

/* condition card (motors page) */
.cond-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr) minmax(0, 1.1fr); }
.cond-block { padding: 18px 20px; min-width: 0; }
.cond-block + .cond-block { border-left: 1px solid var(--border); }
.cond-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: 10px; }
.cond-title small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); margin-left: 4px; }
.cond-rings { display: flex; gap: 18px; justify-content: center; }
.fb-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 0; }
.fb-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.fb-label i { width: 10px; height: 3px; border-radius: 2px; }
.fb-track { position: relative; height: 12px; }
.fb-track .rb-bar { position: absolute; left: 0; top: 1px; height: 10px; }
.fb-track .rb-ghost { top: 1px; bottom: 1px; }
.fb-val { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.fb-val b { color: var(--text); }
.cond-facts { margin: 0; display: grid; gap: 2px; }
.cond-facts div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.cond-facts div:last-child { border-bottom: 0; }
.cond-facts dt { color: var(--text-2); }
.cond-facts dt small, .cond-facts dd small { color: var(--muted); font-size: 11px; }
.cond-facts dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.cond-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cond-checks li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.cc-name small { display: block; font-size: 11px; color: var(--muted); }
.cond-checks b { font-size: 13px; white-space: nowrap; }
.cond-checks li.warn b { color: var(--warn-text); } .cond-checks li.crit b { color: var(--crit-text); }

/* equilibrium gradient columns */
.gc-plot { position: relative; height: 180px; border-bottom: 1px solid var(--axis); background: repeating-linear-gradient(to bottom, transparent 0 35px, var(--grid) 35px 36px); }
.gc-col { position: absolute; bottom: 0; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 2px; }
.gc-col.ok { background: var(--ok); }
.gc-col b { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-size: 10px; color: #fff; font-weight: 700; }
.gc-eq { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--ok); z-index: 1; pointer-events: none; }
.gc-eq em { position: absolute; right: 0; bottom: 3px; font-style: normal; font-size: 11px; font-weight: 600; color: var(--ok-text); background: var(--surface); padding: 0 4px; border-radius: 4px; }
.gc-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }

@media (max-width: 1200px) {
  .cond-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cond-block:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 860px) {
  .grid-pair { grid-template-columns: minmax(0, 1fr); }
  .cond-grid { grid-template-columns: minmax(0, 1fr); }
  .cond-block + .cond-block { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .cond-block { padding: 16px; }
  .fb-row { grid-template-columns: 62px minmax(0, 1fr) auto; gap: 8px; }
  .summary-strip .cond-split { margin: 0 16px 14px; }
  .gc-plot { height: 150px; }
  .cond-facts div { font-size: 12px; }
}

.summary-strip > div:nth-child(4) { border-right: 0; }
