/* ==========================================================================
   Y2J ONE — "Industrial Precision" theme layer.
   Loaded after style.css. Only colours, type, surfaces, spacing rhythm and
   motion — no layout structure — so removing this file restores the old look.
   Idea: the drafting table of a machine builder. Warm drawing-paper page with
   a faint engineering grid, graphite navigation, harvester-amber highlights,
   squared technical numerals (Chakra Petch) and monospace part codes.
   ========================================================================== */

:root {
  --font-body: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --font-display: "Chakra Petch", "IBM Plex Sans Thai", "Leelawadee UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --surface-page:   #f1efe8;
  --surface-1:      #f7f5f0;
  --surface-card:   #fffefb;
  --text-primary:   #16181c;
  --text-secondary: #4d4f55;
  --text-muted:     #85868a;
  --gridline:       #e3e0d6;
  --baseline:       #c9c5b8;
  --border-hairline: rgba(22, 24, 28, 0.10);

  --accent:        #f2a60d;   /* harvester amber */
  --accent-ink:    #7a4d00;
  --accent-soft:   rgba(242, 166, 13, 0.14);
  --brand:         #1d4ed8;   /* Y2J blue, deeper */
  --brand-soft:    rgba(29, 78, 216, 0.10);
  --series-1:      #1d4ed8;

  --sidebar-bg: #15181d;
  --sidebar-fg: #e9e7e1;
  --sidebar-fg-muted: #9b9a95;
  --sidebar-active: rgba(242, 166, 13, 0.12);

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 1px 2px rgba(22, 24, 28, 0.05), 0 8px 24px -12px rgba(22, 24, 28, 0.12);
  --shadow-lift: 0 2px 4px rgba(22, 24, 28, 0.06), 0 16px 32px -14px rgba(22, 24, 28, 0.22);
  --grid-line: rgba(29, 78, 216, 0.045);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --surface-page:   #0f1113;
    --surface-1:      #171a1d;
    --surface-card:   #1a1d21;
    --text-primary:   #f2f1ec;
    --text-secondary: #bdbbb3;
    --text-muted:     #86867f;
    --gridline:       #2a2d31;
    --baseline:       #3a3d42;
    --border-hairline: rgba(255, 255, 255, 0.08);
    --accent-ink:    #ffc24d;
    --accent-soft:   rgba(242, 166, 13, 0.16);
    --brand:         #5b8def;
    --brand-soft:    rgba(91, 141, 239, 0.16);
    --series-1:      #5b8def;
    --sidebar-bg: #0b0d0f;
    --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 28px -16px rgba(0, 0, 0, 0.7);
    --shadow-lift: 0 18px 36px -16px rgba(0, 0, 0, 0.8);
    --grid-line: rgba(255, 255, 255, 0.025);
  }
}
:root[data-theme="dark"] {
  --surface-page:   #0f1113;
  --surface-1:      #171a1d;
  --surface-card:   #1a1d21;
  --text-primary:   #f2f1ec;
  --text-secondary: #bdbbb3;
  --text-muted:     #86867f;
  --gridline:       #2a2d31;
  --baseline:       #3a3d42;
  --border-hairline: rgba(255, 255, 255, 0.08);
  --accent-ink:    #ffc24d;
  --accent-soft:   rgba(242, 166, 13, 0.16);
  --brand:         #5b8def;
  --brand-soft:    rgba(91, 141, 239, 0.16);
  --series-1:      #5b8def;
  --sidebar-bg: #0b0d0f;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 28px -16px rgba(0, 0, 0, 0.7);
  --shadow-lift: 0 18px 36px -16px rgba(0, 0, 0, 0.8);
  --grid-line: rgba(255, 255, 255, 0.025);
}

/* ---- base: paper + engineering grid -------------------------------------------- */
body {
  font-family: var(--font-body);
  background-color: var(--surface-page);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono-cell, code, .bx-code { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.01em; }

/* ---- sidebar ------------------------------------------------------------------- */
.sidebar {
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(242, 166, 13, 0.07), transparent 60%),
    var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}
