/* Run Rate: dark plant-floor theme. Colours live here as tokens. */
:root {
  --bg: #0E1116;
  --bar: #12161C;
  --panel: #161B22;
  --panel-2: #1C222B;
  --line: #262D37;
  --line-2: #2E3642;
  --rule: #20262F;
  --text: #E8EAED;
  --text-2: #B4BCC8;
  --muted: #8B95A3;
  --accent: #3987E5;
  --accent-soft: #1E2E45;
  --accent-text: #7DB4F5;
  --good: #0CA30C;
  --good-bg: #10301A;
  --good-line: #1D5A2C;
  --warn: #FAB219;
  --warn-bg: #2A2410;
  --warn-line: #7A5F14;
  --warn-text: #E2D3A8;
  --crit: #D03B3B;
  --crit-bg: #2E1416;
  --crit-line: #6B2226;
  --crit-text: #F2B8B8;
  --idle-bg: #1C222B;
  --radius: 14px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
a { color: var(--accent-text); }
a:hover { color: #A9CDF8; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; }

/* ---------- boot / fatal ---------- */
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text-2); }
.boot-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.fatal { max-width: 460px; margin: 18vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.fatal p { color: var(--text-2); margin: 0; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px/1 var(--display); letter-spacing: -0.01em; white-space: nowrap; }
.brand svg { flex: none; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; padding: 28px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.login-card h1 { font-size: 24px; margin-top: 8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.login-card input { min-height: 46px; padding: 0 12px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; font-size: 16px; color: var(--text); }
.login-card input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(57, 135, 229, .25); }
.btn-primary { min-height: 46px; padding: 0 18px; background: var(--accent); color: #fff; border: 0; border-radius: 10px; font-weight: 600; cursor: pointer; }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { min-height: 40px; padding: 0 14px; background: transparent; color: var(--text); border: 1px solid var(--line-2); border-radius: 10px; font-weight: 500; cursor: pointer; }
.form-error { margin: 0; min-height: 1em; color: var(--crit-text); font-size: 13px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: 12px 24px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(18, 22, 28, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1392px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.site-pick { position: relative; display: flex; align-items: center; }
.site-pick select {
  appearance: none; -webkit-appearance: none;
  min-height: 40px; max-width: 64vw; padding: 0 34px 0 12px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
  font-weight: 600; cursor: pointer; text-overflow: ellipsis;
}
.site-pick::after { content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; margin-top: -6px; border-right: 1.6px solid var(--text-2); border-bottom: 1.6px solid var(--text-2); transform: rotate(45deg); pointer-events: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.clock { color: var(--text-2); white-space: nowrap; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.live-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-badge.live i { background: var(--good); box-shadow: 0 0 0 3px rgba(12, 163, 12, .18); }
.live-badge.polling i { background: var(--warn); }
.menu { position: relative; }
.menu summary { list-style: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent-soft); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 48px; min-width: 220px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .45); }
.menu-email { color: var(--text-2); font-size: 13px; word-break: break-all; }

/* ---------- live page ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 24px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 16px; }
.page-head .eyebrow { font-size: 13px; color: var(--text-2); }
.page-head h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }

.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 999px; font-weight: 600; border: 1px solid var(--line-2); background: var(--idle-bg); }
.pill.good { background: var(--good-bg); border-color: var(--good-line); }
.pill.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.pill.crit { background: var(--crit-bg); border-color: var(--crit-line); }

.banner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--idle-bg); }
.banner .b-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.banner .b-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.banner .b-sub { font-size: 13px; color: var(--text-2); }
.banner .b-time { font: 700 22px/1 var(--display); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.banner.warn .b-sub { color: var(--warn-text); }
.banner.crit { background: var(--crit-bg); border-color: var(--crit-line); }
.banner.crit .b-sub { color: var(--crit-text); }

.progress { display: flex; flex-direction: column; gap: 8px; }
.progress .p-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 13px; color: var(--text-2); }
.track { position: relative; height: 8px; border-radius: 999px; background: #232A33; overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.track.over > i { background: var(--warn); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.card { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card .k-label { font-size: 13px; color: var(--text-2); }
.card .k-value { font: 700 44px/1 var(--display); letter-spacing: -0.02em; }
.card .k-value small { font-size: 18px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.card .k-value .sep { font-size: 28px; color: var(--muted); }
.card .k-sub { font-size: 13px; color: var(--text-2); }
.card .k-sub strong { color: var(--text); font-weight: 600; }

.cols { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel { padding: 20px 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.panel-head h2 { font-size: 18px; font-weight: 600; }
.panel-head span { font-size: 13px; color: var(--text-2); }
.empty { color: var(--muted); font-size: 13px; margin: 0; }

/* machines */
.machines { display: grid; grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); gap: 10px; }
.mach { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid #2A313C; min-width: 0; }
.mach .m-step { font-size: 12px; color: var(--muted); }
.mach .m-name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.mach .m-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.mach.m-down { background: var(--warn-bg); border-color: var(--warn-line); }
.mach.m-idle { opacity: .75; }

/* hourly bars */
.bars { position: relative; height: 200px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; align-items: end; padding: 0 4px; border-bottom: 1px solid #39414D; }
.bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; outline: none; }
.bar .v { font-size: 12px; font-weight: 600; color: var(--text); min-height: 16px; }
.bar .f { width: 100%; max-width: 56px; border-radius: 4px 4px 0 0; background: var(--accent); min-height: 2px; }
.bar.partial .f { background: #22446E; outline: 1px dashed var(--accent); outline-offset: -1px; }
.bar.nodata .f { background: transparent; min-height: 0; }
.bar .tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 2; padding: 6px 10px; border-radius: 8px; background: #0B0E12; border: 1px solid var(--line-2); font-size: 12px; white-space: nowrap; color: var(--text); pointer-events: none; }
.bar:first-child .tip, .bar:nth-child(2) .tip { left: 0; transform: none; }
.bar:last-child .tip, .bar:nth-last-child(2) .tip { left: auto; right: 0; transform: none; }
.bar:hover .tip, .bar:focus .tip { display: block; }
.bar:hover .f, .bar:focus .f { filter: brightness(1.15); }
.bar-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; padding: 0 4px; }
.bar-labels span { text-align: center; font-size: 12px; color: var(--muted); }

/* stops list */
.stops { display: flex; flex-direction: column; }
.stop { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-top: 1px solid #232A33; }
.stop:first-child { border-top: 0; padding-top: 0; }
.stop .s-row { display: flex; justify-content: space-between; gap: 10px; }
.stop .s-what { font-weight: 600; overflow-wrap: anywhere; }
.stop .s-when { color: var(--text-2); white-space: nowrap; }
.stop .s-sub { font-size: 13px; color: var(--text-2); }
.stop.open .s-sub { color: var(--warn-text); }
.tag { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; vertical-align: 1px; background: #2A3240; color: var(--text-2); }
.tag.safety { background: var(--crit-bg); color: var(--crit-text); }

/* container */
.cont-num { font: 700 32px/1 var(--display); }
.cont-num small { font-size: 16px; color: var(--text-2); font-weight: 600; }
.packs { display: flex; flex-wrap: wrap; gap: 6px; }
.pk { padding: 4px 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid #2A313C; font-size: 12px; }
.pk.light { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }

/* analog tiles */
.analogs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.an { padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid #2A313C; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.an .a-label { font-size: 12px; color: var(--text-2); }
.an .a-val { font: 700 24px/1.1 var(--display); }
.an .a-val small { font-size: 13px; color: var(--text-2); font-weight: 600; }
.an svg { width: 100%; height: 28px; margin-top: 4px; }

/* other sites */
.site-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; background: var(--panel-2); border-radius: 10px; color: var(--text); text-decoration: none; border: 1px solid transparent; }
.site-row:hover { border-color: var(--line-2); color: var(--text); }
.site-row .sr-name { font-weight: 600; }
.site-row .sr-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }

/* all values */
details.values summary { cursor: pointer; font: 600 18px var(--display); list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.values summary::-webkit-details-marker { display: none; }
details.values summary span { font: 400 13px var(--font); color: var(--text-2); }
.vals { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 24px; margin-top: 12px; }
.vals h3 { grid-column: 1 / -1; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 12px 0 4px; font-family: var(--font); }
.val { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.val span:first-child { color: var(--text-2); overflow-wrap: anywhere; }
.val span:last-child { font-weight: 600; white-space: nowrap; }
.val.stale span:last-child { color: var(--muted); font-weight: 400; }

.foot { color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- phone ---------- */
@media (max-width: 960px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .topbar-in { gap: 10px; flex-wrap: nowrap; }
  .topbar .brand span { display: none; }
  .site-pick { min-width: 0; flex: 0 1 auto; }
  .site-pick select { max-width: 100%; width: 100%; }
  .top-right { gap: 10px; flex: none; }
  .clock { display: none; }
  .live-badge .lb-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pill.dup { display: none; }
  .kpis .card:nth-child(even):last-child { grid-column: 1 / -1; }
  .page { padding: 16px 16px 40px; gap: 14px; }
  .page-head h1 { font-size: 26px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpis .card:first-child { grid-column: 1 / -1; }
  .kpis .card:first-child .k-value { font-size: 56px; }
  .card { padding: 14px; }
  .card .k-value { font-size: 28px; }
  .card .k-value small { font-size: 14px; }
  .card .k-value .sep { font-size: 20px; }
  .panel { padding: 16px; }
  .machines { grid-template-columns: 1fr; gap: 0; background: var(--panel-2); border-radius: 12px; border: 1px solid #2A313C; padding: 2px 14px; }
  .mach { flex-direction: row; justify-content: space-between; align-items: center; padding: 10px 0; border: 0; border-top: 1px solid var(--rule); border-radius: 0; background: transparent; }
  .mach:first-child { border-top: 0; }
  .mach .m-step { display: none; }
  .mach.m-down { background: transparent; }
  .mach.m-down .m-name { color: var(--warn); }
  .bars { height: 150px; gap: 6px; }
  .bar-labels { gap: 6px; }
  .bar .v { font-size: 11px; }
}
