/* Optek Precision Optics — Production Report
   Aesthetic: warm off-white control-room hybrid.
   Type: IBM Plex Sans (UI), IBM Plex Mono (numbers).
*/

:root {
  /* Dark control-room theme with colorful KPI accents */
  --bg:        #0b0f1a;
  --bg-2:      #131826;
  --card:      #181d2c;
  --card-2:    #1f2538;
  --ink:       #eef2fb;
  --ink-2:     #c4cbdc;
  --muted:     #8089a3;
  --muted-2:   #5a6383;
  --text-muted:#8089a3;
  --line:      #262d45;
  --line-2:    #303859;

  /* Main accent: vivid cyan-blue */
  --accent:        #38bdf8;
  --accent-2:      #0ea5e9;
  --accent-soft:   rgba(56, 189, 248, 0.14);

  /* Per-metric brand colors (used across KPI cards, bars, charts) */
  --metric-launch:   #a78bfa;     /* violet */
  --metric-yield:    #34d399;     /* emerald */
  --metric-downtime: #f87171;     /* coral */
  --metric-eer:      #fbbf24;     /* amber */

  --good:      #34d399;
  --good-dark: #15803d;
  --good-soft: rgba(52, 211, 153, 0.16);
  --warn:      #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.16);
  --bad:       #f87171;
  --bad-soft:  rgba(248, 113, 113, 0.18);

  --shadow-sm: 0 1px 0 rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.4), 0 24px 64px rgba(0,0,0,0.55);

  --radius:    6px;
  --radius-lg: 10px;

  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ===== Header ===== */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: conic-gradient(from 210deg, var(--metric-launch), var(--accent), var(--metric-yield), var(--metric-eer), var(--metric-downtime), var(--metric-launch));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 0 12px rgba(56,189,248,0.4);
}
.brand-sep {
  width: 1px; height: 18px; background: var(--line-2);
}
.brand-title { color: var(--muted); font-weight: 500; font-size: 12.5px; letter-spacing: 0.04em; text-transform: uppercase; }

.topbar-spacer { flex: 1; }

.topbar-meta {
  display: flex; align-items: center; gap: 14px;
  font-size: 12px; color: var(--muted);
  font-family: var(--font-mono);
}
.topbar-meta .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px rgba(47,122,71,0.15);
}

/* ===== Filter bar ===== */
.filterbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 28px;
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
}
.filterbar .group {
  display: flex; align-items: center; gap: 8px;
}
.label-eyebrow {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}

.seg {
  display: inline-flex; background: var(--bg-2); border-radius: var(--radius);
  padding: 2px; border: 1px solid var(--line);
}
.seg button {
  background: transparent; border: 0;
  padding: 5px 12px;
  font-family: var(--font-sans); font-size: 13px;
  color: var(--ink-2); cursor: pointer; border-radius: 4px;
  font-weight: 500;
}
.seg button:hover { color: var(--ink); }
.seg button.active {
  background: var(--accent); color: #0b0f1a;
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--accent);
  font-weight: 600;
}

.date-step {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.date-step button {
  background: transparent; border: 0; width: 28px; height: 28px;
  cursor: pointer; color: var(--ink-2); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.date-step button:hover { background: var(--bg-2); }
.date-step .date-display {
  padding: 0 10px; font-family: var(--font-mono); font-size: 12.5px;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  height: 28px; display: flex; align-items: center;
  min-width: 130px; justify-content: center;
}

select.linesel, select.spansel {
  font-family: var(--font-sans); font-size: 13px;
  padding: 5px 28px 5px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%238089a3' fill='none' stroke-width='1.4' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select.spansel { font-family: var(--font-mono); font-size: 12.5px; }

/* ===== Line multi-select ===== */
.linems { position: relative; }
.linems-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-sans); font-size: 13px;
  padding: 5px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); cursor: pointer;
  min-width: 150px; justify-content: space-between;
}
.linems-btn:hover { border-color: var(--ink-2); }
.linems-btn.open { border-color: var(--accent); }
.linems-btn svg { color: var(--muted); flex-shrink: 0; }
.linems-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linems-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  min-width: 240px; max-height: 360px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 8px 28px -8px rgba(0,0,0,0.5);
  padding: 6px;
}
.linems-toolbar {
  display: flex; gap: 4px; padding: 2px 2px 6px;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.linems-toolbar button {
  flex: 1; font-family: var(--font-mono); font-size: 10.5px;
  padding: 4px 6px; border-radius: 4px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2);
  cursor: pointer;
}
.linems-toolbar button:hover { background: var(--bg); color: var(--ink); }
.linems-opt {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 6px 8px; border-radius: 4px;
  background: transparent; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; color: var(--ink-2);
}
.linems-opt:hover { background: var(--bg-2); }
.linems-opt.on { color: var(--ink); }
.linems-opt b { color: var(--ink); font-family: var(--font-mono); min-width: 38px; }
.linems-check {
  width: 14px; height: 14px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--accent);
  border: 1.5px solid var(--line); border-radius: 3px;
}
.linems-opt.on .linems-check { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.linems-prod {
  font-size: 10.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.linems-div { height: 1px; background: var(--line); margin: 4px 0; }

.filter-spacer { flex: 1; }

.iconbtn {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 10px; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans);
}
.iconbtn:hover { background: var(--bg-2); }

/* ===== Alerts banner ===== */
.alerts {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--line);
}
.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 28px;
  font-size: 13px;
  background: var(--warn-soft); color: var(--ink);
}
.alert.bad  { background: var(--bad-soft); }
.alert.info { background: var(--accent-soft); }
.alert .pill {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 3px; background: rgba(0,0,0,0.06);
  text-transform: uppercase; font-weight: 600;
}
.alert .alert-msg { flex: 1; }
.alert .alert-msg b { font-weight: 600; }
.alert .alert-cta {
  background: transparent; border: 0; cursor: pointer;
  color: var(--ink); font-weight: 500; font-size: 12.5px;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(20,24,31,0.3);
  padding: 0 4px;
}
.alert .alert-close {
  background: transparent; border: 0; cursor: pointer; color: var(--muted);
  font-size: 16px; padding: 0 4px; line-height: 1;
}

/* ===== Main ===== */
.main { padding: 22px 28px 60px; max-width: 1640px; margin: 0 auto; width: 100%; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 26px 0 12px;
}
.section-head:first-child { margin-top: 0; }
.section-head h2 {
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; margin: 0; color: var(--ink-2);
}
.section-head .sub {
  font-size: 12px; color: var(--muted); font-family: var(--font-mono);
}

/* ===== KPI Cards ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 16px 12px;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 188px;
  overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--kpi-color, var(--accent));
  opacity: 0.85;
}
.kpi[data-metric="launch"]   { --kpi-color: var(--metric-launch); }
.kpi[data-metric="yield"]    { --kpi-color: var(--metric-yield); }
.kpi[data-metric="downtime"] { --kpi-color: var(--metric-downtime); }
.kpi[data-metric="eer"]      { --kpi-color: var(--metric-eer); }
.kpi:hover {
  border-color: var(--kpi-color, var(--line-2));
  box-shadow: var(--shadow-md), 0 0 0 1px var(--kpi-color, transparent);
  transform: translateY(-1px);
}
.kpi .kpi-value { color: var(--kpi-color, var(--ink)); }
.kpi .drill { color: var(--kpi-color, var(--accent)); }
.kpi-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px;
}
.kpi-label {
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}
.kpi-status {
  font-family: var(--font-mono); font-size: 9.5px;
  padding: 2px 6px; border-radius: 3px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.kpi-status::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.kpi-status.good { background: var(--good-soft); color: var(--good); }
.kpi-status.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-status.bad  { background: var(--bad-soft);  color: var(--bad); }
.kpi-status.nodata { background: var(--bg-2); color: var(--muted); }

/* No-data card state */
.kpi-nodata { cursor: default; opacity: 0.88; }
.kpi-nodata:hover { transform: none; }
.kpi-blank {
  display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 4px; flex: 1; min-height: 96px;
}
.kpi-blank-dash {
  font-family: var(--font-mono); font-size: 42px; font-weight: 600;
  color: var(--line); line-height: 1;
}
.kpi-blank-msg {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}
.delta-none {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
  display: flex; align-items: baseline; gap: 6px;
  white-space: nowrap;
  min-width: 0;
}
.kpi-value .unit {
  font-size: 13px; color: var(--muted); font-weight: 400;
  flex-shrink: 0;
}
.kpi-vs {
  font-size: 11.5px; color: var(--muted); font-family: var(--font-mono);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  flex-wrap: wrap;
  row-gap: 2px;
}
.kpi-vs .delta {
  font-weight: 600;
}
.kpi-vs .delta.good { color: var(--good); }
.kpi-vs .delta.bad  { color: var(--bad); }

.kpi-spark {
  margin-top: auto;
  position: relative;
  height: 44px;
}
.kpi-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: var(--muted-2);
  border-top: 1px dashed var(--line);
  padding-top: 8px; margin-top: 2px;
}
.kpi-foot .drill {
  color: var(--accent); font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
}
.kpi:hover .drill { color: var(--accent-2); }
.kpi-source {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  margin-top: 8px; min-width: 0;
}
.kpi-source-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.kpi-source.uploaded .kpi-source-dot { background: var(--good); box-shadow: 0 0 0 2.5px var(--good-soft); }
.kpi-source.sample .kpi-source-dot { background: var(--muted-2); }
.kpi-source-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.kpi-source.sample .kpi-source-name { color: var(--muted); }
.kpi-source-span { flex-shrink: 0; color: var(--muted-2); padding-left: 6px; border-left: 1px solid var(--line); }

