/* style.css - shared look for all pages (Material style, "Stormy Morning" colours).
   Stormy Morning: slate #6B7A8F, orange #F7882F, yellow #F7C331, tan #DCC7AA.
   Light and dark themes are switched by the data-theme attribute set in app.js. */
:root {
  --bg: #f4efe7;
  --surface: #fffcf7;
  --surface-2: #ece3d4;          /* tonal surface (tan) */
  --ink: #232a36;
  --ink2: #4d5566;
  --muted: #7a8090;
  --line: #dccfb9;
  --bar: #4d5b6e;                /* app bar (dark slate) */
  --on-bar: #ffffff;
  --primary: #F7882F;            /* main buttons (orange) */
  --on-primary: #2b1a05;
  --link: #3f4c5f;
  --accent: #F7882F;
  --accent-c: #fde0c0;           /* light orange container */
  --on-accent-c: #5a2d00;
  --good-c: #d4ebd9;  --on-good: #12401f;  --good: #2e7d4f;
  --warn-c: #fbe39b;  --on-warn: #4a3800;  --warn: #b98500;
  --bad-c: #f8d7d2;   --on-bad: #6b0a0a;   --bad: #b3261e;
  --info-c: #dfe5ee;  --on-info: #2b3646;
  --shadow1: 0 1px 2px rgba(35, 42, 54, 0.10), 0 1px 3px 1px rgba(35, 42, 54, 0.08);
  --shadow2: 0 2px 6px 2px rgba(35, 42, 54, 0.14), 0 1px 2px rgba(35, 42, 54, 0.16);
  --r: 14px;
}
:root[data-theme="dark"] {
  --bg: #1c2330; --surface: #262f3f; --surface-2: #313c50;
  --ink: #e9edf3; --ink2: #c1c8d4; --muted: #8b94a6; --line: #38445b;
  --bar: #2f3a4d; --on-bar: #f2f4f8;
  --primary: #F7882F; --on-primary: #2b1a05; --link: #f5b46f;
  --accent: #F7882F; --accent-c: #5a3a17; --on-accent-c: #ffdcb5;
  --good-c: #1d4a30; --on-good: #cfeed8; --good: #6fd08c;
  --warn-c: #574411; --on-warn: #fbe39b; --warn: #F7C331;
  --bad-c: #5c1f1a;  --on-bad: #ffd9d4;  --bad: #f2a099;
  --info-c: #3a465c; --on-info: #dfe5ee;
  --shadow1: 0 1px 2px rgba(0,0,0,0.5); --shadow2: 0 2px 8px rgba(0,0,0,0.6);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden; padding-bottom: 76px;
}
main { max-width: 1400px; margin: 0 auto; padding: 12px; }
h1 { font-size: 1.45rem; font-weight: 500; margin: 6px 0 2px; letter-spacing: -0.2px; }
h2 { font-size: 1.05rem; font-weight: 500; margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 0.95rem; font-weight: 500; margin: 0 0 2px; }
p { margin: 5px 0; }
.muted { color: var(--ink2); font-size: 0.85rem; }
a { color: var(--link); }
svg.ic { width: 24px; height: 24px; fill: currentColor; flex: none; }
svg.ic.sm { width: 18px; height: 18px; }

/* ---------- Top bar, side bar and phone menu (same on every page) ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--bar); color: var(--on-bar); box-shadow: var(--shadow2); }
.appbar-top { max-width: 1400px; margin: 0 auto; padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
.page-title { flex: 1; font-size: 1.05rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: #ffffff; display: grid; place-items: center; flex: none; overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-fallback { font-weight: 800; font-size: 0.78rem; color: #3f4c5f; letter-spacing: 0.5px; }
.role-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,0.18);
  color: inherit; text-decoration: none; font-size: 0.8rem; font-weight: 500; white-space: nowrap; }
.role-chip .ic { width: 18px; height: 18px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,0.18); color: inherit; cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: rgba(255,255,255,0.3); }
@media (max-width: 480px) { .role-chip { padding: 6px 8px; font-size: 0.72rem; } .role-chip .ic { display: none; } }

/* phone: bottom menu */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; gap: 4px; background: var(--surface); color: var(--ink2);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 8px rgba(35,42,54,0.18); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: inherit;
  font-size: 0.75rem; font-weight: 500; padding: 2px 0; min-height: 52px; justify-content: center; }
