/* EPPS — Scits chrome (Pigfarm / Middleware)
   Navy sidebar, cool canvas, white cards, cable-blue accent.
   Floor Start/Pause stay large tap targets; office controls stay compact. */

:root {
  --canvas: #f0f4f8;
  --surface: #ffffff;
  --surface-sunken: #e6edf4;
  --forest: #0b1f33;
  --forest-600: #123049;
  --brand-accent: #0077c0;
  --brand-accent-fg: #ffffff;
  --ink: #0f1c2a;
  --ink-soft: #4a5d73;
  --ink-faint: #8494a8;
  --line: #d3dde8;
  --leaf: #18a36b;
  --leaf-soft: #e5f7ef;
  --poppy: #cf4a4a;
  --poppy-soft: #fff0f0;
  --gold: #d99015;
  --gold-soft: #fff4de;
  --bobbin: #0077c0;

  --ground: var(--canvas);
  --card: var(--surface);
  --card-2: var(--surface-sunken);
  --indigo: var(--brand-accent);
  --indigo-deep: #005a94;
  --indigo-soft: #e9f3fc;
  --muted: var(--ink-soft);

  --display: Inter, system-ui, "Segoe UI", sans-serif;
  --font: Inter, system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, Consolas, "Cascadia Mono", monospace;
  --shadow-card: 0 1px 2px rgba(15, 28, 42, 0.04);
  --shadow-card-hover: 0 2px 8px rgba(15, 28, 42, 0.08);
  --radius: 5px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  color-scheme: light;
  font-family: var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--canvas); color: var(--ink); }