.brand { border-bottom-color: rgba(255, 255, 255, 0.07); }
.brand-mark {
  background: linear-gradient(135deg, var(--accent), #e07b00);
  color: #1a1204;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px -6px rgba(242, 166, 13, 0.6);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%); /* machined corner */
}
.brand-title { font-family: var(--font-display); font-size: 16px; letter-spacing: 0.03em; }
.nav-item {
  position: relative;
  border-radius: 8px;
  font-size: 13.5px;
  padding: 10px 12px 10px 16px;
}
.nav-item .nav-icon { color: rgba(242, 166, 13, 0.55); }
.nav-item::before {
  content: ""; position: absolute; left: 4px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px;
  background: var(--accent); transform: scaleY(0); transition: transform 0.18s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.04); }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.active::before { transform: scaleY(1); }
.nav-item.active .nav-icon { color: var(--accent); }

/* ---- top bar ------------------------------------------------------------------- */
.topbar-title {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex; align-items: center; gap: 10px;
}
.topbar-title::before {
  content: ""; width: 10px; height: 22px; border-radius: 2px;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 4px, #1a1204 4px 7px); /* hazard stripe */
  opacity: 0.9;
}
.data-badge, .theme-toggle { border-radius: 999px; box-shadow: var(--shadow-card); }

/* ---- cards & tiles --------------------------------------------------------------- */
.card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border-color: var(--border-hairline);
}
.card-header { padding: 18px 22px 10px; }
.card-header h3 {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.card-sub { line-height: 1.6; }
.card-body { padding: 8px 22px 22px; }

.stat-tile {
  position: relative;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px 14px;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat-tile::after { /* ruler ticks along the top edge */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: repeating-linear-gradient(90deg, var(--baseline) 0 1px, transparent 1px 10px);
  opacity: 0.55;
}
.stat-label { font-size: 12.5px; letter-spacing: 0.01em; }
.stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
button.stat-tile:hover, a.stat-tile:hover, .stat-tile[data-go]:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

/* ---- tabs: tool-strip with amber marker ---------------------------------------- */
.dept-tabs { gap: 6px; }
.dept-tab {
  border-radius: 10px;
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.dept-tab:hover { border-color: var(--baseline); color: var(--text-primary); }
.dept-tab.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--surface-card);
  box-shadow: inset 0 -3px 0 var(--accent), var(--shadow-card);
}
.dept-tab.active .dept-tab-count { background: var(--accent); color: #1a1204; }

/* ---- buttons ------------------------------------------------------------------- */
.btn-primary {
  background: var(--brand);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 6px 14px -8px var(--brand);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-primary:active, .btn-secondary:active { transform: translateY(1px); }
.btn-secondary { border-radius: 10px; transition: border-color 0.15s, background 0.15s; }
.btn-secondary:hover { border-color: var(--baseline); }
.btn-link { color: var(--brand); }

/* ---- tables -------------------------------------------------------------------- */
.data-table th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--surface-1);
  border-bottom: 1px solid var(--baseline);
}
.data-table th:first-child { border-top-left-radius: 8px; }
.data-table th:last-child { border-top-right-radius: 8px; }
.data-table td { border-bottom-color: var(--gridline); }
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: var(--brand-soft); }
.data-table td.num, .data-table th.num { font-variant-numeric: tabular-nums; }

/* ---- pills --------------------------------------------------------------------- */
.pill { border-radius: 6px; letter-spacing: 0.01em; padding: 3px 8px; }
.pill-warning { color: var(--accent-ink); background: var(--accent-soft); }

/* ---- form controls ------------------------------------------------------------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea {
  border-radius: 9px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--brand); }

/* ---- login --------------------------------------------------------------------- */
.login-card { border-radius: 18px; box-shadow: var(--shadow-lift); }
.login-title { font-family: var(--font-display); letter-spacing: 0.02em; }
.login-user { border-radius: 12px; transition: border-color 0.15s, transform 0.15s; }
.login-user:hover { transform: translateY(-1px); border-color: var(--accent); }
.login-user.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---- job cards / stock (new modules) ------------------------------------------- */
.jc-op { border-radius: var(--radius); background: var(--surface-card); box-shadow: var(--shadow-card); }
.jc-op-wip { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--surface-card); }
.jc-op-head b { font-family: var(--font-display); font-size: 1.1rem; }
.jc-wip td { background: var(--accent-soft); }
.jc-sum b, .jc-cost-t th { font-family: var(--font-display); }