.nav a .pill { width: 60px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background 0.15s; }
.nav a.active { color: var(--ink); }
.nav a.active .pill { background: var(--accent-c); color: var(--on-accent-c); }

/* side bar: a drawer on phones, always visible on wide screens */
.sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 280px; max-width: 86vw; background: var(--surface); color: var(--ink); z-index: 50;
  display: flex; flex-direction: column; box-shadow: var(--shadow2); transform: translateX(-102%); transition: transform 0.2s ease; }
body.drawer-open .sidebar { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(10,14,22,0.5); z-index: 45; display: none; }
body.drawer-open .scrim { display: block; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.sb-brand .title { font-weight: 500; line-height: 1.2; }
.sb-brand .subtitle { font-size: 0.72rem; color: var(--ink2); }
.sb-brand > div { min-width: 0; flex: 1; }
.sb-brand .logo { box-shadow: inset 0 0 0 1px var(--line); }
.sb-close { background: var(--surface-2); color: var(--ink); }
.sb-nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 0; background: transparent; color: var(--ink2);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; text-align: left; }
.sb-link:hover { background: var(--surface-2); }
.sb-link.active { background: var(--accent); color: var(--on-primary); box-shadow: var(--shadow1); }
.sb-search { position: relative; margin: 8px 12px 4px; }
.sb-search .ic { position: absolute; left: 14px; top: 14px; color: var(--muted); pointer-events: none; }
.sb-search input[type="text"] { min-height: 44px; padding-left: 40px; border-radius: 22px; background: var(--surface-2); border-color: transparent; }
.sb-scroll { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.sb-title { padding: 12px 16px 4px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sb-sub-title { padding: 6px 16px 2px; font-size: 0.72rem; color: var(--ink2); font-weight: 500; }
.sb-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 4px 16px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 0.85rem; cursor: pointer; text-align: left; }
.sb-item:hover { background: var(--surface-2); }
.sb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-sub { font-size: 0.72rem; color: var(--muted); }
.sb-foot { padding: 8px 14px; font-size: 0.72rem; color: var(--muted); border-top: 1px solid var(--line); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .sidebar { transform: none; box-shadow: 1px 0 0 var(--line); width: 264px; }
  .scrim { display: none !important; }
  body.has-sidebar .site-header, body.has-sidebar main { margin-left: 264px; }
  .menu-btn, .sb-close, .appbar-top .logo { display: none; }
  .nav { display: none; }
}

/* ---------- Cards, buttons, fields ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 12px; margin: 8px 0; box-shadow: var(--shadow1); }
.card.tonal { background: var(--surface-2); box-shadow: none; }
.hero { background: linear-gradient(135deg, var(--bar), #6B7A8F); color: var(--on-bar); border-radius: 20px; padding: 16px; margin: 6px 0 10px; box-shadow: var(--shadow2); border-left: 6px solid var(--accent); }
.hero h1 { margin-top: 0; }
.hero p { opacity: 0.92; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 10px 18px; margin: 6px 0;
  font: inherit; font-weight: 500; letter-spacing: 0.1px; border-radius: 24px; border: 1px solid transparent;
  background: var(--primary); color: var(--on-primary); cursor: pointer; text-align: center; text-decoration: none;
  box-shadow: var(--shadow1); transition: box-shadow 0.15s, transform 0.05s;
}
.btn:hover { box-shadow: var(--shadow2); }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: transparent; color: var(--link); border-color: var(--line); box-shadow: none; }
.btn.good { background: var(--good-c); color: var(--on-good); box-shadow: none; }
.btn.warn { background: var(--warn-c); color: var(--on-warn); box-shadow: none; }
.btn.bad  { background: var(--bad-c);  color: var(--on-bad);  box-shadow: none; }
.btn.on { outline: 3px solid var(--ink); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { width: auto; min-height: 44px; padding: 8px 16px; margin: 0; }
.btn.tiny { width: auto; min-height: 40px; padding: 6px 14px; margin: 0; font-size: 0.85rem; }
.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.btn-row .btn { margin: 3px 0; }
.role-btn { text-align: left; justify-content: flex-start; padding: 14px 18px; border-radius: 18px; min-height: 76px; }
.role-btn small { display: block; font-weight: 400; opacity: 0.9; }
.role-btn .ic { width: 34px; height: 34px; }

label { display: block; font-weight: 500; font-size: 0.82rem; color: var(--ink2); margin: 10px 0 3px; }
select, input[type="text"], input[type="date"], input[type="password"] {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
select:focus, input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; }

/* ---------- Messages, chips ---------- */
.msg { border-radius: 14px; padding: 10px 12px; margin: 8px 0; background: var(--info-c); color: var(--on-info); overflow-wrap: anywhere; box-shadow: var(--shadow1); }
.msg.ok   { background: var(--good-c); color: var(--on-good); }
.msg.warn { background: var(--warn-c); color: var(--on-warn); }
.msg.err  { background: var(--bad-c);  color: var(--on-bad); }
.msg code { display: block; margin-top: 6px; font-size: 0.85rem; white-space: pre-wrap; }
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 7px; font-size: 0.72rem; font-weight: 500; white-space: nowrap; }
.badge.good { background: var(--good-c); color: var(--on-good); }
.badge.warn { background: var(--warn-c); color: var(--on-warn); }
.badge.bad  { background: var(--bad-c);  color: var(--on-bad); }
.badge.info { background: var(--info-c); color: var(--on-info); }
.badge.none { background: var(--surface-2); color: var(--ink2); }
.badge.wrap { white-space: normal; }