body {
  font-size: 13px; font-weight: 400;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5ccd6; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #b0b8c4; }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); }
.sidebar ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }
button, input, select { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand-accent) 50%, transparent); outline-offset: 2px; }
::selection { background: var(--brand-accent); color: #fff; }

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.nav-open { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nav-scrim, .nav-burger { display: none; }

.sidebar {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  background: var(--forest); color: #fff;
  padding: 12px 10px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 12px;
}
.brand-mark {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--brand-accent); color: var(--brand-accent-fg);
  font-size: 14px; font-weight: 700;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 13px; font-weight: 600; }
.brand small { color: rgba(255, 255, 255, 0.5); font-size: 11px; }

.primary-nav {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1; min-height: 0; overflow-y: auto;
}
.nav-label {
  flex-shrink: 0; margin: 8px 8px 2px; line-height: 1.2;
  color: rgba(255, 255, 255, 0.35);
  font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.nav-rule {
  flex-shrink: 0; height: 1px; margin: 10px 4px 2px;
  background: rgba(255, 255, 255, 0.12);
}
.primary-nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 10px;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px; font-weight: 500;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.primary-nav a svg { width: 18px; height: 18px; flex: 0 0 auto; }
.primary-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.primary-nav a[aria-current="page"] {
  color: var(--brand-accent);
  background: color-mix(in srgb, var(--brand-accent) 22%, transparent);
}
.primary-nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 2px 2px 0; background: var(--brand-accent);
}

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); }
.masthead {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  height: 52px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.page-meta { min-width: 0; flex: 1; }
.page-meta h1 {
  font-size: 15px; font-weight: 600; line-height: 1.2; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-meta p { margin-top: 1px; font-size: 12px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-chip { position: relative; flex-shrink: 0; }
.user-chip summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-size: 12px; color: var(--ink-soft);
}
.user-chip summary::-webkit-details-marker { display: none; }
.user-chip summary:hover { background: var(--surface-sunken); }
.avatar {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: var(--radius);
  background: var(--forest); color: #fff; font-size: 11px; font-weight: 700;
}
.user-chip-copy strong { font-weight: 600; color: var(--ink); }
.user-chip-copy .user-role { color: var(--ink-faint); }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50;
  width: 192px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 10px 24px rgba(15, 28, 42, 0.12);
}
.user-menu a {
  display: block; padding: 8px 12px;
  font-size: 12.5px; font-weight: 500; color: #dc2626;
}
.user-menu a:hover { background: #fef2f2; }

main { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 32px; }

/* --- page heads --------------------------------------------------------- */
.kicker {
  color: var(--brand-accent); font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
}
.page-intro {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 16px; padding: 14px 18px;
  background: var(--forest); color: #fff; border-radius: var(--radius);
}
.page-intro .kicker { color: rgba(255, 255, 255, 0.7); }
.page-intro h1, .work-head h1, .empty-card h1 {
  font-weight: 600; font-size: 18px; letter-spacing: -.015em; line-height: 1.25; margin-top: 2px;
}
.page-intro h1 { color: #fff; }
.page-intro p { margin-top: 2px; color: rgba(255, 255, 255, 0.8); font-size: 12.5px; }
.intro-actions { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.avail-pill {
  padding: 4px 12px 6px; background: rgba(255, 255, 255, 0.12); color: #fff;
  border-radius: var(--radius);
  font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.avail-pill small {
  display: block; font-size: 10px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; opacity: .72;
}
.page-intro .field span { color: rgba(255, 255, 255, 0.7); }
.page-intro .field input, .page-intro .field select {
  background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); color: #fff;
  min-height: 36px; color-scheme: dark;
}
.page-intro .export-link {
  background: rgba(255, 255, 255, 0.12); border-color: transparent; color: #fff; box-shadow: none;
}

/* --- buttons ------------------------------------------------------------ */
.hmi-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: auto; min-height: 0; padding: 8px 14px;
  border: 1px solid rgba(11, 31, 51, 0.4); border-radius: var(--radius);
  background: var(--surface); color: var(--forest);
  font-size: 13px; font-weight: 600; line-height: 1.2; cursor: pointer;
  transition: transform .15s var(--ease-out), filter .15s var(--ease-out), background .15s var(--ease-out);
}
.hmi-btn:hover { background: color-mix(in srgb, var(--forest) 5%, var(--surface)); }
.hmi-btn:active { transform: scale(0.97); }
.hmi-btn.primary {
  background: var(--brand-accent); color: var(--brand-accent-fg); border-color: transparent;
}
.hmi-btn.primary:hover { background: var(--brand-accent); filter: brightness(0.95); }
.hmi-btn.success { background: var(--leaf); color: #fff; border-color: transparent; }
.hmi-btn.success:hover { background: var(--leaf); filter: brightness(0.95); }
.hmi-btn.danger { background: #dc2626; color: #fff; border-color: transparent; }
.hmi-btn.danger:hover { background: #b91c1c; filter: none; }
.hmi-btn.warn { background: var(--gold-soft); color: #8a5608; border-color: transparent; }
.hmi-btn.warn:hover { background: var(--gold-soft); }
.hmi-btn.wide { display: flex; width: 100%; margin-top: 12px; }
.hmi-btn.small { min-height: 0; padding: 5px 10px; font-size: 12px; font-weight: 500; }
.hmi-btn.small.danger {
  background: transparent; color: #dc2626; border-color: transparent;
}
.hmi-btn.small.danger:hover { background: #fef2f2; color: #b91c1c; }
.hmi-btn.is-busy { opacity: .5; }
.hmi-btn:disabled { cursor: not-allowed; opacity: .55; }
.hmi-btn.is-busy:disabled { cursor: progress; }

.page-floor .hmi-btn { display: flex; width: 100%; min-height: 60px; font-size: 17px; }
.page-floor .hmi-btn.wide { min-height: 68px; font-size: 19px; }
.page-floor .hmi-btn.small { width: auto; min-height: 38px; font-size: 13px; }
.page-floor .hmi-btn.danger { background: #dc2626; color: #fff; }
.page-floor .hmi-btn.danger:hover { background: #b91c1c; }

.export-link {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-weight: 600; font-size: 13px;
}
.export-link:hover { background: var(--surface-sunken); }
.text-link {
  display: inline-flex; align-items: center; margin-top: 16px; padding: 8px 14px;
  background: var(--brand-accent); border-radius: var(--radius);
  color: var(--brand-accent-fg); font-weight: 600; font-size: 13px;
}

/* --- machine cards ------------------------------------------------------ */
.machine-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; margin-bottom: 16px; }
.plan-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; margin-bottom: 16px; }
.plan-card { border-top: 1px solid var(--line); padding: 12px 14px; display: grid; gap: 8px; }
.plan-card.held { opacity: 0.6; }
.machine-pick {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
  min-height: 96px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card); color: var(--ink);
}
.machine-pick::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--line);
}
.machine-pick.running::after { background: var(--leaf); }
.machine-pick.paused::after { background: var(--poppy); }
.machine-pick.between-runs::after { background: var(--gold); }
.machine-pick:hover { border-color: color-mix(in srgb, var(--brand-accent) 40%, var(--line)); }
.machine-pick.selected { box-shadow: inset 0 0 0 1px var(--brand-accent); }
.pick-copy { display: grid; gap: 3px; min-width: 0; }
.pick-copy strong { font-size: 20px; font-weight: 650; letter-spacing: -.01em; line-height: 1.1; }
.pick-copy em {
  font-style: normal; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.pick-copy small { color: var(--ink-faint); font-size: 12.5px; }
.machine-pick.running em, .state-chip.running { color: var(--leaf); }
.machine-pick.paused em, .state-chip.paused { color: var(--poppy); }
.machine-pick.between-runs em, .state-chip.between-runs { color: #8a5608; }

.lamp {
  width: 14px; height: 14px; flex: 0 0 auto; border-radius: 50%;
  background: var(--ink-faint);
}
.lamp.running { background: var(--leaf); box-shadow: 0 0 0 4px rgba(24, 163, 107, .16); }
.lamp.paused { background: var(--poppy); box-shadow: 0 0 0 4px rgba(207, 74, 74, .15); }
.lamp.between-runs { background: var(--gold); box-shadow: 0 0 0 4px rgba(217, 144, 21, .18); }
.lamp.loaded, .lamp.assigned { background: var(--brand-accent); }
.lamp.cleaning, .lamp.idle { background: var(--line); }

/* --- panels ------------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden;
}
.work-panel { padding: 18px 20px 20px; margin-bottom: 16px; }
.work-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.page-floor .work-head { align-items: center; }
.work-head h1 { font-size: 22px; }
.page-floor .work-head h1 { font-size: 26px; }
.machine-switch { margin: 0; }
.machine-switch .field { margin-top: 0; }
.machine-switch-row { display: flex; align-items: center; gap: 12px; }
.machine-switch-row select { flex: 1; min-width: 0; }
.page-floor .machine-switch select {
  min-height: 60px; font-size: 18px; font-weight: 650;
}
.job-line { margin-top: 4px; color: var(--ink-soft); font-size: 13.5px; }
.state-chip {
  padding: 6px 10px; border-radius: var(--radius);
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.state-chip.running { background: var(--leaf-soft); }
.state-chip.paused { background: var(--poppy-soft); }
.state-chip.between-runs { background: var(--gold-soft); }
.prompt {
  margin: 16px 0 12px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 16px; font-weight: 650;
}
.page-floor .prompt { font-size: 20px; }
.reason-block { margin-top: 14px; }
.reason-block .kicker { margin-bottom: 7px; color: var(--ink-faint); }
.action-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.action-grid.two { grid-template-columns: 1fr 1fr; }
.action-grid form { margin: 0; }
.working-as { margin: 12px 0 0; color: var(--ink-faint); font-size: 13px; }
.working-as a { color: var(--brand-accent); font-weight: 650; text-decoration: underline; }
.next-job {
  margin-top: 14px; padding: 14px 16px;
  background: var(--surface-sunken); border-radius: var(--radius);
}

/* --- fields ------------------------------------------------------------- */
.field, .note-field { display: grid; gap: 5px; margin-top: 12px; }
.field span, .note-field span {
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.field select, .field input, .note-field input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--canvas); font-size: 14px;
}
.field select:focus, .field input:focus, .note-field input:focus {
  background: var(--surface);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-accent) 20%, transparent);
  outline: none;
}
.select-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.units-hint { margin: 10px 0 4px; color: var(--ink-faint); font-size: 13px; }
.units-hint a { color: var(--brand-accent); font-weight: 650; }
.assign-panel { margin-top: 8px; }
.advanced-details { margin-top: 16px; }
.advanced-details summary { cursor: pointer; color: var(--brand-accent); font-size: 13.5px; font-weight: 650; }
.operator-pick { max-width: 280px; margin: 16px 0 0; }
.period-pick { margin: 0; min-width: 170px; }
.day-pick { margin: 0; }
.day-pick .field { margin-top: 0; }
.day-pick input { min-width: 168px; }
.panel-lead { padding: 12px 18px 0; color: var(--ink-soft); font-size: 13.5px; }

/* --- metrics ------------------------------------------------------------ */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
  border-left: 3px solid var(--forest);
}
.metric-card.run { border-left-color: var(--leaf); }
.metric-card.pause { border-left-color: var(--poppy); }
.metric-card.gap { border-left-color: var(--gold); }
.metric-copy { min-width: 0; }
.metric-card strong {
  display: block;
  font-size: 24px; font-weight: 700; color: var(--forest);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.metric-copy span {
  display: block; margin-top: 4px; max-width: 8rem;
  font-size: 12px; font-weight: 500; color: var(--ink-soft); line-height: 1.3;
}
.metric-card small { display: block; margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--ink-faint); }
.metric-icon {
  flex: 0 0 auto; padding: 8px; border-radius: 4px;
  background: color-mix(in srgb, var(--forest) 10%, transparent); color: var(--forest);
}
.metric-icon svg { display: block; width: 20px; height: 20px; }

.mix-bar { display: flex; height: 8px; margin-top: 10px; background: var(--surface-sunken); border-radius: 99px; overflow: hidden; }
.mix-bar .seg { display: block; height: 100%; }
.seg.Runtime { background: var(--leaf); }
.seg.Explicit-Pause { background: var(--poppy); }
.seg.Between-Runs { background: var(--gold); }
.mix-legend { display: flex; gap: 16px; margin: -4px 0 16px; color: var(--ink-faint); font-size: 12px; }
.mix-legend .key::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px;
  vertical-align: -1px; border-radius: 2px;
}
.mix-legend .run::before { background: var(--leaf); }
.mix-legend .pause::before { background: var(--poppy); }
.mix-legend .gap::before { background: var(--gold); }

/* --- tables ------------------------------------------------------------- */
.panel-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line);
}
.panel-header h2 { font-size: 13px; font-weight: 650; color: var(--forest); }
.panel-header span { color: var(--ink-faint); font-size: 12.5px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.history-table th {
  padding: 8px 14px; color: var(--ink-faint); text-align: left;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.history-table td { padding: 10px 14px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.history-table tbody tr:hover { background: var(--surface-sunken); }
.history-empty { height: 72px; color: var(--ink-faint); text-align: center; }
.code-cell { font-family: var(--mono); font-size: 13px; }

/* --- states, empty, flash ----------------------------------------------- */
.empty-card {
  padding: 48px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.empty-card p { margin-top: 8px; color: var(--ink-soft); }
.empty-card h1 { font-size: 20px; }
.flash {
  margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid; font-weight: 600; font-size: 13px;
}
.flash.ok { background: var(--leaf-soft); border-color: #b7e4cc; color: #0d6b45; }
.flash.err { background: var(--poppy-soft); border-color: #f0c2c2; color: #9b2c2c; }
.toast { transition: opacity .6s ease; }
.toast.fade { opacity: 0; }

/* --- setup -------------------------------------------------------------- */
.setup-shell { margin-bottom: 20px; }
.setup-tab-input {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}
.setup-tablist {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.setup-tablist label {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-soft); font-size: 13px; font-weight: 500; cursor: pointer;
}
.setup-tablist label:hover { color: var(--ink); }
.setup-tablist label span {
  min-width: 1.25em; color: var(--ink-faint);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.setup-panel { display: none; }
.setup-shell:has(#setup-tab-people:checked) [for="setup-tab-people"],
.setup-shell:has(#setup-tab-machines:checked) [for="setup-tab-machines"],
.setup-shell:has(#setup-tab-terminals:checked) [for="setup-tab-terminals"],
.setup-shell:has(#setup-tab-customers:checked) [for="setup-tab-customers"],
.setup-shell:has(#setup-tab-orders:checked) [for="setup-tab-orders"],
.setup-shell:has(#setup-tab-jobs:checked) [for="setup-tab-jobs"] {
  border-bottom-color: var(--forest); color: var(--forest);
}
.setup-shell:has(#setup-tab-people:checked) [for="setup-tab-people"] span,
.setup-shell:has(#setup-tab-machines:checked) [for="setup-tab-machines"] span,
.setup-shell:has(#setup-tab-terminals:checked) [for="setup-tab-terminals"] span,
.setup-shell:has(#setup-tab-customers:checked) [for="setup-tab-customers"] span,
.setup-shell:has(#setup-tab-orders:checked) [for="setup-tab-orders"] span,
.setup-shell:has(#setup-tab-jobs:checked) [for="setup-tab-jobs"] span { color: var(--forest); }
.setup-shell:has(#setup-tab-people:checked) #setup-panel-people,
.setup-shell:has(#setup-tab-machines:checked) #setup-panel-machines,
.setup-shell:has(#setup-tab-terminals:checked) #setup-panel-terminals,
.setup-shell:has(#setup-tab-customers:checked) #setup-panel-customers,
.setup-shell:has(#setup-tab-orders:checked) #setup-panel-orders,
.setup-shell:has(#setup-tab-jobs:checked) #setup-panel-jobs,
.setup-shell:has(#setup-tab-erp:checked) #setup-panel-erp { display: block; }

.people-form {
  grid-template-columns: 1.1fr 0.8fr 0.7fr 1fr 1.1fr auto;
  align-items: end;
}
.people-form .hmi-btn { grid-column: auto; }

.job-form { display: grid; grid-template-columns: 1.2fr 1.2fr 0.55fr auto; align-items: end; }
.add-form { display: grid; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.add-form .field { margin-top: 0; }
.add-form .hmi-btn, .job-form .hmi-btn { justify-self: start; align-self: end; }
.job-form .hmi-btn { grid-column: 1 / -1; }
.panel-note { padding: 10px 16px 0; color: var(--ink-faint); font-size: 13px; }
.panel-flash { margin: 12px 16px 0; }
.muted { color: var(--ink-faint); font-size: 12.5px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; align-items: center; }
.inline-form input {
  width: 96px; min-height: 32px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--canvas); font-size: 13px;
}
.role-tag {
  font-style: normal; font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.role-tag.admin { color: var(--poppy); }
.role-tag.manager { color: var(--brand-accent); }
.role-tag.operator { color: var(--ink-faint); }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-actions form { margin: 0; }

/* --- charts ------------------------------------------------------------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.chart-body { padding: 14px 16px 16px; }
.spark { width: 100%; height: 76px; display: block; }
.chart-legend { margin: 0 0 12px; }
.day-cols { display: flex; align-items: flex-end; gap: 4px; height: 168px; }
.day-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.day-col small { color: var(--ink-faint); font-size: 10.5px; font-weight: 700; }
.stack { width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse; background: var(--surface-sunken); min-height: 4px; border-radius: 2px; overflow: hidden; }
.stack .seg { width: 100%; min-height: 0; }
.avail-bar { width: 100%; max-width: 30px; background: var(--brand-accent); min-height: 2px; border-radius: 2px; }
.hour-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; padding: 14px 16px 16px; }
.hour-cell { display: grid; gap: 5px; text-align: center; }
.hour-cell small { color: var(--ink-faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.heat { display: block; height: 28px; background: var(--poppy); border-radius: 3px; }
.machine-trends { display: grid; gap: 12px; padding: 14px 16px; }
.machine-trend { display: grid; gap: 4px; color: var(--ink); }
.machine-trend strong { font-size: 18px; font-weight: 650; }
.machine-trend em { font-style: normal; color: var(--ink-faint); font-size: 13px; }
.share-bar { display: inline-block; width: 76px; height: 8px; margin-right: 8px; background: var(--surface-sunken); vertical-align: middle; border-radius: 99px; overflow: hidden; }
.share-bar i { display: block; height: 100%; background: var(--gold); }
.run-fill { background: var(--leaf) !important; }
.delta.up { color: var(--leaf); }
.delta.down { color: var(--poppy); }

/* --- sign in ------------------------------------------------------------ */
.page-login { height: auto; min-height: 100%; }
.login-wrap {
  display: flex; min-height: 100vh;
}
.login-brand-panel {
  position: relative; overflow: hidden;
  display: none; flex-direction: column; justify-content: space-between;
  width: 46%; padding: 40px; color: #fff;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(0, 119, 192, 0.35), transparent 55%),
    linear-gradient(165deg, #071422 0%, #0b1f33 48%, #0a2740 100%);
}
@media (min-width: 901px) {
  .login-brand-panel { display: flex; }
}
.login-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background-image:
    linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 48px 48px;
}
.login-scene {
  position: absolute; inset: auto 0 0; width: 100%;
  color: #fff; opacity: .13; pointer-events: none;
}
.login-brand-panel .brand,
.login-hero,
.login-copy { position: relative; z-index: 1; }
.login-brand-panel .brand { border: 0; padding: 0; margin: 0; }
.login-hero h1 {
  max-width: 16ch; font-size: 30px; font-weight: 600;
  letter-spacing: -.025em; line-height: 1.15;
}
.login-hero p { margin-top: 16px; max-width: 36ch; color: rgba(255, 255, 255, 0.65); font-size: 14.5px; line-height: 1.6; }
.login-points { margin: 32px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.login-points li {
  display: flex; align-items: flex-start; gap: 10px;
  color: rgba(255, 255, 255, 0.7); font-size: 13px; line-height: 1.35;
}
.login-points svg { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 2px; color: var(--brand-accent); }
.login-copy { color: rgba(255, 255, 255, 0.35); font-size: 12px; }
.login-form-col {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 40px; background: var(--canvas);
}
.login-form-glow {
  position: absolute; inset: 0; pointer-events: none; opacity: .4;
  background: radial-gradient(ellipse 70% 50% at 80% 0%, rgba(0, 119, 192, 0.12), transparent 55%);
}
.login-mobile-brand { display: none; }
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px; padding: 32px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.login-card h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; color: var(--forest); }
.login-lead { margin: 4px 0 16px; color: var(--ink-faint); font-size: 13.5px; }
.login-alt { margin-top: 14px; text-align: center; font-size: 13px; }
.login-alt .text-link { margin-top: 0; background: none; color: var(--brand-accent); padding: 0; }
.narrow-panel { max-width: 460px; margin: 24px auto; }
.narrow-panel form { padding: 0 16px 16px; }

.people-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.person input { position: absolute; opacity: 0; width: 0; height: 0; }
.person span {
  display: grid; gap: 2px; min-height: 56px; padding: 10px 12px;
  background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.person strong { font-size: 14px; font-weight: 650; }
.person em { font-style: normal; color: var(--ink-faint); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.person input:checked + span { background: var(--brand-accent); border-color: var(--indigo-deep); color: #fff; }
.person input:checked + span em { color: rgba(255, 255, 255, 0.75); }
.person input:focus-visible + span { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

.pin-field input {
  min-height: 52px; font-size: 24px; letter-spacing: .4em; text-align: center;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.pad-key {
  min-height: 56px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-card);
  font-size: 22px; font-weight: 650; cursor: pointer;
}
.pad-key:hover { background: var(--surface-sunken); }
.pad-key:active { transform: scale(0.97); }
.wide-key { font-size: 13px; font-weight: 600; }
.signout {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-size: 12.5px; font-weight: 600;
}
.signout:hover { background: var(--surface-sunken); }

/* --- responsive --------------------------------------------------------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .nav-burger {
    display: grid; place-items: center;
    width: 32px; height: 32px; margin-left: -4px;
    border-radius: var(--radius); cursor: pointer; color: var(--ink-soft);
  }
  .nav-burger svg { width: 20px; height: 20px; }
  .nav-burger:hover { background: var(--surface-sunken); }
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0, 0, 0, 0.4); opacity: 0; pointer-events: none;
  }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: 220px;
    transform: translateX(-100%); transition: transform .2s var(--ease-out);
  }
  .nav-open:checked ~ .nav-scrim { opacity: 1; pointer-events: auto; }
  .nav-open:checked ~ .sidebar { transform: translateX(0); }
  .metrics, .select-grid, .job-form, .people-form, .chart-grid, .login-wrap { grid-template-columns: 1fr; }
  .action-grid, .action-grid.two { grid-template-columns: 1fr 1fr; }
  .hour-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  main { padding: 14px 14px 28px; }
  .page-intro, .work-head { flex-direction: column; align-items: flex-start; }
  .intro-actions { width: 100%; }
  .masthead { gap: 10px; padding: 0 16px; }
  .user-chip-copy { display: none; }
  .people-grid { grid-template-columns: 1fr; }
  .login-form-col { min-height: 100vh; padding: 40px 24px; }
  .login-mobile-brand {
    position: relative; z-index: 1;
    display: flex; justify-content: center; margin-bottom: 24px;
  }
  .login-mobile-brand .brand { color: var(--ink); }
  .login-mobile-brand .brand small { color: var(--ink-faint); }
  .login-card { padding: 24px; }
}

@media (max-width: 560px) {
  .action-grid, .action-grid.two { grid-template-columns: 1fr; }
  .inline-form { flex-wrap: wrap; }
  .metric-card strong { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .hmi-btn, .pad-key, .toast, .sidebar, .primary-nav a { transition: none; }
  .hmi-btn:active, .pad-key:active { transform: none; }
}
