/* CentralPlant design system - shared by the plant server and CentralPlant Cloud.
   Dark by default (shop floors, TVs), light theme via <html data-theme="light">.
   No external fonts or CDNs: plant PCs are often offline. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: dark;
  --bg: #0a0e16;
  --bg-elev: #0e131d;
  --surface: #121925;
  --surface-2: #182130;
  --surface-3: #1f2a3c;
  --seg-on: #253248;
  --hover: rgba(148, 163, 184, .08);
  --border: #212c3e;
  --border-2: #2e3b52;
  --text: #e8edf6;
  --text-2: #a7b2c6;
  --text-3: #6e7a91;
  --accent: #5b8cff;
  --accent-hover: #6f9aff;
  --accent-soft: rgba(91, 140, 255, .14);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, .14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, .14);
  --bad: #ef4444;
  --bad-soft: rgba(239, 68, 68, .14);
  --track: rgba(148, 163, 184, .13);
  --input-bg: #0d131d;
  --scrim: rgba(3, 6, 12, .6);
  --glow: rgba(91, 140, 255, .07);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 6px 20px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .25);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .55), 0 6px 18px rgba(0, 0, 0, .3);
  --ring: 0 0 0 3px rgba(91, 140, 255, .3);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --tabs-h: 0px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f9;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #edf0f5;
  --seg-on: #ffffff;
  --hover: rgba(15, 23, 42, .045);
  --border: #e3e7ee;
  --border-2: #d2d9e4;
  --text: #101828;
  --text-2: #475467;
  --text-3: #8591a6;
  --accent: #2f6bff;
  --accent-hover: #1f5bf0;
  --accent-soft: rgba(47, 107, 255, .1);
  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, .1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, .11);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, .08);
  --track: rgba(15, 23, 42, .07);
  --input-bg: #ffffff;
  --scrim: rgba(15, 23, 42, .35);
  --glow: rgba(47, 107, 255, .06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 6px 16px rgba(16, 24, 40, .07), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 28px 60px rgba(16, 24, 40, .18), 0 6px 16px rgba(16, 24, 40, .08);
  --ring: 0 0 0 3px rgba(47, 107, 255, .22);
}

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(1100px 520px at 12% -8%, var(--glow), transparent 62%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0 0 12px; }
ol, ul { margin: 0; padding-left: 20px; line-height: 1.7; }
code, .mono { font-family: var(--mono); font-size: 12px; background: var(--surface-3); color: var(--text);
  padding: 2px 6px; border-radius: 6px; word-break: break-word; }
.mono { display: inline-block; white-space: pre-wrap; }
details summary { cursor: pointer; color: var(--text-2); font-weight: 550; padding: 4px 0; }
details summary:hover { color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
::selection { background: var(--accent-soft); }
svg.i { flex: none; display: inline-block; vertical-align: middle; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------- shell */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; padding: 16px 12px 12px;
  background: var(--bg-elev); border-right: 1px solid var(--border);
}
.main-col { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
main#view { width: 100%; max-width: 1760px; margin: 0 auto; padding: 24px 28px 40px; padding-bottom: calc(40px + var(--tabs-h)); flex: 1; }

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 18px; color: var(--text); min-width: 0; }
.brand:hover { color: var(--text); }
.brand .logo { display: flex; flex: none; }
.brand .logo svg, .brand .logo img { width: 34px; height: 34px; display: block; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text b { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.brand-text small { font-size: 11.5px; color: var(--text-3); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-label { font-size: 10.5px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 550; font-size: 13.5px; transition: background .15s, color .15s;
}
.nav a svg { color: var(--text-3); transition: color .15s; }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a:hover svg { color: var(--text-2); }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active svg { color: var(--accent); }
.nav a.active::before { content: ""; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: var(--bad); color: #fff;
  font-variant-numeric: tabular-nums;
}
.nav-count.muted { background: var(--surface-3); color: var(--text-2); }

.sidebar-foot { border-top: 1px solid var(--border); margin-top: 10px; padding: 12px 6px 2px; display: flex; flex-direction: column; gap: 10px; font-size: 12px; color: var(--text-3); }
.sidebar-foot a { color: var(--text-2); }
.live { display: flex; align-items: center; gap: 9px; color: var(--text-2); font-weight: 550; font-size: 12.5px; }
.live .pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; }
.live.on .pulse { background: var(--ok); }
.live.on .pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 2.2s cubic-bezier(0, 0, .2, 1) infinite; }
@keyframes ping { 0% { transform: scale(.4); opacity: .9; } 80%, 100% { transform: scale(1.5); opacity: 0; } }
.foot-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 28px; border-bottom: 1px solid var(--border);
  background: var(--bg); background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.5); backdrop-filter: blur(14px) saturate(1.5);
}
.page-title { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.page-title h1 { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.015em; }
.page-title .sub { color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title .sep { width: 1px; height: 18px; background: var(--border-2); flex: none; }
.top-right { display: flex; align-items: center; gap: 10px; flex: none; }
.top-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.top-chip b { color: var(--text); font-weight: 650; }
.clock { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px; color: var(--text); padding: 0 4px; white-space: nowrap; }
.menu-btn { display: none !important; }
#scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 35; display: none; }

/* ----------------------------------------------------------------- buttons */
button, .btn {
  -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 550; line-height: 1; white-space: nowrap; cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s, color .15s, transform .06s;
  box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover { background: var(--surface-3); color: var(--text); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.primary, .btn.primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .16);
}
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); color: #fff; }
button.danger, .btn.danger { background: var(--bad); border-color: transparent; color: #fff; }
button.danger:hover, .btn.danger:hover { filter: brightness(1.08); background: var(--bad); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
button.ghost:hover, .btn.ghost:hover { background: var(--hover); color: var(--text); }
button.link, .btn.link {
  background: none; border: none; box-shadow: none; height: auto; padding: 3px 5px; color: var(--accent); font-weight: 600; border-radius: 6px;
}
button.link:hover { background: var(--accent-soft); color: var(--accent); }
button.link.danger-text, .danger-text { color: var(--bad) !important; }
button.link.danger-text:hover { background: var(--bad-soft); }
button.sm, .btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.icon-btn { width: 36px; padding: 0 !important; flex: none; }
.icon-btn.sm { width: 30px; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ inputs */
input, select, textarea {
  font: inherit; font-size: 13.5px; font-weight: 400; color: var(--text); background: var(--input-bg); border: 1px solid var(--border-2);
  border-radius: 9px; height: 36px; padding: 0 11px; max-width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { display: block; height: auto; min-height: 84px; width: 100%; padding: 9px 11px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a95a8' stroke-width='2.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: 15px;
}
input[type=checkbox] {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; min-width: 18px; padding: 0; margin: 0;
  border: 1.5px solid var(--border-2); border-radius: 5px; background: var(--input-bg); cursor: pointer;
  display: inline-grid; place-content: center; vertical-align: middle; transition: background .12s, border-color .12s;
}
input[type=checkbox]::after {
  content: ""; width: 10px; height: 10px; background: #fff; transform: scale(0); transition: transform .12s;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { transform: scale(1); }
input[type=color] { width: 44px; height: 32px; padding: 3px; cursor: pointer; }
input[type=file] { height: auto; padding: 6px; }
input[type=file]::file-selector-button {
  font: inherit; font-size: 12.5px; font-weight: 550; border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); border-radius: 7px; padding: 5px 10px; margin-right: 10px; cursor: pointer;
}
input[type=date] { min-width: 150px; }
input[type=number] { font-variant-numeric: tabular-nums; }
.search { position: relative; display: inline-flex; align-items: center; }
.search svg { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 34px; }

label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 550; color: var(--text-2); min-width: 0; }
label.f > input:not([type=checkbox]), label.f > select { width: 100%; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; margin-bottom: 14px; align-items: end; }
.form .wide, .form > .wide { grid-column: 1 / -1; }
.form > div:not(.wide) > label.cb { min-height: 36px; }
label.cb { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--text); user-select: none; margin-right: 14px; min-height: 28px; }

/* ------------------------------------------------------------------ layout */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.error { color: var(--bad); }
.ok-text { color: var(--ok); }
.scroll, .table-wrap { overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 20px; }
.grid2 > .panel { margin-bottom: 0; }
.grid2 + *, .grid + * { margin-top: 20px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }
.stack-gap > * + * { margin-top: 20px; }
.hint { color: var(--text-3); font-size: 12.5px; line-height: 1.6; margin: 2px 0 14px; }
.hint code { font-size: 11.5px; }

/* ------------------------------------------------------------------- cards */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow-sm); min-width: 0;
}
.panel > h2 { display: flex; align-items: center; gap: 9px; font-size: 15px; margin-bottom: 14px; }
.panel h2 + .hint { margin-top: -6px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > table th:first-child, .panel.flush > table td:first-child { padding-left: 22px; }
.card-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head .ch-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.card-head .ch-text { flex: 1; min-width: 180px; }
.card-head h2 { font-size: 15px; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.55; max-width: 820px; }
.card-head .ch-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.count { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 99px; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums; }

/* KPI tiles */
.kpis, .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi, .card {
  position: relative; display: flex; align-items: center; gap: 16px; min-width: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
a.kpi { color: var(--text); }
a.kpi:hover { border-color: var(--border-2); }
.kpi-body { flex: 1; min-width: 0; }
.kpi-label, .card .l { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.kpi-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.kpi-value, .card .v { margin-top: 10px; font-size: 28px; font-weight: 750; letter-spacing: -.025em; line-height: 1.05; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.kpi-sub { margin-top: 7px; font-size: 12.5px; line-height: 1.4; color: var(--text-3); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kpi-sub b { color: var(--text-2); font-weight: 600; }
.kpi.ok .kpi-ic { background: var(--ok-soft); color: var(--ok); }
.kpi.bad .kpi-ic { background: var(--bad-soft); color: var(--bad); }
.kpi.bad .kpi-value { color: var(--bad); }
.kpi.warn .kpi-ic { background: var(--warn-soft); color: var(--warn); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.accent .kpi-ic { background: var(--accent-soft); color: var(--accent); }
.kpi.bad::after, .kpi.warn::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--bad), transparent);
}
.kpi.warn::after { background: linear-gradient(90deg, transparent, var(--warn), transparent); }

/* ------------------------------------------------------------------ tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th {
  text-align: left; font-size: 11px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child > td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover > td, table.hover tr:hover > td { background: var(--hover); }
td input:not([type=checkbox]):not([type=color]), td select { width: 100%; height: 32px; }
table.crud td { white-space: nowrap; }
td.actions-cell, th.th-actions { position: sticky; right: 0; background: var(--surface); }
.section td.actions-cell, .section th.th-actions { background: var(--surface-2); }
tr.click:hover > td.actions-cell { background: linear-gradient(var(--hover), var(--hover)), var(--surface); }
/* a list row's key cell is a real link (right-click > Open link in new tab) that looks like the rest of the row */
a.rowlink, a.rowlink:hover { color: inherit; }
a.rowlink:hover { text-decoration: underline; text-underline-offset: 2px; }
td.clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .row { flex-wrap: nowrap; }
.th-actions, td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
table.kv td:first-child { color: var(--text-3); width: 180px; }

/* ------------------------------------------------------- chips, pills, lamps */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px;
  font-size: 12px; font-weight: 650; color: #fff; white-space: nowrap; line-height: 1; background: var(--surface-3); vertical-align: middle;
}
.pill {
  --c: #64748b; display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 650; white-space: nowrap; line-height: 1; vertical-align: middle;
  background: var(--c); color: #fff;
  background: color-mix(in srgb, var(--c) 17%, transparent);
  color: color-mix(in srgb, var(--c) 45%, var(--text));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 32%, transparent);
}
.pill > i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.pill.solid { background: var(--c); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15); }
.pill.solid > i { background: rgba(255, 255, 255, .85); }
.pill.lg { height: 30px; padding: 0 13px 0 11px; font-size: 13px; gap: 8px; }
.pill svg { width: 14px; height: 14px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 8px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); font-weight: 500;
}
.tag svg { color: var(--text-3); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; font-size: 10.5px; font-weight: 700; background: var(--bad); color: #fff; font-variant-numeric: tabular-nums;
}
.lamp { width: 12px; height: 12px; border-radius: 50%; display: inline-block; vertical-align: middle; flex: none; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-2); }
.lamp.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft), 0 0 10px rgba(34, 197, 94, .45); }
.lamp.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft), 0 0 10px rgba(239, 68, 68, .5); }
.lamp.na { background: transparent; box-shadow: none; border: 1.5px dashed var(--border-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); flex: none; vertical-align: middle; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.test-ok { color: var(--ok); font-weight: 600; }
.test-bad { color: var(--bad); font-weight: 600; }

/* -------------------------------------------------- tabs / segmented / filters */
.tabs, .tabsbar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabsbar a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px; white-space: nowrap;
  color: var(--text-2); font-weight: 550; font-size: 13.5px; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.tabs a:hover, .tabsbar a:hover { color: var(--text); }
.tabs a.active, .tabsbar a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs a.active svg, .tabsbar a.active svg { color: var(--accent); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.seg > button, .seg > a {
  height: 30px; padding: 0 12px; border: none; border-radius: 7px; background: transparent; box-shadow: none;
  color: var(--text-2); font-size: 13px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px;
}
.seg > button:hover, .seg > a:hover { background: var(--hover); color: var(--text); }
.seg > .on, .seg > .on:hover { background: var(--seg-on); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.seg.icons > button { width: 32px; padding: 0; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar label.f { flex-direction: row; align-items: center; gap: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fchip {
  --c: var(--text-3); height: 32px; padding: 0 12px 0 11px; border-radius: 99px; gap: 8px; box-shadow: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; font-weight: 550;
}
.fchip > i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.fchip > b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.fchip:hover { background: var(--surface-2); border-color: var(--border-2); }
.fchip.on { color: var(--text); border-color: var(--c); background: var(--surface-2); background: color-mix(in srgb, var(--c) 15%, var(--surface)); }

/* ------------------------------------------------------ callouts / banners */
.callout {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 11px; font-size: 13px; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.callout > svg { margin-top: 1px; color: var(--text-3); }
.callout b { color: var(--text); }
.callout.bad { background: var(--bad-soft); border-color: rgba(239, 68, 68, .3); color: var(--text); }
.callout.bad > svg { color: var(--bad); }
.callout.warn, .warnbar { background: var(--warn-soft); border-color: rgba(245, 158, 11, .32); color: var(--text); }
.callout.warn > svg { color: var(--warn); }
.callout.ok { background: var(--ok-soft); border-color: rgba(34, 197, 94, .3); color: var(--text); }
.callout.ok > svg { color: var(--ok); }
.callout.info { background: var(--accent-soft); border-color: rgba(91, 140, 255, .3); color: var(--text); }
.callout.info > svg { color: var(--accent); }
.warnbar { display: flex; gap: 10px; align-items: center; border: 1px solid rgba(245, 158, 11, .32); border-radius: 11px; padding: 11px 14px; margin-bottom: 16px; font-weight: 550; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 28px; font-weight: 550; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.banner.warn { background: var(--warn-soft); }
.banner.warn svg { color: var(--warn); }
.banner.bad { background: var(--bad-soft); }
.banner.bad svg { color: var(--bad); }
.banner.info { background: var(--accent-soft); }
.banner.info svg { color: var(--accent); }
.banner a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* a test environment says so on every page (same amber in light and dark) */
.env-banner { display: flex; align-items: center; gap: 10px; padding: 8px 28px; font-size: 13.5px; font-weight: 550; line-height: 1.4; background: #f59e0b; color: #1c1405; }
.env-banner svg { color: #1c1405; flex: none; }
.env-banner b { letter-spacing: .05em; }
.env-banner a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; margin-left: auto; white-space: nowrap; }
.top-chip.env-chip { background: #f59e0b; color: #1c1405; font-weight: 750; letter-spacing: .08em; }
body.env-test .topbar { box-shadow: inset 0 -3px 0 #f59e0b; }
@media (max-width: 720px) { .env-banner { padding: 8px 14px; font-size: 12.5px; } }
/* the demo company: rebuilt every night (Pat's test B1) - one line under the TEST banner, its X hides it for the day */
.demo-banner { display: flex; align-items: center; gap: 10px; padding: 7px 18px 7px 28px; font-size: 13.5px; line-height: 1.4; background: var(--accent-soft); color: var(--text); border-bottom: 1px solid var(--border); }
.demo-banner svg { color: var(--accent); flex: none; }
.demo-banner > span { flex: 1; min-width: 0; }
.demo-banner .demo-banner-x { flex: none; padding: 4px; }
@media (max-width: 720px) { .demo-banner { padding: 7px 8px 7px 14px; font-size: 12.5px; } }

/* ------------------------------------------------------------ empty states */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .e-ic { width: 54px; height: 54px; border-radius: 15px; margin: 0 auto 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.empty .e-ic.ok { background: var(--ok-soft); color: var(--ok); }
.empty h3 { color: var(--text); font-size: 15.5px; margin: 0 0 6px; }
.empty p { margin: 0 auto 18px; max-width: 460px; line-height: 1.6; font-size: 13.5px; }
.empty.sm { padding: 26px 12px; }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 24px 4px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ toasts */
#toasts { position: fixed; right: 20px; bottom: calc(20px + var(--tabs-h)); z-index: 200; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
/* with a dialog open, messages go to the top - they covered its buttons at the bottom */
body:has(.modal-bg) #toasts { top: 16px; bottom: auto; }
/* a tile that goes somewhere (Jobs finishing late ...) */
a.kpi-link { color: inherit; text-decoration: none; cursor: pointer; }
th.sortable { cursor: pointer; user-select: none; }
th.sorted { color: var(--accent); }
tr.sel td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.date-l { display: inline-flex; align-items: center; gap: 6px; }
.ok-text { color: var(--ok); }
a.kpi-link:hover { border-color: var(--accent); }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 11px; min-width: 290px; max-width: 420px;
  padding: 12px 10px 12px 14px; border-radius: 13px; background: var(--surface); border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg); font-size: 13.5px; color: var(--text); animation: toast-in .28s cubic-bezier(.2, .8, .2, 1);
}
.toast-ic { display: flex; color: var(--accent); margin-top: 1px; }
.toast.ok .toast-ic { color: var(--ok); }
.toast.error .toast-ic { color: var(--bad); }
.toast.warning .toast-ic { color: var(--warn); }
.toast-msg { flex: 1; line-height: 1.45; padding-top: 1px; word-break: break-word; }
.toast-x { width: 24px; height: 24px; padding: 0; border: none; background: none; box-shadow: none; color: var(--text-3); border-radius: 6px; }
.toast-x:hover { background: var(--hover); }
.toast.out { animation: toast-out .2s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ------------------------------------------------------- drawer / dialogs */
.modal-bg {
  position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; background: var(--scrim);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade .2s ease;
}
.modal {
  display: flex; flex-direction: column; width: min(1080px, 100%); height: 100%; background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: slide-in .3s cubic-bezier(.2, .8, .2, 1);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); flex: none; }
.modal-head .ch-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.modal-head h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-body { flex: 1; overflow-y: auto; padding: 22px 24px 28px; overscroll-behavior: contain; }
.modal .actions { display: flex; gap: 10px; align-items: center; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); flex: none; }
.modal-bg.center { justify-content: center; align-items: flex-start; padding: 8vh 16px 16px; overflow-y: auto; }
.modal-bg.center .modal { height: auto; width: min(660px, 100%); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
.modal-bg.center .modal-body { overflow: visible; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: .4; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.section { border: 1px solid var(--border); border-radius: 14px; padding: 18px 18px 16px; margin-bottom: 16px; background: var(--surface-2); min-width: 0; }
.section > h3 { display: flex; align-items: center; gap: 9px; font-size: 14px; margin-bottom: 12px; }
.section > h3 svg { color: var(--accent); }
.section table td, .section table th { padding-left: 8px; padding-right: 8px; }
.aux-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface); }
.sub-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 4px 0 6px; }

/* ------------------------------------------------------------------- board */
.board-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.area-title, .area { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; margin: 22px 0 10px; }
.area-title::after, .area::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.area-title:first-child, .area:first-child { margin-top: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.size-small .tiles { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 10px; }
.size-large .tiles { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile {
  --c: #64748b; position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; min-height: 168px;
  padding: 14px 15px 13px; border-radius: 16px; color: #fff; cursor: pointer; text-decoration: none;
  background: var(--c);
  background: linear-gradient(155deg, color-mix(in srgb, var(--c) 86%, #fff) 0%, var(--c) 42%, color-mix(in srgb, var(--c) 78%, #000) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), inset 0 0 0 1px rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px -14px var(--c);
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .18s, background .5s;
}
.tile::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(110% 70% at 100% 0%, rgba(255, 255, 255, .17), transparent 60%);
}
/* hover: a ring, no lift - a tile that moves under the pointer flickers at its edge */
.tile:hover { color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 0 0 2px rgba(255, 255, 255, .42), 0 2px 4px rgba(0, 0, 0, .3), 0 16px 34px -12px var(--c); }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile.dark { color: #dbe3ef; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09), 0 1px 2px rgba(0, 0, 0, .3); }
.tile.dark:hover { color: #dbe3ef; }
.t-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.t-num { font-size: 34px; font-weight: 800; line-height: .95; letter-spacing: -.035em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.t-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .18); flex: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15); }
.tile.dark .t-ic { background: rgba(255, 255, 255, .08); }
.t-name { margin-top: 6px; font-size: 12.5px; font-weight: 550; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-status { margin-top: 10px; font-size: 17px; font-weight: 750; letter-spacing: -.01em; line-height: 1.15; }
.t-dur { margin-top: 2px; display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; opacity: .92; font-variant-numeric: tabular-nums; }
.t-dur svg { opacity: .8; }
.t-badge {
  align-self: flex-start; max-width: 100%; margin-top: 7px; display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border-radius: 7px; background: rgba(0, 0, 0, .26); font-size: 11.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.t-badge.rule { background: rgba(0, 0, 0, .5); box-shadow: inset 2px 0 0 #fb923c; }
.t-foot { margin-top: auto; padding-top: 11px; display: flex; flex-direction: column; gap: 7px; }
.t-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 550; opacity: .93; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-meta span { overflow: hidden; text-overflow: ellipsis; }
.t-perf { height: 4px; border-radius: 99px; background: rgba(0, 0, 0, .26); overflow: hidden; }
.t-perf i { display: block; height: 100%; border-radius: inherit; background: rgba(255, 255, 255, .88); }
.t-aux { display: flex; flex-wrap: wrap; gap: 4px; }
.t-aux span { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, .26); font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
.t-aux span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.t-aux span.ok::before { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.t-aux span.bad { background: #7f1d1d; animation: blink 1s infinite; }
.t-aux span.bad::before { background: #fecaca; }
.size-large .t-num { font-size: 50px; }
.size-large .t-status { font-size: 23px; }
.size-large .t-dur { font-size: 16px; }
.size-large .t-name, .size-large .t-meta { font-size: 14px; }
.size-small .tile { min-height: 136px; padding: 11px 12px; }
.size-small .t-num { font-size: 26px; }
.size-small .t-status { font-size: 15px; margin-top: 6px; }
.size-small .t-ic { width: 26px; height: 26px; }
.tile.flash { animation: alarm 1.3s ease-in-out infinite; }
@keyframes alarm {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 0 4px rgba(239, 68, 68, .5), 0 0 30px rgba(239, 68, 68, .6); filter: brightness(1.12); }
}
@keyframes blink { 50% { opacity: .45; } }
.stale { opacity: .55; filter: grayscale(.55); }

/* machine list rows (phones, list mode, cloud) */
.mlist { display: flex; flex-direction: column; gap: 8px; }
.mrow {
  --c: #64748b; position: relative; overflow: hidden; display: flex; align-items: center; gap: 14px; padding: 11px 16px 11px 16px;
  border-radius: 13px; background: var(--surface); border: 1px solid var(--border); color: var(--text); transition: background .15s, border-color .15s;
}
.mrow::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.mrow:hover { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.m-num {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; font-weight: 800; font-size: 15px;
  font-variant-numeric: tabular-nums; background: var(--c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18); overflow: hidden;
}
.m-main { flex: 1; min-width: 0; }
.m-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.m-name svg { color: #fb923c; }
.m-sub { color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.m-cols { display: flex; gap: 26px; }
.m-col { text-align: right; min-width: 64px; }
.m-col b { display: block; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.m-col span { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.m-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.m-dur { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* TV mode */
body.tv .sidebar, body.tv .topbar, body.tv #banner, body.tv #mode-banner { display: none !important; }
body.tv .main-col { margin-left: 0; }
body.tv main#view { max-width: none; padding: 16px 18px; }
.tv-head { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; flex-wrap: wrap; }
.tv-head .logo svg { width: 40px; height: 40px; display: block; }
.tv-head h1 { margin: 0; font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.tv-clock { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tv-stat { display: flex; flex-direction: column; line-height: 1.1; }
.tv-stat b { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.tv-stat span { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 650; }

/* ---------------------------------------------------------- machine page */
.hero {
  --c: #64748b; position: relative; overflow: hidden; margin-bottom: 20px; padding: 22px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-sm);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, rgba(100, 116, 139, .12), transparent 60%);
  background: linear-gradient(100deg, color-mix(in srgb, var(--c) 20%, transparent), transparent 60%);
}
.hero::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.hero > * { position: relative; }
.hero-main { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.hero-badge {
  width: 66px; height: 66px; border-radius: 17px; flex: none; display: grid; place-items: center; color: #fff; font-size: 26px; font-weight: 800;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums; overflow: hidden;
  background: var(--c); background: linear-gradient(150deg, color-mix(in srgb, var(--c) 82%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 80%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 10px 26px -10px var(--c);
}
.hero-text { flex: 1; min-width: 240px; }
.hero-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-title h1 { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -.025em; }
.hero-dur { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.hero-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-extra { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.src-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.sig-val { font-variant-numeric: tabular-nums; font-weight: 650; }
.aux-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.aux-row:first-child { border-top: none; padding-top: 2px; }
.aux-row .aux-name { flex: 1; min-width: 140px; font-weight: 600; }
.aux-row .aux-name small { display: block; color: var(--text-3); font-weight: 500; font-size: 12px; }
/* plant press page: name + values (.aux-main) wrap inside themselves, so the badge (.aux-state) stays at the right of
   the first line - a dryer's temperature and dew point go under its name instead of pushing the badge down */
.aux-row > .aux-main { flex: 1 1 0%; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; column-gap: 14px; row-gap: 6px; }
.aux-row > .aux-main > .aux-name { min-height: 38px; display: flex; flex-direction: column; justify-content: center; }
.aux-row > .aux-main > .aux-vals { display: flex; flex-wrap: wrap; align-items: center; row-gap: 4px; }
.aux-row > .aux-state { flex: none; align-self: flex-start; min-height: 38px; display: flex; align-items: center; }
.io { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); margin-right: 12px; }
.io.aux-val { gap: 5px; font-variant-numeric: tabular-nums; }
.io.aux-val b { color: var(--text); font-weight: 650; }
.io.aux-val.warn, .io.aux-val.warn b { color: var(--warn); }
.io.aux-val.bad, .io.aux-val.bad b { color: var(--bad); }
.stop-detail { font-size: 12px; color: var(--text-2); margin-top: 3px; max-width: 280px; white-space: normal; line-height: 1.35; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 12px; }
.stat-row div { display: flex; flex-direction: column; }
.stat-row b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-row span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; }
.out-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.out-row:first-of-type { border-top: none; }
.out-row .lbl { flex: 1; min-width: 0; }

/* ------------------------------------------------------------------ charts */
.chart { position: relative; width: 100%; }
.chart-cols, .chart-area { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr auto; column-gap: 10px; row-gap: 7px; }
.c-y { position: relative; grid-row: 1; grid-column: 1; min-width: 26px; }
.c-y span { position: absolute; right: 0; transform: translateY(50%); font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1; }
.c-plot { position: relative; grid-row: 1; grid-column: 2; }
.c-gl { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--border); }
.c-gl.base { border-top: 1px solid var(--border-2); }
.c-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 4px; padding: 0 2px; }
.c-col { position: relative; flex: 1; height: 100%; min-width: 0; display: flex; align-items: flex-end; justify-content: center; }
.c-bar {
  width: 100%; max-width: 46px; min-height: 2px; border-radius: 5px 5px 2px 2px; background: var(--accent);
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 50%, transparent));
  transition: height .5s cubic-bezier(.2, .8, .2, 1), filter .15s;
}
.c-bar.ok { background: var(--ok); background: linear-gradient(180deg, var(--ok), color-mix(in srgb, var(--ok) 50%, transparent)); }
.c-col:hover .c-bar { filter: brightness(1.25); }
.c-col[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; top: -6px; left: 50%; transform: translate(-50%, -100%); z-index: 5; pointer-events: none;
  background: var(--text); color: var(--bg); font-size: 11.5px; font-weight: 600; padding: 5px 8px; border-radius: 7px; white-space: nowrap; box-shadow: var(--shadow);
}
.c-x { grid-row: 2; grid-column: 2; display: flex; gap: 4px; padding: 0 2px; }
.c-x span { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; overflow: visible; }
.c-x.edges { justify-content: space-between; }
.c-x.edges span { flex: none; }
.c-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2.25; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.c-ideal { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.c-dot { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); transform: translate(-50%, -50%); box-shadow: 0 0 0 4px var(--accent-soft); }
.c-tag { position: absolute; right: 0; transform: translateY(-125%); font-size: 11px; font-weight: 650; color: var(--ok); background: var(--surface); padding: 0 5px; border-radius: 5px; }
.donut { position: relative; flex: none; }
.donut svg { display: block; overflow: visible; }
.donut circle { fill: none; transition: stroke-dasharray .6s cubic-bezier(.2, .8, .2, 1); }
.donut .d-track { stroke: var(--track); }
.d-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.1; }
.d-center b { font-size: 19px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.d-center span { font-size: 10.5px; color: var(--text-3); font-weight: 600; margin-top: 2px; }
.hbars { display: flex; flex-direction: column; gap: 13px; }
.hb-row { display: grid; grid-template-columns: minmax(110px, 30%) 1fr auto; gap: 14px; align-items: center; font-size: 13px; }
.hb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-weight: 550; }
.hb-track { height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; }
.hb-track i { display: block; height: 100%; border-radius: inherit; background: var(--warn); background: linear-gradient(90deg, var(--warn), color-mix(in srgb, var(--warn) 55%, var(--bad))); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.hb-val { min-width: 64px; text-align: right; color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 600; }
.timeline { display: flex; height: 42px; border-radius: 10px; overflow: hidden; background: var(--track); }
.timeline div { height: 100%; transition: filter .15s; }
.timeline div:hover { filter: brightness(1.25); }
/* nothing recorded (the server or the reading was off): hatched, with a "No data" legend entry */
.timeline .tl-gap, .legend i.tl-gap { background: repeating-linear-gradient(135deg, var(--track) 0 5px, rgba(100, 116, 139, .45) 5px 7px); }
.tl-axis { display: flex; justify-content: space-between; margin-top: 7px; color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 8px 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin: 12px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--c, #64748b); }
.stack, .sbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; min-width: 140px; background: var(--track); gap: 2px; }
.stack div, .sbar div { height: 100%; }
.ubar { flex: 1; min-width: 60px; max-width: 120px; height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.ubar div, .ubar i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.meter { display: inline-flex; align-items: center; gap: 10px; min-width: 130px; justify-content: flex-end; width: 100%; }
.meter b { font-weight: 600; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

/* report charts (round 13: Charts.pareto, Charts.series) - one axis, solid hairline grid, bars at most 24 px with a 2 px
   gap and a 4 px rounded end, 2 px lines, 8 px end dots with a ring in the surface colour. The series colours keep a
   fixed order (validated for colour vision, light and dark); text never wears them. */
:root { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --series-6: #008300; --series-7: #9085e9; --series-8: #e66767; }
:root[data-theme="light"] { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948; }
.chart-wrap { width: 100%; overflow-x: clip; }
.chart-r { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr auto; column-gap: 10px; row-gap: 7px; }
.r-gl { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); }
.r-gl.zero { border-top-color: var(--border-2); }
.r-groups { position: absolute; inset: 0; display: flex; gap: 6px; padding: 0 2px; }
.r-group { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; justify-content: center; gap: 2px; }
.r-bar { position: relative; flex: 0 1 24px; max-width: 24px; min-width: 2px; height: 100%; }
.r-fill { position: absolute; left: 0; right: 0; min-height: 1px; border-radius: 4px 4px 0 0; transition: height .4s cubic-bezier(.2, .8, .2, 1); }
.r-fill.neg { border-radius: 0 0 4px 4px; }
.r-group:hover .r-fill { filter: brightness(1.15); }
.r-line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.r-dot { position: absolute; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); transform: translate(-50%, -50%); pointer-events: none; }
.r-hit { position: absolute; top: 0; bottom: 0; }
.r-hit:hover::before { content: ""; position: absolute; top: 0; bottom: 0; left: var(--at, 50%); border-left: 1px solid var(--border-2); }
.r-group[data-tip]:hover::after, .r-hit[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; top: -6px; left: 50%; transform: translate(-50%, -100%); z-index: 5; pointer-events: none;
  white-space: pre; text-align: left; background: var(--text); color: var(--bg); font-size: 11.5px; font-weight: 600; line-height: 1.45;
  padding: 5px 8px; border-radius: 7px; box-shadow: var(--shadow);
}
.r-group:first-child[data-tip]:hover::after, .r-hit.first[data-tip]:hover::after { left: 0; transform: translate(0, -100%); }
.r-group:last-child[data-tip]:hover::after, .r-hit.last[data-tip]:hover::after { left: auto; right: 0; transform: translate(0, -100%); }
.r-x { grid-row: 2; grid-column: 2; display: flex; gap: 6px; padding: 0 2px; min-width: 0; }
.r-x span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-x.edges { position: relative; display: block; height: 14px; }
.r-x.edges span { position: absolute; transform: translateX(-50%); overflow: visible; }
.r-x.edges span.first { transform: none; }
.r-x.edges span.last { transform: translateX(-100%); }
.r-legend { margin-top: 10px; }

/* --------------------------------------------------------------- settings */
.settings { display: grid; grid-template-columns: 224px minmax(0, 1fr); gap: 28px; align-items: start; }
.subnav { position: sticky; top: calc(var(--topbar-h) + 24px); display: flex; flex-direction: column; gap: 2px; }
.subnav .nav-label { padding: 12px 10px 6px; }
.subnav .nav-label:first-child { padding-top: 0; }
.subnav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); font-size: 13.5px; font-weight: 550; white-space: nowrap; }
.subnav a svg { color: var(--text-3); }
.subnav a:hover { background: var(--hover); color: var(--text); }
.subnav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.subnav a.active svg { color: var(--accent); }
.settings-body { min-width: 0; }
.save-bar { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-top: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg); }

/* ------------------------------------------------------------------- login */
.login-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; padding: 24px 0; }
.login {
  width: min(400px, 100%); margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 32px 30px 28px; box-shadow: var(--shadow-lg); text-align: left;
}
.login .logo { display: flex; justify-content: center; margin-bottom: 16px; }
.login .logo svg, .login .logo img, .login > img { width: 52px; height: 52px; display: block; margin: 0 auto; border-radius: 14px; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 21px; }
.login .lead { text-align: center; color: var(--text-3); font-size: 13.5px; margin: 0 0 22px; }
.login label.f { margin-bottom: 14px; }
.login input { width: 100%; height: 40px; }
.login button.primary { width: 100%; height: 40px; margin-top: 6px; }

/* ------------------------------------------------------------- cloud bits */
.pcard {
  display: flex; flex-direction: column; gap: 16px; padding: 20px; cursor: pointer; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-sm); transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .18s, border-color .18s; min-width: 0;
}
.pcard:hover { box-shadow: var(--shadow); border-color: var(--border-2); }
.pc-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pc-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.pc-title { flex: 1; min-width: 0; }
.pc-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-loc { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-body { display: flex; align-items: center; gap: 20px; }
.pc-stats { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat b { display: block; font-size: 20px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat { min-width: 0; }
.stat span { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.pc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pc-legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.att { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px; }
.att .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.stop { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.stop .top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stop .top b { font-size: 14px; }
.reasons { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.reasons button { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 99px; box-shadow: none; }
.reasons button.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; font-size: 12px; font-weight: 700; }
.account-link { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: var(--text); min-width: 0; }
.account-link:hover { background: var(--hover); color: var(--text); }
.account-link .who { min-width: 0; line-height: 1.25; }
.account-link .who b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-link .who small { font-size: 11.5px; color: var(--text-3); }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: none; padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elev); background: color-mix(in srgb, var(--bg-elev) 88%, transparent); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
#tabs a { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 7px; color: var(--text-3); font-size: 11px; font-weight: 600; }
#tabs a.active { color: var(--accent); }
#tabs .badge { position: absolute; top: 4px; left: 50%; margin-left: 5px; }
.phone-links a { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-top: 1px solid var(--border); color: var(--text); font-weight: 550; }
.phone-links a:first-child { border-top: none; }
.phone-links a svg:last-child { margin-left: auto; color: var(--text-3); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .settings { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .subnav { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; margin: 0 -4px; }
  .subnav .nav-label { display: none; }
  .subnav a { flex: none; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open #scrim { display: block; }
  .main-col { margin-left: 0; }
  .menu-btn { display: inline-flex !important; }
  .topbar { padding: 0 16px; }
  main#view { padding: 20px 18px 36px; }
  .banner { padding: 10px 18px; }
}
@media (max-width: 760px) {
  .grid, .grid2, .grid3 { grid-template-columns: 1fr; }
  .hide-phone { display: none !important; }
  .m-cols { display: none; }
  .top-chip { display: none; }
}
@media (max-width: 640px) {
  :root { --topbar-h: 56px; }
  main#view { padding: 14px 12px 28px; padding-bottom: calc(28px + var(--tabs-h)); }
  .topbar { gap: 8px; padding: 0 10px; }
  .page-title h1 { font-size: 16px; }
  .page-title .sub, .page-title .sep { display: none; }
  .kpis, .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .kpi, .card { padding: 12px 13px; gap: 10px; border-radius: 14px; }
  .kpi .donut { display: none; }
  .kpi-value, .card .v { font-size: 22px; margin-top: 8px; }
  .kpi-ic { width: 26px; height: 26px; }
  .panel { padding: 16px; border-radius: 14px; margin-bottom: 14px; }
  .hero { padding: 16px; border-radius: 14px; }
  .hero-badge { width: 52px; height: 52px; font-size: 20px; border-radius: 14px; }
  .hero-title h1 { font-size: 19px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .modal-head, .modal-body, .modal .actions { padding-left: 16px; padding-right: 16px; }
  .modal-bg.center { padding: 12px; }
  #toasts { left: 12px; right: 12px; bottom: calc(12px + var(--tabs-h)); }
  .toast { min-width: 0; max-width: none; }
  .hb-row { grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; }
  .pc-body .donut { display: none; }
  .form { grid-template-columns: 1fr; }
  .clock { display: none; }
}
@media (max-width: 760px) {
  .has-tabs { --tabs-h: 64px; }
  .has-tabs #tabs { display: flex; }
  .has-tabs .menu-btn { display: none !important; }
}
@media (min-width: 761px) { .only-phone { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .tile.flash { animation: alarm 1.3s ease-in-out infinite !important; }
}

/* help calls (andon) - shared with the cloud */
.help-call { border-left: 4px solid var(--c); }
.help-ic { display: inline-flex; color: var(--c); }
.help-wait { color: var(--bad); font-weight: 650; }
.help-att { color: var(--warn); }
.help-att .n { color: var(--text); }


/* photo notes (photokit.js) - shared with the cloud */
.ph-pick { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ph-grid.small { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
button.ph-tile { position: relative; display: block; width: 100%; height: auto; padding: 0; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 3; cursor: zoom-in; box-shadow: none; }
button.ph-tile:hover { background: var(--surface-2); }
.ph-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.ph-tile:hover img { transform: scale(1.04); }
.ph-tile .ph-tag { position: absolute; top: 6px; left: 6px; }
.ph-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 12px; font-weight: 600; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-grid.small .ph-cap { display: none; }
.ph-tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; background: var(--c); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.ph-tags { display: flex; flex-wrap: wrap; gap: 6px; }
button.ph-tagbtn { height: 32px; padding: 0 13px; border-radius: 99px; border: 1px solid var(--border-2); background: transparent; font-weight: 600;
  font-size: 13px; box-shadow: none; }
button.ph-tagbtn.on, button.ph-tagbtn.on:hover { background: var(--c); border-color: var(--c); color: #fff; }
.ph-preview { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.ph-preview img { width: min(260px, 100%); max-height: 260px; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); background: #000; }
.ph-preview-side { display: flex; flex-direction: column; gap: 10px; }
.ph-viewer { position: fixed; inset: 0; z-index: 150; display: grid; grid-template-rows: 1fr auto; background: rgba(5, 8, 14, .96); color: #fff; }
.ph-stage { display: flex; align-items: center; justify-content: center; min-height: 0; padding: 56px 64px 12px; }
.ph-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
button.ph-x, button.ph-nav { position: absolute; z-index: 1; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 99px;
  background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; }
button.ph-x { top: 12px; right: 12px; width: 44px; height: 44px; padding: 0; }
button.ph-nav { top: 50%; width: 48px; height: 48px; padding: 0; transform: translateY(-50%); }
button.ph-nav.prev { left: 12px; }
button.ph-nav.next { right: 12px; }
button.ph-x:hover, button.ph-nav:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.ph-info { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 14px 24px 18px; background: rgba(0, 0, 0, .35); }
.ph-info-main { flex: 1; min-width: 220px; }
.ph-title { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.ph-meta { margin-top: 4px; font-size: 13px; opacity: .85; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ph-meta a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ph-actions { display: flex; align-items: center; gap: 8px; }
.ph-actions .btn, .ph-actions button { background: rgba(255, 255, 255, .12); color: #fff; border-color: transparent; }
.ph-count { font-size: 13px; opacity: .8; font-variant-numeric: tabular-nums; }
button.ph-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 99px; border: 1px solid var(--border-2);
  background: transparent; color: inherit; font-size: 12px; font-weight: 600; box-shadow: none; vertical-align: middle; }
@media (max-width: 640px) {
  .ph-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
  .ph-stage { padding: 56px 8px 8px; }
  button.ph-nav { display: none; }
  .ph-info { padding: 12px 16px 16px; }
}

@media print {
  .sidebar, .topbar, #toasts, .toolbar button { display: none !important; }
  .main-col { margin: 0; }
  body { background: #fff; }
}

/* revision history: lists, the drawer and the version view (revkit.js) */
.rev-list { display: flex; flex-direction: column; }
.rev-row { display: grid; grid-template-columns: 128px 170px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); font-size: 13px; align-items: start; }
.rev-row:first-child { border-top: 0; }
.rev-when, .rev-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rev-who b { overflow-wrap: anywhere; }
.rev-who small, .rev-when small { font-size: 11.5px; }
.rev-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 26px; }
.rev-name { font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
a.rev-name:hover { color: var(--accent); text-decoration: underline; }
.rev-note { color: var(--text-2); }
.rev-ch { font-size: 12.5px; margin-top: 4px; overflow-wrap: anywhere; line-height: 1.45; }
.rev-lbl { color: var(--text-3); }
.rev-old { text-decoration: line-through; text-decoration-color: var(--text-3); color: var(--text-2); }
.rev-empty { padding: 14px 0; }
.rev-more { display: flex; justify-content: center; margin-top: 10px; }
.rev-drawer { width: min(860px, 100%); }
.rev-ver td { overflow-wrap: anywhere; vertical-align: top; }
.rev-ver td.rev-k { width: 38%; color: var(--text-2); }
.rev-ver tr.chg td { background: var(--warn-soft); }
.rev-now { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.rev-now-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--warn-soft); border: 1px solid var(--border-2); vertical-align: -2px; }
.rev-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.rev-filters .f { margin: 0; min-width: 160px; }
.page-tools { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; }
.name-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--text-2); }
@media (max-width: 720px) {
  .rev-row { grid-template-columns: 1fr; gap: 4px; }
  .rev-when, .rev-who { flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: baseline; }
}

/* help: the drawer, the user guide, articles (Markdown), quick tips (helpkit.js) */
.help-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 90; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: slide-in .24s cubic-bezier(.2, .8, .2, 1); }
.help-drawer[hidden] { display: none; }
/* a guide link inside a dialog: the article opens beside the dialog, above its backdrop (100) - readable while the
   dialog stays open - and below a confirm box (160). Round 19 checker #1: it opened blurred behind the dialog.
   helpkit.js sets .over-dialog only when the drawer opens with a dialog already open, and takes it off when a dialog
   opens after it (recheck A: a confirm opened from the page sat under the drawer). */
.help-drawer.over-dialog { z-index: 150; }
.help-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.help-mark { color: var(--accent); display: inline-flex; }
.help-search { padding: 10px 14px 6px; }
.help-search .search, .guide-nav .search { display: flex; }
.help-search .search input, .guide-nav .search input { width: 100%; }
.help-body { flex: 1; overflow-y: auto; padding: 8px 16px 28px; }
.help-sec { margin-top: 12px; }
.help-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.help-item:hover { background: var(--hover); }
.help-item b { font-weight: 600; }
/* round 16 - a question in the drawer's search: the guide's paragraph that answers it (helpkit.js) */
.help-answer { padding: 10px 12px; border-radius: 10px; background: var(--hover); }
.help-answer .md { font-size: 13.5px; line-height: 1.55; }
.help-answer .md p { margin: 4px 0; }
.help-answer .md-help { display: inline-block; margin-top: 4px; font-size: 13px; }
@media (min-width: 1200px) { body.helpdrawer-open .main-col { margin-right: min(440px, 100vw); } }

.md { line-height: 1.65; font-size: 14.5px; color: var(--text); max-width: 760px; }
.md-title { font-size: 26px; line-height: 1.25; margin: 4px 0 8px; }
.help-drawer .md-title { font-size: 21px; }
.md-crumb { text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 650; }
.md-lead { font-size: 15.5px; color: var(--text-2); margin: 0 0 14px; }
.md .md-h { margin: 26px 0 8px; line-height: 1.3; scroll-margin-top: calc(var(--topbar-h) + 12px); }
.md h2.md-h { font-size: 19px; padding-top: 8px; border-top: 1px solid var(--border); }
.md h3.md-h { font-size: 16px; }
.md h4.md-h { font-size: 14.5px; color: var(--text-2); }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md code { font-size: 12.5px; }
.md-code { white-space: pre-wrap; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; }
.md-table { margin: 10px 0; }
.md-table td, .md-table th { vertical-align: top; }
.md-callout { margin: 12px 0; }
.md-ic { display: inline-flex; vertical-align: -2px; color: var(--text-2); }
.md a.btn { margin: 4px 0 6px; }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--border-2); border-bottom-width: 2px;
  font: 600 11.5px/18px var(--mono); text-align: center; background: var(--surface-2); color: var(--text); }

.guide { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
.guide-nav { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding-right: 6px; }
.guide-nav .search { margin-bottom: 10px; }
.guide-sec { margin-top: 12px; }
.guide-link { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 13.5px; }
.guide-link:hover { background: var(--hover); color: var(--text); }
.guide-link.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.guide-main { min-width: 0; }
.guide-art { display: grid; grid-template-columns: minmax(0, 760px) 200px; gap: 32px; align-items: start; }
.guide-toc { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.guide-toc a { color: var(--text-2); text-decoration: none; padding: 2px 0; }
.guide-toc a:hover { color: var(--accent); }
.guide-cards { columns: 300px 3; column-gap: 16px; margin-top: 18px; }
.guide-cards > .guide-card { break-inside: avoid; margin: 0 0 16px; }
.guide-card h3 { margin: 0 0 6px; font-size: 15px; }
@media (max-width: 1100px) { .guide-art { grid-template-columns: minmax(0, 1fr); } .guide-toc { display: none; } }
.guide-back { display: none; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 13.5px; color: var(--accent); text-decoration: none; }
@media (max-width: 760px) {
  .guide { grid-template-columns: minmax(0, 1fr); }
  .guide-nav { position: static; max-height: none; }
  .guide.has-article .guide-nav { display: none; }
  .guide.has-article .guide-back { display: inline-flex; }
}

.htip { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; min-height: 0; padding: 0; margin: 0 4px;
  border-radius: 99px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2); font: 700 11px/1 var(--font, inherit);
  cursor: help; vertical-align: 1px; flex: none; }
.htip:hover, .htip:focus-visible { border-color: var(--accent); color: var(--accent); }
.htip.demo { cursor: default; }
/* a short label and its tip stay on one line (KPI titles, table headings) */
.kpi-label > span:has(> .htip), th:has(> .htip), .sub-label:has(> .htip) { white-space: nowrap; }
.htip-pop { position: absolute; z-index: 120; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg); font-size: 13.5px; line-height: 1.55; color: var(--text); }
.htip-pop p { margin: 0 0 6px; }
.htip-pop p:last-child { margin-bottom: 0; }
.htip-pop ul { margin: 4px 0; padding-left: 18px; }

/* file drop zone (imports: plant Settings > Import & export, ERP > Import & export) */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 18px; margin-top: 14px; text-align: center;
  border: 2px dashed var(--border-2); border-radius: var(--r-lg); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dz-ic { color: var(--accent); }
.dz-title { font-weight: 600; }
.dz-sub { color: var(--text-3); font-size: 12.5px; max-width: 560px; }

/* dictation: a microphone button beside a note field (Dictate.wrap) */
.dictate-wrap { display: flex; align-items: flex-start; gap: 6px; min-width: 0; flex: 1; }
.dictate-wrap > input, .dictate-wrap > textarea { flex: 1; min-width: 0; }
.dictate.on { color: #fff; background: var(--bad); border-color: transparent; animation: dictate-pulse 1.2s ease-in-out infinite; }
@keyframes dictate-pulse { 50% { box-shadow: 0 0 0 5px var(--bad-soft); } }

/* machine and part history: threads with replies */
.hist-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.hist-form textarea { width: 100%; resize: vertical; }
textarea.prose { font-family: var(--font); font-size: 14px; line-height: 1.5; }
.hist-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; }
.hist-form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hist-form-row .hist-by { width: 150px; }
.hist-checks { display: inline-flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; }
.hist-checks > span { display: inline-flex; align-items: center; gap: 6px; margin-right: 2px; }
.hist-checks label.cb { margin-right: 0; }
.hist-list { margin-top: 10px; display: flex; flex-direction: column; }
.hist-entry { padding: 12px 0; border-top: 1px solid var(--border); }
.hist-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.hist-meta { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; margin-top: 5px; font-size: 12.5px; color: var(--text-3); }
.hist-meta b { color: var(--text-2); font-weight: 600; }
.hist-meta a { display: inline-flex; align-items: center; gap: 4px; }
.hist-meta .spacer { flex: 1; }
.hist-replies { margin: 8px 0 0 14px; padding-left: 12px; border-left: 2px solid var(--border-2); display: flex; flex-direction: column; gap: 9px; }
.hist-reply .hist-meta { margin-top: 3px; }
.hist-reply-box { margin: 8px 0 0 14px; }
.hist-empty { margin-top: 12px; }

/* maintenance record on the press page */
.mt-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mt-stat { flex: 1; min-width: 120px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.mt-stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.mt-stat span { font-size: 12px; color: var(--text-3); }
.mt-stat.warn b { color: var(--warn); }
.pm-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pm-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(80px, 1fr) auto auto; align-items: center; gap: 10px; }
.pm-bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.pm-bar i { display: block; height: 100%; border-radius: 99px; }
@media (max-width: 640px) { .pm-row { grid-template-columns: 1fr auto; } .pm-row .pm-bar { grid-column: 1 / -1; order: 3; } }
/* a workcenter page plan: its name, how often, last done and next due on a line of their own, the bar under it */
.pm-row.pm-dated { grid-template-columns: minmax(80px, 1fr) auto auto; row-gap: 4px; }
.pm-row.pm-dated .pm-name { grid-column: 1 / -1; }
@media (max-width: 640px) { .pm-row.pm-dated { grid-template-columns: 1fr auto; } .pm-row.pm-dated .pm-bar { grid-column: 1 / -1; order: 3; } }

/* the part on the press page, up front */
.hero-part { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 7px 12px; border-radius: var(--r-sm); max-width: 100%;
  background: var(--accent-soft); border: 1px solid transparent; color: var(--text); text-decoration: none; font-size: 15px; flex-wrap: wrap; }
.hero-part:hover { border-color: var(--accent); }
.hero-part > svg { color: var(--accent); flex: none; }
.hero-part b { font-size: 17px; letter-spacing: -.01em; }
.hero-part .hp-label { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.hero-part .hp-more { color: var(--text-2); font-size: 13px; }
a.tag { text-decoration: none; }
a.tag:hover { border-color: var(--accent); color: var(--text); }

/* the part page: presses running it */
.pp-list { display: flex; flex-direction: column; gap: 8px; }
.pp-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--border);
  border-left: 4px solid var(--c); color: var(--text); text-decoration: none; min-width: 0; }
.pp-row:hover { background: var(--hover); }
.pp-num { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; border-radius: 9px; background: var(--c);
  color: #fff; font-weight: 750; flex: none; }
.pp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* TV board: a way out you can read from across the room */
.tv-exit { font-weight: 600; }
.feedback-btn { height: 26px; padding: 0 8px; font-size: 12px; gap: 5px; }

/* waiting for the plant (cloud notes and replies) */
.hist-pending { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 2px; }
.hist-pending svg { vertical-align: -2px; }

/* the job's run log */
.run-log { display: flex; flex-direction: column; max-height: 520px; overflow: auto; }
.run-row { display: grid; grid-template-columns: 18px auto minmax(0, 1fr) auto; align-items: baseline; gap: 10px; padding: 7px 2px; border-top: 1px solid var(--border); font-size: 13.5px; }
.run-row:first-child { border-top: none; }
.run-row > svg { color: var(--text-3); align-self: center; }
.run-row.warn > svg { color: var(--warn); }
.run-row.bad > svg { color: var(--bad); }
.run-row.accent > svg { color: var(--accent); }
.run-text { overflow-wrap: anywhere; }
@media (max-width: 640px) { .run-row { grid-template-columns: 18px minmax(0, 1fr); } .run-row > .muted.nowrap { grid-column: 2; } .run-row .run-text { grid-column: 2; } }

/* feedback to CycleWright */
.fb-list { display: flex; flex-direction: column; }
.fb-row { padding: 12px 0; border-top: 1px solid var(--border); }
.fb-row:first-child { border-top: none; padding-top: 4px; }
.fb-answer { display: flex; gap: 8px; margin-top: 8px; padding: 9px 12px; border-radius: var(--r-sm); background: var(--accent-soft); font-size: 13.5px; line-height: 1.5; }
.fb-answer > svg { color: var(--accent); flex: none; margin-top: 2px; }