/* ===== Line matrix ===== */
.matrix {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.matrix-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.matrix-table th, .matrix-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.matrix-table th {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
  background: var(--card-2);
  position: sticky; top: 0;
}
.matrix-table tr:last-child td { border-bottom: 0; }
.matrix-table tr.row:hover td { background: var(--bg-2); cursor: pointer; }
.matrix-table .line-id {
  font-family: var(--font-mono); font-weight: 600; color: var(--ink);
}
.matrix-table .line-product { color: var(--muted); font-size: 12px; }
.matrix-table td.num {
  font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums;
}
.matrix-table .bar-cell {
  width: 130px; padding-right: 14px;
}
.bar {
  height: 6px; background: var(--bg-2); border-radius: 3px;
  position: relative; overflow: hidden;
}
.bar > i {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 3px;
  position: absolute; top: 0; left: 0;
}
.bar > i.good { background: var(--good); }
.bar > i.warn { background: var(--warn); }
.bar > i.bad  { background: var(--bad);  }
.bar .target-mark {
  position: absolute; top: -2px; bottom: -2px;
  width: 1.5px; background: var(--ink-2);
}

.cell-status {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 8px; vertical-align: middle;
}
.cell-status.good { background: var(--good); }
.cell-status.warn { background: var(--warn); }
.cell-status.bad  { background: var(--bad); }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,24,31,0.42);
  z-index: 50;
  display: flex; align-items: stretch; justify-content: flex-end;
  animation: fade 0.18s ease;
}
.modal {
  width: min(1180px, 92vw);
  background: var(--bg);
  border-left: 1px solid var(--line-2);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slide 0.22s cubic-bezier(.2,.7,.2,1);
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.modal-head .crumb {
  font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.modal-head h1 {
  font-size: 20px; font-weight: 600; margin: 0;
  letter-spacing: -0.01em;
}
.modal-head .title-block { flex: 1; }
.modal-close {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-2);
  font-size: 16px; line-height: 1;
}
.modal-close:hover { background: var(--bg-2); }

.modal-tabs {
  display: flex; gap: 4px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.modal-tabs button {
  background: transparent; border: 0;
  padding: 12px 14px;
  font-family: var(--font-sans); font-size: 13px;
  color: var(--muted); cursor: pointer; font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.modal-tabs button:hover { color: var(--ink); }
.modal-tabs button.active {
  color: var(--ink); border-bottom-color: var(--accent);
}
.modal-tabs button .count {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 5px; border-radius: 3px;
  background: var(--bg-2); margin-left: 6px;
  color: var(--muted);
}

.modal-body {
  flex: 1; overflow-y: auto;
  padding: 22px 24px 40px;
}

/* ===== Login ===== */
/* ===== Login (modern split-screen) ===== */
.login-modern {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  background: var(--bg);
}

/* Left — brand hero */
.login-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 100vh;
  padding: 48px 52px;
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--accent) 26%, transparent) 0%, transparent 55%),
    radial-gradient(100% 80% at 100% 100%, color-mix(in srgb, var(--metric-launch) 22%, transparent) 0%, transparent 50%),
    linear-gradient(155deg, #0e1424 0%, #0a0e18 60%, #070a12 100%);
  color: #eef2fb;
}
.login-hero-glow {
  position: absolute; width: 460px; height: 460px; border-radius: 50%;
  top: -120px; left: -80px; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 40%, transparent) 0%, transparent 70%);
  filter: blur(40px); opacity: 0.5;
}
.login-hero-grid { position: absolute; inset: 0; color: rgba(255,255,255,0.05); pointer-events: none; }
.login-hero-top, .login-hero-mid, .login-hero-stats { position: relative; z-index: 1; }

.login-hero-top { display: flex; align-items: baseline; gap: 12px; }
.login-logo {
  font-family: var(--font-mono); font-weight: 700; font-size: 26px; letter-spacing: -0.02em;
  color: #fff;
  background: linear-gradient(120deg, #fff, color-mix(in srgb, var(--accent) 70%, #fff));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.login-logo-sub { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(238,242,251,0.55); }

.login-hero-mid { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 36px 0; }
.login-hero-mid h1 {
  font-size: 46px; line-height: 1.04; font-weight: 700; letter-spacing: -0.025em;
  margin: 0 0 18px;
}
.login-hero-mid h1 span { color: var(--accent); }
.login-hero-mid p { font-size: 14.5px; line-height: 1.6; color: rgba(238,242,251,0.68); max-width: 42ch; margin: 0; }

.login-hero-bars { display: flex; align-items: flex-end; gap: 7px; height: 84px; margin-top: 34px; }
.login-hero-bars span {
  flex: 1; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 30%, transparent));
  transform-origin: bottom; animation: lhbar 2.6s ease-in-out infinite alternate;
  opacity: 0.85;
}
@keyframes lhbar { from { transform: scaleY(0.55); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .login-hero-bars span { animation: none; } }

.login-hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding-top: 26px; border-top: 1px solid rgba(255,255,255,0.1); }
.login-hero-stats > div { display: flex; flex-direction: column; gap: 3px; }
.login-hero-stats b { font-family: var(--font-mono); font-size: 19px; font-weight: 600; color: #fff; }
.login-hero-stats span { font-size: 10.5px; color: rgba(238,242,251,0.5); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }

/* Right — sign-in pane */
.login-pane { display: grid; place-items: center; padding: 40px 32px; background: var(--bg); }
.login-pane-inner { width: 380px; max-width: 100%; }
.login-pane-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 22px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.login-pane-brand .brand-mark { width: 26px; height: 26px; }
.login-brand { font-weight: 700; font-size: 13px; color: var(--ink); letter-spacing: 0.02em; }
.login-sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }

@media (max-width: 880px) {
  .login-modern { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-pane { min-height: 100vh; }
}

.login-head { display: flex; align-items: center; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.login-head .brand-mark { width: 24px; height: 24px; }
.login-brand { font-weight: 700; font-size: 13px; color: var(--ink); letter-spacing: 0.02em; }
.login-sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.login-title { font-size: 22px; font-weight: 600; color: var(--ink); margin: 0 0 4px; }
.login-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 18px; }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.login-field span { font-size: 11px; font-weight: 600; color: var(--ink); font-family: var(--font-mono); }
.login-field input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; font-size: 13.5px; background: var(--bg); color: var(--ink); font-family: var(--font-sans); transition: border-color .12s; }
.login-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 14px; }
.login-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.login-check input { accent-color: var(--accent); }
.login-link { font-size: 12px; color: var(--accent); text-decoration: none; }
.login-link:hover { text-decoration: underline; }
.login-err { background: rgba(214,65,65,.08); border: 1px solid rgba(214,65,65,.25); color: var(--bad); padding: 8px 12px; border-radius: 3px; font-size: 12px; margin-bottom: 12px; font-family: var(--font-mono); }
.login-notice { background: var(--good-soft); border: 1px solid color-mix(in srgb, var(--good) 30%, transparent); color: var(--good); padding: 8px 12px; border-radius: 3px; font-size: 12px; margin-bottom: 12px; font-family: var(--font-mono); line-height: 1.5; }
.login-btn { width: 100%; background: var(--accent); color: #fff; border: none; padding: 11px 14px; border-radius: 4px; font-size: 13px; font-weight: 600; cursor: pointer; transition: filter .12s; }
.login-btn:hover { filter: brightness(1.08); }
.login-btn:disabled { opacity: 0.6; cursor: wait; }
.login-divider { text-align: center; font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.18em; text-transform: uppercase; margin: 16px 0 12px; position: relative; }
.login-divider::before, .login-divider::after { content: ''; position: absolute; top: 50%; width: 38%; height: 1px; background: var(--line); }
.login-divider::before { left: 0; }
.login-divider::after  { right: 0; }
.login-divider span { background: var(--bg); padding: 0 8px; position: relative; }
.login-sso { width: 100%; background: transparent; border: 1px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: 4px; font-size: 12.5px; cursor: pointer; font-family: var(--font-mono); }
.login-sso:hover { border-color: var(--accent); color: var(--accent); }
.login-ghost { width: 100%; background: transparent; border: none; color: var(--muted); padding: 8px 14px 0; font-size: 12px; cursor: pointer; font-family: var(--font-mono); }
.login-ghost:hover { color: var(--ink-2); }
.login-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.login-field .opt { color: var(--muted-2); font-weight: 400; }
.login-requested { text-align: center; }
.req-check { width: 56px; height: 56px; margin: 6px auto 14px; border-radius: 50%; display: grid; place-items: center; color: var(--good); background: var(--good-soft); }
.login-requested .login-hint { margin-bottom: 18px; }
.login-requested .login-hint b { color: var(--ink); }

/* ===== Admin · access requests ===== */
.access-panel { border: 1px solid var(--line); }
.access-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.access-head h3 { margin: 0; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink); }
.access-count { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: var(--warn-soft); color: var(--warn); }
.access-count.due { background: var(--bad-soft); color: var(--bad); }
.access-section-label { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin: 16px 0 6px; }
.access-section-label:first-of-type { margin-top: 4px; }
.access-section-label.due { color: var(--bad); }
.row-expired { background: var(--bad-soft); }
.rev-ok { color: var(--good); }
.rev-soon { color: var(--warn); }
.rev-due { color: var(--bad); font-weight: 700; }
.access-active { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

/* Access filter / group bar */
.access-filterbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 4px; }
.access-tabs { display: inline-flex; gap: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; padding: 3px; }
.access-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 5px;
  background: transparent; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 12px; color: var(--muted);
}
.access-tab:hover { color: var(--ink-2); }
.access-tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.access-tab-n { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; background: var(--bg); color: var(--muted); }
.access-tab.active .access-tab-n { background: var(--accent-soft); color: var(--accent); }
.access-tab.due .access-tab-n { background: var(--bad-soft); color: var(--bad); }
.access-search { display: inline-flex; align-items: center; gap: 7px; flex: 1; min-width: 180px; max-width: 320px; padding: 6px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
.access-search:focus-within { border-color: var(--accent); }
.access-search input { flex: 1; background: none; border: none; outline: none; color: var(--ink); font-family: var(--font-sans); font-size: 12.5px; min-width: 0; }
.access-search-clear { background: none; border: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.access-search-clear:hover { color: var(--ink); }
.access-reveal { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; padding: 4px 10px; border-radius: 4px; cursor: pointer; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2); margin-right: 10px; }
.access-reveal:hover { border-color: var(--accent); color: var(--accent); }
.masked-status { font-family: var(--font-mono); color: var(--muted-2); letter-spacing: 1px; }
.access-empty { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); padding: 12px 4px; }
.access-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.access-table th { text-align: left; font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 4px 10px 8px; border-bottom: 1px solid var(--line); }
.access-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.access-table .mono { font-family: var(--font-mono); }
.access-table .muted { color: var(--muted); }
.access-reason { color: var(--muted); max-width: 280px; }
.access-btn { font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 4px; cursor: pointer; border: 1px solid var(--line); background: var(--bg-2); margin-left: 6px; }
.access-btn.approve { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.access-btn.approve:hover { background: var(--good-soft); }
.access-btn.reject { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.access-btn.reject:hover { background: var(--bad-soft); }
.access-toggle { margin-top: 12px; background: none; border: none; color: var(--muted); font-family: var(--font-mono); font-size: 11px; cursor: pointer; padding: 4px 0; }
.access-toggle:hover { color: var(--ink-2); }
.access-history { margin-top: 8px; }
.access-role { font-family: var(--font-mono); font-size: 10.5px; padding: 1px 7px; border-radius: 3px; background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line); }
.access-hist-row { display: flex; align-items: center; gap: 10px; padding: 5px 4px; font-size: 12px; border-bottom: 1px solid var(--line); }
.access-pill { font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; }
.access-pill.approved { background: var(--good-soft); color: var(--good); }
.access-pill.rejected { background: var(--bad-soft); color: var(--bad); }
.access-hist-row .mono { font-family: var(--font-mono); }
.access-hist-row .muted { color: var(--muted); }
.login-foot { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); }

