/* Light, minimal theme for everyone; administrators (data-theme="auto") follow the OS and may get dark. */
:root {
  /* Soft grey rather than pure white: easier on the eyes on bright factory screens. */
  --bg: #e9ecf0;
  --surface: #f5f6f8;
  --text: #1f2933;
  --muted: #5f6b78;
  --line: #d5dae1;
  --input-bg: #fbfbfc;
  --primary: #1f6feb;
  --primary-text: #ffffff;
  --danger: #c62828;
  --warn-bg: #fff4e0;
  --warn-text: #8a5300;
  --info-bg: #e8f1ff;
  --lead-bg: #f1edff; --lead-text: #45348f;
  --info-text: #1c4f99;
  --ok: #2e7d32;
  --radius: 10px;
  /* Same font stack as the legacy system (smc-system.net). */
  font-family: "Noto Sans Thai", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #11161c; --surface: #1a212a; --input-bg: #1a212a; --text: #e6edf3; --muted: #9aa7b4; --line: #2c3642;
    --primary: #4c8dff; --warn-bg: #3a2c12; --warn-text: #ffcc80; --info-bg: #16263d; --info-text: #9cc2ff; --lead-bg: #241d3d; --lead-text: #c9bcff;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.topbar { display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.brand span { color: var(--primary); }
.brand { display: inline-flex; align-items: center; gap: .5rem; }
/* The logo artwork has an opaque white background, so it sits on a white chip in dark mode too. */
.brand img, .auth-logo { background: #fff; border-radius: 8px; object-fit: contain; }
.brand img { padding: 2px; }
.auth-card { text-align: left; }
.auth-logo { display: block; margin: 0 auto 1rem; padding: 6px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); }
.nav a.active, .nav a:hover { background: var(--info-bg); color: var(--info-text); }
.user { display: flex; align-items: center; gap: .5rem; }
/* Phones and portrait tablets: logo + logout on the first row, the menu as one full-width row you swipe sideways
   (was squeezed into a narrow column between them, one word per line on phones). */
@media (max-width: 1023px) {
  .topbar { gap: .35rem .75rem; padding: .4rem .75rem; }
  .topbar .user { margin-left: auto; }
  .topbar .nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -.75rem; padding: 0 .75rem; }
  .topbar .nav::-webkit-scrollbar { display: none; }
  .topbar .nav a { flex: none; white-space: nowrap; }
}

