/* =====================================================================
   ค้าส่งมะม่วงนำเข้า · ธีม Soft Blue (ตาม theme-prompt-soft-blue-dashboard.md)
   โครง: sidebar ซ้าย (ยุบได้) + topbar + พื้นที่เนื้อหาแบบการ์ด
   ===================================================================== */
:root {
  --bg: #e4f0fc;
  --bg-grad-a: #f0f6fe;
  --bg-grad-b: #d3e7fa;
  --surface: #f7fafe;
  --surface-solid: #ffffff;
  --glass: rgba(255, 255, 255, 0.72);
  --primary: #087af5;
  --primary-soft: #dcebfd;
  --navy: #174b80;
  --navy-deep: #123969;
  --on-navy: #ffffff;
  --text: #18232d;
  --muted: #5b6a7b;
  --border: #d7e3ef;
  --accent: #91c7d1;
  --ok: #157a4f;     --ok-soft: #dff3ea;
  --warn: #a45a00;   --warn-soft: #fdf0dc;
  --bad: #c0281b;    --bad-soft: #fde7e5;
  --track: #e6eef7;
  --shadow-card: 0 6px 20px rgba(50, 90, 130, 0.06);
  --shadow-pop: 0 24px 60px rgba(29, 52, 81, 0.18);
  --focus: 0 0 0 3px rgba(8, 122, 245, 0.28);
  --font: "Inter", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-card: 26px; --r-ctl: 14px; --r-pill: 999px;
  --sb-w: 264px; --sb-w-mini: 84px;
  --t: 180ms ease;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1828; --bg-grad-a: #102035; --bg-grad-b: #0a1422;
    --surface: #14243a; --surface-solid: #172a43; --glass: rgba(20, 36, 58, 0.78);
    --primary: #3d95f7; --primary-soft: #18365a;
    --navy: #2d6db3; --navy-deep: #0b2a4f; --on-navy: #ffffff;
    --text: #e6eef8; --muted: #9db0c6; --border: #24384f; --accent: #5aa5b3;
    --ok: #4fd39a; --ok-soft: #11372a; --warn: #f2b25c; --warn-soft: #3a2a12; --bad: #ff8a7d; --bad-soft: #3e1c1a;
    --track: #1d3049;
    --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.25); --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1828; --bg-grad-a: #102035; --bg-grad-b: #0a1422;
  --surface: #14243a; --surface-solid: #172a43; --glass: rgba(20, 36, 58, 0.78);
  --primary: #3d95f7; --primary-soft: #18365a;
  --navy: #2d6db3; --navy-deep: #0b2a4f; --on-navy: #ffffff;
  --text: #e6eef8; --muted: #9db0c6; --border: #24384f; --accent: #5aa5b3;
  --ok: #4fd39a; --ok-soft: #11372a; --warn: #f2b25c; --warn-soft: #3a2a12; --bad: #ff8a7d; --bad-soft: #3e1c1a;
  --track: #1d3049;
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.25); --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text);
  background: linear-gradient(160deg, var(--bg-grad-a), var(--bg) 45%, var(--bg-grad-b)) fixed, var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100%; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sb-w);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 14px;
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--border); transition: width var(--t), transform var(--t);
  padding-top: max(18px, env(safe-area-inset-top));
}
@supports not (backdrop-filter: blur(1px)) { .sidebar { background: var(--surface); } }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px; min-height: 48px; }
.brand-logo {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: var(--on-navy); font-size: 18px;
}
.brand-text { line-height: 1.25; white-space: nowrap; overflow: hidden; }
.brand-text b { display: block; font-weight: 600; font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--muted); }