/* ===== Home portal ===== */
.home-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); position: relative; overflow: hidden; }
.home-bg { position: absolute; inset: 0; pointer-events: none; }
.home-bg .hb { position: absolute; border-radius: 50%; filter: blur(100px); }
.home-bg .hb.a { width: 560px; height: 560px; background: var(--accent); top: -180px; left: -140px; opacity: 0.18; }
.home-bg .hb.b { width: 420px; height: 420px; background: var(--metric-launch); bottom: -160px; right: -120px; opacity: 0.12; }

.home-top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--line); }
.home-top .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14.5px; color: var(--ink); }
.home-top-meta { display: flex; align-items: center; gap: 12px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.home-top-meta .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.home-changepw-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 5px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2);
  font-family: var(--font-mono); font-size: 11px; cursor: pointer;
}
.home-changepw-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Change-password modal */
.cpw-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(4,7,13,0.6); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 24px; }
.cpw-card { position: relative; width: 380px; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 26px 28px 24px; box-shadow: var(--shadow-lg); }
.cpw-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.cpw-close:hover { color: var(--ink); }
.cpw-title { font-size: 20px; font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.cpw-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 18px; }
.cpw-sub b { color: var(--ink-2); }
.cpw-temp { color: var(--warn); }
.cpw-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.cpw-actions .login-ghost { width: auto; padding: 10px 14px; }
.cpw-actions .login-btn { flex: 1; }
.cpw-done { text-align: center; }
.cpw-check { width: 52px; height: 52px; margin: 4px auto 12px; border-radius: 50%; background: var(--good-soft); color: var(--good); display: grid; place-items: center; font-size: 24px; font-weight: 700; }
.cpw-done h2 { font-size: 19px; color: var(--ink); margin: 0 0 8px; }
.cpw-done p { font-size: 12.5px; color: var(--muted); margin: 0 0 18px; line-height: 1.5; }

.home-main { position: relative; z-index: 1; flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 56px 28px 40px; }
.home-welcome h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; color: var(--ink); }
.home-welcome p { margin: 0 0 36px; color: var(--muted); font-size: 14px; }
.home-welcome p b { color: var(--ink-2); }

.home-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: stretch; }

.home-module { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.home-module-primary {
  display: flex; flex-direction: column; gap: 14px;
  padding: 26px 28px; cursor: pointer; color: var(--ink);
  transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
}
.home-module-primary:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.hm-head { display: flex; align-items: center; justify-content: space-between; }
.hm-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.hm-icon.sm { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-2); color: var(--muted); }
.hm-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; letter-spacing: 0.04em; }
.hm-badge.live { background: var(--good-soft); color: var(--good); display: inline-flex; align-items: center; gap: 5px; }
.hm-badge.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.hm-badge.soon { background: var(--bg-2); color: var(--muted-2); }
.hm-badge.locked { background: var(--bg-2); color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.hm-badge.locked::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }

.home-module-locked { cursor: default; }
.home-module-locked:hover { border-color: var(--line); transform: none; box-shadow: none; }
.hm-locked-note {
  margin-top: 6px; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
}
.home-module-primary h2 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.home-module-primary > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; max-width: 52ch; }

.hm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 4px; }
.hm-stat {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--accent));
}
.hm-stat-v { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--ink); }
.hm-stat-l { font-size: 11px; color: var(--muted); }
.hm-stat-d { font-family: var(--font-mono); font-size: 10px; color: var(--muted-2); margin-top: 2px; }
.hm-stats-label { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); margin: 2px 0 -4px; }
.hm-cta {
  margin-top: 6px; align-self: flex-start;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  color: var(--accent);
}

.home-side { display: flex; flex-direction: column; gap: 18px; }
.home-module-soon {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; flex: 1; opacity: 0.72;
}
.home-module-soon .hm-soon-body { flex: 1; }
.home-module-soon h3 { margin: 0 0 3px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.home-module-soon p { margin: 0; font-size: 11.5px; color: var(--muted); }

/* Actionable side module (Data Import) */
.home-module-action {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; flex: 1; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.home-module-action:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.home-module-action .hm-icon.sm { background: var(--accent-soft); color: var(--accent); }
.home-module-action .hm-soon-body { flex: 1; }
.home-module-action h3 { margin: 0 0 3px; font-size: 14px; font-weight: 600; color: var(--ink); }
.home-module-action p { margin: 0; font-size: 11.5px; color: var(--muted); }
.hm-badge.action { background: var(--accent-soft); color: var(--accent); }

/* ===== Data Import Center ===== */
.di-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(4,7,13,0.62); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 28px; }
.di-shell { width: 980px; max-width: 100%; max-height: 90vh; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); }
.di-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 26px 18px; background: var(--bg); border-bottom: 1px solid var(--line); }
.di-head h2 { margin: 0 0 5px; font-size: 21px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.di-head p { margin: 0; font-size: 12.5px; color: var(--muted); max-width: 64ch; }
.di-close { background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.di-close:hover { color: var(--ink); }
.di-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 26px; }
.di-foot { padding: 12px 26px 18px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-2); }

.di-slot { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--card); border-top: 3px solid var(--c); }
.di-slot-head { display: flex; align-items: center; gap: 10px; }
.di-slot-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); flex-shrink: 0; }
.di-slot-title { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.di-slot-title b { font-size: 14.5px; color: var(--ink); }
.di-slot-title span { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.di-slot-ext { font-family: var(--font-mono); font-size: 10px; color: var(--muted-2); background: var(--bg-2); padding: 2px 7px; border-radius: 4px; border: 1px solid var(--line); }
.di-slot-desc { margin: 10px 0 12px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }

.di-drop { border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 18px 12px; text-align: center; cursor: pointer; background: var(--bg-2); display: flex; flex-direction: column; gap: 4px; transition: border-color .14s, background .14s; }
.di-drop:hover, .di-drop.drag { border-color: var(--c); background: color-mix(in srgb, var(--c) 7%, var(--bg-2)); }
.di-drop.busy { cursor: progress; opacity: 0.7; }
.di-drop-main { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.di-drop-hint { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.di-drop-busy { font-size: 12.5px; color: var(--muted); font-family: var(--font-mono); }

.di-conflict { border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: 8px; padding: 12px; background: var(--warn-soft); }
.di-conflict-msg { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; margin-bottom: 10px; }
.di-conflict-msg b { color: var(--ink); }
.di-conflict-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.di-btn { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; padding: 9px 11px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; background: var(--card); color: var(--ink); }
.di-btn span { font-weight: 400; font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.di-btn.overwrite:hover { border-color: var(--bad); }
.di-btn.append:hover { border-color: var(--good); }
.di-cancel { margin-top: 8px; width: 100%; background: none; border: none; color: var(--muted); font-family: var(--font-mono); font-size: 11px; cursor: pointer; }
.di-cancel:hover { color: var(--ink-2); }

.di-error { margin-top: 10px; padding: 8px 10px; border-radius: 6px; background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); font-size: 11.5px; font-family: var(--font-mono); line-height: 1.4; }
.di-ok { margin-top: 10px; display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--ink-2); }
.di-ok-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: var(--good-soft); color: var(--good); }

.di-history { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px; }
.di-history-row { display: flex; align-items: center; gap: 8px; font-size: 11px; font-family: var(--font-mono); }
.di-h-name { flex: 1; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.di-h-meta { color: var(--muted); }
.di-h-mode { font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 3px; }
.di-h-mode.overwrite { background: var(--bad-soft); color: var(--bad); }
.di-h-mode.append { background: var(--good-soft); color: var(--good); }

@media (max-width: 720px) { .di-grid { grid-template-columns: 1fr; } }

.home-foot {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between;
  padding: 16px 28px; border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-2);
}

/* Home button on dashboard topbar */
.home-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 14px; padding: 5px 11px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-2); font-family: var(--font-sans); font-size: 12px; cursor: pointer;
}
.home-btn:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 760px) {
  .home-grid { grid-template-columns: 1fr; }
  .hm-stats { grid-template-columns: repeat(2, 1fr); }
}