/* ---------- Lists ---------- */
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pair:last-child { border-bottom: none; }
.pair .arrow { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.pair > div { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .pair { grid-template-columns: 1fr; gap: 2px; }
  .pair .arrow { display: none; }
}

/* ---------- Dense grid of tiles (machines and operators) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr)); gap: 8px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.tcard { background: var(--surface); border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow1); border-top: 3px solid var(--line); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tcard.good { border-top-color: var(--good); }
.tcard.warn { border-top-color: var(--warn); }
.tcard.bad  { border-top-color: var(--bad); }
.tcard.info { border-top-color: var(--muted); }
.tcard .head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tcard .head > div { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.tcard .foot { margin-top: auto; padding-top: 2px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tcard .chips { display: flex; gap: 4px; flex-wrap: wrap; }
.tcard.big { padding: 12px; gap: 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.72rem; flex: none; color: #fff; }
.tcard.big .avatar { width: 40px; height: 40px; font-size: 0.85rem; }
.av-ex { background: #d9701c; } .av-du { background: #5b6f8a; } .av-gs { background: #8a7550; }
.meter { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); }

/* ---------- Dashboard tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.tile { background: var(--surface); border-radius: 12px; padding: 10px; box-shadow: var(--shadow1); display: flex; flex-direction: column; gap: 1px; }
.tile .ico { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-c); color: var(--on-accent-c); margin-bottom: 3px; }
.tile .ico .ic { width: 18px; height: 18px; }
.tile .num { font-size: 1.35rem; font-weight: 500; line-height: 1.15; }
.tile .lbl { color: var(--ink2); font-size: 0.75rem; line-height: 1.25; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; margin-top: 6px; background: var(--surface); }
.seg button { font: inherit; border: 0; background: transparent; color: var(--ink2); min-height: 48px; padding: 4px; cursor: pointer; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-c); color: var(--on-accent-c); }
.seg small { display: block; font-weight: 400; font-size: 0.72rem; opacity: 0.85; }
.chart-box { position: relative; height: 230px; }
.legend-note { color: var(--ink2); font-size: 0.82rem; }

/* ---------- Calendars ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cal-head b { font-weight: 500; font-size: 1rem; }
.cal-nav { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink); font-size: 1.3rem; cursor: pointer; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 0.72rem; color: var(--muted); padding: 2px 0; }
.cal-day { aspect-ratio: 1 / 1; min-height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); font: inherit; cursor: pointer; padding: 0; position: relative; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day.past { color: var(--muted); opacity: 0.45; cursor: default; }
.cal-day.off { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 4px, transparent 4px, transparent 8px); color: var(--muted); cursor: default; }
.cal-day.leave { background: var(--warn-c); color: var(--on-warn); font-weight: 700; }
.cal-day.add { background: var(--accent); color: var(--on-primary); font-weight: 700; }
.cal-day.remove { background: transparent; color: var(--bad); outline: 2px dashed var(--bad); outline-offset: -2px; text-decoration: line-through; }
.cal-day.empty { visibility: hidden; }
.key { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.75rem; color: var(--ink2); margin: 6px 0; }
.key i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
/* dashboard production calendar: each day shows its projected production */
.dcal-day { min-height: 54px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--ink); font: inherit; cursor: pointer; padding: 3px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.dcal-day b { font-weight: 500; font-size: 0.9rem; }
.dcal-day small { font-size: 0.68rem; color: var(--ink2); }
.dcal-day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.dcal-day.sel { outline: 3px solid var(--ink); outline-offset: 1px; }
.dcal-day.past { opacity: 0.55; }
.dcal-day.empty { visibility: hidden; }

.hidden { display: none; }

/* ---------- Dashboard layout (cards in a 12-column grid) ---------- */
.dash { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.dash > * { grid-column: span 12; min-width: 0; }
.dash > .card { margin: 0; }
@media (min-width: 900px) {
  .dash > .s8 { grid-column: span 8; } .dash > .s7 { grid-column: span 7; } .dash > .s6 { grid-column: span 6; }
  .dash > .s5 { grid-column: span 5; } .dash > .s4 { grid-column: span 4; } .dash > .s3 { grid-column: span 3; }
}
.card h3.ct { font-size: 1rem; margin-bottom: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h3 { margin: 0; font-size: 1rem; }
.toggle { display: inline-grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.toggle button { font: inherit; font-size: 0.82rem; border: 0; background: transparent; color: var(--ink2); min-height: 36px; padding: 4px 14px; cursor: pointer; font-weight: 500; }
.toggle button.on { background: var(--accent-c); color: var(--on-accent-c); }

/* pastel summary cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow1); }
.kpi .kico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.55); margin-bottom: 4px; }
.kpi .kico .ic { width: 18px; height: 18px; }
.kpi .num { font-size: 1.5rem; font-weight: 500; line-height: 1.15; }
.kpi .lbl { font-size: 0.82rem; }
.kpi .note { font-size: 0.72rem; opacity: 0.8; }
.kpi.k1 { background: #f6e3d0; color: #4a2c0e; } .kpi.k2 { background: #fde3b8; color: #4a3200; }
.kpi.k3 { background: #fbf0bd; color: #453800; } .kpi.k4 { background: #dfe5ee; color: #26313f; } .kpi.k5 { background: #e2ecd8; color: #223a16; }
:root[data-theme="dark"] .kpi.k1 { background: #4a3626; color: #ffe1c5; } :root[data-theme="dark"] .kpi.k2 { background: #5a4218; color: #ffe6b3; }
:root[data-theme="dark"] .kpi.k3 { background: #514618; color: #fbf0bd; } :root[data-theme="dark"] .kpi.k4 { background: #364358; color: #dfe5ee; }
:root[data-theme="dark"] .kpi.k5 { background: #2f4529; color: #dcefd0; }
:root[data-theme="dark"] .kpi .kico { background: rgba(255,255,255,0.14); }

/* what-if sliders */
.sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; }
.slider label { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 2px; font-size: 0.82rem; }
.slider label b { color: var(--ink); font-weight: 500; }
.slider .delta { font-size: 0.72rem; color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 34px; margin: 0; }
.whatif-result { margin-top: 8px; }

/* pop-up panel for a machine or an operator */
.modal-back { position: fixed; inset: 0; background: rgba(10,14,22,0.55); z-index: 60; display: none; align-items: center; justify-content: center; padding: 12px; }
.modal-back.show { display: flex; }
.modal { background: var(--surface); color: var(--ink); border-radius: 20px; padding: 16px; width: min(460px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow2); }
.modal .mhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal .mhead h3 { flex: 1; font-size: 1.1rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.9rem; }
.kv dt { color: var(--ink2); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* login page */
.login-box { max-width: 460px; margin: 0 auto; }
details.help { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; margin: 10px 0; }
details.help summary { cursor: pointer; font-weight: 500; }
details.help ol { margin: 6px 0; padding-left: 20px; }
code.inline { background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: 0.85em; }

/* =====================================================================
   Modern polish: glass top bar, dark side bar, hero banner, gauge cards
   ===================================================================== */
body {
  background:
    radial-gradient(900px 420px at 92% -8%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%),
    radial-gradient(800px 420px at -8% 4%, color-mix(in srgb, #6B7A8F 20%, transparent), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  font-feature-settings: "tnum" 1;
}
:root[data-theme="dark"] { --shadow-soft: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.35); }
:root { --shadow-soft: 0 1px 2px rgba(35,42,54,.05), 0 10px 28px rgba(35,42,54,.07); }

/* top bar: light glass */
.site-header { background: var(--surface); background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); color: var(--ink); box-shadow: 0 1px 0 var(--line); }
.page-title { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.2px; }
.role-chip { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.icon-btn { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.icon-btn:hover { background: var(--accent-c); }
.appbar-top .logo { box-shadow: inset 0 0 0 1px var(--line); }

/* side bar: dark slate with soft glow */
.sidebar { --sbt: rgba(255,255,255,.78); color: #eef1f6;
  background: radial-gradient(320px 220px at 0% 0%, rgba(247,136,47,.20), transparent 70%), linear-gradient(180deg, #3b4759 0%, #262f3e 100%); }
:root[data-theme="dark"] .sidebar { background: radial-gradient(320px 220px at 0% 0%, rgba(247,136,47,.16), transparent 70%), linear-gradient(180deg, #232c3b 0%, #141a25 100%); }
.sidebar .title { color: #fff; font-weight: 600; }
.sidebar .subtitle { color: rgba(255,255,255,.68); }
.sidebar .sb-close { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; }
.sb-link { color: var(--sbt); border-radius: 14px; }
.sb-link:hover { background: rgba(255,255,255,.09); color: #fff; }
.sb-link.active { background: linear-gradient(135deg, #F7A04F, #F7882F); color: #2b1a05; box-shadow: 0 6px 16px rgba(247,136,47,.35); }
.sb-search .ic { color: rgba(255,255,255,.55); }
.sb-search input[type="text"] { background: rgba(255,255,255,.10); color: #fff; border-color: transparent; }
.sb-search input[type="text"]::placeholder { color: rgba(255,255,255,.55); }
.sb-search input[type="text"]:focus { outline: 2px solid var(--accent); }
.sb-title { color: rgba(255,255,255,.5); }
.sb-sub-title { color: rgba(255,255,255,.72); }
.sb-item { color: #eef1f6; }
.sb-item:hover { background: rgba(255,255,255,.09); }
.sb-sub { color: rgba(255,255,255,.55); }
.sb-foot { border-top-color: rgba(255,255,255,.12); color: rgba(255,255,255,.55); }
.sidebar .dot { box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.sidebar .dot.good { background: #6fd08c; } .sidebar .dot.warn { background: #F7C331; } .sidebar .dot.bad { background: #f2a099; }
.sb-scroll::-webkit-scrollbar { width: 6px; } .sb-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }

/* cards */
.card { border-radius: 20px; box-shadow: var(--shadow-soft); border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.card h3.ct, .card-head h3 { font-weight: 600; letter-spacing: -0.1px; }
.tcard { border-radius: 14px; box-shadow: var(--shadow-soft); transition: transform .15s ease, box-shadow .15s ease; }
.tcard:hover { transform: translateY(-2px); box-shadow: var(--shadow2); }
.badge { border-radius: 999px; padding: 1px 9px; }
.meter { height: 6px; border-radius: 3px; }
.meter > i { background: linear-gradient(90deg, #F7C331, #F7882F); border-radius: 3px; }

/* hero banner with the big number */
.hero-dash { position: relative; overflow: hidden; border-radius: 26px; padding: 18px; color: #fff; display: grid; gap: 16px; grid-template-columns: 1fr;
  background: linear-gradient(135deg, #37435a 0%, #4d5b6e 45%, #6B7A8F 100%); box-shadow: 0 14px 34px rgba(55,67,90,.35); }
:root[data-theme="dark"] .hero-dash { background: linear-gradient(135deg, #202a3a 0%, #2f3a4d 55%, #435068 100%); }
.hero-dash::before { content: ""; position: absolute; width: 380px; height: 380px; right: -110px; top: -170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(247,136,47,.65), rgba(247,136,47,0) 68%); pointer-events: none; }
.hero-dash::after { content: ""; position: absolute; width: 260px; height: 260px; left: -90px; bottom: -150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(247,195,49,.35), rgba(247,195,49,0) 68%); pointer-events: none; }
.hero-dash > * { position: relative; z-index: 1; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .7rem; opacity: .85; font-weight: 600; }
.hero-num { font-size: clamp(2.1rem, 7vw, 3.3rem); font-weight: 600; line-height: 1.05; letter-spacing: -1px; margin: 4px 0; }
.hero-num small { font-size: .45em; font-weight: 500; opacity: .85; margin-left: 4px; letter-spacing: 0; }
.hero-sub { opacity: .92; font-size: .92rem; }
.spark { margin-top: 10px; height: 64px; }
.spark svg { width: 100%; height: 64px; display: block; }
.hero-ctl { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-radius: 20px; padding: 12px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.hero-ctl .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.hero-ctl .day-title { font-weight: 600; }
.hero-ctl input[type="date"] { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.28); color-scheme: dark; min-height: 46px; }
.hero-ctl label { color: rgba(255,255,255,.8); margin-top: 0; }
.hero-ctl .btn.secondary { color: #fff; border-color: rgba(255,255,255,.4); }
.hero-ctl .seg { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.25); }
.hero-ctl .seg button { color: rgba(255,255,255,.85); }
.hero-ctl .seg button + button { border-left-color: rgba(255,255,255,.22); }
.hero-ctl .seg button.on { background: linear-gradient(135deg, #F7A04F, #F7882F); color: #2b1a05; }
@media (min-width: 900px) { .hero-dash { grid-template-columns: 1.25fr 1fr; align-items: end; padding: 24px; } }

/* insight chips */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.insight { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-soft);
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); font-size: .86rem; line-height: 1.35; }
.insight .ii { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-c); color: var(--on-accent-c); }
.insight .ii .ic { width: 20px; height: 20px; }
.insight b { font-weight: 600; }
.insight small { display: block; color: var(--ink2); font-size: .76rem; }

/* summary cards with gauge rings */
.kpi { position: relative; display: block; border-radius: 20px; padding: 14px; box-shadow: var(--shadow-soft); transition: transform .15s ease; }
.kpi:hover { transform: translateY(-2px); }
.kpi .kt { min-width: 0; }
.kpi .num { font-size: 1.55rem; font-weight: 600; letter-spacing: -.5px; }
.kpi .ring { position: absolute; right: 12px; top: 12px; width: 54px; height: 54px; }
.kpi .ring text { font-family: inherit; }

/* production calendar */
.dcal-day { border-radius: 12px; transition: transform .12s ease; }
.dcal-day:hover { transform: scale(1.06); }
.dcal-day b { font-weight: 600; }
.heat-key { display: flex; align-items: center; gap: 8px; font-size: .72rem; color: var(--ink2); margin-top: 8px; }
.heat-key i { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 60%, var(--surface-2)), var(--surface-2)); }

/* rankings */
.rank { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--ink2); margin-right: 6px; flex: none; }
.rank.r1 { background: #F7C331; color: #4a3800; } .rank.r2 { background: #d5d9df; color: #2b3646; } .rank.r3 { background: #e2b38a; color: #4a2c0e; }

/* loading shimmer */
.skel { position: relative; overflow: hidden; background: var(--surface-2) !important; color: transparent !important; min-height: 88px; }
.skel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); transform: translateX(-100%); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* gentle entrance */
@media (prefers-reduced-motion: no-preference) {
  .dash > .card, .hero-dash { animation: rise .5s ease both; }
  .dash > .card:nth-child(2) { animation-delay: .05s; } .dash > .card:nth-child(3) { animation-delay: .1s; }
  .dash > .card:nth-child(4) { animation-delay: .15s; } .dash > .card:nth-child(5) { animation-delay: .2s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* sliders: a little friendlier */
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent), #F7C331); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent), #F7C331); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow1); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.slider { background: var(--surface-2); border-radius: 14px; padding: 8px 12px 6px; }

/* ---------- Decision cards ---------- */
.dgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 12px; }
.dcard { background: var(--surface); border-radius: 20px; padding: 14px; box-shadow: var(--shadow-soft); border-left: 6px solid var(--line);
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dcard.high { border-left-color: var(--bad); } .dcard.medium { border-left-color: var(--warn); } .dcard.low { border-left-color: var(--muted); } .dcard.none { border-left-color: var(--good); }
.dcard .dhead { display: flex; gap: 10px; align-items: flex-start; }
.dcard .dhead h3 { font-size: 1rem; font-weight: 600; }
.dcard .dhead > div { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.dcard .dloss { font-size: .9rem; }
.dcard .best { background: var(--accent-c); color: var(--on-accent-c); border-radius: 14px; padding: 8px 10px; font-size: .88rem; }
.dcard .dopt { border-top: 1px dashed var(--line); padding-top: 8px; }
.dcard .dopt h4 { margin: 0 0 2px; font-size: .9rem; font-weight: 600; }
.chips2 { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.opt { border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; font-size: .8rem; background: var(--surface-2); text-align: center; line-height: 1.25; }
.opt b { display: block; font-size: .9rem; }
.opt.rec { border-color: var(--accent); background: var(--accent-c); color: var(--on-accent-c); }
.opt.zero { opacity: .65; }
.sim-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; align-items: end; margin-top: 8px; }
.sim-row .btn { margin: 0; }
.allclear { display: flex; gap: 12px; align-items: center; }

/* ---------- Planned maintenance timeline ---------- */
.tl-axis, .tl-row { display: grid; grid-template-columns: 116px 1fr; gap: 8px; align-items: center; }
.tl-ticks { position: relative; height: 18px; font-size: .68rem; color: var(--muted); }
.tl-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-row { margin: 6px 0; }
.tl-name { font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 24px; border-radius: 12px; overflow: hidden;
  background: repeating-linear-gradient(90deg, var(--surface-2) 0, var(--surface-2) calc(100% / 6 - 1px), color-mix(in srgb, var(--line) 80%, transparent) calc(100% / 6 - 1px), color-mix(in srgb, var(--line) 80%, transparent) calc(100% / 6)); }
.tl-bar { position: absolute; top: 4px; bottom: 4px; min-width: 7px; border-radius: 9px; background: linear-gradient(90deg, #F7A04F, #F7882F); box-shadow: 0 1px 4px rgba(247,136,47,.4); }
.tl-bar.now { background: linear-gradient(90deg, #d03b3b, #F7882F); }
.tl-ghost { position: absolute; top: 3px; bottom: 3px; min-width: 9px; border-radius: 9px; border: 2px dashed var(--good); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .5; }
.tl-key { display: flex; flex-wrap: wrap; gap: 12px; font-size: .75rem; color: var(--ink2); margin-top: 8px; }
.tl-key i { display: inline-block; width: 22px; height: 10px; border-radius: 5px; margin-right: 4px; vertical-align: -1px; }
.opt.cost b { font-weight: 600; }

/* labels inside small tiles may wrap instead of pushing the page sideways */
.tcard .badge { max-width: 100%; white-space: normal; text-align: left; }
.tcard .chips, .tcard .foot { min-width: 0; }
