/* Warehouse KPI — styled to match the Training Road Map app. */
:root {
  --bg: #0f1726;
  --panel: #16213a;
  --panel-2: #1d2b49;
  --line: #2b3c61;
  --text: #ffffff;
  --muted: #c7d2ea;
  --accent: #4f8cff;
  --green: #2fbf71;
  --amber: #f5a623;
  --red: #ef5350;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  transition: .15s; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffd7d6; border-color: rgba(239, 83, 80, .4); }
.btn.danger:hover { background: rgba(239, 83, 80, .15); border-color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Header ---------- */
header.app {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0, rgba(22, 33, 58, .7) 100%);
  position: sticky; top: 0; z-index: 30;
}
header.app .brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
header.app .brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7ab0ff);
  display: grid; place-items: center; font-size: 15px; font-weight: 800; color: #fff;
  box-shadow: var(--shadow); letter-spacing: .5px;
}
header.app h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
header.app .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.who .role-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  background: rgba(79, 140, 255, .18); color: #9fc0ff; border: 1px solid rgba(79, 140, 255, .35);
}
.who .role-badge.operative {
  background: rgba(159, 176, 208, .12); color: var(--muted); border-color: var(--line);
}

/* ---------- Sign-in ---------- */
.signin-wrap { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 40px; }
.signin-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 40px 44px; max-width: 460px; box-shadow: var(--shadow);
}
.signin-card .mark-lg {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), #7ab0ff);
  display: grid; place-items: center; font-size: 24px; font-weight: 800; color: #fff;
}
.signin-card h2 { margin: 0 0 8px; }
.signin-card p { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.gbtn {
  display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #222;
  border: none; border-radius: 10px; padding: 11px 18px; font-weight: 600; font-size: 14px;
}
.gbtn:disabled { opacity: .6; cursor: default; }
.gbtn svg { width: 18px; height: 18px; }
.signin-err { color: var(--red); margin-top: 16px; font-size: 13px; min-height: 18px; }

/* ---------- Main / sections ---------- */
main { padding: 22px; }
.section { max-width: 1040px; margin: 0 auto 30px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 14px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head .sub { color: var(--muted); font-size: 13px; }

/* ---------- Quick-entry tiles ---------- */
.quick-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.quick-tile {
  --accent: var(--accent);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 14px; text-align: left; transition: .15s;
  display: flex; flex-direction: column; gap: 8px; min-height: 92px;
}
.quick-tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-tile { position: relative; }
.quick-tile .q-icon { font-size: 22px; }
.quick-tile .q-label { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.quick-tile.tile-overdue { border-color: rgba(239, 83, 80, .6); }
.q-badge { display: none; }
.q-badge.due, .q-badge.overdue {
  display: inline-block; position: absolute; top: 8px; right: 8px;
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
}
.q-badge.overdue { background: var(--red); color: #fff; }
.q-badge.due { background: var(--amber); color: #3a2600; }
.due-banner { display: none; }
.due-banner.show {
  display: block; max-width: 1040px; margin: 0 auto 18px;
  background: rgba(239, 83, 80, .12); border: 1px solid rgba(239, 83, 80, .45);
  color: #ffc0bf; border-radius: 10px; padding: 12px 16px; font-size: 13px; font-weight: 600;
}

/* ---------- Pillar tiles (review) ---------- */
.pillar-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.pillar-tile {
  --accent: #4f8cff;
  text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-left: 5px solid var(--accent); border-radius: var(--radius);
  padding: 20px 18px; transition: .15s;
  display: flex; flex-direction: column; gap: 8px; min-height: 110px;
}
.pillar-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.pillar-name { font-size: 16px; font-weight: 700; }
.pillar-count { color: var(--muted); font-size: 12px; }

/* ---------- Settings / cards ---------- */
.settings-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; max-width: 540px; margin-bottom: 18px;
}
.settings-h3 { margin: 0 0 6px; font-size: 16px; }
.settings-note { color: var(--muted); font-size: 13px; margin: 0 0 20px; line-height: 1.5; }
.field-row { display: flex; gap: 18px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field > span, .field > label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input[type="time"], .field input[type="text"], .field input[type="email"] {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; color-scheme: dark;
}
.day-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.day-toggle { position: relative; cursor: pointer; }
.day-toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.day-toggle span {
  display: inline-block; padding: 9px 14px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; user-select: none;
}
.day-toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.settings-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.settings-status { font-size: 13px; color: var(--muted); }
.settings-status.ok { color: var(--green); }
.settings-status.error { color: var(--red); }

/* manager list */
.manager-list { list-style: none; padding: 0; margin: 0 0 14px; }
.manager-list li {
  display: flex; align-items: center; gap: 8px; padding: 9px 0;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.manager-list li .em { flex: 1; }
.manager-list li .tag { font-size: 11px; color: var(--muted); }
.manager-add { display: flex; gap: 8px; align-items: flex-end; }
.manager-add .field { flex: 1; margin-bottom: 0; }

/* ---------- Labour rates ---------- */
.rates-head { display: flex; gap: 8px; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 7px; }
.rates-head .rh-name { flex: 1; }
.rates-head .rh-rate { width: 130px; }
.rate-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.rate-row input {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font-size: 14px; color-scheme: dark;
}
.rate-row .r-name { flex: 1; min-width: 0; }
.rate-row .r-rate { width: 96px; }

/* ---------- Manage screen ---------- */
.manage-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.manage-group { margin-bottom: 22px; }
.manage-group-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
  padding-left: 10px; border-left: 4px solid var(--accent);
}
.manage-group-head .mg-name { font-size: 15px; font-weight: 800; letter-spacing: .02em; }
.metric-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 7px;
}
.metric-row .m-icon { font-size: 18px; width: 22px; text-align: center; }
.metric-row .m-name { font-weight: 600; font-size: 14px; }
.metric-row .m-badges { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.badge.qe { background: rgba(79,140,255,.18); color: #9fc0ff; border-color: rgba(79,140,255,.35); }
.badge.mgr { background: rgba(245,166,35,.16); color: #ffd9a6; border-color: rgba(245,166,35,.4); }
.badge.off { background: rgba(239,83,80,.14); color: #ffc0bf; border-color: rgba(239,83,80,.4); }

/* ---------- Slide-in editor panel ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(6,10,20,.6); z-index: 50;
  display: flex; justify-content: flex-end; backdrop-filter: blur(2px);
}
.panel {
  width: 460px; max-width: 94vw; height: 100%; background: var(--panel);
  border-left: 1px solid var(--line); padding: 22px; overflow-y: auto; box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 2px; font-size: 18px; }
.panel .panel-sub { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.panel .field { margin-bottom: 14px; }
.panel .field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.panel select, .panel input[type=text] {
  width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; color-scheme: dark;
}
.toggle-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.switch { position: relative; width: 50px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; transition: .15s; }
.slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--green); border-color: var(--green); }
.switch input:checked + .slider::before { transform: translateX(22px); background: #fff; }
.ed-fields { display: flex; flex-direction: column; gap: 7px; }
.ed-field-row { display: flex; align-items: center; gap: 6px; }
.ed-field-row .ef-label { flex: 1; min-width: 0; }
.ed-field-row .ef-type { width: 96px; flex: 0 0 auto; }
.ed-field-row .ef-options { flex: 1; min-width: 0; }
.ed-field-row .ef-req { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.panel-actions { display: flex; gap: 10px; margin-top: 22px; }
.panel-actions .btn { flex: 1; justify-content: center; }
.dim { color: var(--muted); font-size: 12px; }

/* ---------- Entry forms ---------- */
.entry-field { margin-bottom: 14px; }
.entry-field > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.entry-field input, .entry-field select, .entry-field textarea {
  width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; color-scheme: dark;
}
.entry-field textarea { resize: vertical; }
.req-star { color: var(--amber); }
.check-q { margin-bottom: 12px; }
.check-q > label { color: var(--text); font-weight: 500; }

.yesno-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.yesno-seg .yn { background: var(--panel-2); border: none; color: var(--muted); padding: 9px 22px; font-size: 13px; font-weight: 700; }
.yesno-seg .yn + .yn { border-left: 1px solid var(--line); }
.yesno-seg .yn.active.ok { background: var(--green); color: #04230f; }
.yesno-seg .yn.active.bad { background: var(--red); color: #2a0606; }

.check-score { font-size: 13px; margin: 10px 0 4px; font-weight: 600; }
.check-score.ok-text { color: var(--green); }

.timer-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0 0 16px; }
.timer-display { text-align: center; padding: 18px 0 22px; }
.timer-clock { font-size: 46px; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.timer-clock.dim { color: var(--muted); }
.link-btn { background: none; border: none; color: var(--accent); font-size: 12.5px; cursor: pointer; padding: 14px 0 0; text-decoration: underline; display: block; }
.link-btn:hover { filter: brightness(1.12); }

/* ---------- Labour calculator ---------- */
.labour-row { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.lr-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.lr-top .lr-name { font-size: 13.5px; font-weight: 600; }
.lr-top .lr-rate { font-size: 12px; color: var(--muted); }
.lr-inputs { display: flex; align-items: flex-end; gap: 10px; }
.lr-field { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.lr-field input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font-size: 13px; color-scheme: dark; }
.lr-cost { width: 72px; text-align: right; font-size: 13.5px; font-weight: 700; padding-bottom: 7px; }
.labour-total { margin: 16px 0 4px; font-size: 15px; }
.labour-total strong { font-size: 18px; }
.cap-actuals { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.cap-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; padding: 4px 0; }
.cap-row span { color: var(--muted); }
.cap-row strong { font-size: 14px; }

/* ---------- Dashboard ---------- */
.dashboard-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.dash-empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(29,43,73,.3); }
.dash-card { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: var(--radius); padding: 16px 18px; }
.dash-card-head { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dash-pillar { font-size: 15px; font-weight: 800; }
.health-pill { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.health-pill.green { background: rgba(47,191,113,.16); color: #9fe9c0; border-color: rgba(47,191,113,.45); }
.health-pill.amber { background: rgba(245,166,35,.16); color: #ffd9a6; border-color: rgba(245,166,35,.45); }
.health-pill.red { background: rgba(239,83,80,.16); color: #ffc0bf; border-color: rgba(239,83,80,.45); }
.health-pill.none { color: var(--muted); }
.rag-green { color: var(--green); }
.rag-amber { color: var(--amber); }
.rag-red { color: var(--red); }
.dash-metric.clickable { cursor: pointer; border-radius: 6px; }
.dash-metric.clickable:hover { background: var(--panel-2); }

/* drill-down */
.drill-chart { margin: 8px 0 6px; }
.chart-scroll { overflow-x: auto; padding-bottom: 4px; }
.bar-chart rect { fill: var(--accent); opacity: .85; }
.bar-chart text.bar-val { font-size: 9px; fill: var(--text); text-anchor: middle; }
.bar-chart text.bar-lbl { font-size: 9px; fill: var(--muted); text-anchor: middle; }
.bar-chart .target-line { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 4 3; }
.bar-chart text.target-lbl { font-size: 9px; fill: var(--amber); }
.bar-chart .baseline-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; }
.chart-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.chart-legend .lg-item { display: flex; align-items: center; gap: 6px; }
.chart-legend .lg-line { width: 16px; height: 0; border-top: 2px dashed; display: inline-block; }
.chart-legend .lg-line.baseline { border-color: var(--muted); }
.chart-legend .lg-line.target { border-color: var(--amber); }
.drill-h { font-size: 13px; margin: 16px 0 8px; }
.drill-list { display: flex; flex-direction: column; gap: 2px; }
.drill-entry { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; padding: 7px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.drill-entry:hover { background: var(--panel-2); }
.de-caret { flex: none; color: var(--muted); font-size: 10px; transition: transform .12s; }
.drill-entry.open .de-caret { transform: rotate(90deg); }
.de-when { width: 84px; flex: none; color: var(--muted); font-size: 11.5px; }
.de-sum { flex: 1; }
.de-who { font-size: 11px; }
.drill-detail { padding: 4px 0 10px 26px; }
.dd { display: flex; flex-direction: column; gap: 2px; }
.dd-head { font-weight: 700; font-size: 12.5px; margin-bottom: 4px; }
.dd-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding: 3px 0; }
.dd-row span { color: var(--muted); }
.dd-row strong { font-weight: 600; text-align: right; }

/* pattern alerts */
.pattern-alerts { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.pattern { padding: 10px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); }
.pattern.amber { background: rgba(245,166,35,.12); border-color: rgba(245,166,35,.45); color: #ffd9a6; }
.pattern.red { background: rgba(239,83,80,.12); border-color: rgba(239,83,80,.45); color: #ffc0bf; }
.dash-metric { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dash-metric:last-child { border-bottom: none; }
.dm-name { flex: 1; font-size: 12.5px; min-width: 0; }
.dm-spark { flex: none; height: 20px; line-height: 0; opacity: .9; }
.dm-value { flex: none; font-size: 14px; font-weight: 700; min-width: 48px; text-align: right; }
.dm-trend { flex: none; width: 16px; text-align: center; font-weight: 700; color: var(--muted); }
.dm-trend.good { color: var(--green); }
.dm-trend.bad { color: var(--red); }
.dm-trend.flat { color: var(--muted); }

/* ---------- Dispatch upload preview ---------- */
.disp-preview { margin: 6px 0 4px; font-size: 13px; }
.disp-preview.error { color: var(--red); }
.disp-week { margin-bottom: 10px; font-size: 13.5px; }
.disp-stat { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.disp-stat span:first-child { flex: 1; color: var(--muted); }
.disp-stat strong { font-size: 15px; }
.disp-stat .disp-pct { color: var(--green); font-weight: 700; flex: none; }
.disp-stat.total { border-bottom: none; margin-top: 4px; }
.disp-stat.total strong { font-size: 17px; }

/* ---------- Pillar entry/review panel ---------- */
.pillar-metric-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.pm-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.pm-row .pm-icon { width: 20px; text-align: center; }
.pm-row .pm-name { flex: 1; font-size: 13.5px; font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow);
  z-index: 80; opacity: 0; transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--red); color: #ffd7d6; }