/* User chip on top bar */
.user-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); padding: 2px 4px 2px 2px; border-radius: 999px; }
.user-avatar { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.user-logout { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 0 2px; font-size: 12px; }
.user-logout:hover { color: var(--bad); }

/* ===== Day/Night stacked cell ===== */
.dn-stack-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.4;
}
.dn-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.dn-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 2px;
  letter-spacing: 0.04em;
  min-width: 14px;
  text-align: center;
}
.dn-row-day .dn-tag   { background: rgba(56,189,248,0.18);  color: #38bdf8; }
.dn-row-night .dn-tag { background: rgba(167,139,250,0.18); color: #a78bfa; }
.dn-row.dn-total .dn-tag {
  background: rgba(56,189,248,0.20);
  color: var(--accent);
}
.dn-row.dn-total { padding-top: 1px; border-top: 1px dashed var(--line); margin-top: 1px; }
.dn-val { font-variant-numeric: tabular-nums; }
.dn-empty { color: var(--muted-2); text-align: right; }

/* ===== Shift pills + alternating shift rows in matrix ===== */
.shift-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}
.shift-pill.shift-day   { background: rgba(56,189,248,0.14); color: #38bdf8; }
.shift-pill.shift-night { background: rgba(167,139,250,0.14); color: #a78bfa; }
.matrix-table tr.shift-row-day td:not(.line-cell):not(.bar-cell) { background: rgba(255,255,255,0.01); }
.matrix-table tr.shift-row-night td:not(.line-cell):not(.bar-cell) { background: rgba(0,0,0,0.12); border-bottom: 2px solid var(--line); }
.matrix-table tr.shift-row-night td.line-cell { border-bottom: 2px solid var(--line); }
.matrix-table td.line-cell { vertical-align: middle; }

/* ===== Matrix sub-headers & design grouping ===== */
.matrix-table th.th-group {
  text-align: center;
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
}
.matrix-table tr.subhead th {
  font-size: 9.5px;
  padding: 6px 12px;
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
  text-transform: none;
  letter-spacing: 0.02em;
}
.matrix-table th.design-col,
.matrix-table td.design-col {
  font-family: var(--font-mono);
  background: rgba(255,255,255,0.015);
}
.matrix-table th.design-col.design-SFSV { color: var(--metric-launch); }
.matrix-table th.design-col.design-SPAL { color: var(--metric-yield); }
.matrix-table th.design-col.design-FSV  { color: var(--metric-eer); }
.matrix-table th.total-col,
.matrix-table td.total-col {
  background: rgba(56,189,248,0.05);
  color: var(--ink);
  font-family: var(--font-mono);
}
.matrix-foot td {
  background: var(--bg-2) !important;
  border-top: 2px solid var(--line-2);
  font-family: var(--font-mono);
  padding: 10px 12px;
}
.matrix-foot td.total-col {
  background: var(--accent-soft) !important;
  color: var(--accent);
  font-size: 14px;
}

/* ===== Design multi-select chips ===== */
.design-multi { display: inline-flex; gap: 4px; align-items: center; }
.dmulti-chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.12s;
}
.dmulti-chip:hover { color: var(--ink); border-color: var(--line-2); }
.dmulti-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.dmulti-chip.dmulti-SFSV.on { background: rgba(167,139,250,0.18); border-color: var(--metric-launch); color: var(--metric-launch); }
.dmulti-chip.dmulti-SPAL.on { background: rgba(52,211,153,0.18);  border-color: var(--metric-yield);  color: var(--metric-yield); }
.dmulti-chip.dmulti-FSV.on  { background: rgba(251,191,36,0.18);  border-color: var(--metric-eer);    color: var(--metric-eer); }

/* ===== Design tags (Product Design types) ===== */
.design-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid currentColor;
}
.design-SFSV { color: var(--metric-launch); background: rgba(167,139,250,0.10); }
.design-SPAL { color: var(--metric-yield);  background: rgba(52,211,153,0.10);  }
.design-FSV  { color: var(--metric-eer);    background: rgba(251,191,36,0.10);  }

/* ===== Admin panel ===== */
.admin-btn { border-color: var(--metric-eer) !important; color: var(--metric-eer) !important; }
.admin-btn:hover { background: rgba(251,191,36,0.08); }
.admin-badge { font-family: var(--font-mono); font-size: 10.5px; padding: 3px 8px; background: var(--warn-soft); color: var(--warn); border-radius: 999px; font-weight: 600; }

.admin-lock {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 28px 32px; width: 380px; margin: auto;
  box-shadow: var(--shadow-lg); align-self: center;
}
.modal-backdrop:has(.admin-lock) { align-items: center; justify-content: center; }
.admin-lock-icon { font-size: 32px; margin-bottom: 8px; }
.admin-lock-title { font-size: 20px; margin: 0 0 4px; color: var(--ink); }
.admin-lock-sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 18px; }
.admin-pw {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg); color: var(--ink); font-family: var(--font-mono); font-size: 14px;
  letter-spacing: 0.1em;
}
.admin-pw:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.admin-lock-hint { margin-top: 16px; text-align: center; font-size: 11px; color: var(--muted-2); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-2); padding: 9px 14px; border-radius: 4px; cursor: pointer; font-size: 12.5px; font-family: var(--font-sans); }
.btn-ghost:hover { background: var(--bg-2); }

/* EER before→after dumbbell legend */
.eer-ba-legend {
  display: flex; flex-wrap: wrap; gap: 18px;
  align-items: center;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.eer-ba-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.eba-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.eba-dot.hollow { background: var(--card); border: 2px solid var(--muted); }
.eba-dot.solid  { background: var(--ink-2); }
.eba-bands { gap: 5px !important; }
.eba-band { width: 14px; height: 9px; border-radius: 2px; display: inline-block; margin-left: 6px; }
.eba-band.bad  { background: rgba(214,65,65,0.55); margin-left: 0; }
.eba-band.warn { background: rgba(217,119,6,0.6); }
.eba-band.good { background: rgba(46,138,91,0.55); }

/* ===== Defect Pareto (Yield deep-dive) ===== */
.defect-swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15);
}
.defect-bar {
  height: 14px;
  background: var(--bg-2);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line);
}
.defect-fill {
  height: 100%;
  border-radius: 3px;
  opacity: 0.85;
  transition: width 0.25s ease;
}
.defect-code {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
  margin-right: 8px;
}
.defect-name {
  font-size: 11px;
  color: var(--muted);
}

/* ===== By-type launch vs total target ===== */
.bytype-target-bar {
  position: relative;
  display: flex;
  height: 28px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: visible;
  box-shadow: inset 0 0 0 1px var(--line);
  margin-top: 6px;
}
.bytype-seg {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  color: rgba(0,0,0,0.7);
  border-right: 1px solid var(--bg);
  transition: width 0.25s ease;
  overflow: hidden;
}
.bytype-seg:first-child { border-radius: 4px 0 0 4px; }
.bytype-target-mark {
  position: absolute; top: -4px; bottom: -4px;
  width: 2px; background: var(--ink);
  transform: translateX(-1px);
}
.bytype-target-mark::after {
  content: 'TARGET';
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.06em; color: var(--ink-2); white-space: nowrap;
}
.bytype-axis {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  margin-top: 6px;
}
.bytype-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px 110px;
  gap: 10px; align-items: center;
  padding: 7px 0;
  font-size: 12.5px;
  border-bottom: 1px solid var(--line);
}
.bytype-row-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.bytype-row-total {
  border-bottom: none; border-top: 1.5px solid var(--line);
  margin-top: 2px;
}
.bytype-swatch {
  width: 11px; height: 11px; border-radius: 2px; flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15);
}

/* Caster trend controls + legend */
.caster-trend-controls { display: flex; align-items: center; gap: 8px; }
.seg-sm button { font-size: 11px; padding: 3px 9px; }
.caster-trend-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
  margin-top: 10px;
}
.caster-trend-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.caster-trend-legend .bytype-swatch { width: 9px; height: 9px; }