.nav { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; -ms-overflow-style: none; display: flex; flex-direction: column; gap: 4px; }
.nav::-webkit-scrollbar { display: none; width: 0; height: 0; }
.nav-item, .nav-group > button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 14px;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text);
  font: inherit; font-size: 14.5px; text-decoration: none; cursor: pointer; text-align: left; white-space: nowrap;
  transition: background var(--t), color var(--t);
}
.nav-item i, .nav-group > button i.ico { font-size: 19px; width: 22px; text-align: center; flex: none; color: var(--muted); }
.nav-item:hover, .nav-group > button:hover { background: var(--primary-soft); }
.nav-item.active { background: var(--navy); color: var(--on-navy); }
.nav-item.active i { color: var(--on-navy); }
.nav-group > button .chev { margin-left: auto; font-size: 13px; color: var(--muted); transition: transform var(--t); }
.nav-group.open > button .chev { transform: rotate(180deg); }
.nav-group.has-active > button { color: var(--navy); font-weight: 600; }
.nav-group.has-active > button i.ico { color: var(--navy); }
.nav-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t); }
.nav-group.open .nav-sub { grid-template-rows: 1fr; }
.nav-sub > div { overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding-left: 22px; }
.nav-sub .nav-item { min-height: 40px; font-size: 14px; }
.nav-sub .nav-item i { font-size: 16px; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { font-size: 12px; color: var(--muted); padding: 4px 10px; white-space: nowrap; overflow: hidden; }

/* ยุบ sidebar (เดสก์ท็อป) */
body.sb-mini .sidebar { width: var(--sb-w-mini); }
body.sb-mini .brand-text, body.sb-mini .nav-label, body.sb-mini .chev, body.sb-mini .sidebar-foot { display: none; }
body.sb-mini .nav-item, body.sb-mini .nav-group > button { justify-content: center; padding: 8px; }
body.sb-mini .nav-sub { display: none; }
body.sb-mini .brand { justify-content: center; }
.flyout {
  position: fixed; z-index: 60; min-width: 220px; padding: 8px; border-radius: 18px;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 2px;
}
.flyout .flyout-title { font-size: 12px; color: var(--muted); padding: 4px 12px 6px; }

.main { flex: 1; min-width: 0; margin-left: var(--sb-w); transition: margin-left var(--t); display: flex; flex-direction: column; }
body.sb-mini .main { margin-left: var(--sb-w-mini); }
.sb-overlay { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; font-size: 18px;
  transition: background var(--t);
}
.icon-btn:hover { background: var(--primary-soft); }
.user-chip {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px 0 6px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 14px;
}
.user-chip .av { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: var(--on-navy); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-dot.on::before { background: var(--ok); }

.content {
  width: 100%; max-width: 1480px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
  padding: 24px max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left));
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(-105%); box-shadow: var(--shadow-pop); background: var(--surface-solid); }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .sb-overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 20, 35, 0.35); }
  .main, body.sb-mini .main { margin-left: 0; }
  body.sb-mini .sidebar { width: var(--sb-w); }
  body.sb-mini .brand-text, body.sb-mini .nav-label, body.sb-mini .chev, body.sb-mini .sidebar-foot { display: revert; }
  body.sb-mini .nav-item, body.sb-mini .nav-group > button { justify-content: flex-start; padding: 8px 14px; }
  body.sb-mini .nav-sub { display: grid; }
  .hide-md { display: none !important; }
}
@media (max-width: 600px) {
  .hide-sm { display: none !important; }
  .content { padding-top: 16px; gap: 12px; }
  .topbar { gap: 8px; }
  .icon-btn { width: 40px; height: 40px; }
}

