@import url("https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap");

/* Design tokens — lifted from "KMKTH ERP.dc.html" › UI Kit page.
   Red = primary button / NG / delete only. Never a large background. */
:root {
  --red: #e01b24;
  --red-2: #b8141b;
  --ink: #14171c;
  --ink-2: #1c1f24;
  --canvas: #eef0f3;
  --pass: #1f8a4c;
  --warn: #c97a0a;
  --info: #2563a8;
  --text: #4a5260;
  --muted: #6a7280;
  --muted-2: #8a919c;
  --muted-3: #a8aeb8;
  --line: #d8dce2;
  --line-2: #e5e8ed;
  --line-3: #eef0f3;
  --surface-2: #f7f8fa;
  --surface-3: #f0f1f4;
  --rail: #1c1f24;
  --rail-2: #25292f;
  --rail-ink: #9aa2ae;
  --rail-line: #2e333a;
  --font: Sarabun, system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
  /* radius: 2 badge · 3 input/button · 4 card · 5 modal */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 12px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red); text-decoration: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes pop { from { transform: translateY(10px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shim { to { background-position: 200% 0; } }

/* ——————————— shell: 248px grouped sidebar (66px collapsed) + workspace ——————————— */
.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  overflow: hidden;
}
body.nav-collapsed .shell { grid-template-columns: 66px 1fr; }

.nav {
  background: var(--rail);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--rail-ink);
}
.nav-top {
  flex: none; height: 56px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--rail-line);
}
.nav-logo {
  width: 40px; height: 32px;
  border-radius: 3px; background: #fff; object-fit: contain;
  flex: none;
}
.nav-toggle {
  margin-left: auto;
  width: 26px; height: 26px; flex: none;
  border: 0; border-radius: 3px; background: none; cursor: pointer;
  color: var(--rail-ink);
  display: flex; align-items: center; justify-content: center;
}
.nav-toggle:hover { background: var(--rail-2); color: #fff; }
/* collapsed: logo over a flipped toggle, so re-expanding stays one click away */
body.nav-collapsed .nav-top { flex-direction: column; height: auto; gap: 4px; padding: 8px 6px; }
body.nav-collapsed .nav-toggle { margin: 0; transform: rotate(180deg); }

.nav-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 0 10px; }
.nav-scroll::-webkit-scrollbar { width: 6px; }
.nav-scroll::-webkit-scrollbar-thumb { background: #3a4048; border-radius: 3px; }

.nav-grp, .nav-item {
  width: 100%;
  border: 0; background: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  color: var(--rail-ink);
  text-align: left;
}
.nav-g { margin: 1px 6px; border-radius: 4px; }
.nav-g.is-open { background: rgba(255, 255, 255, .028); }
.nav-grp {
  padding: 9px 10px;
  border-radius: 4px;
  font: 500 12.5px/1.35 var(--font);
}
.nav-grp:hover { background: var(--rail-2); color: #fff; }
.nav-g.has-on > .nav-grp { color: #e7ebf0; }
.nav-grp svg { flex: none; }
.nav-grp .tx, .nav-item .tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-grp .cv { display: flex; flex: none; transform: rotate(-90deg); transition: transform .12s; opacity: .8; }
.nav-g.is-open > .nav-grp .cv { transform: rotate(-270deg); }

.nav-g.is-open .nav-sub { display: block; }
.nav-sub { display: none; padding: 0 4px 4px; }
.nav-item {
  position: relative;
  padding: 7px 8px 7px 22px;
  border-radius: 4px;
  font: 400 12px/1.35 var(--font);
}
.nav-item::before {
  content: ""; position: absolute; left: 13px; top: 0; bottom: 0;
  width: 1px; background: var(--rail-line);
}
.nav-item:hover { background: var(--rail-2); color: #fff; }
.nav-item.is-on {
  background: var(--red); color: #fff; font-weight: 500;
}
.nav-item.is-on::before { background: var(--red); }
.nav-item svg { flex: none; opacity: .85; }

.nav-badge {
  flex: none;
  min-width: 20px; height: 17px; padding: 0 5px;
  border-radius: 9px;
  background: var(--red); color: #fff;
  font: 600 10px/17px var(--mono);
  text-align: center;
}
.nav-item.is-on .nav-badge { background: rgba(0, 0, 0, .28); }

/* collapsed: icon rail — groups only, sub-items live behind the icon */
body.nav-collapsed .nav-grp { justify-content: center; padding: 11px 2px; }
body.nav-collapsed .nav-grp .tx,
body.nav-collapsed .nav-grp .cv,
body.nav-collapsed .nav-g.is-open .nav-sub,
body.nav-collapsed .nav-ver .v,
body.nav-collapsed .role-box { display: none; }
body.nav-collapsed .nav-g.has-on > .nav-grp { background: var(--rail-2); color: #fff; }
body.nav-collapsed .nav-g.has-on > .nav-grp::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; background: var(--red);
}
body.nav-collapsed .nav-g { position: relative; margin: 0; border-radius: 0; background: none; }
body.nav-collapsed .nav-grp { position: relative; border-radius: 0; }
body.nav-collapsed .nav-badge {
  position: absolute; top: 4px; right: 8px;
  min-width: 15px; height: 15px; padding: 0 3px;
  font: 600 9px/15px var(--mono);
}
body.nav-collapsed .nav-foot { padding: 8px 6px 10px; }
body.nav-collapsed .who { flex-direction: column; gap: 0; }
body.nav-collapsed .nav-ver { justify-content: center; }

.nav-foot {
  flex: none;
  border-top: 1px solid var(--rail-line);
  padding: 9px 10px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.who { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: #3a4048; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font: 700 10.5px/1 var(--mono);
}
.role-box { flex: 1; min-width: 0; }
.role-box span { display: none; }
#role {
  width: 100%; height: 28px; padding: 0 6px;
  border: 1px solid #3a4048; border-radius: 3px;
  background: var(--rail-2); color: #e7ebf0;
  font: 500 11px/1 var(--font);
}
.nav-ver { display: flex; align-items: center; gap: 8px; }
.nav-ver .v { flex: 1; min-width: 0; font: 500 10px/1.4 var(--font); color: #7c8592; }
.nav-ver .v b { color: #aab2bd; font-weight: 600; }
.nav-ver .tag {
  display: inline-block; padding: 0 4px; border-radius: 2px;
  background: #3a4048; color: #cfd5dd;
  font: 600 8.5px/14px var(--mono); letter-spacing: .4px;
}
.nav-ver .c { color: #626b77; font-size: 9.5px; }
.nav-book {
  width: 28px; height: 28px; flex: none;
  border: 1px solid #3a4048; border-radius: 3px;
  background: none; color: var(--rail-ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.nav-book:hover { background: var(--rail-2); color: #fff; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ——————————————————————— header 52px ——————————————————————— */
.app-bar {
  flex: none; height: 52px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.app-bar .ttl { min-width: 0; }
.app-bar .th { font: 600 15px/1.15 var(--font); letter-spacing: -.01em; white-space: nowrap; }
.app-bar .en {
  font: 400 9.5px/1.3 var(--mono);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-2); white-space: nowrap;
}
.app-bar .grow { flex: 1; }
.searchbox {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px; width: 290px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface-2);
}
.searchbox:focus-within { border-color: var(--ink); }
.searchbox input {
  border: 0; background: none; outline: none; flex: 1; min-width: 0;
  font: 400 12px/1 var(--font);
}
.kbd {
  font: 400 9px/1 var(--mono); color: var(--muted-3);
  border: 1px solid var(--line); border-radius: 2px; padding: 2px 4px;
}
.icon-btn {
  position: relative;
  width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: 3px;
  background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--ink); }
.dot-count {
  position: absolute; top: -5px; right: -5px;
  min-width: 15px; height: 15px; border-radius: 8px;
  background: var(--red); color: #fff;
  font: 700 9px/15px var(--mono); text-align: center;
}
.who {
  display: flex; align-items: center; gap: 7px;
  padding-left: 12px; border-left: 1px solid var(--line-2);
  text-align: right;
}
.who .nm { font: 500 11.5px/1.2 var(--font); }
.who .rl { font: 400 9px/1.2 var(--mono); color: var(--muted-2); text-transform: uppercase; }

/* ——————————————————————— tab bar 37px ——————————————————————— */
.tabs {
  flex: none; height: 37px;
  display: flex; align-items: stretch; gap: 2px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  position: relative;
  border: 0; background: none; cursor: pointer;
  padding: 0 12px;
  font: 500 12px/1 var(--font);
  color: var(--muted);
  white-space: nowrap;
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.is-on { color: var(--ink); font-weight: 600; }
.tab.is-on::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0;
  height: 2px; background: var(--red);
}

#main { flex: 1; min-height: 0; overflow: auto; padding: 13px 16px 44px; }

/* ——————————————————————— cards / sections ——————————————————————— */
.card, .sect {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.sect { margin-bottom: 9px; }
.sect-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line-2);
}
.sect-head h3 { margin: 0; font: 600 12.5px/1.2 var(--font); }
.sect-head .en {
  font: 400 9px/1 var(--mono);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-3);
}
.sect-head .grow { flex: 1; }
.sect-body { padding: 12px; }
.live {
  display: flex; align-items: center; gap: 5px;
  font: 400 10px/1 var(--font); color: var(--muted);
}
.live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--pass); animation: pulse 2s infinite;
}

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; margin-bottom: 9px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 9px 11px 10px; }
.kpi .lbl {
  font: 400 9px/1 var(--mono);
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .val { display: flex; align-items: baseline; gap: 3px; margin-top: 7px; }
.kpi .val b { font: 600 23px/1 var(--font); letter-spacing: -.02em; }
.kpi .val i { font: 400 10.5px/1 var(--font); color: var(--muted); font-style: normal; }
.kpi .meter { margin-top: 8px; height: 3px; background: var(--line-3); border-radius: 2px; overflow: hidden; }
.kpi .meter span { display: block; height: 100%; background: var(--pass); }

/* ——————————————————————— table ——————————————————————— */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; white-space: nowrap; cursor: pointer; user-select: none;
  padding: 6px 11px;
  font: 400 9px/1 var(--mono);
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.table th:hover, .table th.is-sorted { color: var(--ink); }
.table td {
  padding: 6px 11px;
  border-bottom: 1px solid var(--line-3);
  font: 400 11.5px/1.3 var(--font);
  white-space: nowrap;
}
.table td.id { font: 700 11px/1.3 var(--mono); }
.table td.code { font: 400 11px/1.3 var(--mono); color: var(--text); }
.table td.n { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-open { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--red); }
.row-acts { display: flex; gap: 5px; }

.table-top {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line-2);
}
.count { margin-left: auto; font: 400 9.5px/1 var(--mono); color: var(--muted-2); }

/* ——————————————————————— badges ——————————————————————— */
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 2px;
  font: 600 10px/1.5 var(--font);
  background: var(--surface-3); color: var(--text);
}
.badge-pass { background: var(--pass); color: #fff; font-weight: 700; }
.badge-ng { background: var(--red); color: #fff; font-weight: 700; }
.badge-ok { background: #e8f4ec; color: var(--pass); }
.badge-fail { background: #fde8e9; color: var(--red); }
.badge-warn { background: #fdf3e3; color: var(--warn); }
.badge-info { background: #eaf1f9; color: var(--info); }
.badge-dot { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; }
.badge-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-run { background: #e8f4ec; color: var(--pass); }
.badge-down { background: #fde8e9; color: var(--red); }
.badge-down::before { animation: pulse 1.4s infinite; }
.sev {
  display: inline-block; padding: 2px 8px; border-radius: 2px;
  font: 700 10px/1.7 var(--mono); text-transform: uppercase;
  border: 1px solid var(--muted-3); color: var(--muted);
}
.sev-critical { border-color: var(--red); color: var(--red); }
.sev-major { border-color: var(--warn); color: var(--warn); }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ——————————————————————— buttons (one primary per screen) ——————————————————————— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 33px; padding: 0 15px;
  border: 1px solid var(--line); border-radius: 3px;
  background: #fff; cursor: pointer;
  font: 500 12.5px/1 var(--font);
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); background: var(--surface-2); }
.btn-primary { border: 0; background: var(--red); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--red-2); }
.btn-secondary { border: 0; background: var(--ink-2); color: #fff; font-weight: 600; }
.btn-secondary:hover { background: #000; }
.btn-ghost { border: 0; background: none; color: var(--text); padding: 0 11px; }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { border-color: var(--red); color: var(--red); font-weight: 600; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 11px; }
.btn[disabled] { border-color: var(--line-2); background: var(--surface-2); color: var(--muted-3); cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ——————————————————————— fields ——————————————————————— */
.field { display: block; }
.field > .label { display: block; font: 500 11px/1.2 var(--font); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 3px;
  background: #fff; outline: none;
  font: 400 12px/1 var(--font);
}
.field input { font: 500 13px/1 var(--mono); }
.field textarea { height: auto; min-height: 66px; padding: 8px 10px; font: 400 12px/1.5 var(--font); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); }
.field .hint { display: block; margin-top: 4px; font: 400 10px/1.3 var(--font); color: var(--muted-2); }
.form-grid { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ——————————————————————— feedback / empty / bars ——————————————————————— */
.note {
  display: flex; gap: 8px;
  padding: 10px 11px; margin-bottom: 9px;
  border: 1px solid #e5d4b0; border-left: 3px solid var(--warn);
  border-radius: 3px; background: #fffbf3;
  font: 400 11px/1.45 var(--font); color: #8a6118;
}
.empty {
  padding: 16px; margin: 12px;
  border: 1px dashed var(--line); border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center;
}
.empty b { font: 600 12px/1.3 var(--font); color: var(--muted); }
.empty span { font: 400 10.5px/1.4 var(--font); color: var(--muted-3); }

.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 76px; gap: 10px; align-items: center; }
.bar-lbl { font: 400 11.5px/1.3 var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: var(--line-3); border-radius: 2px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ink-2); }
.bar-val { text-align: right; font: 700 11px/1 var(--mono); }

/* ——————————————————————— detail drawer ——————————————————————— */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; align-items: start; }
.layout.with-drawer { grid-template-columns: minmax(0, 1fr) 296px; }
.drawer { position: sticky; top: 0; }
.dr-row {
  display: grid; grid-template-columns: 96px 1fr; gap: 9px;
  padding: 6px 0; border-bottom: 1px solid var(--line-3);
}
.dr-row .k {
  font: 400 9.5px/1.5 var(--mono);
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2);
}
.dr-row .v { font: 400 11.5px/1.4 var(--font); word-break: break-word; }

/* ——————————————————————— modal (design: overlay .55 + blur, radius 5) ——————————————————————— */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 23, 28, .55);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 20px;
}
.overlay.center { align-items: center; padding: 32px 20px; }
.modal {
  width: 100%; max-width: 470px; max-height: 100%;
  display: flex; flex-direction: column;
  background: #fff; border-radius: 5px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  animation: pop .16s ease-out;
  overflow: hidden;
}
.modal.wide { max-width: 940px; }
.modal-head {
  flex: none; display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-2);
}
.modal-head h2 { margin: 0; font: 600 14.5px/1.25 var(--font); }
.modal-head .en {
  margin-top: 2px;
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2);
}
.modal-head .grow { flex: 1; }
.close {
  flex: none; width: 28px; height: 28px;
  border: 1px solid var(--line); border-radius: 3px;
  background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.close:hover { border-color: var(--ink); background: var(--surface-2); }
.modal-body { flex: 1; overflow: auto; padding: 15px 16px 17px; }
.modal-body.grey { padding: 14px 16px 18px; background: var(--surface-2); }
.modal-foot {
  flex: none; display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px;
  background: var(--surface-2); border-top: 1px solid var(--line-2);
}

/* module picker (design: "โมดูลทั้งหมด" overlay) */
.mod-group { margin-bottom: 16px; }
.mod-group > .g {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted-2);
  margin-bottom: 8px;
}
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 7px; }
.mod-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: #fff; border: 1px solid var(--line-2); border-radius: 3px;
  cursor: pointer; text-align: left;
}
.mod-item:hover { border-color: var(--ink); }
.mod-item.is-on { border-color: var(--red); }
.mod-item .tx { flex: 1; min-width: 0; }
.mod-item .th { display: block; font: 500 11.5px/1.25 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-item .en { display: block; font: 400 9px/1.3 var(--mono); color: var(--muted-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ——————————————————————— toast ——————————————————————— */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex; align-items: center; gap: 9px;
  min-width: 260px; max-width: min(460px, 90vw);
  padding: 11px 14px;
  background: var(--ink-2); color: #fff;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
  font: 500 12.5px/1.4 var(--font);
  pointer-events: none;
  opacity: 0; transition: opacity .15s ease;
}
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; flex: none; }
.toast.is-on { opacity: 1; }
.toast.ok::before { background: #6fdc9c; }
.toast.ng::before { background: #ff8b90; }

/* ——————————————————————— shop-floor tablet (design rule: ปุ่ม ≥46px) ——————————————————————— */
.tablet .btn { min-height: 46px; padding: 0 18px; font-size: 14px; }
.tablet .btn-xs { min-height: 46px; padding: 0 12px; font-size: 13px; }  /* UI Kit: ปุ่มหน้างาน ≥46px (กดด้วยถุงมือ) */
.tablet .table td { padding: 11px; font-size: 13.5px; }
.tablet .field input, .tablet .field select { height: 46px; font-size: 15px; }

body.role-customer .nav-item:not([data-slug="portal"]),
body.role-customer .nav-grp { opacity: .3; pointer-events: none; }

/* ——————————————————————— print ——————————————————————— */
.print-sheet { background: #fff; color: #000; padding: 24px; border: 1px solid var(--line); }
@media print {
  .nav, .app-bar, .tabs, .toast, .overlay, .row-acts, .table-top { display: none !important; }
  .shell { display: block; height: auto; }
  #main { overflow: visible; padding: 0; }
}

@media (max-width: 860px) {
  .layout.with-drawer { grid-template-columns: minmax(0, 1fr); }
  .searchbox { width: 160px; }
  .who { display: none; }
}

/* ——————————————————————— dense dashboard (design: "Executive Dashboard") ——————————————————————— */
.grid2 { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); gap: 9px; align-items: start; }
.gcol { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.gcol > .sect { margin-bottom: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px; }
.split > .sect { margin-bottom: 0; }

.kpi .delta { margin-left: auto; font: 700 9.5px/1 var(--mono); }
.kpi .delta.up { color: var(--pass); }
.kpi .delta.dn { color: var(--red); }
.pill { padding: 1px 6px; border-radius: 2px; background: #fde8e9; color: var(--red); font: 700 9.5px/1.6 var(--mono); }
.cap {
  margin-bottom: 8px; font: 400 9px/1 var(--mono);
  letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2);
}

/* WIP by process — label over a full-width bar */
.bars-stack { display: grid; gap: 9px; }
.bars-stack .hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.bars-stack .hd span { font: 400 11.5px/1.2 var(--font); color: var(--text); }
.bars-stack .hd b { font: 600 11px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.bars-stack .bar-track { display: block; height: 6px; border-radius: 3px; }
.bars-stack .bar-fill { background: var(--info); }

/* energy — stacked columns, LPG red over electricity ink */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 104px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; }
.chart .stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 2px; }
.chart .s-a { display: block; background: var(--red); border-radius: 2px 2px 0 0; }
.chart .s-b { display: block; background: var(--ink-2); }
.chart .x { font: 400 9px/1 var(--mono); color: var(--muted-2); }
.legend { display: flex; gap: 14px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-3); }
.legend span { display: flex; align-items: center; gap: 5px; font: 400 10.5px/1 var(--font); color: var(--muted); }
.legend i { width: 8px; height: 8px; border-radius: 1px; }
.legend .k-a { background: var(--red); }
.legend .k-b { background: var(--ink-2); }

/* alert feed */
.fd { display: flex; gap: 9px; padding: 9px 11px; border-bottom: 1px solid var(--line-3); cursor: pointer; }
.fd:last-child { border-bottom: 0; }
.fd:hover { background: var(--surface-2); }
.fd .rail { flex: none; width: 3px; border-radius: 2px; background: var(--info); }
.fd > div { min-width: 0; flex: 1; }
.fd .hd { display: flex; justify-content: space-between; gap: 8px; }
.fd .kind { font: 400 9px/1.2 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--info); }
.fd .tm { font: 400 9px/1.2 var(--mono); color: var(--muted-3); white-space: nowrap; }
.fd .msg { margin-top: 3px; font: 400 11.5px/1.4 var(--font); color: var(--ink); }
.fd .ref { margin-top: 2px; font: 400 10px/1.3 var(--mono); color: var(--muted-2); }
.fd-fail .rail, .fd-fail .kind { background: var(--red); color: var(--red); }
.fd-fail .kind { background: none; }
.fd-warn .rail { background: var(--warn); }
.fd-warn .kind { color: var(--warn); }

/* 3-up mini stats */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.st { border: 1px solid var(--line-2); border-radius: 3px; padding: 8px 9px; }
.st b { display: block; font: 600 20px/1 var(--font); }
.st span { display: block; margin-top: 5px; font: 400 10.5px/1.2 var(--font); color: var(--text); }
.st-fail { background: #fdf2f3; } .st-fail b { color: var(--red); }
.st-warn { background: #fdf6e9; } .st-warn b { color: var(--warn); }
.st-ok   { background: #eef7f1; } .st-ok b   { color: var(--pass); }
.st-info { background: var(--surface-2); } .st-info b { color: var(--info); }

/* dark delivery card */
.sect-dark { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.sect-dark .sect-head { border-bottom-color: var(--rail-line); }
.sect-dark .sect-head h3 { color: #fff; }
.sect-dark .sect-head .en { color: #7c838f; }
.tl { padding: 2px 12px 10px; }
.tl-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--rail-line); }
.tl-row:last-child { border-bottom: 0; }
.tl-row .t { flex: none; width: 58px; font: 700 11px/1 var(--mono); color: #fff; }
.tl-row .m { flex: 1; min-width: 0; }
.tl-row .a { font: 400 11.5px/1.3 var(--font); color: #e8eaee; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row .b { font: 400 9.5px/1.3 var(--mono); color: #7c838f; }

@media (max-width: 1180px) {
  .grid2, .split { grid-template-columns: minmax(0, 1fr); }
}
.bars-red .bar-fill { background: var(--red); }   /* design: Pareto defect bars are red */