/* Caster → diameter/base drill-down */
.caster-row:hover { background: var(--bg-2); }
.caster-drill-tag {
  margin-left: 10px; font-family: var(--font-mono); font-size: 9.5px;
  color: var(--accent); font-weight: 600;
}
.caster-drill-close {
  margin-left: 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 4px; color: var(--ink-2); cursor: pointer;
  font-family: var(--font-mono); font-size: 10px; padding: 2px 8px;
}
.caster-drill-close:hover { background: var(--card); color: var(--ink); }
.caster-drill { border-left: 3px solid var(--accent); }
.caster-drill-sub {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  margin-bottom: 8px;
}
.drill-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; font-family: var(--font-mono); font-size: 11.5px;
}
.drill-k { width: 64px; color: var(--ink); }
.drill-v { width: 64px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.drill-p { width: 52px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Downtime equipment → reason nested drill */
.dt-eq-block { margin-bottom: 12px; }
.dt-eq-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 12px;
}
.dt-eq-name { width: 130px; color: var(--ink); font-weight: 600; }
.dt-eq-mins { width: 54px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.dt-eq-pct { width: 40px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.dt-reasons {
  margin: 5px 0 0 16px; padding-left: 12px;
  border-left: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 3px;
}
.dt-reason-row {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-2);
}
.dt-reason-name { width: 124px; display: flex; align-items: center; gap: 4px; }
.dt-reason-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dt-reason-note { flex-shrink: 0; color: var(--accent); font-size: 9.5px; }
.dt-reason-bar { flex: 1; height: 8px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.dt-reason-bar i { display: block; height: 100%; background: #a78bfa; border-radius: 4px; }
.dt-reason-mins { width: 48px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.dt-reason-cnt { width: 34px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* By-line product-type mix bar */
.byline-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
  margin-bottom: 8px;
}
.byline-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.byline-mix {
  display: flex;
  height: 18px;
  width: 240px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.byline-mix-seg {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  color: rgba(0,0,0,0.7);
  white-space: nowrap; overflow: hidden;
  border-right: 1px solid var(--bg);
  transition: width 0.25s ease;
}

/* ===== Yield by design — admin panel ===== */
/* Design chips for the multi-design Admin column */
.design-chips {
  display: inline-flex;
  gap: 4px;
}
.design-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 3px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.12s ease;
}
.design-chip:hover { border-color: var(--ink-2); color: var(--ink-2); }
.design-chip.sf.on  { background: rgba(167,139,250,0.18); border-color: #a78bfa; color: #a78bfa; }
.design-chip.fsv.on { background: rgba(52,211,153,0.18);  border-color: #34d399; color: #34d399; }

/* Per-design yield cells in Admin */
.yield-cell {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.yield-cell.sf  { color: #a78bfa; }
.yield-cell.fsv { color: #34d399; }
.yield-cell.dim { color: var(--muted); opacity: 0.4; }

.design-yield-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 12px;
  align-items: stretch;
}
.design-yield-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px;
  background: var(--bg-2);
  display: flex; flex-direction: column; gap: 8px;
}
.design-yield-card.sf  { border-top: 3px solid #a78bfa; }
.design-yield-card.fsv { border-top: 3px solid #34d399; }
.dy-head {
  display: flex; align-items: baseline; gap: 8px;
}
.dy-swatch {
  width: 10px; height: 10px; border-radius: 2px;
  display: inline-block;
  align-self: center;
}
.dy-swatch.sf  { background: #a78bfa; }
.dy-swatch.fsv { background: #34d399; }
.dy-name {
  font-size: 13px; font-weight: 700; color: var(--ink);
  letter-spacing: 0.04em;
}
.dy-sub {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted);
}
.dy-input-row {
  display: flex; align-items: baseline; gap: 6px;
}
.dy-input {
  width: 100px;
  font-size: 18px !important;
  text-align: right;
}
.dy-unit {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 14px;
}
.dy-lines {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted);
}
.design-yield-help {
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.dy-help-title {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--accent);
}
.dy-help-body {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.45;
}

.admin-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.btn-primary { background: var(--accent); color: #0b0f1a; border: none; padding: 8px 14px; border-radius: 4px; font-weight: 600; cursor: pointer; font-size: 12.5px; }
.btn-primary:hover { filter: brightness(1.1); }
.admin-msg { color: var(--good); font-family: var(--font-mono); font-size: 11px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.admin-table th, .admin-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.admin-table th { background: var(--bg-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; text-align: left; }
.admin-table th.num, .admin-table td.num { text-align: right; font-family: var(--font-mono); }
.admin-table tfoot td { background: var(--bg-2); border-top: 2px solid var(--line-2); border-bottom: none; }
.admin-new-row td { background: rgba(56,189,248,0.05); }
.admin-input {
  width: 100%; padding: 5px 8px; border: 1px solid transparent; border-radius: 3px;
  background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 12.5px;
}
.admin-input:focus { outline: none; border-color: var(--accent); }
.admin-input.ro { color: var(--muted); cursor: not-allowed; background: var(--bg-2); font-family: var(--font-mono); font-weight: 600; }
.admin-input.num { font-family: var(--font-mono); text-align: right; }
.admin-input.wide { min-width: 180px; }
.admin-del { background: transparent; border: 1px solid var(--line); color: var(--bad); width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: 14px; line-height: 1; }
.admin-del:hover { background: var(--bad); color: var(--card); }

/* ===== Compare grid (4 per-line charts on main) ===== */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 6px; }
.compare-card { background: var(--card); border-color: var(--line); }
.compare-card[data-metric="launch"]   { border-top: 2px solid var(--metric-launch); }
.compare-card[data-metric="yield"]    { border-top: 2px solid var(--metric-yield); }
.compare-card[data-metric="downtime"] { border-top: 2px solid var(--metric-downtime); }
.compare-card[data-metric="eer"]      { border-top: 2px solid var(--metric-eer); }
@media (max-width: 1100px) {
  .compare-grid { grid-template-columns: 1fr; }
}

.line-legend { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 0 0; }
.line-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-2);
  cursor: pointer; transition: all .12s;
}
.line-chip:hover, .line-chip.on { background: var(--card-2); border-color: var(--line-2); color: var(--ink); transform: translateY(-1px); }
.line-chip-swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ===== Line Detail modal ===== */
.ld-line-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; height: 28px; padding: 0 10px; border-radius: 4px; font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: #0b0f1a; vertical-align: middle; margin-right: 6px; }
.ld-range-toggle { display: flex; align-items: center; gap: 12px; }

.ld-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.ld-stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.ld-stat::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--ls-color, var(--accent)); opacity: 0.85; }
.ld-stat-launch   { --ls-color: var(--metric-launch); }
.ld-stat-yield    { --ls-color: var(--metric-yield); }
.ld-stat-downtime { --ls-color: var(--metric-downtime); }
.ld-stat-eer      { --ls-color: var(--metric-eer); }
.ld-stat-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ld-stat-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ld-stat-value { font-family: var(--font-mono); font-size: 22px; font-weight: 500; color: var(--ls-color, var(--ink)); }
.ld-stat-tgt { margin-top: 6px; font-size: 11px; color: var(--muted); font-family: var(--font-mono); }

.ld-charts .chart-card { background: var(--card); }
.ld-chart-line {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
}
.ld-table tr td { font-family: var(--font-mono); font-size: 12px; }

@media (max-width: 1024px) {
  .ld-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Shift timeline (Day/Night split) ===== */
.shift-timeline { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; overflow-x: auto; }
.shift-axis-head, .shift-row, .shift-hours { display: grid; grid-template-columns: 60px 1fr; gap: 12px; align-items: center; padding: 3px 0; }
.shift-axis-head .shift-tag { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.04em; padding: 4px 8px; background: var(--bg-2); border-radius: 3px; display: inline-block; }
.shift-axis-head .shift-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.shift-axis-head .shift-col { padding: 2px 0; }
.shift-axis-head .shift-col.day { border-bottom: 2px solid var(--accent); }
.shift-axis-head .shift-col.night { border-bottom: 2px solid var(--warn); }
.shift-row .lab { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.shift-row .shift-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.shift-rail { position: relative; height: 24px; background: var(--card); border-radius: 3px; border: 1px solid var(--line); }
.shift-rail.day-rail { background: linear-gradient(180deg, rgba(30,77,140,0.04), var(--card)); }
.shift-rail.night-rail { background: linear-gradient(180deg, rgba(176,116,7,0.04), var(--card)); }
.shift-rail .ev { position: absolute; top: 3px; bottom: 3px; border-radius: 2px; opacity: 0.92; cursor: pointer; min-width: 2px; }
.shift-rail .ev:hover { opacity: 1; outline: 2px solid var(--ink); outline-offset: 1px; }
.shift-rail .ev.mech       { background: var(--bad); }
.shift-rail .ev.process    { background: var(--warn); }
.shift-rail .ev.production { background: var(--accent); }
.shift-rail .ev.planned    { background: var(--muted); }
.shift-rail .ev:not(.mech):not(.process):not(.production):not(.planned) { background: var(--muted); }
.shift-hours .shift-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.shift-hours .day-hours, .shift-hours .night-hours {
  display: grid; grid-template-columns: repeat(13, 1fr);
  font-family: var(--font-mono); font-size: 9px; color: var(--muted-2);
}
.shift-hours span { text-align: left; }

/* Day vs Night stacked bar */
.dn-stack { display: flex; height: 14px; background: var(--bg-2); border-radius: 2px; overflow: hidden; gap: 2px; padding: 1px; }
.dn-stack .dn-day { background: var(--accent); border-radius: 2px; }
.dn-stack .dn-night { background: var(--warn); border-radius: 2px; }

/* Re-style existing single-rail .timeline events to use category color classes */
.timeline-axis .ev.mech       { background: var(--bad); }
.timeline-axis .ev.process    { background: var(--warn); }
.timeline-axis .ev.production { background: var(--accent); }
.timeline-axis .ev.planned    { background: var(--muted); }

/* ===== EER Compensate form ===== */
.ec-form { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 16px; margin-bottom: 16px; }
.ec-form-head { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.ec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.ec-field { display: flex; flex-direction: column; gap: 4px; }
.ec-field-label { font-size: 10.5px; font-weight: 600; color: var(--text-muted); font-family: var(--font-mono); }
.ec-field input, .ec-field select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 3px; font-size: 12.5px; font-family: var(--font-mono); background: var(--card); color: var(--ink); }
.ec-field input:focus, .ec-field select:focus { outline: none; border-color: var(--accent); }
.ec-preview { background: var(--card); border: 1px solid var(--accent); border-radius: 3px; padding: 12px 14px; margin-bottom: 12px; }
.ec-preview-head { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 8px; letter-spacing: 0.04em; }
.ec-preview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 16px; font-family: var(--font-mono); font-size: 11px; }
.pv-cell { display: flex; gap: 6px; align-items: baseline; }
.pv-n { color: var(--text-muted); font-weight: 700; }
.pv-l { color: var(--text-muted); flex: 1; }
.pv-cell b { color: var(--ink); }
.ec-preview-eer { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 14px; }
.ec-add { background: var(--accent); color: #fff; border: none; padding: 8px 18px; border-radius: 3px; font-size: 12px; font-weight: 600; cursor: pointer; }
.ec-add:disabled { background: var(--line); color: var(--text-muted); cursor: not-allowed; }
.ec-table th { background: var(--bg-2); color: var(--ink-2); font-size: 10px; padding: 6px 8px; white-space: nowrap; }
.ec-table td { font-size: 11px; padding: 5px 8px; font-family: var(--font-mono); }
.ec-del { background: transparent; border: 1px solid var(--line); color: var(--bad); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; line-height: 1; }
.ec-del:hover { background: var(--bad); color: #fff; }

/* ===== Speed Loss matrix ===== */
.sl-matrix { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 11px; }
.sl-matrix th, .sl-matrix td { border: 1px solid var(--line); padding: 4px 6px; text-align: center; white-space: nowrap; }
.sl-line-head, .sl-sum-head { background: var(--bg-2); color: var(--ink-2); font-size: 10px; text-align: left; }
.sl-sum-head { text-align: right; }
.sl-date-head { background: var(--bg-2); color: var(--text-muted); font-size: 10px; font-weight: 600; }
.sl-dow { font-size: 9px; opacity: 0.55; margin-top: 1px; }
.sl-line { text-align: left; padding: 6px 10px; background: var(--card); position: sticky; left: 0; min-width: 160px; }
.sl-line-prod { font-size: 10px; color: var(--text-muted); font-family: var(--font-sans); margin-top: 1px; }
.sl-cell { color: var(--ink); }
.sl-sum { background: var(--bg-2); font-weight: 700; }
.sl-total td { background: var(--bg-2); color: var(--ink-2); font-weight: 700; }
.sl-tot { color: var(--ink-2) !important; }

/* ===== Formula card ===== */
.formula-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-family: var(--font-mono);
}
.formula-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.formula-pill {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.12em;
  background: var(--accent); color: #fff;
  padding: 2px 6px; border-radius: 2px;
}
.formula-text { font-size: 12.5px; color: var(--ink); }
.formula-note { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

/* ===== Charts ===== */
.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.chart-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px; gap: 12px;
}
.chart-head h3 {
  font-size: 13px; font-weight: 600; margin: 0;
  letter-spacing: -0.01em;
}
.chart-head .meta { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }

.chart-legend {
  display: flex; gap: 14px; font-size: 11.5px; color: var(--muted);
}
.chart-legend .swatch {
  display: inline-block; width: 10px; height: 2px; vertical-align: middle;
  margin-right: 4px;
}
.chart-legend .swatch.line { background: var(--accent); }
.chart-legend .swatch.target { background: var(--ink); height: 1.5px; }
.chart-legend .swatch.bar { background: var(--accent); height: 8px; border-radius: 1px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--font-mono); font-size: 20px; margin-top: 4px; }
.stat-value .unit { font-size: 12px; color: var(--muted); margin-left: 3px; }
.stat-delta { font-size: 11.5px; margin-top: 4px; font-family: var(--font-mono); }
.stat-delta.good { color: var(--good); }
.stat-delta.warn { color: var(--warn); }
.stat-delta.bad  { color: var(--bad); }

/* Shift split inside the WO stat card */
.stat-shift {
  grid-column: span 2;
  display: flex; flex-direction: column; gap: 10px;
}
.stat-head-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.stat-right {
  text-align: right;
}
.stat-mini-label {
  font-size: 9.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 600;
}
.stat-mini-val {
  font-family: var(--font-mono);
  font-size: 18px; font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-mini-val.good { color: var(--good); }
.stat-mini-val.warn { color: var(--warn); }
.stat-mini-val.bad  { color: var(--bad); }
.stat-mini-val .unit { font-size: 11px; color: var(--muted); font-weight: 400; }

/* Stacked horizontal bar */
.shift-bar {
  display: flex;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.shift-bar-fill {
  display: flex; align-items: center; justify-content: flex-start;
  padding: 0 8px;
  transition: width 0.25s ease;
  position: relative;
}
.shift-bar-fill.day   { background: linear-gradient(90deg, #fbbf24, #f59e0b); color: #2a1f00; }
.shift-bar-fill.night { background: linear-gradient(90deg, #6366f1, #4f46e5); color: #f3f0ff; }
.shift-bar-label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

/* Per-shift stat columns */
.shift-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.shift-col {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.shift-col-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px;
}
.shift-stats {
  display: flex; gap: 12px; align-items: baseline;
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.shift-stats b { color: var(--ink); font-weight: 600; }
.shift-stats .unit { font-size: 10px; color: var(--muted); margin-left: 2px; }

.shift-lowbar {
  position: relative;
  height: 14px;
  background: var(--bg-2);
  border-radius: 7px;
  overflow: hidden;
}
.shift-lowbar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.25s ease;
  opacity: 0.55;
}
.shift-lowbar-fill.day   { background: #fbbf24; }
.shift-lowbar-fill.night { background: #6366f1; }
.shift-lowbar-label {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.shift-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.shift-dot.day   { background: #fbbf24; box-shadow: 0 0 0 2px rgba(251,191,36,0.18); }
.shift-dot.night { background: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,0.18); }
.shift-name { color: var(--ink); font-weight: 700; font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; }
.shift-time { color: var(--muted); font-size: 10px; font-family: var(--font-mono); }

/* ===== WOs by period card ===== */
.stat-period {
  grid-column: span 2;
  display: flex; flex-direction: column; gap: 8px;
}
.period-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.period-cell {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 3px;
}
.period-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
}
.period-lab {
  font-size: 9.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 700;
}
.period-sub {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-2);
}
.period-wos {
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.period-wos .unit { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.period-delta {
  font-family: var(--font-mono); font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.period-delta.good { color: var(--good); }
.period-delta.bad  { color: var(--bad); }
.period-delta-vs { color: var(--muted); font-weight: 400; }

.period-seq {
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 26px;
  padding: 2px 0;
  border-top: 1px dashed var(--line);
  margin-top: 2px;
}
.period-seq-bar {
  flex: 1;
  background: var(--accent);
  opacity: 0.4;
  border-radius: 1px 1px 0 0;
  min-height: 2px;
  transition: opacity 0.15s ease;
}
.period-seq-bar:hover { opacity: 0.9; }
.period-seq-bar.anchor { opacity: 1; background: var(--accent); }

.period-low {
  font-family: var(--font-mono); font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.period-low.good { color: var(--good); }
.period-low.warn { color: var(--warn); }
.period-low.bad  { color: var(--bad); }

/* ===== Design comparison card (period grid layout, matches WOs by period) ===== */
.design-period-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.design-period-cell {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.design-period-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
}
.design-period-total {
  font-family: var(--font-mono);
  font-size: 18px; font-weight: 600;
  color: var(--ink); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.design-period-total .unit {
  font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px;
}
.design-stack-bar {
  display: flex;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.design-stack-seg {
  display: flex; align-items: center; justify-content: center;
  cursor: help;
  transition: filter 0.15s ease;
}
.design-stack-seg:hover { filter: brightness(1.15); }
.design-stack-label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  color: rgba(0,0,0,0.65);
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
}
.design-rows {
  display: flex; flex-direction: column; gap: 3px;
}
.design-row {
  display: grid;
  grid-template-columns: 10px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-family: var(--font-mono);
  font-size: 11px;
}
.design-row .design-swatch {
  width: 8px; height: 8px;
  margin-right: 0;
}
.design-name {
  font-weight: 700;
  color: var(--ink);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}
.design-qty {
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.design-pct {
  text-align: right;
  color: var(--muted);
  font-size: 10px;
  min-width: 38px;
}

/* original .design-swatch (still used in legacy bits) */
.design-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15);
}

/* ===== Period comparison card (D7/W4/M4) ===== */
.pc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.pc-section {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.pc-section-head {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.pc-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.pc-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pc-delta {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1;
}
.pc-delta.good { color: var(--good); }
.pc-delta.bad  { color: var(--bad); }
.pc-delta-vs {
  font-size: 9.5px; color: var(--muted); font-weight: 400;
  margin-top: 3px; letter-spacing: 0.05em;
}
.pc-rows {
  display: flex; flex-direction: column; gap: 4px;
}
.pc-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 2px 0;
}
.pc-row-lab {
  display: flex; flex-direction: column; line-height: 1.1;
}
.pc-row-name {
  font-size: 11px; font-weight: 700; color: var(--ink);
  letter-spacing: 0.03em;
}
.pc-row-sub {
  font-family: var(--font-mono);
  font-size: 9.5px; color: var(--muted);
}
.pc-row-bar {
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line);
}
.pc-row-fill {
  height: 100%; border-radius: 5px;
  background: var(--accent);
  opacity: 0.45;
  transition: width 0.25s ease;
}
.pc-row.anchor .pc-row-fill { opacity: 1; }
.pc-row.no-data .pc-row-fill { background: var(--ink-2); opacity: 0.2; }
.pc-row-val {
  display: flex; flex-direction: column; align-items: flex-end;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.pc-row-val b {
  font-size: 12px; color: var(--ink); font-weight: 600;
}
.pc-row-wos {
  font-size: 9.5px; color: var(--muted); margin-top: 1px;
}
.pc-row.no-data .pc-row-val b { color: var(--muted); }
.pc-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.pc-foot > div {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-mono);
}
.pc-foot-lab {
  font-size: 9.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.pc-foot-val {
  font-size: 12px; color: var(--ink); font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Design segments inside pc rows */
.pc-row-bar-stack {
  display: flex;
  padding: 0;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.pc-seg {
  height: 100%;
  opacity: 0.55;
  cursor: help;
  transition: filter 0.15s ease;
}
.pc-row.anchor .pc-seg { opacity: 1; }
.pc-row.no-data .pc-row-bar-stack { background: var(--bg); }
.pc-seg:hover { filter: brightness(1.15); }

/* Shared legend across the 3 sections */
.pc-legend {
  display: flex; gap: 16px;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted);
  padding: 6px 2px 10px;
}
.pc-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pc-legend-swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15);
}

/* Per-design totals strip at bottom of each section */
.pc-design-totals {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
}
.pc-design-line {
  display: grid;
  grid-template-columns: 10px auto 1fr auto;
  gap: 8px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.pc-design-line .pc-legend-swatch {
  width: 8px; height: 8px;
}
.pc-design-name { font-weight: 700; color: var(--ink); font-size: 10px; letter-spacing: 0.04em; }
.pc-design-qty  { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.pc-design-pct  { text-align: right; color: var(--muted); min-width: 36px; }

/* ===== Item summary cards (By Item tab top) ===== */
.item-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.item-summary-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--item-color, var(--accent));
  border-radius: 4px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.item-summary-head {
  display: flex; align-items: center; gap: 8px;
}
.item-summary-swatch {
  width: 10px; height: 10px; border-radius: 2px;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15);
}
.item-summary-name {
  font-size: 13px; font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.item-summary-qty {
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 600;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.item-summary-qty .unit {
  font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px;
}
.item-summary-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line);
}
.item-summary-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.25s ease;
}
.item-summary-pct {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Last-7-days per-day grid in the worst-performers table */
.last7-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.last7-grid {
  display: grid;
  grid-template-columns: repeat(7, 22px);
  gap: 3px;
}
.last7-day {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 30px;
  border-radius: 3px;
  font-family: var(--font-mono);
  cursor: help;
  position: relative;
  border: 1px solid transparent;
  transition: transform 0.12s ease;
}
.last7-day:hover { transform: scale(1.08); }
.last7-day.good { background: color-mix(in srgb, var(--good) 28%, transparent); color: var(--good); }
.last7-day.warn { background: color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn); }
.last7-day.bad  { background: color-mix(in srgb, var(--bad)  32%, transparent); color: var(--bad); }
.last7-day.is-anchor { border-color: var(--ink-2); }
.last7-day-lbl { font-size: 8px; opacity: 0.7; line-height: 1; letter-spacing: 0.04em; }
.last7-day-num { font-size: 10px; font-weight: 700; line-height: 1.1; }
.last7-on-tgt {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}

/* ===== Chart hover tooltip ===== */
.chart-hover-wrap { position: relative; }
.chart-tip {
  position: absolute;
  top: 6px;
  transform: translateX(8px);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 8px 12px;
  min-width: 140px;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 4px 18px -6px rgba(0,0,0,0.45);
  font-family: var(--font-mono);
}
.chart-tip.flip { transform: translateX(calc(-100% - 12px)); }
.chart-tip-date {
  font-size: 11px; font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--line);
}
.chart-tip-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 7px;
  align-items: center;
  font-size: 11px;
  padding: 2px 0;
}
.chart-tip-row.delta {
  grid-template-columns: 1fr auto;
  padding-top: 4px; margin-top: 3px;
  border-top: 1px dashed var(--line);
}
.chart-tip-swatch {
  width: 9px; height: 9px; border-radius: 2px;
  display: inline-block;
}
.chart-tip-swatch.actual { background: var(--accent); }
.chart-tip-swatch.target { background: transparent; border: 1.5px dashed var(--ink-2); }
.chart-tip-lab { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.chart-tip-val { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip-val.good { color: var(--good); }
.chart-tip-val.bad  { color: var(--bad); }

/* ===== By-line table inside modal ===== */
.dl-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.dl-table th, .dl-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.dl-table th {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; text-align: left;
}
.dl-table td.num {
  font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums;
}
.dl-table td .bar { width: 90px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.dl-table tr.row:hover td { background: var(--card-2); }

/* ===== Pareto bars ===== */
.pareto-row {
  display: grid; grid-template-columns: 130px 1fr 70px 70px;
  gap: 10px; align-items: center;
  padding: 6px 0;
  font-size: 12.5px;
}
.pareto-row .label { color: var(--ink); }
.pareto-row .category {
  font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  margin-left: 6px;
}
.pareto-row .pbar {
  height: 14px; background: var(--bg-2); border-radius: 2px;
  position: relative; overflow: hidden;
}
.pareto-row .pbar > i {
  display: block; height: 100%; background: var(--accent); border-radius: 2px;
}
.pareto-row .pct, .pareto-row .min {
  font-family: var(--font-mono); text-align: right; color: var(--muted);
}

/* ===== Downtime timeline ===== */
.timeline {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
}
.timeline-row {
  display: grid; grid-template-columns: 60px 1fr;
  align-items: center; gap: 12px;
  padding: 4px 0;
}
.timeline-row .lab {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--muted);
}
.timeline-axis {
  position: relative; height: 28px; background: var(--card); border-radius: 3px;
  border: 1px solid var(--line);
}
.timeline-axis .ev {
  position: absolute; top: 3px; bottom: 3px;
  background: var(--bad); border-radius: 2px; opacity: 0.85;
  cursor: pointer;
}
.timeline-axis .ev.warn { background: var(--warn); }
.timeline-axis .ev.info { background: var(--muted); }
.timeline-axis .ev:hover { opacity: 1; outline: 2px solid var(--ink); outline-offset: 1px; }
.timeline-hours {
  display: grid; grid-template-columns: repeat(24, 1fr);
  font-family: var(--font-mono); font-size: 10px; color: var(--muted-2);
  margin-left: 72px; margin-top: 4px;
}
.timeline-hours span { text-align: left; }

/* ===== Files ===== */
.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--card-2);
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.dropzone .dz-title { font-weight: 600; margin-bottom: 4px; }
.dropzone .dz-sub { color: var(--muted); font-size: 12px; }

.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; }
.file-row {
  display: grid;
  grid-template-columns: 26px 1fr 80px 110px 130px 32px;
  gap: 12px; align-items: center;
  background: var(--card);
  padding: 10px 12px;
  font-size: 13px;
}
.file-row .ficon {
  width: 26px; height: 30px; border-radius: 3px;
  background: var(--bg-2); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
}
.file-row .ficon.xlsx { background: #e3efe5; color: #2f7a47; }
.file-row .ficon.pdf  { background: #f4dedb; color: #a72f25; }
.file-row .ficon.csv  { background: #e7eef7; color: #1e4d8c; }

/* ===== OEE import ===== */
.oee-drop {
  border: 1.5px dashed var(--line-2); border-radius: 10px;
  padding: 30px 20px; text-align: center; cursor: pointer;
  background: var(--bg-2); transition: border-color .14s, background .14s;
}
.oee-drop:hover, .oee-drop.drag { border-color: var(--metric-eer); background: color-mix(in srgb, var(--metric-eer) 8%, var(--bg-2)); }
.oee-drop.busy { cursor: progress; opacity: 0.7; }
.oee-drop-icon { color: var(--metric-eer); margin-bottom: 8px; display: flex; justify-content: center; }
.oee-drop-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.oee-drop-sub { font-size: 12px; color: var(--muted); margin-top: 5px; font-family: var(--font-mono); }
.oee-drop-sub b { color: var(--ink-2); }

.oee-error {
  margin-top: 12px; padding: 10px 12px; border-radius: 6px;
  background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
  color: var(--bad); font-size: 12.5px; font-family: var(--font-mono);
}

.oee-success { margin-top: 14px; border: 1px solid color-mix(in srgb, var(--good) 35%, var(--line)); border-radius: 8px; overflow: hidden; }
.oee-success-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--good-soft); }
.oee-check { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: var(--good); color: #08130d; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.oee-success-head b { display: block; color: var(--ink); font-size: 13.5px; }
.oee-success-head span { font-size: 11.5px; color: var(--good); font-family: var(--font-mono); }
.oee-success-grid { display: flex; flex-direction: column; gap: 7px; padding: 12px 14px; }
.oee-success-grid > div { display: flex; gap: 12px; align-items: baseline; font-size: 12.5px; }
.oee-success-grid .k { width: 64px; flex-shrink: 0; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.oee-success-grid .v { color: var(--ink-2); font-family: var(--font-mono); }
.oee-success-grid .v.warn { color: var(--warn); }
.oee-apply {
  margin: 4px 14px 14px; padding: 9px 16px; border-radius: 6px;
  background: var(--metric-eer); color: #1a1304; border: none; cursor: pointer;
  font-weight: 600; font-size: 12.5px; font-family: var(--font-sans);
}
.oee-apply:hover { filter: brightness(1.06); }

.oee-format { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.oee-format-title { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.oee-format-cols { display: flex; flex-wrap: wrap; gap: 5px; }
.oee-format-cols span { font-family: var(--font-mono); font-size: 10.5px; padding: 3px 7px; border-radius: 4px; background: var(--bg-2); color: var(--muted); border: 1px solid var(--line); }
.oee-format-cols span.hot { color: var(--metric-eer); border-color: color-mix(in srgb, var(--metric-eer) 35%, var(--line)); }
.oee-format-note { font-size: 11.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.oee-format-note b { color: var(--ink-2); }
.file-row .ficon.img  { background: #f6ecd6; color: #b07407; }
.file-row .fname { font-weight: 500; }
.file-row .fmeta { color: var(--muted); font-size: 11.5px; font-family: var(--font-mono); }
.file-row .fdel {
  background: transparent; border: 0; cursor: pointer; color: var(--muted);
  width: 26px; height: 26px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.file-row .fdel:hover { background: var(--bad-soft); color: var(--bad); }

/* ===== Misc ===== */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 3px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-2); color: var(--ink-2);
  font-family: var(--font-mono); letter-spacing: 0.02em;
}
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad  { background: var(--bad-soft);  color: var(--bad); }

.text-muted { color: var(--muted); }

.empty {
  padding: 24px; text-align: center; color: var(--muted);
  background: var(--card-2); border-radius: var(--radius);
  border: 1px dashed var(--line);
}

/* Density tweak */
body.density-compact .kpi { padding: 14px 14px 10px; min-height: 162px; }
body.density-compact .kpi-value { font-size: 30px; }
body.density-compact .matrix-table th,
body.density-compact .matrix-table td { padding: 7px 12px; }
body.density-compact .main { padding-top: 14px; }

/* ===================================================================
   EXPRESSIVE TWEAKS — Mood · Intensity · Data emphasis
   Each reshapes the whole feel, not one property.
   =================================================================== */

/* ---- MOOD: Daylight — light control-room for the floor / tablets ---- */
body.mood-daylight {
  --bg:        #eef1f6;
  --bg-2:      #e4e8f0;
  --card:      #ffffff;
  --card-2:    #f4f6fb;
  --ink:       #161b28;
  --ink-2:     #39435c;
  --muted:     #66708a;
  --muted-2:   #95a0bb;
  --text-muted:#66708a;
  --line:      #d6dce8;
  --line-2:    #c2cad9;
  --good-soft: rgba(22, 163, 94, 0.12);
  --warn-soft: rgba(202, 138, 4, 0.14);
  --bad-soft:  rgba(220, 60, 60, 0.12);
  --accent-soft: rgba(2, 132, 199, 0.12);
  --good:      #16a35e;
  --warn:      #ca8a04;
  --bad:       #dc3c3c;
  --shadow-sm: 0 1px 2px rgba(20,30,60,0.06);
  --shadow-md: 0 2px 6px rgba(20,30,60,0.08), 0 12px 28px rgba(20,30,60,0.07);
  --shadow-lg: 0 10px 24px rgba(20,30,60,0.12), 0 30px 70px rgba(20,30,60,0.14);
  --metric-launch:   #7c5cf0;
  --metric-yield:    #16a35e;
  --metric-downtime: #e0524f;
  --metric-eer:      #c98a00;
}

/* ---- MOOD: Amber CRT — retro phosphor terminal, monochrome amber ---- */
body.mood-amber {
  --bg:        #0a0700;
  --bg-2:      #120c02;
  --card:      #16100400;
  --card:      #161004;
  --card-2:    #1d1506;
  --ink:       #ffcf6e;
  --ink-2:     #e0a948;
  --muted:     #a9802f;
  --muted-2:   #6e531e;
  --text-muted:#a9802f;
  --line:      #2e2208;
  --line-2:    #3f300c;
  --accent:        #ffb627;
  --accent-2:      #ffcf6e;
  --accent-soft:   rgba(255, 182, 39, 0.16);
  --metric-launch:   #ffce6b;
  --metric-yield:    #d6b24a;
  --metric-downtime: #ff8a3c;
  --metric-eer:      #ffb627;
  --good:      #d4b24c; --good-soft: rgba(212, 178, 76, 0.16);
  --warn:      #ffb627; --warn-soft: rgba(255, 182, 39, 0.16);
  --bad:       #ff7a33; --bad-soft:  rgba(255, 122, 51, 0.18);
}
body.mood-amber {
  font-family: var(--font-mono);
  text-shadow: 0 0 1px rgba(255, 182, 39, 0.25);
}
body.mood-amber .kpi-value,
body.mood-amber .di-head h2,
body.mood-amber .home-welcome h1 { text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 45%, transparent); }
/* Scanlines + CRT vignette over the whole app */
body.mood-amber::after {
  content: ''; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.18) 0px, rgba(0,0,0,0.18) 1px, transparent 2px, transparent 3px);
  mix-blend-mode: multiply; opacity: 0.5;
}
body.mood-amber::before {
  content: ''; position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: radial-gradient(120% 120% at 50% 50%, transparent 60%, rgba(0,0,0,0.55) 100%);
}

/* ---- INTENSITY: Calm — muted urgency, soft surfaces ---- */
body.intensity-calm { --good-soft: color-mix(in srgb, var(--good) 9%, transparent); --warn-soft: color-mix(in srgb, var(--warn) 9%, transparent); --bad-soft: color-mix(in srgb, var(--bad) 9%, transparent); }
body.intensity-calm .kpi-status,
body.intensity-calm .alert .pill { filter: saturate(0.65); font-weight: 500; }
body.intensity-calm .alert.bad,
body.intensity-calm .alert.warn { border-left-width: 2px; }
body.intensity-calm .kpi { box-shadow: var(--shadow-sm); }
body.intensity-calm .alert-msg { font-weight: 400; }

/* ---- INTENSITY: War Room — amplified status, pulsing criticals ---- */
body.intensity-war .kpi-status.bad,
body.intensity-war .kpi-status.warn { font-weight: 800; letter-spacing: 0.03em; filter: saturate(1.3) brightness(1.08); }
body.intensity-war .kpi[data-metric] { border-color: var(--line-2); }
body.intensity-war .kpi-value { font-weight: 700; }
body.intensity-war .alert.bad {
  border-left-width: 5px;
  background: linear-gradient(90deg, var(--bad-soft), transparent 70%);
  animation: warpulse 1.8s ease-in-out infinite;
}
body.intensity-war .alert.bad .pill { background: var(--bad); color: #fff; font-weight: 800; }
@keyframes warpulse {
  0%, 100% { box-shadow: inset 3px 0 0 var(--bad), 0 0 0 rgba(248,113,113,0); }
  50%      { box-shadow: inset 3px 0 0 var(--bad), 0 0 22px -4px var(--bad); }
}
@media (prefers-reduced-motion: reduce) { body.intensity-war .alert.bad { animation: none; } }

/* ---- DATA EMPHASIS: Hero — oversized headline numbers, airy ---- */
body.emphasis-hero .kpi-value { font-size: 52px; letter-spacing: -0.03em; line-height: 0.95; }
body.emphasis-hero .kpi-value .unit { font-size: 14px; }
body.emphasis-hero .kpi { min-height: 232px; padding: 22px 22px 16px; }
body.emphasis-hero .kpi-spark { opacity: 0.62; }
body.emphasis-hero .section-head h2 { font-size: 22px; }
body.emphasis-hero .kpi-source { opacity: 0.6; }

/* ---- DATA EMPHASIS: Dense — packs more signal per screen ---- */
body.emphasis-dense .kpi-vs { font-size: 10.5px; }
body.emphasis-dense .kpi-source { margin-top: 5px; }
body.emphasis-dense .kpi-foot { padding-top: 6px; }
body.emphasis-dense .section-head { margin-bottom: 6px; }


/* ===== Treemap — separated by category ===== */
.treemap-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.tm-cat-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--cat-color, var(--accent));
  border-radius: 4px;
  padding: 12px 12px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.tm-cat-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px;
}
.tm-cat-name-row {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.tm-cat-swatch {
  width: 10px; height: 10px; border-radius: 2px;
  flex-shrink: 0;
}
.tm-cat-name {
  font-size: 12px; font-weight: 700; color: var(--ink);
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tm-cat-stats {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.tm-cat-total {
  font-size: 16px; font-weight: 600; color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tm-cat-pct {
  font-size: 11px; color: var(--cat-color, var(--accent));
  font-weight: 600;
}
.tm-cat-count {
  font-size: 10px; color: var(--muted);
}
.tm-cat-bar {
  height: 3px; background: var(--card); border-radius: 2px; overflow: hidden;
}
.tm-cat-bar-fill {
  height: 100%; border-radius: 2px;
  transition: width 0.25s ease;
}
.tm-cat-svg {
  width: 100%;
  aspect-ratio: 3 / 2;
  display: block;
  background: var(--card);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.tm-cat-foot {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  font-family: var(--font-mono); font-size: 10.5px;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
.tm-cat-foot-lab { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 9.5px; }
.tm-cat-foot-val { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-cat-foot-mins { color: var(--ink); font-weight: 600; }

/* ===== Treemap hover bar (used by both layouts) ===== */
.treemap-hover {
  margin-top: 10px;
  padding: 9px 14px;
  background: var(--bg-2);
  border: 1px solid var(--accent);
  border-left-width: 3px;
  border-radius: 4px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px;
}
.treemap-hover .th-cat { color: var(--accent); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 10.5px; }
.treemap-hover .th-arrow { color: var(--muted-2); }
.treemap-hover .th-name { color: var(--ink); font-weight: 600; }
.treemap-hover .th-val  { color: var(--ink); }
.treemap-hover .th-sep  { color: var(--muted-2); }
.treemap-hover .th-pct  { color: var(--muted); }

@media (max-width: 980px) {
  .treemap-cat-grid { grid-template-columns: 1fr; }
}