/* ---------- Components ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h2 { font-size: clamp(24px, 3vw, 32px); font-weight: 500; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
  background: var(--glass); border: 1px solid rgba(255, 255, 255, 0.6); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); padding: 20px; min-width: 0;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
:root[data-theme="dark"] .card { border-color: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card { border-color: var(--border); } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 17px; font-weight: 500; }
.card.navy { background: var(--navy-deep); color: var(--on-navy); border-color: transparent; }
.card.navy .muted, .card.navy .card-head .muted { color: rgba(255, 255, 255, 0.72); }
.circle-link {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center;
  color: var(--text); text-decoration: none; background: var(--surface); flex: none;
}
.card.navy .circle-link { border-color: rgba(255,255,255,.25); background: transparent; color: #fff; }

.grid { display: grid; gap: 16px; }
.g-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }
@media (max-width: 1199px) { .span-3 { grid-column: span 6; } .span-4, .span-5, .span-7, .span-8, .span-9 { grid-column: span 12; } .span-6 { grid-column: span 12; } }
@media (max-width: 640px) { .g-12 > * { grid-column: span 12 !important; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 18px;
  border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14.5px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t), border-color var(--t), opacity var(--t);
}
.btn:hover { background: var(--primary-soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 13.5px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 9px 14px; border-radius: var(--r-ctl); border: 1px solid var(--border);
  background: var(--surface-solid); color: var(--text); font: inherit; font-size: 15px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.hint { font-size: 12.5px; color: var(--muted); }
.be-hint { font-size: 12px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 500; white-space: nowrap; background: var(--track); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }

.table-wrap { overflow-x: auto; border-radius: 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); background: var(--primary-soft); padding: 10px 12px; white-space: nowrap; }
.tbl th:first-child { border-radius: 12px 0 0 12px; } .tbl th:last-child { border-radius: 0 12px 12px 0; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--primary-soft); }
.tbl tr.row-bad td { background: var(--bad-soft); }
.tbl .wrap { white-space: normal; min-width: 180px; }
.empty-state { text-align: center; color: var(--muted); padding: 32px 12px; white-space: normal; }
.empty-state i { font-size: 30px; display: block; margin-bottom: 6px; color: var(--accent); }

.kpi-row { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-end; }
.kpi { display: flex; align-items: flex-end; gap: 10px; }
.kpi .ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 15px; margin-bottom: 6px; }
.kpi b { display: block; font-size: clamp(30px, 3.4vw, 44px); font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill-bar { height: 44px; border-radius: var(--r-pill); display: flex; align-items: center; padding: 0 16px; font-size: 13.5px; color: #fff; background: var(--navy); min-width: 64px; font-variant-numeric: tabular-nums; }
.pill-bar.blue { background: var(--primary); }
.pill-bar.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.pill-bar.hatch { background: repeating-linear-gradient(135deg, var(--track) 0 6px, transparent 6px 12px); color: var(--muted); }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 14px 16px; }
.tile small { display: block; color: var(--muted); font-size: 12.5px; }
.tile b { display: block; font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tile em { font-style: normal; font-size: 12.5px; color: var(--muted); }
.tile.pos b { color: var(--ok); } .tile.neg b { color: var(--bad); }

.cap-bar { height: 12px; border-radius: var(--r-pill); background: var(--track); display: flex; overflow: hidden; gap: 3px; }
.cap-bar i { display: block; height: 100%; border-radius: var(--r-pill); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: var(--c); }

.steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.steps li { padding: 6px 14px; border-radius: var(--r-pill); background: var(--track); color: var(--muted); font-size: 13px; }
.steps li.done { background: var(--primary-soft); color: var(--primary); }
.steps li.now { background: var(--navy); color: var(--on-navy); }

/* ออกบิล: สต๊อก | บิล บนจอกว้าง, ซ้อนกันบนจอเล็ก */
.sale-grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1500px) { .sale-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }

/* Stock matrix */
.matrix { border-collapse: separate; border-spacing: 6px; }
.matrix th { font-size: 12.5px; color: var(--muted); font-weight: 500; text-align: center; padding: 2px 4px; white-space: nowrap; }
.matrix th:first-child { text-align: left; }
.cell {
  width: 100%; min-width: 92px; min-height: 64px; border: 1px solid var(--border); background: var(--surface-solid);
  border-radius: 16px; padding: 8px; display: grid; gap: 1px; justify-items: center; cursor: pointer;
  font: inherit; color: var(--text); line-height: 1.2; transition: background .6s, border-color var(--t);
}
.cell:hover { border-color: var(--primary); }
.cell b { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.cell em, .cell span { font-style: normal; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell.low b { color: var(--warn); }
.cell.zero { opacity: .45; cursor: not-allowed; }
.cell.sel { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cell.flash { background: var(--primary-soft); }
.lot-block + .lot-block { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.lot-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 4px; }
.lot-head h4 { margin: 0; font-size: 15px; font-weight: 600; }

.err-text { color: var(--bad); font-size: 12.5px; display: block; white-space: normal; }
.warn-text { color: var(--warn); font-size: 12.5px; display: block; white-space: normal; }
.totals { display: grid; justify-content: end; gap: 4px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 48px; }
.totals .grand { font-size: 20px; font-weight: 600; border-top: 1px solid var(--border); padding-top: 6px; }

.task-list { display: flex; flex-direction: column; gap: 10px; list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; align-items: center; gap: 12px; }
.task-list .t-ico { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.1); display: grid; place-items: center; flex: none; }
.task-list .t-main { flex: 1; min-width: 0; }
.task-list .t-main b { display: block; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-list .t-main small { font-size: 12px; opacity: .72; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { min-width: 150px; flex: 1 1 150px; max-width: 260px; }
.seg { display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: var(--r-pill); font: inherit; font-size: 13.5px; color: var(--muted); cursor: pointer; min-height: 34px; }
.seg button.on { background: var(--navy); color: var(--on-navy); }

.skeleton { height: 120px; border-radius: var(--r-card); background: linear-gradient(90deg, var(--track), var(--surface), var(--track)); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.login-card { width: min(420px, 100%); background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-radius: 32px; padding: 32px; box-shadow: var(--shadow-pop); border: 1px solid var(--border); display: grid; gap: 16px; }
.login-card h1 { font-size: 26px; font-weight: 500; }

/* ---------- TV mode ---------- */
body.tv .sidebar, body.tv .topbar { display: none; }
body.tv .main { margin-left: 0; }
body.tv .content { max-width: none; padding: 24px 32px; }
.tv-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 32px; }
.tv-head h2 { font-size: clamp(28px, 2.6vw, 48px); font-weight: 500; }
.tv-clock { margin-left: auto; font-size: clamp(32px, 3vw, 56px); font-weight: 300; font-variant-numeric: tabular-nums; }
.tv-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.tv-kpis .card b { display: block; font-size: clamp(36px, 3.6vw, 72px); font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tv-kpis .card small { font-size: clamp(14px, 1.1vw, 22px); color: var(--muted); }
.tv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr)); gap: 16px; }
.tv .matrix .cell { min-width: 120px; min-height: 84px; cursor: default; }
.tv .matrix .cell b { font-size: clamp(22px, 1.8vw, 34px); }
.tv .matrix .cell em { font-size: clamp(12px, .9vw, 16px); }
.tv-exit { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 50; opacity: .35; transition: opacity var(--t); }
.tv-exit:hover, .tv-exit:focus-visible { opacity: 1; }

/* ---------- Print ---------- */
.doc { background: #fff; color: #111; border-radius: 12px; padding: 32px; max-width: 900px; margin: 0 auto; font-size: 14px; box-shadow: var(--shadow-card); }
.doc h1 { font-size: 22px; font-weight: 600; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.doc th, .doc td { border: 1px solid #c9d3de; padding: 6px 8px; }
.doc th { background: #eef4fb; font-weight: 600; }
.doc .r { text-align: right; font-variant-numeric: tabular-nums; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.doc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; text-align: center; }
.doc-sign div { border-top: 1px dotted #555; padding-top: 6px; }
.void-stamp { color: #c0281b; border: 3px solid #c0281b; display: inline-block; padding: 2px 14px; font-weight: 700; transform: rotate(-6deg); }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .tv-exit { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  .doc { box-shadow: none; padding: 0; border-radius: 0; }
}

/* ---------- SweetAlert2 ปรับให้เข้าธีม ---------- */
.swal2-popup { border-radius: 26px !important; background: var(--surface-solid) !important; color: var(--text) !important; font-family: var(--font) !important; }
.swal2-title { font-size: 20px !important; font-weight: 500 !important; color: var(--text) !important; }
.swal2-html-container { color: var(--text) !important; font-size: 15px !important; }
.swal2-styled { border-radius: var(--r-pill) !important; min-height: 44px; padding: 8px 22px !important; font-weight: 500 !important; }
.swal2-styled.swal2-confirm { background: var(--primary) !important; }
.swal2-styled.swal2-cancel { background: var(--track) !important; color: var(--text) !important; }
.swal2-styled.swal2-deny { background: var(--bad) !important; }
.swal2-input, .swal2-textarea, .swal2-select { border-radius: var(--r-ctl) !important; border: 1px solid var(--border) !important; background: var(--surface) !important; color: var(--text) !important; box-shadow: none !important; }
.swal2-validation-message { background: var(--bad-soft) !important; color: var(--bad) !important; }
.swal2-toast { box-shadow: var(--shadow-pop) !important; }
.swal-form { display: grid; gap: 12px; text-align: left; }
.swal-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .swal-form .row2 { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
#loginMsg { color: var(--bad); min-height: 1.4em; margin: 0; }