.main { padding: 1rem; max-width: 1400px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.panel.narrow { max-width: 520px; margin: 2rem auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.subnav { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.subnav a { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.subnav a.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

.auth-card { max-width: 400px; margin: 10vh auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2rem; }

.form { display: grid; gap: .85rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; align-content: start; }
input, select, textarea { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--input-bg); color: var(--text); min-height: 44px; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.manual { max-width: 1100px; margin: 0 auto; }
.manual-bar { position: sticky; top: var(--topbar-h, 0px); z-index: 3; background: var(--surface); padding: .5rem 0; margin-bottom: 1rem;
  border-bottom: 1px solid var(--line); display: grid; gap: .45rem; }
.manual-roles, .manual-steps { display: flex; flex-wrap: wrap; gap: .35rem; }
.manual-roles .btn.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.manual-steps a { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--text); font-size: .9rem; white-space: nowrap; }
/* Phones: each row is one line you swipe sideways, so the bar stays small while it follows the scroll. */
@media (max-width: 700px) {
  .manual-roles, .manual-steps { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .manual-roles .btn { white-space: nowrap; flex: none; }
  /* The phone menu is several lines tall: let it scroll away here so only the button bar stays pinned. */
  body[data-page="manual"] .topbar { position: static; }
}
.manual-steps a:hover { border-color: var(--primary); color: var(--primary); }
.manual-page { margin: 0 0 1.5rem; scroll-margin-top: var(--manual-bar, 7rem); }
.manual-page figcaption { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; margin-bottom: .4rem; }
.manual-page figcaption .muted { margin-left: auto; font-weight: 400; }
.manual-no { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--primary); color: var(--primary-text); font-size: .9rem; }
.manual-page img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; box-sizing: border-box; padding-right: 3rem; }
.pw-eye { position: absolute; top: 0; right: 0; height: 100%; width: 2.9rem; display: grid; place-items: center;
  border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 0 8px 8px 0; }
.pw-eye:hover, .pw-eye:focus-visible { color: var(--text); }
.field-error { color: var(--danger); font-size: .85rem; font-weight: 400; }
.form-error { color: var(--danger); min-height: 1.2em; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .85rem; }
.checks { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; padding: .75rem; }
.checks label { display: flex; align-items: center; gap: .4rem; font-weight: 400; }
.checks input { min-height: auto; width: 1.1rem; height: 1.1rem; }

.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: .45rem .9rem; cursor: pointer; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 52px; font-size: 1.05rem; justify-content: center; }
.btn.sm { min-height: 32px; padding: .2rem .55rem; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: progress; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tr[data-clickable] { cursor: pointer; }
.table tr[data-clickable]:hover { background: var(--info-bg); }
.table td.actions { white-space: nowrap; text-align: right; }
/* Audit log: the first four columns keep their width, "what changed" takes the rest and wraps (owner 2026-11-16). */
.audit-table { table-layout: fixed; min-width: 50rem; }
.audit-table .c-at { width: 8.5rem; }
.audit-table .c-who { width: 8rem; }
.audit-table .c-act { width: 11rem; }
.audit-table .c-item { width: 10.5rem; }
.audit-table td { overflow-wrap: anywhere; }
/* Changed fields run on one line, separated by a dot, and wrap when the column is full (owner 2026-11-16). */
.audit-diff > div { display: inline-block; max-width: 100%; }
.audit-diff > div:not(:last-child)::after { content: "  ·  "; white-space: pre; color: var(--muted); }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--info-bg); color: var(--info-text); margin: 0 .2rem .2rem 0; }
.badge.off { background: var(--warn-bg); color: var(--warn-text); }
.badge.ok { background: #e3f4e5; color: var(--ok); }

.notice { padding: .7rem .9rem; border-radius: 8px; margin: .75rem 0; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.info { background: var(--info-bg); color: var(--info-text); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.tiles a { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--text); background: var(--bg); }
.tiles a:hover { border-color: var(--primary); }

.dialog { border: none; border-radius: var(--radius); padding: 1.5rem; max-width: 460px; width: calc(100% - 32px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog.wide { max-width: 820px; }
.dialog-x { position: sticky; top: 0; justify-self: end; z-index: 3; width: 2.4rem; height: 2.4rem; margin: -.6rem -.6rem -2.6rem 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text); font-size: 1.15rem; line-height: 1;
  cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.dialog-x:hover, .dialog-x:focus-visible { background: #fdecea; border-color: var(--danger); color: var(--danger); }
.dialog::backdrop { background: rgba(10, 15, 20, .45); }
.dialog .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
/* askConfirm(): the system's own confirmation box (owner 2026-11-14) */
.confirm-dialog { max-width: 420px; border-top: 6px solid var(--primary); }
.confirm-dialog.danger { border-top-color: var(--danger); }
.confirm-head { display: flex; align-items: center; gap: .75rem; }
.confirm-head h2 { margin: 0; font-size: 1.15rem; }
.confirm-icon { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  font-size: 1.2rem; background: var(--info-bg, #e8f0fe); color: var(--primary); }
.confirm-dialog.danger .confirm-icon { background: #fdecea; color: var(--danger); }
.confirm-message { margin: 1rem 0 .25rem; font-size: 1.02rem; white-space: pre-line; }
.confirm-detail { margin: 0; white-space: pre-line; }
.confirm-dialog .actions .btn { min-width: 7.5rem; }
.confirm-field { display: grid; gap: .35rem; margin-top: 1rem; font-weight: 600; }
.confirm-field input { font-weight: 400; }
@media (max-width: 480px) { .confirm-dialog .actions { flex-direction: column-reverse; } .confirm-dialog .actions .btn { width: 100%; } }
.code { font-family: Consolas, monospace; font-size: 1.8rem; letter-spacing: .15em; text-align: center; padding: .5rem;
  border: 1px dashed var(--line); border-radius: 8px; user-select: all; }
.perm-groups { display: grid; gap: .75rem; max-height: 60vh; overflow: auto; }
.perm-groups fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; display: grid; gap: .3rem; }
.perm-groups label { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.perm-groups code { color: var(--muted); font-size: .8rem; }

.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #222; color: #fff;
  padding: .6rem 1rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50; }
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
pre.diff { white-space: pre-wrap; font-size: .8rem; margin: 0; max-width: 520px; max-height: 160px; overflow: auto; }

@media (max-width: 640px) {
  .main { padding: .5rem 16px; }
  .panel { padding: 1rem; }
  .user a:not(.bell) { display: none; }
}

/* ---------------------------------------------------------------- planning */
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.bad { background: #fdecea; color: var(--danger); font-weight: 700; }
.legend { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; }
.dot.pub { background: var(--primary); }
.dot.draft { border: 2px dashed var(--primary); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month-grid .dow { text-align: center; color: var(--muted); font-weight: 600; padding: .25rem 0; }
.month-grid .day { min-height: 108px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; text-align: left; padding: .35rem .45rem; display: flex; flex-direction: column; gap: 2px; cursor: pointer; overflow: hidden; }
.month-grid .day:hover { border-color: var(--primary); }
.month-grid .day.empty { border: none; background: transparent; cursor: default; }
.month-grid .day.today { outline: 2px solid var(--primary); }
.month-grid .day.holiday { background: var(--warn-bg); }
.month-grid .num { font-weight: 700; }
.month-grid .cnt { font-weight: 600; font-size: .9rem; }
.month-grid .sub, .month-grid .hol { font-size: .8rem; color: var(--muted); }
.month-grid .ratio { height: 6px; border-radius: 3px; background: repeating-linear-gradient(45deg, var(--line) 0 4px, transparent 4px 8px); overflow: hidden; margin: 2px 0; }
.month-grid .ratio .pub { display: block; height: 100%; background: var(--primary); }
.month-grid .badge { font-size: .72rem; }

/* The line list scrolls inside its own box, the time scale stays on top (owner 2026-11-12). */
.timeline { overflow: auto; border: 1px solid var(--line); border-radius: 8px; max-height: calc(100vh - 230px); min-height: 320px; }
.tl-row { display: grid; grid-template-columns: 150px minmax(900px, 1fr); border-bottom: 1px solid var(--line); min-height: 52px; }
.tl-row:last-child { border-bottom: none; }
.tl-head { min-height: 30px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.tl-label { padding: .35rem .5rem; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center;
  position: sticky; left: 0; background: var(--surface); z-index: 1; font-size: .9rem; }
.tl-label small { color: var(--muted); }
.tl-track { position: relative; }
.tl-track.off { background: repeating-linear-gradient(45deg, var(--warn-bg) 0 6px, transparent 6px 12px); }
.tl-head .tick { position: absolute; top: 6px; transform: translateX(-50%); font-size: .75rem; color: var(--muted); }
.tl-track .brk { position: absolute; top: 0; bottom: 0; background: var(--line); opacity: .6; }
.tl-track .bar { position: absolute; top: 5px; bottom: 5px; border-radius: 6px; border: 2px solid var(--primary); background: var(--primary);
  color: var(--primary-text); font: inherit; font-size: .78rem; text-align: left; padding: 2px 6px; overflow: hidden; white-space: nowrap;
  display: flex; flex-direction: column; justify-content: center; cursor: pointer; line-height: 1.25; }
.tl-track .bar.draft { background: var(--info-bg); color: var(--info-text); border-style: dashed; }
.tl-track .bar.revised { background: #6f42c1; border-color: #6f42c1; }
.tl-track .bar.cancelled { opacity: .4; }
.tl-track .bar strong, .tl-track .bar span { overflow: hidden; text-overflow: ellipsis; }
.tl-track .bar .ack, .tl-track .bar .issue { position: absolute; right: 4px; top: 2px; font-weight: 700; }
.tl-track .bar .issue { color: #ffd54f; right: 16px; }

.dialog.xwide { max-width: 1100px; }
.plan-form-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 1rem; }
.span2 { grid-column: 1 / -1; }
.calc { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; }
.calc h3 { margin: 0 0 .5rem; font-size: 1rem; }
.calc dl, dl.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin: 0; }
.calc dt, dl.kv dt { color: var(--muted); }
.calc dd, dl.kv dd { margin: 0; font-weight: 600; }
.conflicts { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .35rem; }
.conflicts li { padding: .4rem .6rem; border-radius: 6px; font-size: .9rem; }
.conflicts li.block { background: #fdecea; color: var(--danger); }
.conflicts li.warning { background: var(--warn-bg); color: var(--warn-text); }
/* Overlapping plan times are allowed but stand out in orange-red (owner 2026-11-12). */
.conflicts li.line_overlap { background: #fff1e6; color: #c2410c; border-left: 4px solid #ea580c; font-weight: 600; }
.tl-track .bar.overlap { border-color: #ea580c; box-shadow: 0 0 0 2px #ea580c; }
/* Calculated read-outs look different from boxes you type in. */
input.calc-out { background: var(--line); border-style: dashed; color: var(--text); font-weight: 700; cursor: default; }
input.calc-out:focus { outline: none; }
.calc-how { display: block; font-size: .72rem; color: var(--muted); font-weight: 400; }
/* Basket (Supervisor ผลิต) */
.basket-h { font-size: 1.05rem; margin: 1rem 0 .5rem; display: flex; align-items: center; gap: .5rem; }
.basket-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .75rem; }
.basket-card { border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; background: var(--surface); display: grid; gap: .5rem; }
.basket-card.sent { opacity: .85; }
.basket-card.held { border-color: #ea580c; }
.basket-head { display: flex; flex-direction: column; gap: .2rem; }
.basket-head .basket-item strong { font-size: 1.02rem; }
/* ก.76: which line the plan is for and its planned time open the card, large. */
.basket-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .5rem; }
.basket-line-cap { font-size: .8rem; color: var(--muted); font-weight: 600; }
.basket-line strong { font-size: 1.45rem; line-height: 1.15; }
.basket-facts dd.basket-lead .who-name { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.basket-facts dd.basket-lead .who-user { font-size: .85rem; }
.basket-facts dt.basket-lead-cap { align-self: center; }
.basket-facts { display: grid; grid-template-columns: auto 1fr; gap: .15rem .75rem; margin: 0; font-size: .9rem; }
.basket-facts dt { color: var(--muted); }
.basket-facts dd { margin: 0; }
.basket-actions { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.basket-actions .span-all { flex-basis: 100%; }
.basket-actions .basket-workers { flex: 0 0 90px; min-width: 90px; }
.basket-problem { flex-basis: 100%; display: flex; gap: .4rem; flex-wrap: wrap; }
.basket-problem input { flex: 1; min-width: 140px; }
.basket-preview { flex-basis: 100%; background: var(--bg); border-radius: 6px; padding: .35rem .5rem; }
.basket-preview .overlap-line { color: #c2410c; font-weight: 600; }
.btn.warn-btn { background: #ea580c; border-color: #ea580c; color: #fff; }
.basket-actions label { display: grid; gap: .2rem; flex: 1; min-width: 160px; font-size: .85rem; font-weight: 600; }
/* "+ สร้างงาน" in the basket while planning is off (owner 2026-11-16, ก.42). */
.quick-job { margin-bottom: 1rem; }
.quick-job h2 { margin-top: 0; }
.quick-job h3 { font-size: .95rem; margin: 1rem 0 .5rem; padding-top: .75rem; border-top: 1px dashed var(--line); }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.quick-grid label { display: grid; gap: .2rem; align-content: start; font-size: .85rem; font-weight: 600; }
.quick-grid .span-2 { grid-column: span 2; }
/* ตั้งค่าการผลิต (owner 2026-11-16, ก.43). */
.prod-settings .panel { margin-bottom: 1rem; }
.prod-settings h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.ps-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.ps-num { display: grid; gap: .35rem; align-content: start; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--input-bg); }
.ps-num b { font-size: .9rem; }
.ps-num-row { display: flex; align-items: center; gap: .5rem; }
.ps-num input { width: 6rem; font-size: 1.15rem; font-weight: 700; text-align: right; }
.prod-settings .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.ps-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.ps-table-wrap { overflow-x: auto; }
.ps-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ps-table th, .ps-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.ps-table th { font-size: .82rem; color: var(--muted); font-weight: 600; }
.ps-table .ps-act { text-align: right; white-space: nowrap; width: 1%; }
.ps-chip { display: inline-flex; align-items: center; gap: .3rem; margin: 0 .35rem .35rem 0; padding: .15rem .55rem; border-radius: 999px;
  background: var(--info-bg); color: var(--info-text); font-size: .85rem; }
.ps-chip.default { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.ps-chip.stop { background: var(--warn-bg); color: var(--warn-text); }
.ps-stops { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-bottom: .6rem; }
.ps-stops > b { font-size: .85rem; margin-right: .35rem; }
.ps-stops .ps-chip { margin: 0; }
.ps-x { border: 0; background: none; color: inherit; font-size: 1rem; line-height: 1; cursor: pointer; padding: 0 .1rem; }
.ps-break-form, .ps-stop-form, .ps-times { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .4rem; }
.ps-stop-form { gap: .75rem; padding: .75rem; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: .75rem; }
.ps-stop-form label { display: grid; gap: .2rem; font-size: .85rem; font-weight: 600; }
.ps-stop-form .ps-check { display: flex; align-items: center; gap: .35rem; }
.ps-stop-form .ps-reason { flex: 1; min-width: 220px; }
@media (max-width: 700px) { .ps-nums { grid-template-columns: 1fr; } }
.time24 { display: flex; align-items: center; gap: .35rem; font-weight: 600; }
.time24 select { width: auto; min-width: 4.2rem; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-top: .75rem; }
.pager-nav { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.pager-nav .btn[disabled] { opacity: .45; cursor: default; }
.time-now { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.quick-calc { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; padding: .75rem; border-radius: 8px;
  background: var(--info-bg); color: var(--info-text); }
.quick-calc strong { display: block; font-size: 1.15rem; color: var(--text); }
.quick-job .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
@media (max-width: 700px) {
  .quick-grid, .quick-calc { grid-template-columns: 1fr 1fr; }
  .quick-grid .span-2 { grid-column: 1 / -1; }
}
/* Product fixed by a sales order: shown, not changeable. */
.combo input[readonly] { background: var(--line); cursor: not-allowed; }
.combo:has(input[readonly]) .combo-arrow { display: none; }
/* "Back to the month" stands apart from the date arrows (owner 2026-11-13). */
.day-range-bar { display: flex; justify-content: flex-end; margin-bottom: .4rem; }
#day-range.has-late { background: #fff7f0; border-color: #ea580c; color: #9a3412; font-weight: 700; }
.tl-track .bar.cut { border-right-style: dashed; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tl-track .bar.cut::after { content: '→'; position: absolute; right: 3px; bottom: 2px; font-weight: 700; }
.btn.back-btn { background: #475569; border-color: #475569; color: #fff; font-weight: 600; }
.btn.back-btn:hover { background: #334155; border-color: #334155; }
.order-search { margin-bottom: .6rem; }
.order-search input { width: 100%; max-width: 360px; }
.order-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; border: 2px dashed #ea580c; background: #fff7f0;
  color: #9a3412; border-radius: 8px; padding: .5rem .75rem; margin-bottom: .6rem; font-weight: 600; }
.order-pick select { flex: 1; min-width: 260px; font-weight: 400; }
.order-banner.urgent { border-color: var(--danger); background: #fdecea; color: var(--danger); }
.order-banner { border: 2px solid var(--primary); background: var(--info-bg); color: var(--info-text); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .6rem; }
.overlap-box { border: 2px solid #ea580c; background: #fff1e6; color: #9a3412; border-radius: 8px; padding: .55rem .8rem; margin-bottom: .75rem; }
.overlap-box ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.overlap-box li { margin: .15rem 0; }
.overlap-box .badge { margin-left: .4rem; }
.overlap-dialog { max-width: 560px; border-top: 6px solid #ea580c; }
.overlap-dialog h2 { color: #c2410c; margin-top: 0; }
.overlap-dialog .overlap-yes { background: #ea580c; border-color: #ea580c; }
.push-choice { border: 2px solid #ea580c; border-radius: 8px; padding: .5rem .75rem; display: grid; gap: .35rem; background: #fff7f0; }
.push-choice legend { font-weight: 700; color: #c2410c; padding: 0 .3rem; }
.push-choice label { display: flex; align-items: center; gap: .45rem; font-weight: 400; }
.push-choice input { min-height: auto; width: 1.1rem; height: 1.1rem; }
.file-btn { cursor: pointer; }
.import-rows { max-height: 50vh; overflow: auto; }
@media (max-width: 860px) {
  .plan-form-grid { grid-template-columns: 1fr; }
  .month-grid .day { min-height: 72px; font-size: .8rem; }
  .month-grid .sub, .month-grid .badge { display: none; }
}
.table code { white-space: nowrap; }
.impact { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .3rem; font-size: .9rem; }
#calc-impact h3 { margin: .75rem 0 0; font-size: .95rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; border: none; border-right: 1px solid var(--line); background: var(--surface); color: var(--text); padding: .4rem .75rem; min-height: 40px; cursor: pointer; }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--primary); color: var(--primary-text); }
.tl-track .bar.compact { padding: 2px 3px; font-size: .7rem; }
.tl-track .bar.compact .ack, .tl-track .bar.compact .issue { display: none; }
.tl-head .tick { white-space: nowrap; }
.tl-head .tick.day-tick { transform: none; padding-left: 4px; border-left: 2px solid var(--line); font-weight: 600; color: var(--text); }

/* ---------------------------------------------------------------- floor / tablet */
.tablet-shell { max-width: 900px; margin: 0 auto; }
.tablet-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.tablet-head img { background: #fff; border-radius: 10px; padding: 4px; }
.tablet-head h1 { margin: 0; }
.big-input { font-size: 2rem; letter-spacing: .2em; text-align: center; min-height: 64px; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.person { font: inherit; min-height: 96px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  display: flex; flex-direction: column; justify-content: center; gap: .25rem; cursor: pointer; padding: .75rem; }
.person strong { font-size: 1.3rem; }
.person span { color: var(--muted); font-size: .9rem; }
.person.no-pin { opacity: .55; }
.pin-dialog { max-width: 380px; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: .75rem; margin: 1rem 0; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots span.on { background: var(--primary); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .75rem 0; }
.keypad .key { font: inherit; font-size: 1.6rem; font-weight: 700; min-height: 72px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); cursor: pointer; touch-action: manipulation; }
.keypad .key:active { background: var(--info-bg); }

.floor { max-width: 1100px; margin: 0 auto; display: grid; gap: 1rem; }
.queue-banner { background: var(--info-bg); color: var(--info-text); border-radius: 10px; padding: .6rem .9rem; }
.queue-banner.offline { background: #fdecea; color: var(--danger); }
.todo { border: 2px solid var(--primary); border-radius: 12px; padding: .75rem; }
.todo h2 { margin: 0 0 .5rem; }
.job-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .75rem; }
.job-card { display: grid; gap: .3rem; border: 1px solid var(--line); border-left: 6px solid var(--muted); border-radius: 12px; padding: .9rem 1rem;
  background: var(--surface); color: var(--text); text-decoration: none; }
.job-card.run { border-left-color: #2e7d32; } .job-card.wait { border-left-color: #9e9e9e; } .job-card.pause { border-left-color: #ef6c00; }
/* ก.89: a band across the card of a job whose machine is down. */
.job-card.down { position: relative; border-color: var(--danger); border-left-color: var(--danger); overflow: hidden; }
.job-card.down > :not(.job-down) { opacity: .4; }
.job-down { position: absolute; left: -1px; right: -1px; top: 50%; transform: translateY(-50%) rotate(-4deg); z-index: 1; display: grid; gap: .1rem; justify-items: center;
  padding: .55rem 1.2rem; margin: 0 -1rem; background: var(--danger); color: #fff; text-align: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.job-down strong { font-size: 1.1rem; } .job-down span { font-size: .85rem; }
/* ก.107: a job set aside — the same band as a breakdown, in amber. */
.job-card.held { position: relative; border-color: var(--warn-text); border-left-color: var(--warn-text); overflow: hidden; }
.job-card.held > :not(.job-down) { opacity: .45; }
.job-down.job-held { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-text); }
.job-card.close { border-left-color: #6f42c1; } .job-card.done { border-left-color: var(--primary); }
.job-card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
/* ก.109: the line on a band across the top of the card, large; the line lead in a box under it. */
.job-card-line { margin: -.9rem -1rem .25rem; padding: .5rem 1rem; border-bottom: 1px solid var(--line); border-radius: 0 11px 0 0;
  background: color-mix(in srgb, var(--text) 7%, transparent); }
.job-card-line strong { font-size: 1.7rem; line-height: 1.1; letter-spacing: .01em; }
.job-lead-box { display: grid; gap: .05rem; padding: .4rem .65rem; margin-bottom: .2rem; border: 1px solid var(--line); border-radius: 8px; }
.job-lead-cap { font-size: .75rem; color: var(--muted); font-weight: 600; }
.job-lead-box .job-lead { font-size: 1.2rem; line-height: 1.2; }
.job-lead-box.none .job-lead { color: var(--muted); font-size: 1rem; font-weight: 600; }
.job-lead-entry { font-size: .85rem; color: var(--muted); }
/* ก.109: งานที่ปิดไปแล้ว in the basket — one production day at a time. */
/* ก.125: the basket's line filter */
.basket-line-filter { display: flex; align-items: center; gap: .5rem; margin: 0 0 .6rem; font-weight: 600; }
.basket-line-filter select { width: auto; min-width: 12rem; max-width: 100%; }
.done-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.done-filter input[type="date"] { width: auto; }
/* ก.110: when a closed job was closed. */
.job-closed-at { font-size: .9rem; color: var(--primary); }
/* ก.124: the plan maker's note on the card */
.plan-note { padding: .3rem .55rem; border-left: 3px solid var(--warn, #d97706); border-radius: 4px; font-size: .92rem; line-height: 1.35;
  background: color-mix(in srgb, var(--warn, #d97706) 12%, transparent); white-space: pre-wrap; overflow-wrap: anywhere; }
.plan-note-cap { display: block; font-size: .75rem; font-weight: 700; color: var(--muted); }
.job-time { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .6rem; margin: .1rem 0; }
.job-time strong { font-size: 1.45rem; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--primary); white-space: nowrap; }
.job-time strong span { font-size: .85rem; font-weight: 600; }
/* ก.64: the oven room's form — hours across, เป้า/ชม. over ทำได้จริง, then ปัญหาที่พบ and ประสิทธิภาพ. */
.sheet-grid.oven-form th { position: static; text-align: center; }
.sheet-grid.oven-form th.of-label { text-align: left; white-space: nowrap; }
.sheet-grid.oven-form th.of-hour { min-width: 104px; }
.sheet-grid.oven-form td.of-item { white-space: normal; min-width: 180px; max-width: 260px; padding: 8px 10px; vertical-align: top; }
.sheet-grid.oven-form td.of-qty { padding: 8px 10px; vertical-align: top; }
.sheet-grid.oven-form td { text-align: center; }
.sheet-grid.oven-form td.num { text-align: center; font-weight: 600; }
.sheet-grid.oven-form td.rest { color: var(--muted); }
.sheet-grid.oven-form td.small { font-size: .8rem; white-space: normal; max-width: 130px; }
.sheet-grid.oven-form td.low { color: var(--danger); }
.sheet-grid.oven-form .cell-btn { width: 100%; min-height: 40px; }
.sheet-grid.oven-form tr.of-head + tr td { border-top: 0; }
.job-time-day { font-size: .9rem; font-weight: 600; color: var(--text, inherit); }
.job-time strong .job-time-pre { font-size: .9rem; }
.job-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.job-tag { padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.job-tag.late { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.job-tag.early { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.job-tag.jump { background: var(--warn-bg); color: var(--warn-text); }
/* ก.69: a job for several lines — extra lines in the create form, and the lead's line picker when taking the job. */
.quick-warn { color: var(--warn-text); font-weight: 600; }
.quick-also { display: grid; gap: .2rem; }
.quick-also-title { font-size: .9rem; }
.quick-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.quick-chip { border: 1px solid var(--line); background: transparent; color: inherit; border-radius: 999px; padding: .35rem .9rem; font: inherit; cursor: pointer; }
.quick-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.line-pick-dialog { width: min(34rem, calc(100vw - 2rem)); }
.line-picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .75rem; margin: .75rem 0; }
.line-pick { display: flex; flex-direction: column; gap: .3rem; align-items: center; text-align: center; padding: 1rem .75rem; border: 2px solid var(--line); border-radius: 12px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.line-pick strong { font-size: 1.6rem; }
.line-pick.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.line-pick.busy { opacity: .6; cursor: not-allowed; }
.line-pick-why { color: var(--danger); }
/* ก.104: the start a person picks when taking a job. */
.start-dialog h3 { margin: .9rem 0 .4rem; font-size: 1rem; }
.start-quick { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.start-fields { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; }
.start-fields label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }
.start-note { margin: .5rem 0 0; font-weight: 600; }
.start-note.bad { color: var(--danger); }
.start-reason { display: flex; flex-direction: column; gap: .25rem; margin-top: .6rem; font-size: .9rem; }
.job-card-head h1 { margin: 0; }
.job-item { font-weight: 600; font-size: 1.05rem; }
.job-numbers { display: flex; align-items: baseline; gap: .4rem; }
.big-num { font-size: 2rem; font-weight: 800; }
.pct { margin-left: auto; font-weight: 700; font-size: 1.2rem; }
.bar-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: #2e7d32; }
.pill { display: inline-block; padding: .15rem .65rem; border-radius: 999px; background: var(--info-bg); color: var(--info-text); font-size: .85rem; font-weight: 600; white-space: nowrap; }
.pill.run { background: #e3f4e5; color: #2e7d32; } .pill.pause { background: var(--warn-bg); color: var(--warn-text); } .pill.close { background: #efe7fb; color: #6f42c1; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-top: .5rem; }
.stat { background: var(--bg); border-radius: 12px; padding: .6rem .8rem; display: grid; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat strong { font-size: 2.2rem; line-height: 1.1; }
.actions-bar { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions-bar .btn.big { min-height: 64px; padding: 0 1.4rem; font-size: 1.1rem; }
.btn.big.danger { border-color: var(--danger); }
.hour-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.chip { font: inherit; min-width: 72px; min-height: 56px; border-radius: 10px; border: 1px dashed var(--muted); background: var(--surface); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
.chip small { font-size: .75rem; color: var(--muted); }
.chip.done { border-style: solid; border-color: #2e7d32; background: #e3f4e5; color: #1b5e20; }
.chip.queued { border-style: solid; border-color: #ef6c00; background: var(--warn-bg); }
.chip.active { outline: 3px solid var(--primary); }
.entry-form { display: grid; gap: .75rem; }
.entry-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.big-field { display: grid; gap: .2rem; font-weight: 600; }
.big-field input { font-size: 1.8rem; font-weight: 700; min-height: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.save-state { color: var(--muted); font-size: .9rem; }
.batch-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.batch-card { font: inherit; display: grid; gap: .1rem; text-align: left; min-width: 150px; min-height: 64px; padding: .5rem .75rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.batch-card.active { outline: 3px solid var(--primary); }
.batch-card.new { border-style: dashed; justify-content: center; font-weight: 700; }
.checklist { list-style: none; padding: 0; display: grid; gap: .3rem; }
.checklist li { padding: .4rem .6rem; border-radius: 8px; }
.checklist li.ok { background: #e3f4e5; color: #1b5e20; } .checklist li.bad { background: #fdecea; color: var(--danger); } .checklist li.warn { background: var(--warn-bg); color: var(--warn-text); }
.photos { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.photos figure { margin: 0; display: grid; gap: .25rem; }
.photos img { width: 140px; height: 105px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.kind-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.history { max-height: 220px; overflow: auto; padding-left: 1rem; }
.entry-fields > *, .big-field input { min-width: 0; width: 100%; }
.big-field span[data-unit] { font-weight: 400; color: var(--muted); }

/* Job screen: a fixed frame with one tab of work inside, so a tablet does not scroll up and down. Phones keep normal page flow. */
.floor-job { grid-template-columns: minmax(0, 1fr); }
.job-bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.job-bar-row { display: flex; align-items: center; gap: .5rem; padding: .3rem .8rem; }
.job-menu { display: none; position: relative; min-height: 44px; font-size: 1.2rem; }
.job-menu.alert::after { content: ""; position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.job-back { flex: none; min-height: 44px; }
.job-toggle { font: inherit; color: inherit; background: none; border: 0; flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; gap: .7rem; text-align: left; cursor: pointer; padding: 0 .2rem; }
.job-toggle strong { font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-line { white-space: nowrap; }
.job-sum { margin-left: auto; font-weight: 700; white-space: nowrap; }
.job-chev { color: var(--muted); transition: transform .15s; }
.job-toggle[aria-expanded="true"] .job-chev { transform: rotate(180deg); }
.job-head { padding: 0 .8rem .6rem; }
.job-head p { margin: 0; }
.job-head .stat-row { grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .3rem; }
.job-head .stat { padding: .3rem .7rem; }
.job-head .stat strong { font-size: 1.5rem; }
.job-alerts:empty, .actions-bar:empty { display: none; }
.job-alerts { padding: 0 .8rem; }
.job-alerts .notice { margin: .4rem 0; padding: .4rem .8rem; }
.floor-job > .actions-bar { padding: .4rem .8rem; }
/* Before the job is accepted: one big button in the middle of the screen, no tabs (owner 2026-11-16). */
.floor-job.pre-accept #job-tabs, .floor-job.pre-accept #job-tab-body, .floor-job.pre-accept .job-tab-foot { display: none; }
.floor-job.pre-accept > .actions-bar { flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem; min-height: 55vh; padding: 2rem 1rem; }
.floor-job.pre-accept > .actions-bar > .btn.big { min-height: 88px; min-width: min(420px, 90vw); font-size: 1.5rem; border-radius: 16px; box-shadow: 0 8px 24px rgba(37, 99, 235, .25); }
.floor-job.pre-accept .pre-accept-more { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.floor-job > .queue-banner { margin: .4rem .8rem; }
.job-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-bottom: 2px solid var(--line); counter-reset: job-step; }
.job-tab { font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2; min-height: 58px; padding: .2rem; border: 0; border-bottom: 4px solid transparent; margin-bottom: -2px;
  background: none; color: var(--muted); cursor: pointer; counter-increment: job-step; touch-action: manipulation; }
.job-tab::before { content: counter(job-step) " "; }
.job-tab small { display: block; font-weight: 400; font-size: .72rem; min-height: 1.2em; }
.job-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--info-bg); }
/* The FM sheet tab is for the line supervisor / production head only: tinted so it reads as theirs. */
.job-tab.lead-tab { background: var(--lead-bg, #f1edff); }
.job-tab.lead-tab.active { background: var(--info-bg); }
.lead-note { margin: 0 0 .5rem; padding: .35rem .7rem; border-radius: 8px; background: var(--lead-bg, #f1edff); color: var(--lead-text, #45348f); font-size: .9rem; }
#batch-ui { margin-top: 1rem; padding-top: .7rem; border-top: 2px solid var(--line); }
#batch-ui > p { margin: 0 0 .4rem; }
#batch-form .big-field select { font: inherit; font-size: 1.1rem; min-height: 50px; width: 100%; }
/* QC on the FM sheet (owner 2026-11-10): big ✓ / ✗ buttons a finger hits on a tablet; tap the chosen one again to clear. */
.qc-block { margin-top: .8rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.qc-block h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.qc-need { font-size: .85rem; font-weight: 600; border-radius: 8px; padding: .1rem .5rem; background: var(--info-bg); color: var(--info-text); }
.qc-need.must { background: var(--warn-bg); color: var(--warn-text); }
.pf { display: inline-flex; gap: .25rem; }
.pf-btn { font: inherit; font-size: 1.15rem; font-weight: 700; min-width: 46px; min-height: 44px; border: 2px solid var(--line); border-radius: 10px; background: var(--input-bg); color: var(--muted); cursor: pointer; touch-action: manipulation; }
.pf-btn.pass.on { background: #e3f4e8; border-color: #3a9a5c; color: #17663a; }
.pf-btn.fail.on { background: #fde8e8; border-color: #c94a4a; color: #9b1c1c; }
.pf-row { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; margin-top: .5rem; }
.pf-row > span { display: inline-flex; gap: .4rem; align-items: center; font-weight: 600; }
.pf-row label { display: grid; gap: .1rem; font-size: .9rem; font-weight: 600; min-width: 200px; }
.pf-row select, .qc-samples select { font: inherit; min-height: 44px; width: 100%; }
.qc-samples { width: 100%; border-collapse: collapse; margin-top: .5rem; }
.qc-samples th, .qc-samples td { border-bottom: 1px solid var(--line); padding: .3rem; text-align: center; }
.qc-samples th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.qc-samples td:last-child { min-width: 150px; }
.sum-ok { color: #17663a; font-weight: 700; } .sum-bad { color: #9b1c1c; font-weight: 700; }
.qc-due { margin: .3rem 0 .5rem; }
.floor-job .chip.need { background: var(--warn-bg); border-color: #f0c27a; }
.floor-job .chip.qc-ok small { color: #17663a; }
.batch-when { margin: .4rem 0 0; }
.sheet-history { margin-top: .9rem; }
.sheet-history h3 { margin: 0 0 .3rem; font-size: 1rem; }
.sheet-history ul { margin: 0; padding-left: 1.1rem; }
.stage { border-radius: 6px; padding: 0 .4rem; }
.stage-live { background: #e3f4e8; color: #17663a; } .stage-close_requested { background: var(--info-bg); color: var(--info-text); } .stage-after_close { background: var(--warn-bg); color: var(--warn-text); }
@media (max-width: 640px) { .qc-samples .pf-btn { min-width: 38px; } .qc-samples td:last-child { min-width: 110px; } }
.job-tab-body { padding: .7rem .8rem; }
.tab-pane { display: none; max-width: 1100px; margin: 0 auto; }
.tab-pane.active { display: block; }
.tab-pane h2 { margin: 0 0 .4rem; }
.tab-pane .panel-head { margin-bottom: .4rem; gap: .3rem .8rem; }
.tab-pane .history { max-height: none; }
.job-tab-foot { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem .8rem; background: var(--surface); border-top: 1px solid var(--line); }
.process-types { display: grid; gap: .45rem; }
.process-types p { margin: 0; }
.process-type { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; align-items: center; padding: .45rem .7rem; border: 2px solid var(--line); border-radius: 12px; background: var(--input-bg); cursor: pointer; }
.process-type input { width: 24px; height: 24px; margin: 0; }
.process-type:has(input:checked) { border-color: var(--primary); background: var(--info-bg); }
.process-type.fixed { grid-template-columns: 1fr; cursor: default; }
.process-rule { grid-column: -2 / -1; display: flex; flex-wrap: wrap; gap: .3rem .5rem; }
.process-rule span { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .05rem .5rem; font-size: .9rem; }
.process-rule i { font-style: normal; color: var(--muted); }
#form-header-form .entry-fields { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
#form-header-form .big-field input { font-size: 1.25rem; min-height: 50px; text-align: left; }
.header-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .5rem; }
.header-buttons .btn { justify-content: center; text-align: center; text-decoration: none; }
.entry-rule { background: var(--info-bg); color: var(--info-text); border-radius: 8px; padding: .1rem .6rem; font-size: .9rem; margin-right: auto; }
.entry-main > label:not(.big-field) { display: grid; gap: .1rem; font-size: .9rem; font-weight: 600; }
.entry-main > label:not(.big-field) input { width: 100%; }
.entry-side .form-error:empty { display: none; }
.entry-rule.missing { background: var(--warn-bg); color: var(--warn-text); }
.floor-job .hour-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; margin-bottom: .45rem; }
.floor-job .chip { flex: none; }
.entry-split { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: .7rem; }
.entry-main, .entry-side { display: grid; gap: .45rem; min-width: 0; }
.entry-split .entry-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.entry-split .big-field { font-size: .9rem; }
.entry-split .big-field input { font-size: 1.3rem; min-height: 50px; }
.entry-split .keypad { gap: .4rem; margin: 0; }
.entry-split .keypad .key { min-height: 62px; }
.report-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .8rem; }
.report-actions .btn.big { flex: 1 1 200px; min-height: 76px; font-size: 1.1rem; }
.report-actions p { margin: 0; }
@media (min-width: 641px) {
  /* The page itself scrolls (2026-11-17), never a box inside it. The line tablets open the system inside an app whose
     "pull down to refresh" only looks at how far the page is scrolled: with a scroll box inside a page that never
     moves, every swipe down reloaded the page instead of scrolling back up. Tabs stay on top, the foot at the bottom. */
  body[data-page="floor-job"] { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
  body[data-page="floor-job"] .topbar { position: static; flex: none; }
  body[data-page="floor-job"] .main { flex: 1 0 auto; display: flex; flex-direction: column; width: 100%; max-width: none; padding: 0; }
  /* width: 100% — its auto side margins would otherwise shrink it to its content inside the flex column. */
  .floor-job { flex: 1 0 auto; width: 100%; max-width: none; display: flex; flex-direction: column; gap: 0; }
  .floor-job > * { flex: none; }
  .floor-job > .job-tab-body { flex: 1 0 auto; }
  .floor-job > .job-tabs { position: sticky; top: 0; z-index: 4; }
  .floor-job > .job-tab-foot { position: sticky; bottom: 0; z-index: 4; }
}
@media (min-width: 641px) and (max-height: 700px) {
  body[data-page="floor-job"]:not(.job-menu-open) .topbar { display: none; }
  .job-menu { display: inline-flex; }
  .job-tab-foot { display: none; }
}
@media (min-width: 900px) {
  .process-type { grid-template-columns: auto minmax(220px, auto) 1fr; }
  .process-type.fixed { grid-template-columns: auto 1fr; }
  .process-rule { grid-column: auto; }
}
@media (min-width: 641px) and (orientation: portrait) {
  .entry-split { grid-template-columns: 1fr; }
  .entry-split .entry-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .entry-split .keypad { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 640px) {
  .job-line { display: none; }
  .job-bar-row { flex-wrap: wrap; }
  .job-toggle { flex: 1 1 100%; flex-wrap: wrap; gap: .1rem .5rem; }
  .job-toggle strong { white-space: normal; }
  .job-head .stat-row { grid-template-columns: repeat(2, 1fr); }
  .job-tabs { display: flex; overflow-x: auto; }
  .job-tab { flex: none; min-width: 92px; }
  .entry-split { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- hourly dashboard */
.dash { display: grid; gap: 1rem; }
.dash-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.live { font-size: .85rem; font-weight: 700; color: var(--muted); }
.live.on { color: #2e7d32; } .live.off { color: #ef6c00; }
.tiles4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: 12px; padding: .9rem 1rem; display: grid; gap: .2rem; }
.tile span { color: var(--muted); font-size: .85rem; text-transform: uppercase; }
.tile strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); }
.tile.actual { border-left-color: #c53d42; } .tile.ok { border-left-color: #1f8a5b; } .tile.near { border-left-color: #b7840c; }
.tile.low { border-left-color: #c53d42; } .tile.lines { border-left-color: #e0a200; } .tile.none { border-left-color: #71808a; }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--line); }
.chart .axis, .chart .legend { font-size: 11px; fill: var(--muted); }
.chart .bar-actual { fill: #4a7bff; }
.chart .line-plan { fill: none; stroke: #d9342b; stroke-width: 2; stroke-dasharray: 6 4; }
.line-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.line-card { border: 1px solid var(--line); border-top: 4px solid #71808a; border-radius: 12px; padding: .75rem .9rem; display: grid; gap: .3rem; background: var(--surface); }
.line-card.st-running { border-top-color: #2e7d32; } .line-card.st-delayed { border-top-color: #ef6c00; } .line-card.st-breakdown { border-top-color: #c53d42; }
.line-card.st-completed { border-top-color: var(--primary); } .line-card.st-idle { border-top-color: #9e9e9e; }
.line-card.st-no_data { border-top-style: dashed; }
.status { font-size: .8rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: #eef2f6; color: #71808a; white-space: nowrap; }
.status.st-running { background: #e3f4e5; color: #2e7d32; } .status.st-delayed { background: var(--warn-bg); color: var(--warn-text); }
.status.st-breakdown { background: #fde4e5; color: #c53d42; } .status.st-completed { background: var(--info-bg); color: var(--info-text); }
.card-foot { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.band { padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; }
.band.ok { background: #e3f6ec; color: #1f8a5b; } .band.near { background: #fdf3d6; color: #b7840c; } .band.low { background: #fde4e5; color: #c53d42; }
.band.missing { background: #eef2f6; color: #71808a; }
.history-list { display: grid; gap: .6rem; }
.history-card { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: 12px; padding: .7rem .9rem; display: grid; gap: .25rem; }
.history-card.voided { opacity: .6; border-left-color: #9e9e9e; }
.history-card.breakdown { border-left-color: #c53d42; }
.history-card.open-stop { border-left-color: #ef6c00; }
.small-num { font-size: 1.5rem; }

/* Phase 6: loss & breakdown on the job screen */
.notice.danger { background: #fdecea; color: var(--danger); border-left: 4px solid var(--danger); }
.notice-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.btn.danger.primary, .dialog .btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.loss-form { margin-bottom: 1rem; }
.big-field.wide { grid-column: 1 / -1; }
.incident-list { display: grid; gap: .5rem; }
.incident-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.incident-row.open { border-color: var(--danger); }
.incident-row.voided { opacity: .55; }
.incident-row.voided strong { text-decoration: line-through; }

/* Phase 6: notifications */
.bell { position: relative; text-decoration: none; font-size: 1.15rem; padding: .2rem .35rem; }
.bell-count { position: absolute; top: -.35rem; right: -.5rem; min-width: 1.15rem; padding: 0 .3rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.15rem; text-align: center; }
.bell.has-ack .bell-count { background: #ef6c00; }
.notify-stack { position: fixed; top: 4.2rem; right: 1rem; z-index: 50; display: grid; gap: .6rem; width: min(380px, calc(100vw - 2rem)); }
.notify-card { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: 10px; padding: .75rem .9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .14); display: grid; gap: .25rem; }
.notify-card.high { border-left-color: #ef6c00; }
.notify-card.critical { border-left-color: var(--danger); background: #fdecea; }
.notify-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .3rem; }
.notify-list { display: grid; gap: .6rem; }
.notify-card.in-list { box-shadow: none; }
.notify-card.read { opacity: .6; }
/* Phase 6: start of shift (attendance + GMP) */
.ss-summary { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill.bad { background: #fdecea; color: var(--danger); }
.ss-list { display: grid; gap: .6rem; margin: .75rem 0 6rem; }
.ss-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; display: grid; gap: .55rem; }
.ss-card.off { opacity: .75; }
.gmp-chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.gmp-chip { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.6rem; padding: .3rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--input-bg); font: inherit; cursor: pointer; }
.gmp-chip .mark { font-weight: 800; width: 1.1rem; text-align: center; }
.gmp-chip.pass { background: #e3f4e5; border-color: #81c784; color: #1b5e20; }
.gmp-chip.fail { background: #fdecea; border-color: var(--danger); color: var(--danger); }
.gmp-chip.na { background: var(--bg); color: var(--muted); }
.gmp-chip.unset { border-style: dashed; }
.ss-save { position: sticky; bottom: 0; z-index: 5; display: grid; gap: .5rem; box-shadow: 0 -4px 16px rgba(0, 0, 0, .08); }
/* Phase 6: handover / acting */
.ho-card { display: grid; gap: .45rem; }
.ho-card.waiting { border-left: 5px solid #ef6c00; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; align-items: end; }
.grid-form .wide, .grid-form .form-error, .grid-form .actions { grid-column: 1 / -1; }
.notify-body { white-space: pre-line; }

/* Phase 7: Dashboard KPI (doc 08 §3.0) */
.kpi { display: grid; grid-template-columns: 230px 1fr; gap: 1rem; align-items: start; }
.kpi-side { position: sticky; top: 4.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .9rem; display: grid; gap: .8rem; max-height: calc(100vh - 5rem); overflow: auto; }
.kpi-brand { display: flex; gap: .5rem; align-items: center; }
.kpi-brand small { display: block; font-size: .7rem; letter-spacing: .08em; color: var(--muted); }
.kpi-groups, .kpi-line-group { display: grid; gap: .15rem; }
.kpi-groups a, .kpi-line-group a { display: flex; align-items: center; gap: .45rem; padding: .35rem .5rem; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .9rem; }
.kpi-groups a.active, .kpi-line-group a.active, .kpi-groups a:hover, .kpi-line-group a:hover { background: var(--bg); }
.kpi-groups a.active, .kpi-line-group a.active { font-weight: 700; }
.kpi-line-group small { font-size: .68rem; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.kpi-line-group .dot { width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
.kpi-main { min-width: 0; display: grid; gap: .9rem; }
.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.kpi-head h1 { margin: 0; }
.kpi-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.kpi-summary { flex-basis: 100%; margin: 0; }
.kpi-dates { display: inline-flex; gap: .3rem; align-items: center; }
.kpi-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; }
.kpi-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .8rem .9rem; display: grid; gap: .15rem; border-bottom: 4px solid var(--line); }
.kpi-tile small { font-size: .72rem; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.kpi-tile strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-tile.good { border-bottom-color: #1f9d57; } .kpi-tile.good strong { color: #1f8a5b; }
.kpi-tile.warn { border-bottom-color: #e0a100; } .kpi-tile.warn strong { color: #b7840c; }
.kpi-tile.bad { border-bottom-color: #d8343f; } .kpi-tile.bad strong { color: #c53d42; }
.kpi-tile.none strong { color: var(--muted); }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: .9rem; }
.kpi-panel { border-radius: 16px; margin: 0; }
.chart .target { stroke: #9fb5c3; stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .spark, .kpi-spark polyline { fill: none; stroke: #4a7bff; stroke-width: 2; }
.kpi-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem; }
.kpi-card { display: grid; gap: .3rem; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); text-decoration: none; border-top: 4px solid #9aa6b2; }
.kpi-card.good { border-top-color: #1f9d57; } .kpi-card.warn { border-top-color: #e0a100; } .kpi-card.bad { border-top-color: #d8343f; }
.kpi-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.kpi-card-pct { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi-card.good .kpi-card-pct { color: #1f8a5b; } .kpi-card.warn .kpi-card-pct { color: #b7840c; } .kpi-card.bad .kpi-card-pct { color: #c53d42; }
.kpi-spark { height: 28px; } .kpi-spark svg { width: 100%; height: 28px; }
.kpi-bar { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; } .kpi-bar i { display: block; height: 100%; }
.pill.process { background: #efe7fb; color: #6f42c1; } .pill.packing { background: #e3eefc; color: #2f5fb3; }
.kpi-pill { padding: .1rem .5rem; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.kpi-pill.good { background: #e3f6ec; color: #1f8a5b; } .kpi-pill.warn { background: #fdf3d6; color: #b7840c; } .kpi-pill.bad { background: #fde4e5; color: #c53d42; } .kpi-pill.none { background: #eef2f6; color: #71808a; }
.kpi-line-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border-radius: 16px; background: #203645; color: #fff; }
.kpi-line-head h2 { margin: 0 0 .2rem; color: #fff; }
.kpi-line-pct small { display: block; font-size: .72rem; letter-spacing: .08em; opacity: .8; }
.kpi-line-pct strong { font-size: 2.4rem; font-variant-numeric: tabular-nums; }
.kpi-line-head.good .kpi-line-pct strong { color: #7ee2a8; } .kpi-line-head.warn .kpi-line-pct strong { color: #ffd56b; } .kpi-line-head.bad .kpi-line-pct strong { color: #ff8f94; }
.table tr.down td:first-child { box-shadow: inset 4px 0 0 #d8343f; }
.table tr.down { background: #fff4f4; }
@media (max-width: 900px) { .kpi { grid-template-columns: 1fr; } .kpi-side { position: static; max-height: none; } .kpi-row { grid-template-columns: 1fr; } }
@media print { .kpi-side, .kpi-filters, .kpi-head .tools, .topbar, .notify-stack { display: none !important; } .kpi { grid-template-columns: 1fr; } }
.kpi-dates { flex-wrap: wrap; }
.kpi-dates input[type="date"] { min-width: 0; max-width: 11rem; }
@media (max-width: 900px) { .kpi { grid-template-columns: minmax(0, 1fr); } .kpi-filters select { max-width: 100%; } }

/* Phase 7 part 2: dark theme for the TV monitor (doc 08 §5) */
:root[data-theme="dark"] {
  --bg: #0d1218; --surface: #161d26; --input-bg: #161d26; --text: #e9eff5; --muted: #9aa7b4; --line: #27313d;
  --primary: #4c8dff; --warn-bg: #3a2c12; --warn-text: #ffcc80; --info-bg: #16263d; --info-text: #9cc2ff; --lead-bg: #241d3d; --lead-text: #c9bcff;
  color-scheme: dark;
}
.monitor { display: grid; gap: .8rem; }
.mon-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.mon-brand { display: flex; gap: .6rem; align-items: center; } .mon-brand b { font-size: 1.4rem; } .mon-brand small { display: block; color: var(--muted); }
.mon-counts { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1; align-items: center; }
.mon-count, .mon-ach { padding: .3rem .7rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; }
.mon-ach { font-size: 1.3rem; } .mon-ach small { font-size: .75rem; font-weight: 400; margin-left: .3rem; color: var(--muted); }
.mon-ach.good { color: #4ade80; } .mon-ach.warn { color: #fbbf24; } .mon-ach.bad { color: #f87171; }
.mon-right { display: flex; gap: .8rem; align-items: center; }
.mon-clock { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.mon-conn.on { color: #4ade80; } .mon-conn.off { color: #fbbf24; }
.mon-stale { background: #3a2c12; color: #ffcc80; padding: .6rem 1rem; border-radius: 10px; font-weight: 700; }
.mon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; }
.mon-card { background: var(--surface); border: 1px solid var(--line); border-left: 10px solid #64748b; border-radius: 14px; padding: .8rem 1rem; display: grid; gap: .25rem; }
.mon-card-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; } .mon-card-head b { font-size: 1.35rem; }
.mon-status { font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.mon-item { font-size: 1.05rem; } .mon-step { color: #fbbf24; font-weight: 700; min-height: 1.3em; }
.mon-pct { font-size: 3rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.mon-pct.good { color: #4ade80; } .mon-pct.warn { color: #fbbf24; } .mon-pct.bad { color: #f87171; } .mon-pct.none { color: var(--muted); }
.mon-nums { font-size: 1.1rem; font-variant-numeric: tabular-nums; } .mon-meta { color: var(--muted); font-size: .9rem; }
.mon-card.running { border-left-color: #22c55e; } .mon-card.running .mon-status { color: #4ade80; }
.mon-card.breakdown { border-left-color: #ef4444; background: #2a1517; } .mon-card.breakdown .mon-status { color: #f87171; }
.mon-card.delayed { border-left-color: #f97316; } .mon-card.delayed .mon-status { color: #fb923c; }
.mon-card.completed { border-left-color: #3b82f6; } .mon-card.completed .mon-status { color: #60a5fa; }
.mon-card.idle { border-left-color: #94a3b8; } .mon-card.idle .mon-status { color: #cbd5e1; }
.mon-card.no_data { border-left-color: #475569; background: repeating-linear-gradient(45deg, var(--surface) 0 12px, #1b232d 12px 24px); }
.mon-card.no_data .mon-status { color: var(--muted); }
.mon-count.breakdown { color: #f87171; } .mon-count.delayed { color: #fb923c; } .mon-count.running { color: #4ade80; } .mon-count.completed { color: #60a5fa; }
.mon-grid.compact { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .5rem; }
.mon-grid.compact .mon-card { padding: .5rem .7rem; } .mon-grid.compact .mon-pct { font-size: 2rem; } .mon-grid.compact .mon-card-head b { font-size: 1.1rem; }
.mon-grid.compact .mon-meta { display: none; }
/* Executive */
.exec { display: grid; gap: .9rem; }
.exec-line-name { display: grid; min-width: 0; } .exec-lead { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exec-group { display: grid; gap: .35rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.exec-line { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; gap: .6rem; align-items: center; padding: .35rem 0; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
.chart .exec-trend-line { fill: none; stroke: #4a7bff; stroke-width: 2.5; }
.kpi-tile .up { color: #1f8a5b; font-weight: 700; } .kpi-tile .down { color: #c53d42; font-weight: 700; }
/* Dashboard KPI: look of the factory's Apps Script dashboard (owner 2026-11-03) */
.kpi { grid-template-columns: 250px minmax(0, 1fr); gap: 1.2rem; }
.kpi.side-hidden { grid-template-columns: minmax(0, 1fr); } .kpi.side-hidden .kpi-side { display: none; }
/* The line menu sits against the left edge of the screen (owner 2026-11-12): this page uses the full width. */
/* The factory's KPI dashboard fills the space under the top bar (owner 2026-11-15). */
body[data-page="dashboard-kpi"] { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body[data-page="dashboard-kpi"] .main { max-width: none; padding: 0; margin: 0; width: 100%; flex: 1; min-height: 0; }
.kpi-frame { display: block; width: 100%; height: 100%; border: 0; }
@media (min-width: 901px) {
  body[data-page="dashboard-kpi"] .kpi-side { border-left: 0; border-radius: 0 16px 16px 0; }
}
.kpi-side { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 1rem .8rem; gap: 1rem; top: 4.4rem; }
.kpi-brand b { color: var(--text); font-size: 1.15rem; } .kpi-brand small { color: var(--muted); font-weight: 700; }
.kpi-logo { background: #fff; border-radius: 12px; padding: .25rem; display: inline-flex; }
.kpi-groups a, .kpi-line-group a { color: var(--text); justify-content: space-between; padding: .5rem .6rem; border-left: 3px solid transparent; }
.kpi-groups a small { color: var(--muted); font-weight: 700; }
.kpi-groups a.active, .kpi-line-group a.active { background: var(--info-bg); border-left-color: var(--primary); color: var(--info-text); }
.kpi-groups a:hover, .kpi-line-group a:hover { background: var(--bg); }
.kpi-line-group a { justify-content: flex-start; font-size: .88rem; }
.kpi-line-group small { color: var(--muted); letter-spacing: .1em; padding-left: .6rem; }
.kpi-line-group .dot { border: 1px solid var(--line); }
.kpi-line-scroll { display: grid; gap: .6rem; }
.kpi-title { display: flex; gap: .7rem; align-items: center; }
.kpi-title h1 { font-size: 1.7rem; margin: 0; color: var(--text); }
.kpi-crumb { margin: .1rem 0 0; font-size: .85rem; color: var(--muted); } .kpi-crumb a { color: var(--primary); text-decoration: none; }
.kpi-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.kpi-icon-btn { width: 2.6rem; height: 2.6rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; color: var(--text); text-decoration: none; cursor: pointer; }
.kpi-updated { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .4rem .8rem .4rem .45rem; font-size: .85rem; font-weight: 600; }
.kpi-updated i { font-style: normal; background: #e3f6ec; color: #1f8a5b; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.kpi-filters { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .9rem 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem 1rem; align-items: end; margin: 0; }
.kpi-f { display: grid; gap: .3rem; } .kpi-f.dates, .kpi-f.quick { grid-column: 1 / -1; }
.kpi-f label { font-size: .72rem; font-weight: 800; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; }
.kpi-f label span { color: var(--text); letter-spacing: 0; }
.kpi-f select { width: 100%; }
.kpi-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--bg); justify-self: start; }
.kpi-seg button { border: 0; background: transparent; padding: .4rem .9rem; border-radius: 8px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--text); }
.kpi-seg button.active { background: var(--primary); color: var(--primary-text); font-weight: 700; }
.kpi-dates { display: grid; grid-template-columns: auto 1fr auto 1fr auto; gap: .5rem; align-items: center; }
.kpi-dates input[type="date"] { max-width: none; width: 100%; }
.kpi-step { width: 2.4rem; height: 2.4rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1.1rem; }
.kpi-reset { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: .55rem .9rem; font: inherit; cursor: pointer; }
.kpi-summary { grid-column: 1 / -1; margin: 0; padding-top: .5rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.kpi-tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; }
.kpi-tile { border: 1px solid var(--line); border-left: 5px solid #c4ccd6; border-radius: 14px; padding: .8rem .9rem; box-shadow: 0 1px 3px rgba(20, 30, 50, .05); }
.kpi-tile.good { border-left-color: #1f9d57; } .kpi-tile.warn { border-left-color: #e39b0b; } .kpi-tile.bad { border-left-color: #e0485a; }
.kpi-tile.good, .kpi-tile.warn, .kpi-tile.bad, .kpi-tile.none { border-bottom: 1px solid var(--line); }
.kpi-tile-head { display: flex; justify-content: space-between; gap: .4rem; } .kpi-tile-head span { font-size: .7rem; color: var(--muted); text-align: right; }
.kpi-tile strong { font-size: 1.9rem; color: var(--text); } .kpi-tile strong em { font-style: normal; font-size: .95rem; color: var(--muted); font-weight: 600; }
.kpi-tile.good strong { color: #1f8a5b; } .kpi-tile.warn strong { color: var(--text); } .kpi-tile.bad strong { color: #c53d42; } .kpi-tile.none strong { color: var(--text); }
.kpi-tile-sub { font-size: .8rem; color: var(--muted); }
.kpi-tile .kpi-bar { margin-top: .4rem; }
.kpi-card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem; box-shadow: 0 1px 3px rgba(20, 30, 50, .05); }
.kpi-card-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.kpi-card-head h2 { margin: 0; font-size: 1.1rem; color: var(--text); } .kpi-card-head p { margin: .15rem 0 0; font-size: .8rem; color: var(--muted); }
.kpi-legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .78rem; color: var(--muted); align-items: center; }
.kpi-legend span { display: inline-flex; gap: .3rem; align-items: center; }
.kpi-legend i { width: .7rem; height: .7rem; border-radius: 3px; display: inline-block; } .kpi-legend i.dotted { width: 1.2rem; height: 0; border-top: 2px dotted; border-radius: 0; }
.chart .plan-line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 2 4; stroke-linecap: round; }
.chart .plan-dot { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.chart .value { font-size: 11px; font-weight: 700; fill: var(--text); } .chart .value.bad { fill: #c53d42; } .chart .value.good { fill: #1f8a5b; } .chart .value.warn { fill: #b7840c; }
.chart .axis.strong { font-weight: 600; fill: var(--text); }
.kpi-noactual { margin-top: .6rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem; font-size: .85rem; }
.kpi-section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; } .kpi-section-head h2 { margin: 0; color: var(--text); }
.kpi-line-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; }
.kpi-lc { display: grid; gap: .45rem; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid #d5dbe3; border-radius: 14px; padding: .8rem .9rem; color: var(--text); text-decoration: none; box-shadow: 0 1px 3px rgba(20, 30, 50, .05); }
.kpi-lc.good { border-top-color: #1f9d57; } .kpi-lc.warn { border-top-color: #e39b0b; } .kpi-lc.bad { border-top-color: #e0485a; }
.kpi-lc:hover { box-shadow: 0 6px 18px rgba(20, 30, 50, .1); }
.kpi-lc-head { display: flex; justify-content: space-between; gap: .5rem; align-items: center; } .kpi-lc-head b { color: var(--text); }
.kpi-chip { font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.kpi-chip.process { background: #e7eefb; color: #2f5fb3; } .kpi-chip.packing { background: #f1e9fb; color: #6f42c1; }
.kpi-chip.run, .kpi-chip.good { background: #e3f6ec; color: #1f8a5b; } .kpi-chip.warn { background: #fdf3d6; color: #b7840c; } .kpi-chip.bad { background: #fde4e5; color: #c53d42; }
.kpi-chip.hero { background: var(--info-bg); color: var(--info-text); }
.kpi-lc-chips { display: flex; gap: .3rem; flex-wrap: wrap; min-height: 1.3rem; }
.kpi-lc-mid { display: flex; justify-content: space-between; align-items: flex-end; gap: .5rem; }
.kpi-lc-pct { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; color: var(--muted); }
.kpi-lc-pct small { font-size: .78rem; font-weight: 600; color: var(--muted); }
.kpi-lc-pct.good { color: #1f8a5b; } .kpi-lc-pct.warn { color: #b7840c; } .kpi-lc-pct.bad { color: #c53d42; }
.kpi-spark { width: 110px; height: 34px; } .kpi-spark svg { width: 110px; height: 34px; }
.kpi-spark polyline { stroke: var(--primary); stroke-width: 1.6; fill: none; }
.kpi-lc-last { display: flex; justify-content: space-between; gap: .4rem; font-size: .78rem; color: var(--muted); align-items: center; }
.kpi-minis { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.kpi-mini { border: 1px solid var(--line); border-radius: 10px; padding: .35rem .5rem; background: var(--bg); } .kpi-mini small { display: block; font-size: .7rem; color: var(--muted); } .kpi-mini b { font-size: .95rem; }
.kpi-line-hero { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: 16px; padding: 1.2rem 1.4rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.kpi-line-hero h2 { margin: .35rem 0 .15rem; color: var(--text); font-size: 1.5rem; } .kpi-line-hero p { margin: 0; color: var(--muted); font-size: .85rem; }
.kpi-hero-pct { text-align: right; } .kpi-hero-pct strong { display: block; font-size: 2.8rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-hero-pct small { font-size: .72rem; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.kpi-hero-pct.good strong { color: #1f8a5b; } .kpi-hero-pct.warn strong { color: #b7840c; } .kpi-hero-pct.bad strong { color: #c53d42; } .kpi-hero-pct.none strong { color: var(--muted); }
.kpi-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.kpi-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.kpi-table th { text-align: left; font-size: .72rem; letter-spacing: .06em; color: var(--muted); background: var(--bg); padding: .55rem .7rem; font-weight: 800; }
.kpi-table td { padding: .55rem .7rem; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.kpi-table tr.down td:first-child { box-shadow: inset 4px 0 0 #e0485a; } .kpi-table tr.down { background: #fff5f5; }
.kpi-table tr[data-clickable] { cursor: pointer; } .kpi-table tr[data-clickable]:hover { background: var(--bg); }
.kpi-pct-text { font-weight: 700; } .kpi-pct-text.good { color: #1f8a5b; } .kpi-pct-text.warn { color: #b7840c; } .kpi-pct-text.bad { color: #c53d42; } .kpi-pct-text.none { color: var(--muted); }
.kpi-empty { color: var(--muted); text-align: center; padding: 1rem; margin: 0; }
@media (max-width: 900px) {
  .kpi { grid-template-columns: minmax(0, 1fr); }
  .kpi .kpi-side { display: none; } .kpi.side-hidden .kpi-side { display: grid; }
  .kpi-dates { grid-template-columns: auto 1fr auto; } .kpi-dates > span { display: none; }
}

/* Phase 8: reports and print pages (A4 landscape, Save as PDF) */
.reports-form { border: 0; padding: 0; background: transparent; }
.reports-form .form-error, .reports-form .actions { grid-column: 1 / -1; }
.report-sheet { background: #fff; color: #1f2933; padding: 1rem 1.2rem; border-radius: 10px; }
.report-tools { display: flex; gap: .5rem; margin-bottom: 1rem; }
.report-head { display: flex; gap: .8rem; align-items: center; border-bottom: 2px solid #1f6feb; padding-bottom: .5rem; margin-bottom: .6rem; }
.report-head h1 { margin: 0; font-size: 1.25rem; } .report-head p { margin: .1rem 0 0; font-size: .85rem; }
.report-meta { margin-left: auto !important; text-align: right; font-size: .75rem !important; color: #5f6b78; }
.report-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.report-table th { background: #e8f1ff; text-align: left; padding: .3rem .4rem; border: 1px solid #c9d3df; }
.report-table td { padding: .25rem .4rem; border: 1px solid #d5dae1; vertical-align: top; }
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table thead { display: table-header-group; } .report-table tr { break-inside: avoid; }
@page { size: A4 landscape; margin: 10mm; }
@media print {
  .topbar, .report-tools, .notify-stack, .toast { display: none !important; }
  body, .main { background: #fff; padding: 0; margin: 0; max-width: none; }
  .report-sheet { padding: 0; border-radius: 0; }
}
/* Product picker in the plan form */
.combo { position: relative; display: block; font-weight: 400; }
.combo input { width: 100%; padding-right: 2.2rem; }
.combo-arrow { position: absolute; right: .85rem; top: 50%; width: .5rem; height: .5rem; margin-top: -.35rem; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
.combo input[aria-expanded="true"] + .combo-arrow { transform: rotate(225deg); margin-top: -.1rem; }
.combo-panel { position: fixed; z-index: 20; overflow-y: auto; padding: .3rem; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 28px rgba(15, 23, 42, .18); }
.combo-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 7px; cursor: pointer; font-size: .95rem; }
.combo-item.active { background: var(--info-bg); }
.combo-item.selected { box-shadow: inset 3px 0 0 var(--primary); font-weight: 600; }
.combo-code { flex: none; min-width: 4.6rem; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.combo-name { flex: 1; min-width: 0; }
.combo-item mark { background: #fde68a; color: inherit; border-radius: 2px; }
.combo-empty, .combo-more { padding: .6rem; font-size: .875rem; color: var(--muted); text-align: center; }

.issue-options { display: grid; gap: .5rem; margin: .4rem 0 .8rem; }
.issue-note { display: grid; gap: .3rem; }
.issue-note textarea { width: 100%; }

.big-field input.locked { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.big-field select { font-size: 1.1rem; min-height: 64px; }

/* FM-PD-02 / FM-PD-21: laid out like the controlled paper forms */
.fm-sheet { background: #fff; color: #000; padding: 4mm; margin: 0 auto 6mm; width: 281mm; font-family: "Noto Sans Thai", Tahoma, sans-serif; font-size: 7.5pt; line-height: 1.25; page-break-after: always; }
.fm-sheet:last-of-type { page-break-after: auto; }
.fm-company { text-align: center; font-size: 10pt; }
.fm-title { text-align: center; font-size: 11.5pt; font-weight: 700; margin-bottom: 1.5mm; }
.fm-head { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 1mm 6mm; font-size: 8.5pt; }
.fm-head4 { grid-template-columns: .8fr 1.1fr 1.4fr 1fr; }
.fm-head span { border-bottom: .2mm solid #000; min-height: 4.6mm; }
.fm-head span:empty { border: 0; }
.fm-head b { font-weight: 600; margin-left: 1.5mm; }
.fm-types { font-size: 7.3pt; margin: 1mm 0; }
.fm-box { display: inline-block; width: 3mm; height: 3mm; line-height: 3mm; border: .25mm solid #000; text-align: center; font-size: 7pt; margin-right: 1mm; }
.fm-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.fm-table th, .fm-table td { border: .2mm solid #000; padding: .2mm .5mm; font-weight: 400; vertical-align: middle; text-align: center; }
.fm-table thead tr:first-child th { font-weight: 700; }
.fm-table td { height: 4.2mm; font-size: 7pt; word-break: break-word; }
.fm-table th.v { height: 21mm; padding: .5mm 0; }
.fm-table th.v span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; max-height: 20mm; white-space: normal; }
.fm21 td { height: 3.9mm; font-size: 6.5pt; }
.fm21 th { font-size: 6.5pt; }
.fm-note { font-size: 7.5pt; margin-top: 1mm; }
.fm-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm; margin-top: 3mm; font-size: 8pt; }
.fm-sign i { display: inline-block; width: 38mm; border-bottom: .2mm solid #000; }
.fm-sign small { display: block; text-align: center; font-size: 7.5pt; }
.fm-code { font-size: 8pt; font-weight: 600; margin-top: 1mm; }
@media print { .fm-sheet { margin: 0; padding: 0; width: auto; } }
.fm02 td { height: 3.6mm; }
.fm02 th.v { height: 18mm; }
.fm02 th.v span { max-height: 17mm; }

/* บันทึกรายชั่วโมง: hourly grid like the old Google Sheet (owner 2026-11-14) */
.sheet-page { max-width: none; }
.sheet-legend { display: flex; gap: 14px; flex-wrap: wrap; margin: .25rem 0 .5rem; }
.sheet-legend span::before { content: ""; display: inline-block; width: 14px; height: 14px; border: 1px solid var(--line); vertical-align: -2px; margin-right: 4px; }
.sheet-legend .l-ro::before { background: #eef2f6; } .sheet-legend .l-in::before { background: #fff; border: 2px solid #2b6cb0; }
.sheet-legend .l-lock::before { background: repeating-linear-gradient(45deg, #f3f3f3, #f3f3f3 3px, #e6e6e6 3px, #e6e6e6 6px); }
.sheet-wrap { overflow: auto; border: 1px solid var(--line); background: var(--surface); max-height: calc(100vh - 230px); }
.sheet-grid { border-collapse: collapse; font-size: .95rem; white-space: nowrap; min-width: 100%; }
.sheet-grid th { position: sticky; top: 0; z-index: 2; background: #0b2e59; color: #fff; font-weight: 600; padding: 8px 10px; border: 1px solid #2c4a75; text-align: left; }
.sheet-grid th.mp { background: #3b4f66; text-align: center; }
.sheet-grid td { border: 1px solid var(--line); padding: 0; height: 40px; }
.sheet-grid td.ro { background: #eef2f6; padding: 0 10px; color: #3c4a5c; }
.sheet-grid td.num, .sheet-grid tfoot td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-grid td.in { background: #fff; }
.sheet-grid td input { width: 100%; height: 40px; border: 0; padding: 0 10px; font: inherit; background: transparent; color: #1b2430; }
.sheet-grid td input.n { text-align: right; width: 120px; font-weight: 600; font-size: 1.05rem; }
.sheet-grid td input.w { width: 260px; }
.sheet-grid td input:focus { outline: 2px solid #2b6cb0; outline-offset: -2px; background: #f0f7ff; }
/* Actual / Remark open a pop-up when tapped (owner 2026-11-16): the cells look like fields but are not typed into. */
.sheet-grid .cell-btn { all: unset; box-sizing: border-box; display: block; height: 40px; line-height: 40px; padding: 0 10px; cursor: pointer; color: #1b2430; overflow: hidden; text-overflow: ellipsis; }
.sheet-grid .cell-btn.n { width: 120px; text-align: right; font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.sheet-grid .cell-btn.w { width: 260px; }
.sheet-grid .cell-btn:hover, .sheet-grid .cell-btn:focus-visible { background: #f0f7ff; outline: 2px solid #2b6cb0; outline-offset: -2px; }
.sheet-grid .cell-hint { font-size: .8rem; font-weight: 500; color: #7a8796; }
/* ก.65: kept on the device (no network), or typed and not saved yet */
.sheet-grid .cell-hint.wait { color: #c05600; font-weight: 700; }
.quick-restored { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.entry-pop .entry-pop-n { font-size: 1.6rem; font-weight: 700; text-align: right; height: 3.2rem; font-variant-numeric: tabular-nums; }
.entry-pop .entry-pop-note { margin: 0 0 .6rem; padding: .45rem .7rem; border-radius: 8px; background: #fff6e5; color: #9a5b00; font-size: .9rem; }
.entry-pop.editing .confirm-head h2 { color: #b45309; }
.entry-pop .actions .btn.big { min-width: 7rem; }
.sheet-grid td.lock { background: repeating-linear-gradient(45deg, #f7f7f7, #f7f7f7 4px, #efefef 4px, #efefef 8px); padding: 0 10px; color: #3c4a5c; }
.sheet-grid td.low input.n, .sheet-grid td.lock.low { color: var(--danger); }
.sheet-grid tr.job-start td { border-top: 3px solid #0b2e59; }
.sheet-grid td.mp { background: #f3f5f8; text-align: center; padding: 0 10px; color: #3c4a5c; }
.sheet-grid td.mp b { color: #1b2430; } .sheet-grid td.mp b.short { color: var(--danger); }
.sheet-grid td.status { padding: 0 10px; font-size: .82rem; color: var(--muted); }
.sheet-grid td.status.saved { color: #1e7e34; } .sheet-grid td.status.dirty { color: #c05600; white-space: normal; max-width: 260px; }
.sheet-grid tfoot td { background: #e8edf3; font-weight: 600; padding: 0 10px; color: #1b2430; }

/* Hourly grid in the job page: full width, fits a tablet without sideways scrolling (owner 2026-11-14) */
.tab-pane.full { max-width: none; }
/* The page itself scrolls (see the floor-job block above), so the grid is plain content: no scroll box of its own,
   and its heading row scrolls away with it. */
.job-sheet .sheet-wrap { overflow: visible; overflow-x: clip; max-height: none; }
.job-sheet .sheet-grid th { position: static; }
/* The tap cells keep to their column (2026-11-17): at their sheet-page widths (120px / 260px) the number ran into Remark
   on a tablet held upright. */
.job-sheet .sheet-grid .cell-btn.n, .job-sheet .sheet-grid .cell-btn.w { width: 100%; }
.job-sheet .sheet-grid .cell-btn { height: 44px; line-height: 44px; padding: 0 8px; white-space: nowrap; }
.job-sheet .sheet-grid { width: 100%; min-width: 0; table-layout: fixed; white-space: normal; }
.job-sheet .sheet-grid caption { text-align: left; padding: 0 0 .5rem; }
.job-sheet .sheet-grid th, .job-sheet .sheet-grid td.ro, .job-sheet .sheet-grid td.lock, .job-sheet .sheet-grid td.mp { padding: 6px 8px; overflow-wrap: anywhere; }
.job-sheet .sheet-grid td input.n, .job-sheet .sheet-grid td input.w { width: 100%; }
.job-sheet .sheet-grid td input { height: 44px; }
.job-sheet .c-no { width: 4.5%; } .job-sheet .c-prod { width: 15%; } .job-sheet .c-carton { width: 6%; } .job-sheet .c-loss { width: 15%; }
.job-sheet .c-time { width: 10%; } .job-sheet .c-target { width: 8%; } .job-sheet .c-plan { width: 6.5%; } .job-sheet .c-actual { width: 10%; }
.job-sheet .c-mp { width: 9%; } .job-sheet .c-st { width: 3%; text-align: center; padding: 0 !important; }
.job-sheet .sheet-grid td.status { font-size: 1.1rem; }
.job-sheet .sheet-grid td.status.error { color: var(--danger); }
.job-sheet .sheet-grid td.mp { text-align: left; font-size: .85rem; line-height: 1.35; }
.job-sheet .sheet-grid td.lock .small { font-size: .78rem; }
@media (max-width: 1100px) {
  .job-sheet .sheet-grid { font-size: .88rem; }
  .job-sheet .c-no { width: 5%; } .job-sheet .c-prod { width: 15%; } .job-sheet .c-loss { width: 15%; } .job-sheet .c-time { width: 12%; } .job-sheet .c-target { width: 9%; }
  .job-sheet .c-plan { width: 7.5%; } .job-sheet .c-actual { width: 12%; } .job-sheet .c-mp { width: 11%; } .job-sheet .c-st { width: 4%; }
}
.job-sheet .sheet-grid th { overflow-wrap: normal; word-break: keep-all; }
/* Real entry time (hidden until asked for) and late entries (owner 2026-11-14) */
.sheet-tools { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; margin: 0 0 .5rem; }
.late-text { color: var(--danger); }
.sheet-grid .c-when { display: none; }
.sheet-grid.show-when .c-when { display: table-cell; width: 11%; font-size: .82rem; line-height: 1.3; }
.sheet-grid td.c-actual { position: relative; }
.sheet-grid td.c-actual.late::after { content: attr(data-late); position: absolute; top: 2px; left: 4px; font-size: .68rem; font-weight: 600; line-height: 1;
  padding: 2px 4px; border-radius: 3px; background: #fde2e1; color: var(--danger); pointer-events: none; }
.sheet-grid td.c-actual.overdue { background: #fff6e5; }
.sheet-grid td.c-actual.overdue input::placeholder { color: #c05600; font-weight: 400; font-size: .85rem; }
@media (max-width: 1100px) { .job-sheet .sheet-grid th { font-size: .8rem; padding: 6px 5px; } .job-sheet .c-no { width: 6%; } .job-sheet .c-prod { width: 18%; } }
/* งานของฉัน grouped: coming / in progress / closed (owner 2026-11-14) */
.job-group { margin-top: 1.25rem; }
.job-group h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
.job-group h2 .count { color: var(--muted); font-weight: 400; font-size: .95rem; }
#group-done .job-card { opacity: .85; }
/* Close pop-up from the job card (owner 2026-11-14) */
.close-dialog { max-width: 520px; width: calc(100vw - 32px); }
.close-dialog .close-item { margin: .25rem 0 .4rem; font-size: 1.05rem; }
.close-dialog .job-numbers { display: flex; align-items: baseline; gap: .35rem; }
.close-dialog .job-numbers .pct { margin-left: auto; font-weight: 700; }
.close-dialog .job-numbers .pct.short { color: #c05600; }
.close-dialog .bar-track { margin: .3rem 0 .75rem; }
.close-facts { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin: 0 0 .6rem; font-size: .9rem; }
.close-facts dt { color: var(--muted); } .close-facts dd { margin: 0; }
.close-checks { list-style: none; padding: .5rem .75rem; margin: 0 0 .6rem; background: #f5f7fa; border-radius: 8px; font-size: .9rem; }
.close-checks li { padding: .15rem 0; } .close-checks .mark { display: inline-block; width: 1.1rem; font-weight: 700; }
.close-checks li.ok .mark { color: #1e7e34; } .close-checks li.bad .mark { color: var(--danger); } .close-checks li.warn .mark { color: #c05600; }
.close-dialog textarea { width: 100%; font: inherit; }
.close-dialog .actions { flex-wrap: wrap; }
/* งานของฉัน tabs (owner 2026-11-14) */
.floor-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 1rem 0 .9rem; border-bottom: 2px solid var(--line); }
.floor-tabs button { background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: .75rem .5rem; font: inherit; font-weight: 600;
  color: var(--muted); cursor: pointer; min-height: 48px; }
.floor-tabs button:hover { color: var(--text, #1b2430); background: #f0f4f9; }
.floor-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); background: #eaf2fd; }
.floor-tabs .count { display: inline-block; min-width: 1.6em; padding: 0 .4em; margin-left: .3rem; border-radius: 999px; background: #e3e8ef; color: #3c4a5c; font-size: .85rem; }
.floor-tabs button.active .count { background: var(--primary); color: #fff; }
@media (max-width: 560px) { .floor-tabs button { font-size: .9rem; padding: .6rem .25rem; } }
/* งานของฉัน uses the whole screen width (owner 2026-11-14) */
.floor#floor, .floor#dispatch { max-width: none; }
.main:has(> #floor), .main:has(> #dispatch) { max-width: none; padding-left: 1.5rem; padding-right: 1.5rem; }
@media (max-width: 760px) { .main:has(> #floor), .main:has(> #dispatch) { padding-left: 16px; padding-right: 16px; } }
.floor#dispatch #basket-hint { margin: -.4rem 0 0; }
/* ประวัติการบันทึก: one line per record, 25 per page (owner 2026-11-14) */
.main:has(> #history-page) { max-width: none; }
#history-page { max-width: none; }
.history-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.history-table { font-size: .9rem; }
.history-table th { position: sticky; top: 0; background: #f3f5f8; }
.history-table td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; padding: .45rem .6rem; vertical-align: middle; }
.history-table th.num, .history-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.history-table tbody tr:nth-child(even) { background: #fafbfc; }
.history-table tbody tr:hover { background: #eef5ff; }
.history-table tr.voided td { color: var(--muted); text-decoration: line-through; }
.history-table tr.voided td:last-child { text-decoration: none; }
.history-table tr.open td { background: #fff4e5; }
.history-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; margin-top: .75rem; }
.history-pager [data-info] { min-width: 16rem; text-align: center; color: var(--muted); }

/* Login: PIN button for line tablets (owner 2026-11-15) — big on tablet-size touch screens, a small link elsewhere. */
.auth-card .tablet-entry { display: none; width: 100%; margin-top: 1rem; text-align: center; }
@media (pointer: coarse) and (min-width: 600px) {
  .auth-card .tablet-entry { display: block; }
  .auth-card .tablet-entry-link { display: none; }
}

/* ก.142: put SMC on the home screen (login page, phones and tablets only — app.js decides when it is shown). */
.auth-card .install-app { width: 100%; margin-top: 1rem; justify-content: center; }
.install-help ol { padding-left: 1.3rem; display: grid; gap: .7rem; line-height: 1.6; }
.install-help .install-share { width: 1.3rem; height: 1.3rem; vertical-align: -.25rem; margin: 0 .15rem; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Tablet roster (owner 2026-11-15, ทางเลือก ค): search, groups, tags, first-PIN steps. */
.people-search { width: 100%; font: inherit; font-size: 1.1rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); margin-bottom: .5rem; box-sizing: border-box; }
.people-group h2 { font-size: .95rem; color: var(--muted); margin: 1rem 0 .5rem; }
.person.lead { border-color: var(--primary); }
.person-tag { align-self: center; font-style: normal; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--info-bg); color: var(--primary); }
.person-tag.warn { background: var(--warn-bg); color: var(--warn-text); }
.pin-steps { display: flex; justify-content: center; gap: .4rem; margin: .25rem 0 .5rem; font-size: .8rem; }
.pin-steps span { padding: 2px 10px; border-radius: 99px; background: var(--bg); color: var(--muted); font-weight: 600; }
.pin-steps span.on { background: var(--primary); color: #fff; }
.pin-dialog .big-pw { font-size: 1.2rem; min-height: 52px; }
.pin-dialog [data-note] { min-height: 0; margin: .25rem 0; }

/* งานค้าง (owner 2026-11-15): not started and past its planned end. */
.floor-tabs button.overdue { color: var(--danger, #c62828); }
.floor-tabs button.overdue .count { background: var(--danger, #c62828); color: #fff; }
.floor-tabs button.overdue.active { border-bottom-color: var(--danger, #c62828); background: #fdecec; }
.late-flag { background: #fdecec; color: var(--danger, #c62828); font-size: .8rem; font-weight: 600; padding: .3rem .5rem; border-radius: 6px; margin-bottom: .4rem; }

/* Master list group buttons (employees: ทั้งหมด / หัวหน้าไลน์ / พนักงาน, owner 2026-11-15). */
.seg-buttons { display: inline-flex; margin-right: .5rem; }
.seg-buttons .btn { border-radius: 0; margin: 0; }
.seg-buttons .btn:first-child { border-radius: 8px 0 0 8px; }
.seg-buttons .btn:last-child { border-radius: 0 8px 8px 0; }
.seg-buttons .btn + .btn { margin-left: -1px; }

/* Picture guide: real screenshots + numbered steps (owner 2026-11-15). */
.manual .mk { display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 .3rem; border-radius: 999px; background: #d92d20; color: #fff;
  font-size: .78rem; font-weight: 700; line-height: 1; box-shadow: 0 0 0 2px #fff; }
.manual-page .guide { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
@media (max-width: 860px) { .manual-page .guide { grid-template-columns: 1fr; } }
.guide-shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.guide-steps { margin: 0; padding: 0; list-style: none; counter-reset: g; display: grid; gap: .55rem; }
.guide-steps li { counter-increment: g; position: relative; padding-left: 2rem; line-height: 1.55; }
.guide-steps li::before { content: counter(g); position: absolute; left: 0; top: .1rem; display: grid; place-items: center; width: 1.45rem; height: 1.45rem;
  border-radius: 999px; background: #d92d20; color: #fff; font-size: .8rem; font-weight: 700; }
.manual-flow .flow { list-style: none; margin: 0; padding: 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; counter-reset: f; }
.manual-flow .flow li { counter-increment: f; position: relative; display: grid; gap: .15rem; padding: .7rem .7rem .7rem 2.4rem; border-radius: 10px; background: #f3f6fb; border: 1px solid #d8dde6; }
.manual-flow .flow li::before { content: counter(f); position: absolute; left: .6rem; top: .7rem; display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 999px; background: #1f6feb; color: #fff; font-size: .8rem; font-weight: 700; }
.manual-flow .flow .who { font-size: .75rem; color: #1d4fbf; font-weight: 700; }
.manual-flow .flow small { color: #667085; }
/* An hour wholly at rest on the hourly sheet (ก.43): no entry needed. */
tr.rest td { background: var(--surface); color: var(--muted); }

/* Quantity + unit side by side in "สร้างงานใหม่และจ่ายงาน" (owner 2026-11-17). */
.quick-qty { display: flex; gap: .4rem; }
.quick-qty input { flex: 1; min-width: 0; }
.quick-qty select.quick-unit { flex: none; width: auto; min-width: 6.5rem; }

/* "+ สร้างสินค้าใหม่" at the end of the product search list (owner 2026-11-17). */
.combo-create { color: var(--primary); font-weight: 600; border-top: 1px dashed var(--line); margin-top: .2rem; }

/* ก.112 (owner 2026-11-19): the sheet's heading says what is made and on which day; losses on the hour's row and in its pop-up. */
.sheet-grid caption.sheet-caption { caption-side: top; text-align: left; padding: 0 0 .5rem; }
.sheet-caption strong { display: block; font-size: 1.25rem; line-height: 1.25; }
.sheet-caption span { color: var(--muted); font-size: .95rem; }
.loss-chip { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 8px; border-radius: 999px; line-height: 1.5; font-size: .8rem; font-weight: 600;
  background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); white-space: nowrap; }
.sheet-grid td.c-loss { padding: 2px 6px; white-space: normal; line-height: 1.2; }
.sheet-grid .cell-btn.loss-cell { width: 100%; height: auto; min-height: 40px; line-height: 1.2; padding: 4px 2px; white-space: normal; display: flex; flex-wrap: wrap; align-items: center; }
.job-sheet .sheet-grid .cell-btn.loss-cell { height: auto; min-height: 44px; line-height: 1.2; white-space: normal; }
.entry-pop .loss-box { border: 1px solid var(--line); border-radius: 10px; padding: .4rem .7rem .6rem; margin: .4rem 0 .6rem; }
.entry-pop .loss-box legend { font-weight: 700; color: var(--danger); padding: 0 .3rem; }
.entry-pop .loss-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, .9fr) minmax(0, 1fr) auto; gap: .4rem; margin: .4rem 0; }
.entry-pop .loss-row select, .entry-pop .loss-row input { min-width: 0; }
.entry-pop .loss-saved-row { display: flex; align-items: center; gap: .3rem; }
.entry-pop .loss-saved-row.dropped .loss-chip { text-decoration: line-through; opacity: .5; }
.entry-pop .loss-x { border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: .2rem .4rem; }
.entry-pop .loss-add { margin-top: .2rem; }
/* ก.113: people on the job (real / plan) in the sheet's heading. */
.sheet-people-row { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .25rem; }
.sheet-people { font-size: 1rem; }
.sheet-people b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.sheet-people b.short { color: var(--danger); }
/* ก.115: เปลี่ยนงาน — pick another job of the line. */
#switch-state:empty { display: none; }
.switch-dialog { width: min(560px, calc(100vw - 32px)); }
.switch-list { display: grid; gap: .45rem; max-height: 50vh; overflow: auto; margin: .6rem 0; }
.switch-pick { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; text-align: left; padding: .6rem .8rem; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.switch-pick strong { grid-column: 1; } .switch-pick span:not(.pill) { grid-column: 1; font-size: .88rem; color: var(--muted); }
.switch-pick .pill { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.switch-pick.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
/* ก.116: รวมงาน */
.job-tag.merge { background: color-mix(in srgb, #6f42c1 16%, transparent); color: #6f42c1; font-weight: 700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .job-tag.merge { color: #c3b0ff; } }
:root[data-theme="dark"] .job-tag.merge { color: #c3b0ff; }
.merge-btn { border-color: #6f42c1; color: #6f42c1; }
.merge-pick { grid-template-columns: auto 1fr auto; cursor: pointer; }
.merge-pick input { grid-row: 1 / span 2; align-self: center; width: 1.2rem; height: 1.2rem; }
.merge-pick strong, .merge-pick span:not(.pill) { grid-column: 2; }
.merge-pick .pill { grid-column: 3; grid-row: 1 / span 2; }
.merge-pick.on { border-color: #6f42c1; box-shadow: 0 0 0 2px #6f42c1 inset; }
.merge-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: .3rem 0; }
.merge-table th, .merge-table td { border: 1px solid var(--line); padding: .35rem .5rem; text-align: left; }
.merge-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.merge-table tr.sum td { font-weight: 700; color: #6f42c1; }
/* ก.119: รวมกับไลน์อื่น — a small drop-down of tick boxes in the create-job form. */
.quick-also { position: relative; }
.quick-also-dd { position: relative; }
.quick-also-dd > summary { list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: space-between;
  padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--input-bg, var(--surface)); font-weight: 400; }
.quick-also-dd > summary::-webkit-details-marker { display: none; }
.quick-also-dd > summary::after { content: "▾"; color: var(--muted); margin-left: .5rem; }
.quick-also-dd.off > summary { color: var(--muted); cursor: default; }
.quick-also-menu { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); display: grid; gap: .1rem; padding: .35rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 6px 18px rgba(0, 0, 0, .25); max-height: 280px; overflow: auto; }
.quick-also-opt { display: flex !important; align-items: center; gap: .5rem; padding: .4rem .5rem; border-radius: 6px; font-weight: 400 !important; cursor: pointer; }
.quick-also-opt:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.quick-also-opt input { width: 1.1rem; height: 1.1rem; }

/* ก.128: a page that is not open yet (planner preview) — a faint page outline under a "กำลังพัฒนา" card */
.nav-dev { margin-left: .25rem; padding: .05rem .4rem; border-radius: 999px; font-size: .7rem; font-weight: 700; background: var(--warn-bg); color: var(--warn-text); white-space: nowrap; }
.dev-cover { position: relative; min-height: 70vh; display: grid; place-items: center; overflow: hidden; border-radius: 12px; }
.dev-ghost { position: absolute; inset: 0; display: grid; gap: 1rem; align-content: start; padding: 1.25rem; opacity: .5; filter: blur(2px); pointer-events: none; }
.dev-ghost-head { height: 2.2rem; width: 40%; border-radius: 8px; background: var(--line); }
.dev-ghost-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.dev-ghost-row span { height: 4.5rem; border-radius: 10px; background: var(--line); }
.dev-ghost-block { height: 9rem; border-radius: 10px; background: var(--line); }
.dev-card { position: relative; max-width: 26rem; margin: 1rem; padding: 1.75rem 1.5rem; text-align: center; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.dev-card h1 { margin: .25rem 0; font-size: 1.35rem; }
.dev-icon { font-size: 2.5rem; line-height: 1; }
.dev-state { display: inline-block; margin: .25rem 0 .6rem; padding: .2rem .9rem; border-radius: 999px; font-weight: 800; background: var(--warn-bg); color: var(--warn-text); }

/* ก.131: the plan calendar as a calendar of jobs (planning off) — coloured by where each job stands */
.job-chip { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.month-grid .job-line { display: block; margin-top: 2px; padding: 1px 5px; border-radius: 5px; font-size: .74rem; font-weight: 600; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jg-wait { background: #fef3c7; color: #92400e; }
.jg-sent { background: #dbeafe; color: #1d4ed8; }
.jg-run { background: #dcfce7; color: #166534; }
.jg-done { background: #e2e8f0; color: #334155; }
.tl-track .bar.jg-wait { background: #fef3c7; border-color: #d97706; color: #78350f; }
.tl-track .bar.jg-sent { background: #dbeafe; border-color: #2563eb; color: #1e3a8a; }
.tl-track .bar.jg-run { background: #dcfce7; border-color: #16a34a; color: #14532d; }
.tl-track .bar.jg-done { background: #e2e8f0; border-color: #64748b; color: #1e293b; }
#quick-job-dialog .quick-job { border: 0; padding: 0; margin: 0; }
@media (max-width: 700px) { .month-grid .job-line { display: none; } }
#quick-job-dialog .quick-qty input { width: 0; }

/* ก.133: a Product List row opens for editing when tapped */
#pl-table tbody tr.row-inactive td { color: var(--muted); background: var(--bg); }
#pl-table tbody tr.row-open { cursor: pointer; }
#pl-table tbody tr.row-open:hover td { background: var(--info-bg); }
#pl-table tbody tr.row-open:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