/* ---- motion: cards rise in when a page opens ---------------------------------- */
@keyframes y2jRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view.active > * { animation: y2jRise 0.38s cubic-bezier(0.2, 0.7, 0.2, 1); }
.view.active > *:nth-child(2) { animation-delay: 0s; }
.view.active > *:nth-child(3) { animation-delay: 0s; }
.view.active > *:nth-child(4) { animation-delay: 0s; }
.view.active > *:nth-child(n+5) { animation-delay: 0s; }
@media (prefers-reduced-motion: reduce) {
  .view.active > * { animation: none; }
  * { transition: none !important; }
}

/* ---- touch devices: bigger targets ---------------------------------------------- */
@media (max-width: 1024px), (pointer: coarse) {
  .btn-primary, .btn-secondary, .dept-tab { min-height: 42px; }
  .dept-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .dept-tabs::-webkit-scrollbar { display: none; }
  .dept-tab { flex: 0 0 auto; }
  .topbar-title { font-size: 20px; }
  .stat-value { font-size: 27px; }
}

/* ---- print stays plain ------------------------------------------------------------ */
@media print {
  body { background: #fff !important; }
  .card, .stat-tile { box-shadow: none !important; }
  .view.active > * { animation: none !important; }
}

/* ---- documents & forms polish ---- */
.paper-head { align-items: stretch; }
.paper-qr { width: 74px; height: 74px; flex: none; align-self: center; }
.paper-qr svg { width: 100%; height: 100%; }
.paper { box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 18px 40px -20px rgba(0,0,0,0.35); }
.paper-stamp { transform: rotate(-4deg); border-width: 2.5px; letter-spacing: 0.04em; font-family: var(--font-display, inherit); box-shadow: inset 0 0 0 2px currentColor; opacity: 0.92; }
.paper-title { font-family: var(--font-display, inherit); letter-spacing: 0.01em; }
.docview-actions { position: sticky; top: 0; z-index: 3; backdrop-filter: blur(8px); }
.modal h3 { font-family: var(--font-display, inherit); }
.modal .modal-actions { position: sticky; bottom: -1px; background: var(--surface-card); padding-top: 12px; padding-bottom: 4px; margin-top: 14px; border-top: 1px solid var(--gridline); z-index: 2; }
.form-field label { font-weight: 600; color: var(--text-secondary); }
.form-field input, .form-field select, .form-field textarea { min-height: 40px; }
.scan-wrap { display: flex; gap: 6px; align-items: stretch; }
.scan-wrap > input, .scan-wrap > select { flex: 1; min-width: 0; }
.scan-btn { flex: none; width: 42px; border-radius: 9px; border: 1px solid var(--border-hairline); background: var(--surface-1); cursor: pointer; font-size: 17px; }
.scan-btn:hover { border-color: var(--accent, #f2a60d); }
@media print { .paper-qr svg { display: block; } .scan-btn { display: none; } }

/* ==== readable colours in both themes (WCAG AA: 4.5:1 text, 3:1 large) ==== */
:root {
  --text-muted: #65676c;
  --txt-good: #0a7a0a;
  --txt-bad: #b3261e;
  --txt-warn: #8a5a00;
  --link: #1d4ed8;
  --btn-bg: #1d4ed8;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --text-muted: #a2a29b;
    --txt-good: #5ed45e;
    --txt-bad: #ff7b70;
    --txt-warn: #ffc24d;
    --link: #7ea6ff;
    --btn-bg: #2f62cc;
  }
}
:root[data-theme="dark"] {
  --text-muted: #a2a29b;
  --txt-good: #5ed45e;
  --txt-bad: #ff7b70;
  --txt-warn: #ffc24d;
  --link: #7ea6ff;
  --btn-bg: #2f62cc;
}
.btn-primary, .org-logo { background: var(--btn-bg); color: #fff; }
.btn-primary { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 6px 14px -8px var(--btn-bg); }
.btn-link { background: none; border: 0; padding: 2px 4px; font: inherit; color: var(--link); cursor: pointer; text-decoration: none; border-radius: 4px; }
.btn-link:hover { text-decoration: underline; }
.btn-link:disabled { color: var(--text-muted); cursor: default; text-decoration: none; }
.bx-link, .ms-wo-link:hover b { color: var(--link); }
.pill-good { color: var(--txt-good); }
.pill-critical, .pill-doFirst { color: var(--txt-bad); }
.pill-delegate, .pill-warning { color: var(--txt-warn); }
.pill-schedule { color: var(--link); }
.bx-neg, .ov-decide-crit, .ms-this-week, .ms-late .gantt-row-label b, .ms-due-late, .mt-stat-bad b, .ov-ec-bad b, .plan-overdue { color: var(--txt-bad); }
.bx-low, .p2p-issue-sev { color: var(--txt-warn); }
.status-chip.status-good { color: var(--txt-good); }
.status-chip.status-warning { color: var(--txt-warn); }
.status-chip.status-critical { color: var(--txt-bad); }
/* related-document chips outside a paper form follow the app theme; on paper they stay black on white */
.rel-chip { background: var(--surface-card); color: var(--text-primary); border-color: var(--border-hairline); }
.rel-chip .rel-status, .rel-chip .rel-dir { color: var(--text-muted); }
.paper .rel-chip { background: #fff; color: var(--p-ink); border-color: var(--p-line); }
.paper .rel-chip .rel-status, .paper .rel-chip .rel-dir { color: var(--p-muted); }
.org-logo-big span { color: var(--link); }
.p2p-issue-critical .p2p-issue-sev { color: var(--txt-bad); }
.btn-chip.active { background: var(--btn-bg); border-color: var(--btn-bg); color: #fff; }

/* ==== paper forms / report PDF: always ink on white, never wider than A4 ==== */
.paper {
  --text-primary: #1a1a1a; --text-secondary: #3f4146; --text-muted: #5d5f63;
  --surface-1: #f4f4f2; --surface-card: #ffffff; --gridline: #d9d9d4; --baseline: #bdbdb6;
  --border-hairline: rgba(0, 0, 0, 0.14); --txt-good: #0a6e0a; --txt-bad: #b3261e; --txt-warn: #7a4f00; --link: #1d4ed8;
  --shadow-card: none;
  color: #1a1a1a;
}
.paper .data-table { width: 100%; table-layout: auto; font-size: 11.5px; }
.paper .data-table th, .paper .data-table td { white-space: normal; word-break: break-word; padding: 5px 6px; color: #1a1a1a; }
.paper .data-table th { background: #eceae4 !important; color: #1a1a1a !important; border-bottom: 1.5px solid #9d9b93; }
.paper .data-table tbody tr:hover { background: transparent; }
.paper .table-scroll { overflow: visible; }
.paper .stat-tile { box-shadow: none; background: #fff; border: 1px solid #cfcfcf; padding: 10px 12px; }
.paper .stat-tile::after { display: none; }
.paper .stat-value { font-size: 22px; }
.paper .stat-grid { gap: 8px; }
.paper .pill { border: 1px solid currentColor; background: transparent; }
@media print {
  .paper .data-table { font-size: 10px; }
  .paper .stat-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media print {
  html, body { background: #fff !important; background-image: none !important; color-scheme: light; }
  .paper-section-title, .rp-block-title, .paper h3, .paper h4 { break-after: avoid; page-break-after: avoid; }
  .rp-block { break-inside: auto; }
  .paper .data-table thead { display: table-header-group; }
}
@media print {
  :root, :root[data-theme="dark"], :root[data-theme="light"] { color-scheme: light !important; background: #fff !important; }
}

/* ---- โหมดหน้างาน (floor.js): one simple screen, huge targets, Thai only ---- */
.floor { display: none; }
html[data-floor="1"]:not([data-floor-away]) .sidebar,
html[data-floor="1"]:not([data-floor-away]) .topbar,
html[data-floor="1"]:not([data-floor-away]) .bottom-bar,
html[data-floor="1"]:not([data-floor-away]) .main > .view { display: none !important; }
html[data-floor="1"]:not([data-floor-away]) .floor { display: block; max-width: 1100px; margin: 0 auto; }
html[data-floor="1"]:not([data-floor-away]) .main { padding: 16px; }
.floor-back { display: none; }
html[data-floor="1"][data-floor-away] .floor-back { display: block; position: fixed; right: 16px; bottom: 76px; z-index: 60; padding: 14px 20px; font-size: 1.05rem; font-weight: 700;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-lift); cursor: pointer; }
.fl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.fl-hello { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--text-primary); }
.fl-date { color: var(--text-secondary); font-size: 1rem; }
.fl-sync-synced { color: var(--txt-good); } .fl-sync-error, .fl-sync-offline { color: var(--txt-warn); }
.fl-h { font-size: 1.25rem; margin: 22px 0 10px; color: var(--text-primary); }
.fl-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fl-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; min-height: 96px; font-size: 1.05rem; font-weight: 600;
  border: 1px solid var(--border-hairline); border-radius: var(--radius); background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-card); cursor: pointer; }
.fl-tile span { font-size: 2rem; line-height: 1; }
.fl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.fl-card { border: 2px solid var(--border-hairline); border-radius: var(--radius); background: var(--surface-card); padding: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-card); }
.fl-wip { border-color: var(--txt-good); } .fl-hold { border-color: var(--txt-bad); }
.fl-state { font-weight: 700; font-size: 0.95rem; color: var(--text-secondary); }
.fl-wip .fl-state { color: var(--txt-good); } .fl-hold .fl-state { color: var(--txt-bad); }
.fl-op { margin: 0; font-size: 1.5rem; color: var(--text-primary); }
.fl-sub, .fl-time { color: var(--text-secondary); font-size: 1rem; }
.fl-time b { color: var(--text-primary); font-size: 1.15rem; }
.fl-over b { color: var(--txt-bad); }
.fl-why { color: var(--txt-bad); font-weight: 600; }
.fl-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.fl-btn { flex: 1 1 140px; min-height: 64px; padding: 10px 16px; font-size: 1.25rem; font-weight: 700; border-radius: 12px; border: 0; cursor: pointer; }
.fl-go { background: #1f8a4c; color: #fff; }
.fl-stop { background: #c0392b; color: #fff; }
.fl-plain { background: var(--btn-bg); color: var(--text-primary); border: 1px solid var(--border-hairline); font-size: 1.05rem; min-height: 52px; }
.fl-exit { flex: 0 0 auto; min-height: 44px; font-size: 0.95rem; }
.fl-ask { width: 100%; font-weight: 700; font-size: 1.1rem; }
.fl-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; width: 100%; }
.fl-chip { min-height: 56px; padding: 8px; font-size: 1rem; border-radius: 10px; border: 2px solid var(--txt-bad); background: var(--surface-card); color: var(--text-primary); cursor: pointer; }
.fl-qty { display: flex; align-items: center; gap: 14px; width: 100%; justify-content: center; }
.fl-qty output { font-size: 2rem; font-weight: 700; min-width: 60px; text-align: center; }
.fl-step { width: 64px; height: 64px; font-size: 2rem; border-radius: 50%; border: 1px solid var(--border-hairline); background: var(--btn-bg); color: var(--text-primary); cursor: pointer; }
.fl-link { align-self: flex-start; background: none; border: 0; color: var(--link); font-size: 1rem; padding: 8px 0; cursor: pointer; }
.fl-empty { font-size: 1.05rem; color: var(--text-secondary); }
.fl-inbox { display: flex; flex-direction: column; gap: 8px; }
.fl-row { display: flex; align-items: center; gap: 12px; padding: 14px; min-height: 60px; text-align: left; border: 1px solid var(--border-hairline); border-radius: 12px; background: var(--surface-card); color: var(--text-primary); cursor: pointer; }
.fl-row > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; } .fl-row small { color: var(--text-secondary); }
.fl-row-i { font-size: 1.5rem; }
@media (max-width: 520px) { .fl-tiles { grid-template-columns: repeat(3, 1fr); } .fl-tile { font-size: 0.9rem; min-height: 84px; } .fl-grid { grid-template-columns: 1fr; } .fl-hello { font-size: 1.35rem; } }
html[data-floor="1"] .floor-toggle { display: none; }

/* ---- จับเวลาวัดผลจริง (pilot-timer.js) ---- */
.pt-form { display: grid; gap: 12px; margin-bottom: 14px; }
.pt-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.pt-seg { display: flex; gap: 0; }
.pt-seg button { flex: 1; min-height: 44px; border: 1px solid var(--border-hairline); background: transparent; color: var(--text-primary); cursor: pointer; font-size: 1rem; }
.pt-seg button:first-child { border-radius: 10px 0 0 10px; } .pt-seg button:last-child { border-radius: 0 10px 10px 0; }
.pt-seg button.on { background: var(--accent); border-color: var(--accent); color: #16181c; font-weight: 700; }
.pt-watch { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pt-watch output { font-family: var(--font-mono); font-size: 2.4rem; min-width: 140px; }
.pt-big { min-height: 52px; font-size: 1.1rem; padding: 8px 22px; }
.pt-manual { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pt-manual input { width: 110px; }
.pt-table small { color: var(--text-secondary); }
.pt-good { color: var(--txt-good); font-weight: 700; } .pt-bad { color: var(--txt-bad); font-weight: 700; }
.pt-recent { margin-top: 10px; } .pt-recent li { margin: 4px 0; }

/* ---- คำย่อ (glossary.js) ---- */
.gl-modal { max-width: 560px; }
.gl-list { margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.gl-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-hairline); }
.gl-row dt { font-family: var(--font-mono); font-weight: 600; color: var(--accent); }
.gl-row dd { margin: 0; display: flex; flex-direction: column; } .gl-row small { color: var(--text-secondary); }
@media print { .floor, .floor-back { display: none !important; } }
.fl-wait { color: var(--txt-warn); font-weight: 600; }
.fl-later { opacity: 0.8; border-style: dashed; }
.fl-req { max-width: 640px; }
.fl-note { color: var(--text-secondary); margin: 6px 0 10px; }
.fl-req-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 50vh; overflow-y: auto; }
.fl-req-row { display: grid; grid-template-columns: 32px 1fr 90px; gap: 10px; align-items: center; padding: 10px; min-height: 60px; border: 1px solid var(--border-hairline); border-radius: 10px; cursor: pointer; }
.fl-req-row input[type=checkbox] { width: 26px; height: 26px; }
.fl-req-row span { display: flex; flex-direction: column; } .fl-req-row small { color: var(--text-secondary); }
.fl-req-qty { min-height: 44px; font-size: 1.1rem; text-align: center; }
.fl-req-note { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 600; }

/* ---- sign-in / password dialog ---- */
.pw-modal { max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.pw-modal label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.pw-modal input[type=password], .pw-modal input[type=text] { min-height: 44px; font-size: 1.05rem; }
.pw-modal .pw-show { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.pw-modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.login-eye { margin-left: -4px; }
.login-more { display: flex; gap: 12px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.st-secure { margin: 14px 0; padding: 14px; border: 1px solid var(--border-hairline); border-radius: var(--radius); }
.st-secure h4 { margin: 0 0 8px; }
.st-secure-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.st-log { max-height: 360px; overflow-y: auto; }
.st-log-bad td { color: var(--txt-bad); }
.bx-short { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--txt-warn); border-radius: var(--radius-sm); }
.bx-short ul { margin: 6px 0 0; padding-left: 18px; } .bx-short li { margin: 4px 0; }
.bx-proof { font-family: var(--font-mono); font-size: 0.8em; color: var(--text-secondary); }

/* ---- ลำดับขั้น & การอนุมัติ (approval.js) ---- */
.apv-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(320px, 2fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 900px) { .apv-grid { grid-template-columns: 1fr; } }
.apv-card { padding: 14px 16px; }
.apv-card h3 { margin: 0 0 10px; font-size: 1rem; }
.apv-levels { margin: 0 0 8px; padding-left: 22px; }
.apv-levels li { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.apv-levels .apv-lvname { flex: 1 1 160px; min-width: 0; }
.apv-users { max-height: 420px; overflow: auto; }
.apv-users select { max-width: 220px; }
.apv-kind { border-top: 1px solid var(--border, #d0d5dd); padding: 10px 0; }
.apv-kind-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.apv-step { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 6px 8px; margin: 4px 0; border-radius: var(--radius-sm, 6px); background: color-mix(in srgb, currentColor 5%, transparent); }
.apv-step label { display: inline-flex; gap: 6px; align-items: center; }
.apv-step input[type=number] { width: 120px; }
.apv-stepno { font-weight: 700; min-width: 48px; }
.apv-stepbtns { margin-left: auto; display: inline-flex; gap: 4px; }
.apv-preview { margin-top: 6px; font-size: .9em; line-height: 1.9; }
.apv-chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--border, #d0d5dd); border-radius: 999px; }
.apv-trail { margin: 6px 0 10px; padding-left: 20px; font-size: .92em; }
.apv-trail li { margin: 3px 0; }
.apv-trail li.done { color: var(--txt-good, #067647); }
.apv-trail li.now { font-weight: 600; color: var(--txt-warn, #b54708); }
.paper-apv { margin-top: 14px; font-size: 10pt; }

/* ประวัติรายคัน: responsible people */
.sn-owner { margin-top: 4px; }
.sn-steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 10px 0 4px; }
.sn-step { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border: 1px solid var(--gridline, #d0d5dd); border-left-width: 4px; border-radius: 6px; font-size: 12.5px; }
.sn-step small { opacity: .75; }
.sn-st-done { border-left-color: var(--txt-good, #067647); }
.sn-st-wip { border-left-color: var(--link, #1570ef); }
.sn-st-hold { border-left-color: var(--txt-bad, #b42318); }
.sn-st-open { border-left-color: var(--gridline, #98a2b3); }
.sn-by { font-weight: 600; }
.sn-by-none { opacity: .6; font-weight: 400; }

/* signing: pick the box */
.es-slots { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.es-slots legend { font-weight: 600; margin-bottom: 6px; }
.es-slot { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--gridline, #d0d5dd); border-radius: 8px; cursor: pointer; }
.es-slot span { display: flex; flex-direction: column; }
.es-slot small { opacity: .75; }
.es-slot:has(input:checked) { border-color: var(--link, #1570ef); box-shadow: 0 0 0 1px var(--link, #1570ef); }
.es-slot-off { opacity: .6; cursor: not-allowed; }
.sig-box.sig-can { cursor: pointer; border-radius: 8px; outline: 2px dashed var(--link, #1570ef); outline-offset: 4px; }
.sig-box.sig-can .sig-line { color: var(--link, #1570ef); font-weight: 600; }
@media print { .sig-box.sig-can { outline: 0; } .sig-box.sig-can .sig-line { color: transparent; } }
.pdf-capture .sig-box.sig-can { outline: 0; } .pdf-capture .sig-box.sig-can .sig-line { color: transparent; }

.es-slot-proxy { border-style: dashed; }
.es-proxy { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--txt-warn, #b54708) 8%, transparent); }
.sig-proxy { font-size: 11px; color: var(--txt-warn, #b54708); }

/* store operations (stockops.js) */
.st-additem { margin: 8px 0 12px; }
.st-additem summary { cursor: pointer; font-weight: 600; color: var(--link, #1570ef); }
.st-addgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-items: end; margin-top: 8px; }
.st-addgrid label, .st-countnew label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.st-countnew { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
tr.st-var td { background: color-mix(in srgb, var(--txt-warn, #b54708) 8%, transparent); }

/* Admin › การเข้าสู่ระบบ */
.la-policy { display: flex; flex-wrap: wrap; gap: 12px; }
.la-policy label { display: flex; flex-direction: column; gap: 4px; }
.la-table input.la-user, .la-table input.la-emp { max-width: 140px; }
.la-acts { white-space: nowrap; }
.la-off td { opacity: .55; }
.la-slips { margin: 8px 0; padding: 8px 10px; border-radius: 8px; line-height: 2; background: color-mix(in srgb, var(--txt-warn, #b54708) 8%, transparent); }

.la-trial { margin-top: 10px; padding: 10px 12px; border-radius: 8px; border: 1px dashed var(--gridline, #d0d5dd); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.la-trial.on { border: 1px solid var(--txt-warn, #b54708); background: color-mix(in srgb, var(--txt-warn, #b54708) 10%, transparent); }

/* master schedule: lots with their machines */
.ms-lot { border-top: 1px solid var(--gridline); padding-top: 4px; margin-top: 4px; }
.ms-lot .gantt-row-label small.ms-cust { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.ms-child .gantt-row-label { padding-left: 14px; }
.ms-child { min-height: 38px; }
.ms-behind { color: var(--txt-bad, #b42318); font-weight: 700; }
@media (min-width: 900px) { #view-schedule .gantt-row, #view-schedule .gantt-header { grid-template-columns: 310px 1fr; } .ms-lot .gantt-row-label small.ms-cust { max-width: 210px; } }
#view-schedule .gantt-row-label small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-schedule .gantt-row-label small.ms-actual { white-space: normal; }

/* work orders: grouped by sales order, production progress */
tr.wo-group-row td { background: color-mix(in srgb, var(--accent, #f2a60d) 10%, transparent); font-size: 13px; padding-top: 10px; padding-bottom: 8px; }
.wo-steps { display: flex; align-items: center; gap: 8px; }
.wo-steps-bar { width: 90px; height: 8px; border-radius: 4px; background: var(--gridline, #d0d5dd); overflow: hidden; }
.wo-steps-bar span { display: block; height: 100%; background: var(--txt-good, #067647); }
.wo-late-txt { color: var(--txt-bad, #b42318); }

/* capacity heat map */
.cap-heat td, .cap-heat th { text-align: center; white-space: nowrap; }
.cap-heat td:first-child, .cap-heat th:first-child { text-align: left; }
.cap-heat .cap-past { color: var(--text-muted); }
.cap-heat .cap-ok { background: color-mix(in srgb, var(--txt-good, #067647) 16%, transparent); }
.cap-heat .cap-warn { background: color-mix(in srgb, var(--txt-warn, #b54708) 22%, transparent); font-weight: 600; }
.cap-heat .cap-over { background: color-mix(in srgb, var(--txt-bad, #b42318) 28%, transparent); font-weight: 700; }
.cap-heat th.cap-now { color: var(--txt-bad, #b42318); }

.res-live { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--gridline, #d0d5dd); font-size: 13px; }
.res-live-bad { border-color: var(--txt-bad, #b42318); background: color-mix(in srgb, var(--txt-bad, #b42318) 8%, transparent); }

.p2p-who { font-weight: 600; margin-top: 2px; }

/* ผังองค์กร */
.og-tree, .og-tree ul { list-style: none; margin: 0; padding-left: 22px; }
.og-tree { padding-left: 0; }
.og-tree ul { border-left: 2px solid var(--gridline, #d0d5dd); margin-left: 12px; }
.og-tree li { position: relative; margin: 8px 0; }
.og-tree ul > li::before { content: ""; position: absolute; left: -22px; top: 22px; width: 18px; border-top: 2px solid var(--gridline, #d0d5dd); }
.og-card { display: inline-flex; flex-direction: column; gap: 4px; min-width: 260px; max-width: 560px; padding: 8px 12px; border: 1px solid var(--gridline, #d0d5dd); border-radius: 10px; background: var(--surface-1, transparent); }
.og-card.og-adv { border-style: dashed; opacity: .9; }
.og-head { display: flex; align-items: center; gap: 6px; }
.og-head b { flex: 1; }
.og-n { min-width: 28px; text-align: center; border-radius: 6px; font-weight: 700; font-size: 12px; padding: 1px 6px; }
.og-plan { background: color-mix(in srgb, var(--txt-warn, #b54708) 22%, transparent); }
.og-full { background: color-mix(in srgb, var(--txt-good, #067647) 28%, transparent); }
.og-short { background: color-mix(in srgb, var(--txt-bad, #b42318) 26%, transparent); }
.og-people { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.og-linked { font-weight: 600; }
.og-free { opacity: .75; }
.og-vac { color: var(--txt-bad, #b42318); font-weight: 600; }
.og-meta { font-size: 12px; opacity: .8; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.og-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.og-imp textarea { width: 100%; min-width: 220px; font: inherit; }

tr.sup-best td { background: color-mix(in srgb, var(--txt-good, #067647) 12%, transparent); }

.mob-pick { grid-column: 1 / -1; }
.mob-pick input { width: 100%; }
