/* =====================================================================
   Commission Suite — styles
   ===================================================================== */
:root {
  --bg: #f3f6fc;
  --bg-2: #eef2fa;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #8494ad;
  --line: #e6ebf4;
  --line-2: #eef2f8;
  --brand: #3b5bfd;
  --brand-2: #22d3ee;
  --brand-soft: #eef2ff;
  --ok: #0ea472;
  --ok-soft: #e7f8f1;
  --warn: #d97706;
  --warn-soft: #fff7e6;
  --bad: #e11d48;
  --bad-soft: #fff1f4;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-s: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 28px -14px rgba(15, 23, 42, .28);
  --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, .38);
  --sidebar-w: 268px;
  --font: "Segoe UI", "Leelawadee UI", "Noto Sans Thai", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow-anchor: none; scroll-behavior: auto; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }

/* ------------------------------- shell ------------------------------ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(178deg, #0a1120 0%, #101c33 52%, #0b1526 100%);
  color: #cbd6e8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(520px 240px at -10% 0%, rgba(59, 91, 253, .35), transparent 70%),
    radial-gradient(420px 220px at 110% 100%, rgba(34, 211, 238, .18), transparent 70%);
  pointer-events: none;
}
.brand {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 22px 22px 18px;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  background: linear-gradient(135deg, #3b5bfd, #22d3ee);
  display: grid; place-items: center;
  box-shadow: 0 6px 16px -9px rgba(59, 91, 253, .55);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-txt strong { display: block; color: #fff; font-size: 15px; letter-spacing: .2px; }
.brand-txt span { display: block; font-size: 11.5px; color: #7f92b0; margin-top: 2px; }

.nav { position: relative; z-index: 1; padding: 6px 12px 16px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #5d6f8d; padding: 16px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px; border: 0;
  background: transparent; color: #b8c6dd; text-align: left;
  font-size: 13.5px; line-height: 1.35; width: 100%;
  transition: background .16s, color .16s, transform .16s;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .8; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.on {
  background: linear-gradient(90deg, rgba(59, 91, 253, .30), rgba(34, 211, 238, .10));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(122, 148, 255, .22);
}
.nav-item.on svg { opacity: 1; color: #8fb0ff; }
.nav-item .num {
  margin-left: auto; font-size: 10.5px; color: #91a6c8;
  background: rgba(255, 255, 255, .07); border-radius: 999px; padding: 1px 7px;
}
.sidebar-foot { margin-top: auto; padding: 10px 16px 14px; position: relative; z-index: 1; }
.sidebar-note {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 2px 0; border-radius: 0;
  background: none; border: 0; border-top: 1px solid rgba(255, 255, 255, .055);
  font-size: 10px; font-weight: 400; line-height: 1.2;
  color: rgba(203, 214, 232, .48); letter-spacing: .15px; text-align: center;
}
.sidebar-note svg { width: 11px; height: 11px; flex: 0 0 11px; opacity: .6; }
.sidebar-note b { color: rgba(203, 214, 232, .5); font-weight: 500; }

/* ------------------------------- main ------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  background: rgba(243, 246, 252, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  flex-wrap: nowrap;
  min-height: 64px;
}
.crumb { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; white-space: nowrap; min-width: 0; overflow: hidden; }
.crumb b { color: var(--ink); font-weight: 600; }
.crumb span { overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.period-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 10px 6px 12px;
  box-shadow: var(--shadow-s);
}
.period-box span { font-size: 12px; color: var(--ink-3); }
.period-box input[type="month"] {
  border: 0; outline: 0; background: transparent; font-weight: 600; font-size: 13.5px; width: 132px;
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 14px; border-radius: 11px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-s); transition: .16s;
  white-space: nowrap;
}
.btn:hover { border-color: #cfd9ea; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: linear-gradient(135deg, #3b5bfd, #4f7bff);
  color: #fff; border-color: transparent;
  box-shadow: 0 8px 20px -10px rgba(59, 91, 253, .9);
}
.btn.primary:hover { box-shadow: 0 12px 24px -10px rgba(59, 91, 253, .95); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.view { padding: 24px 28px 48px; }

/* page head */
.page-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 280px; flex: 1 1 380px; }
.page-head h1 { margin: 0; font-size: 23px; letter-spacing: -.2px; }
.page-head p { margin: 7px 0 0; color: var(--ink-2); font-size: 13px; max-width: 720px; line-height: 1.6; }
.page-head .head-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* cards */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-h {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line-2);
}
.card-h h2 { margin: 0; font-size: 14.5px; }
.card-h .sub { font-size: 12px; color: var(--ink-3); }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 18px; }
.card-b.tight { padding: 0; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stats.four { grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); }
.stats.four .v { font-size: 19px; }
.stats.hist6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats.hist6 .v { font-size: 20px; }
.stats.hist8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats.hist8 .v { font-size: 18px; }
.stats.hist8 .k { font-size: 11px; }
.stats.hist9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats.hist9 .v { font-size: 19px; }
.stats.five { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stats.five .v { font-size: 20px; }
@media (max-width: 700px) {
  .stats.four { grid-template-columns: repeat(2, 1fr); }
  .stats.hist6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.hist8 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.hist9 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-s); position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand); opacity: .9;
}
.stat.ok::before { background: var(--ok); }
.stat.warn::before { background: var(--warn); }
.stat.bad::before { background: var(--bad); }
.stat .k { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.4px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

/* ------------------------------ grid table --------------------------- */
.grid-wrap {
  overflow: auto; max-height: calc(100vh - 330px);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--panel);
  overflow-anchor: none;
}
table.grid {
  border-collapse: separate; border-spacing: 0;
  table-layout: fixed; font-size: 12.5px; width: max-content;
}
table.grid th, table.grid td {
  padding: 0 8px; height: 34px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-bottom: 1px solid var(--line-2);
  background: var(--panel);
  font-variant-numeric: tabular-nums;
}
table.grid thead th {
  position: sticky; z-index: 6;
  background: #f7f9fd; color: var(--ink-2);
  font-weight: 600; font-size: 11.5px;
  border-bottom: 1px solid var(--line);
}
table.grid thead tr.grp th {
  top: 0; height: 32px; font-size: 11px; letter-spacing: .02em;
  background: #eef2fa; color: #2b3a55;
  border-right: 1px solid #e3e9f4;
}
table.grid thead tr.lbl th { top: 32px; height: 40px; vertical-align: middle; }
table.grid thead tr.lbl th span {
  display: block; overflow: hidden; text-overflow: ellipsis;
  white-space: normal; line-height: 1.25; max-height: 30px;
}
table.grid thead tr.lbl th.calc { background: #e8f2ff; color: #1b4f86; }

table.grid tbody tr:nth-child(even) td { background: #fbfcff; }
table.grid tbody tr:hover td { background: #f4f8ff; }
table.grid td.calc { background: #f2f8ff; color: #0b3f70; font-weight: 600; }
table.grid tbody tr:nth-child(even) td.calc { background: #eaf4ff; }
table.grid tbody tr:hover td.calc { background: #e2f0ff; }
table.grid td.neg, table.grid td.calc.neg { color: var(--bad); }
table.grid td.num, table.grid td.calc { text-align: right; }
table.grid td.center { text-align: center; }
table.grid td.editable { cursor: cell; }
table.grid td.editable:hover { box-shadow: inset 0 0 0 1px #b9cdf5; }
table.grid td.editing { padding: 0; box-shadow: inset 0 0 0 2px var(--brand); z-index: 3; }
table.grid td input {
  width: 100%; height: 34px; border: 0; outline: 0; padding: 0 8px;
  background: #fff; font: inherit; text-align: right; font-variant-numeric: tabular-nums;
}
table.grid td.editing.txt input { text-align: left; }
table.grid td .gstart, table.grid th .gstart { border-left: 2px solid #e2e8f4; }

/* sticky columns */
table.grid .sticky { position: sticky; z-index: 4; }
table.grid thead .sticky { z-index: 8; }
table.grid .s0 { left: 0; }
table.grid .s1 { left: 48px; box-shadow: 1px 0 0 var(--line); }
table.grid .s2 { left: 156px; box-shadow: 1px 0 0 var(--line); }
table.grid tbody td.s1 { font-weight: 600; color: #1e293b; }
table.grid tbody td.s2 { color: #334155; }
table.grid td.s0 { color: var(--ink-3); text-align: center; font-size: 11.5px; }

table.grid tfoot td {
  position: sticky; bottom: 0; z-index: 5;
  background: #f0f4fb; font-weight: 700; color: #12233d;
  border-top: 1px solid #dbe3f1; height: 40px;
}
table.grid tfoot td.sticky { z-index: 9; }

/* hide groups */
.hide-g26 .c-g26, .hide-gcard .c-gcard, .hide-g78 .c-g78, .hide-g9 .c-g9,
.hide-ghyb .c-ghyb, .hide-gse .c-gse, .hide-gchk .c-gchk, .hide-gsum .c-gsum,
.hide-g26 .gh-g26, .hide-gcard .gh-gcard, .hide-g78 .gh-g78, .hide-g9 .gh-g9,
.hide-ghyb .gh-ghyb, .hide-gse .gh-gse, .hide-gchk .gh-gchk, .hide-gsum .gh-gsum { display: none; }

/* chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--ink-2);
  box-shadow: var(--shadow-s); transition: .15s;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.chip.on { border-color: #c7d6ff; background: var(--brand-soft); color: #21376e; }
.chip:hover { border-color: #cfd9ea; }

/* toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.seg { display: flex; background: #eef2fa; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 11px; border-radius: 8px;
  font-size: 12px; color: var(--ink-2); font-weight: 600;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-s); }

/* drop zone */
.drop {
  border: 1.5px dashed #c6d3ea; border-radius: var(--radius);
  background: linear-gradient(180deg, #fbfdff, #f5f9ff);
  padding: 34px 24px; text-align: center; color: var(--ink-2);
  transition: .18s; margin-bottom: 16px;
}
.drop.hot { border-color: var(--brand); background: #eff4ff; }
.drop .big {
  width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 12px;
  background: linear-gradient(135deg, #e8eeff, #dff7ff);
  display: grid; place-items: center; color: var(--brand);
}
.drop .big svg { width: 26px; height: 26px; }
.drop h3 { margin: 0 0 6px; font-size: 15px; color: var(--ink); }
.drop p { margin: 0; font-size: 12.5px; }
.drop .row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* file list */
.file-list { display: flex; flex-direction: column; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--line-2); font-size: 13px;
}
.file-row:last-child { border-bottom: 0; }
.file-ico {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
  background: #eaf7ef; color: #0e9f6e; display: grid; place-items: center;
}
.file-ico svg { width: 16px; height: 16px; }
.file-name { font-weight: 600; }
.file-meta { font-size: 11.5px; color: var(--ink-3); }
.file-row .spacer { flex: 1; }

/* คลังเก็บระเบียบ (ไฟล์ PDF) */
.drop.compact { padding: 20px 18px; margin-bottom: 14px; }
.drop.compact .big { width: 44px; height: 44px; border-radius: 13px; margin-bottom: 8px; }
.drop.compact .big svg { width: 22px; height: 22px; }
.drop.compact h3 { font-size: 14px; }
.drop.compact p { max-width: 620px; margin: 0 auto; line-height: 1.6; }
.doc-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.doc-q {
  flex: 1 1 260px; max-width: 360px; padding: 9px 12px; font: inherit; font-size: 13px;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.doc-q:focus { outline: 0; border-color: #a9bdf0; box-shadow: 0 0 0 3px #eef3ff; }
.doc-list { border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: #fff; }
.doc-list .file-row { flex-wrap: wrap; row-gap: 8px; }
.doc-list .file-main { min-width: 0; flex: 1 1 200px; }
.doc-list .file-acts {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  justify-content: flex-end; margin-left: auto;
}
.doc-list .file-name { word-break: break-word; }
.file-ico.pdf { background: #fdecea; color: #dc2626; }
.doc-view {
  height: 62vh; min-height: 340px; border: 1px solid var(--line-2);
  border-radius: 12px; overflow: hidden; background: #eef2f9;
}
.doc-view iframe { width: 100%; height: 100%; border: 0; display: block; }
.doc-tools { white-space: nowrap; }
.doc-tools .muted { font-size: 12px; }
#docCard .card-h h2 { white-space: nowrap; }
.doc-note { font-size: 11.5px; color: var(--ink-3); margin-top: 10px; line-height: 1.6; }

/* ---- โฟลเดอร์หมวดหมู่: พนักงาน / Area Manager / Manager ---- */
.fdr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.fdr {
  --tone: #3b5bfd; --tint: #eef3ff;
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 9px;
  width: 100%; padding: 13px 14px 12px; border: 1px solid var(--line-2); border-radius: 14px;
  background: #fff; font: inherit; text-align: left; cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 32, 64, .04);
  transition: transform .16s, box-shadow .16s, border-color .16s, background .16s;
}
.fdr:hover { transform: translateY(-1px); border-color: #c7d6f2; box-shadow: 0 10px 22px -16px rgba(16, 32, 64, .6); }
.fdr.hot { border-color: var(--tone); background: var(--tint); box-shadow: 0 0 0 3px var(--tint); }
.fdr .fdr-ico {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px;
  display: grid; place-items: center; background: var(--tint); color: var(--tone);
  transition: background .16s, color .16s, box-shadow .16s;
}
.fdr .fdr-ico svg { width: 20px; height: 20px; }
.fdr .fdr-txt { min-width: 0; width: 100%; }
.fdr strong { display: block; font-size: 12.5px; line-height: 1.35; color: var(--ink); }
.fdr small {
  display: block; font-size: 11px; color: var(--ink-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fdr.on { border-color: var(--tone); background: linear-gradient(180deg, #fff 35%, var(--tint)); }
.fdr.on .fdr-ico { background: var(--tone); color: #fff; box-shadow: 0 8px 16px -10px var(--tone); }
.c-all { --tone: #475569; --tint: #eef2f8; }
.c-staff { --tone: #2563eb; --tint: #e9f0ff; }
.c-am { --tone: #7c3aed; --tint: #f2ecff; }
.c-mgr { --tone: #0e9f6e; --tint: #e6f8f0; }
.c-misc { --tone: #d97706; --tint: #fdf3e3; }
.c-none { --tone: #94a3b8; --tint: #f0f3f8; }
.fdr-grid.pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fdr-grid.pick .fdr { flex-direction: row; align-items: center; gap: 11px; }
.fdr-grid.pick .fdr small { white-space: normal; }

/* หัวกลุ่มไฟล์ในมุมมอง “ทั้งหมด” */
.doc-group + .doc-group { margin-top: 14px; }
.doc-group-h {
  display: flex; align-items: center; gap: 7px; padding: 0 2px 7px;
  font-size: 12px; font-weight: 700; color: var(--tone, var(--ink-2));
}
.doc-group-h svg { width: 15px; height: 15px; }
.doc-group-h .n { font-size: 11px; font-weight: 600; color: var(--ink-3); }
.doc-group-h::after { content: ''; flex: 1; height: 1px; margin-left: 4px; background: var(--line-2); }
.doc-bar .doc-clear {
  border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
  background: #eef3ff; color: #2f4c9b; font: inherit; font-size: 12px; font-weight: 600;
}
.doc-bar .doc-clear:hover { background: #e2ebff; }
@media (max-width: 900px) {
  .fdr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fdr-grid.pick { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .fdr-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .doc-list .file-row .spacer { display: none; }
  .doc-q { max-width: none; }
}

.icon-btn {
  border: 0; background: transparent; color: var(--ink-3); padding: 6px; border-radius: 8px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: #f1f5fb; color: var(--bad); }
.icon-btn svg { width: 15px; height: 15px; }

/* mapping grid */
.map-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field label { display: block; font-size: 11.5px; color: var(--ink-3); margin-bottom: 6px; font-weight: 600; }
.field select, .field input[type="text"], .field input[type="email"], .field input[type="password"], .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; background: #fff; outline: 0; font-size: 13px;
}
.field input[type="date"] {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 11px; background: #fff; outline: 0; font-size: 13px; font-family: inherit; color: var(--ink);
}
.field select:focus, .field input:focus, .field textarea:focus { border-color: #a9bdf0; box-shadow: 0 0 0 3px #eef3ff; }

/* ช่วงเวลาที่ใช้เกณฑ์จ่าย */
.eff-state {  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: #f6f8fc;
}
.eff-state.ok { border-color: #b9e6cd; background: #f1fbf5; color: #166534; }
.eff-state.warn { border-color: #f7c9a8; background: #fff7ed; color: #b45309; }
.eff-warn { border-color: #f7c9a8; background: #fffaf3; }
.eff-warn a { color: #b45309; font-weight: 700; }

/* ---------- แถบเชื่อมไฟล์ใบเตรียมต้นทาง (อัปเดตอัตโนมัติ) ---------- */
.file-link { overflow: hidden; }
.file-link .lk {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px;
}
.file-link .lk-ico {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.file-link .lk-ico svg { width: 16px; height: 16px; }
.file-link .lk-main { flex: 1 1 280px; min-width: 0; }
.file-link .lk-main b { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
.file-link .lk-sub { font-size: 11.5px; color: var(--ink-3); line-height: 1.55; margin-top: 2px; }
.file-link .lk-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.file-link .lk-auto .lk-ico { background: var(--ok-soft); color: var(--ok); }
.file-link .lk-auto { background: linear-gradient(90deg, #f4fdf9, #fff 55%); }
.file-link .lk-perm .lk-ico { background: var(--warn-soft); color: var(--warn); }
.file-link .lk-perm { background: linear-gradient(90deg, #fffaf3, #fff 55%); }
.file-link .lk-perm b { color: #b45309; }
@media (max-width: 900px) {
  .file-link .lk-acts { width: 100%; }
}

/* แถบโหมดดูข้อมูลย้อนหลัง */
.ro-bar {  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; margin: 0 0 14px; font-size: 13px; color: #92400e;
  border: 1px solid #f7c9a8; background: #fff7ed; border-radius: 12px;
}
.ro-bar b { color: #92400e; }
.ro-bar span { color: #a16207; font-size: 12.5px; }
.ro-bar.hidden { display: none; }

/* simple table */
table.simple { width: 100%; border-collapse: collapse; font-size: 13px; }
table.simple th {
  text-align: left; font-size: 11.5px; color: var(--ink-3); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #f9fbfe;
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.simple td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); }
table.simple tbody tr:hover td { background: #f7faff; }
table.simple td.num, table.simple th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.simple td.mono { font-variant-numeric: tabular-nums; }
table.simple tfoot td { font-weight: 700; background: #f4f7fd; border-top: 1px solid var(--line); }

.scroll-y { max-height: 420px; overflow: auto; }

/* seizure table */
table.sz { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.sz th {
  position: sticky; top: 0; z-index: 3; background: #f7f9fd;
  font-size: 11.5px; color: var(--ink-2); font-weight: 600; text-align: left;
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.sz td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.sz tr:hover td { background: #fafcff; }
table.sz input.szin {
  width: 100%; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 8px; font-size: 12.5px; background: #f8fafd; outline: 0;
}
table.sz input.szin:hover { background: #f2f6fd; }
table.sz input.szin:focus { background: #fff; border-color: #a9bdf0; box-shadow: 0 0 0 3px #eef3ff; }
table.sz input.szin.bad { background: #fff1f4; border-color: #ffc9d4; }
table.sz input.szin.paid { background: #fff8ea; border-color: #f3d9a4; color: #92400e; font-weight: 600; }
table.sz .amt { font-size: 11px; color: var(--brand); font-weight: 700; margin-top: 3px; padding-left: 8px; }
table.sz .amt.zero { color: #b6c2d4; font-weight: 500; }
table.sz .who { font-weight: 600; }
table.sz .who small { display: block; font-weight: 500; color: var(--ink-3); font-size: 11px; }
table.sz tfoot td { position: sticky; bottom: 0; background: #f2f6fd; font-weight: 700; }

/* criteria */
.crit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.crit-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.crit-table th {
  text-align: left; font-size: 11px; color: var(--ink-3); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: #f9fbfe;
}
.crit-table td { padding: 4px 10px; border-bottom: 1px solid var(--line-2); }
.crit-table td.num { text-align: right; }
.crit-table input {
  width: 88px; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; text-align: right; outline: 0; background: #fff;
  font-variant-numeric: tabular-nums; font-size: 12.5px;
}
.crit-table input.txt { width: 100%; text-align: left; }
.crit-table input:focus { border-color: #a9bdf0; box-shadow: 0 0 0 3px #eef3ff; }

/* history */
.hist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.month-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  background: linear-gradient(180deg, #fff, #fbfcff); box-shadow: var(--shadow-s);
  transition: .16s;
}
.month-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.month-card .m { font-size: 15px; font-weight: 700; }
.month-card .d { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.month-card .amt { font-size: 20px; font-weight: 700; margin-top: 12px; color: var(--ok); font-variant-numeric: tabular-nums; }
.month-card .meta { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.month-card .sub3 {
  display: grid; gap: 3px; margin-top: 10px; padding-top: 9px;
  border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--ink-3);
}
.month-card .sub3 b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.month-card .sub3 em { font-style: normal; color: var(--ok); font-weight: 600; }
.month-card .sub3 .sep { height: 0; border-top: 1px dashed var(--line); margin: 5px 0 4px; }
.month-card .sub3 .tot { color: var(--ink-3); font-size: 11px; }
.month-card .acts { display: flex; gap: 6px; margin-top: 14px; }

/* empty state */
.empty {
  text-align: center; padding: 54px 24px; color: var(--ink-2);
}
.empty .ico {
  width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #e9efff, #e2f8ff);
  display: grid; place-items: center; color: var(--brand);
}
.empty .ico svg { width: 30px; height: 30px; }
.empty h3 { margin: 0 0 8px; color: var(--ink); font-size: 16px; }
.empty p { margin: 0 auto 18px; max-width: 440px; font-size: 13px; line-height: 1.65; }
.empty .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* toast */
#toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: #0f1c33; color: #fff; padding: 12px 16px; border-radius: 12px;
  font-size: 13px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center;
  animation: slide .22s ease-out; max-width: 380px;
}
.toast.ok { background: #0b3f33; }
.toast.bad { background: #4a1024; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); }
.toast.ok .dot { background: #34d399; }
.toast.bad .dot { background: #fb7185; }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(10, 17, 32, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel); border-radius: 20px; box-shadow: var(--shadow-lg);
  width: min(920px, 100%); max-height: calc(100vh - 60px); display: flex; flex-direction: column;
  overflow: hidden; animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: scale(.98) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-h .sub { font-size: 12px; color: var(--ink-3); }
.modal-h .x { margin-left: auto; }
.modal-h { flex: 0 0 auto; }
.modal-b { padding: 22px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.modal-f { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: #fbfcff; flex: 0 0 auto; }

/* payslip */
.slip { font-size: 12.5px; }
.slip-head { display: flex; gap: 18px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); margin-bottom: 14px; }
.slip-head .who { font-size: 16px; font-weight: 700; }
.slip-head .meta { color: var(--ink-3); font-size: 12px; margin-top: 3px; }
.slip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.slip-sec h4 {
  margin: 0 0 8px; font-size: 12px; color: var(--brand); letter-spacing: .02em;
  padding-bottom: 6px; border-bottom: 1px solid var(--line-2);
}
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 5px 0; border-bottom: 1px dotted #eef2f8; }
table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
table.kv tr.total td { border-top: 1px solid var(--line); border-bottom: 0; padding-top: 9px; font-size: 14px; }
.slip-sum { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.slip-sum .b { background: #f7f9fd; border-radius: 12px; padding: 12px 14px; }
.slip-sum .b .k { font-size: 11px; color: var(--ink-3); }
.slip-sum .b .v { font-size: 18px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }
.slip-sum .b.ok .v { color: var(--ok); }
.slip-sum .b.bad .v { color: var(--bad); }

.muted { color: var(--ink-3); }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.row-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hide { display: none !important; }

/* row actions in first column */
table.grid tbody td.s0 .rowdel {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; background: #fff1f4; color: var(--bad);
  font-size: 15px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
table.grid tbody tr:hover td.s0 .rowdel { opacity: 1; }
table.grid tbody td.s0 .rowdel:hover { background: #ffe0e7; }

/* eye icon in name column */
table.grid tbody td.s2 .nm { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
table.grid tbody td.s2 .eye {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  border: 0; background: #e9f1ff; color: var(--brand); border-radius: 7px;
  width: 22px; height: 22px; display: grid; place-items: center;
  opacity: 0; transition: opacity .12s; cursor: pointer;
}
table.grid tbody td.s2 .eye svg { width: 13px; height: 13px; }
table.grid tbody tr:hover td.s2 .eye { opacity: 1; }
table.grid tbody td.s2:hover .nm { padding-right: 24px; }
/* ป้าย “B·ซ้ำ” = แถวเขตรักษาการ (รหัส Bxxxxx ที่ซ้ำกับ Axxxxx) — ไม่นับซ้ำในยอดรวม จำนวนคน/คงเหลือ/จ่ายสุทธิ */
table.grid tbody td.s2 .dup-badge {
  display: inline-block; margin-left: 5px; padding: 0 5px;
  border-radius: 6px; background: #fef3c7; color: #92400e;
  font-size: 10px; font-weight: 700; line-height: 16px;
  vertical-align: middle; cursor: help;
}


/* ============================ payslip document ======================= */
.slip-bar { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.slip-nav { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.doc-wrap { display: flex; justify-content: center; padding: 4px 0 34px; }
.doc {
  width: 820px; max-width: 100%; background: #fff;
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 28px 34px 24px;
  font-size: 12.5px; color: #0f172a;
}
.doc-addr { font-size: 11px; color: var(--ink-3); text-align: center; }
.doc-title { text-align: center; font-size: 18px; font-weight: 700; margin: 5px 0 16px; letter-spacing: .2px; }
.doc-meta { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.doc-meta th {
  text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11px;
  padding: 4px 8px 4px 0; width: 76px; white-space: nowrap;
}
.doc-meta td { padding: 4px 18px 4px 0; border-bottom: 1px dotted #e8eef8; }
.doc-meta td.strong { font-weight: 700; }
.doc-sec { margin-top: 12px; }
.doc-sec h5 {
  margin: 0 0 6px; font-size: 11.5px; color: #1e3a8a; background: #eef4ff;
  padding: 5px 9px; border-radius: 7px; font-weight: 600;
}
.doc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mt8 { margin-top: 8px; }
.doc-kv { width: 100%; border-collapse: collapse; }
.doc-kv td { padding: 4px 0; border-bottom: 1px dotted #eef2f8; }
.doc-kv td small { color: var(--ink-3); font-size: 10.5px; }
.doc-kv td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #f6f9ff; border: 1px solid #e6eefc; border-radius: 9px;
  padding: 8px 12px; font-size: 12px;
}
.doc-box span { color: var(--ink-2); }
.doc-box span small { display: block; color: var(--ink-3); font-size: 10.5px; margin-top: 2px; }
.doc-box b { font-size: 15px; font-variant-numeric: tabular-nums; }
.doc-box b i { font-style: normal; font-size: 10.5px; color: var(--ink-3); margin-left: 4px; font-weight: 600; }
.doc-box.slim { margin-top: 6px; }
.doc-calc { width: 100%; border-collapse: collapse; }
.doc-calc td { padding: 4px 0; border-bottom: 1px dotted #eef2f8; }
.doc-calc td.lbl small { display: block; color: var(--ink-3); font-size: 10px; }
.doc-calc td.lbl small.inl {
  display: inline; font-size: 11px; margin-left: 3px;
  color: #1e3a8a; font-weight: 700; letter-spacing: .1px;
}
.doc-calc.am-block td.lbl { width: auto; font-size: 11px; }
.doc-calc.am-block td.q { width: 30%; text-align: left; }
.doc-calc.am-block td.r { width: 70px; text-align: right; }
.doc-calc.am-block td.a { width: 92px; }
.doc-calc.am-block tr.am-tot td { background: #f1f7ff; font-weight: 700; }
.am-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 10px 14px; }
.am-inputs label { font-size: 11.5px; color: var(--ink-2); }
.am-inputs label em { font-style: normal; color: var(--ink-3); font-size: 11px; }
.am-inputs input { width: 100%; }
/* ช่องที่ระบบรวมยอดจากทีมให้ (คอลัมน์ “ทีม”) — อ่านอย่างเดียว */
.am-inputs label em.auto-tag {
  background: #e7f8f1; color: #0e8f68; border-radius: 6px;
  padding: 0 5px; font-size: 10.5px; font-weight: 700;
}
.am-inputs input[readonly] {
  background: #f4f7fb; color: #5b6b7f; font-style: italic; cursor: not-allowed;
}
.doc-calc td.q, .doc-calc td.r { width: 70px; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.doc-calc td.a { width: 92px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.doc-total {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  padding: 10px 14px; border-radius: 10px; background: #0f172a; color: #fff;
}
.doc-total span { font-size: 12px; opacity: .82; }
.doc-total b { margin-left: auto; font-size: 19px; font-variant-numeric: tabular-nums; }
.doc-total i { font-style: normal; font-size: 11px; opacity: .6; }
.doc-total.ok { background: linear-gradient(135deg, #0f7a5a, #0d9b70); }

/* แถบ “รวมรายการค่าตอบแทน” ให้สี/ขนาดเดียวกับหัวข้อ “รายการหักและสรุปการจ่าย” */
.doc.sd .doc-total {
  background: linear-gradient(90deg, #2f7a5b, #3f8f6b);
  border-radius: 4px; padding: 5px 9px; margin-top: 10px;
  font-size: 11px; font-weight: 700; gap: 8px;
}
.doc.sd .doc-total span { font-size: 11px; font-weight: 700; opacity: 1; }
.doc.sd .doc-total b { font-size: 11px; font-weight: 700; }
.doc.sd .doc-total i { font-size: 10px; opacity: .75; }
.doc-note { margin-top: 10px; font-size: 11.5px; color: var(--ink-2); }
.doc-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 26px; text-align: center; }
.doc-sign .line { display: block; border-bottom: 1px dotted #c9d5e8; height: 34px; margin-bottom: 6px; }
.doc-sign .sign-name { display: block; white-space: pre-wrap; font-size: 13px; color: var(--ink); margin-bottom: 2px; }
.doc-sign small { font-size: 11px; color: var(--ink-3); }

/* ---- payslip form layout (ตามฟอร์มเอกสารเดิม) ---- */
.doc.sd { padding: 20px 26px 22px; }
.sd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.sd-co { display: flex; align-items: center; gap: 10px; }
.sd-logo { display: block; flex: 0 0 auto; }
.sd-logo img { height: 48px; width: auto; display: block; }
.sd-co-t b { display: block; font-size: 13px; }
.sd-co-t span { display: block; font-size: 10.5px; color: #6b7c8d; margin-top: 3px; }
.sd-page { font-size: 10.5px; color: #6b7c8d; white-space: nowrap; }
.sd-title { text-align: center; font-size: 16.5px; font-weight: 700; margin: 14px 0 3px; letter-spacing: .3px; }
.sd-sub { text-align: center; font-size: 12px; font-weight: 700; color: #2f7a5b; margin-bottom: 12px; }
.sd-info { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 4px; }
.sd-info th {
  text-align: left; font-weight: 600; color: #55677a; background: #f6f9fc;
  border: 1px solid #dde6ee; padding: 4px 8px; width: 92px; white-space: nowrap;
}
.sd-info td { border: 1px solid #dde6ee; padding: 4px 10px; }
.sd-info td.b { font-weight: 700; }
.doc.sd .doc-sec { margin-top: 10px; }
.doc.sd .doc-sec h5 {
  background: linear-gradient(90deg, #2f7a5b, #3f8f6b); color: #fff;
  font-weight: 700; font-size: 11px; padding: 5px 9px; border-radius: 4px;
  letter-spacing: .2px; margin: 0;
}
.doc.sd .doc-kv { font-size: 11.5px; }
.doc.sd .doc-kv td { border-bottom: 1px solid #e2ebe4; padding: 4px 8px; }
.doc.sd .doc-kv tr:nth-child(odd) td { background: #f3f8f4; }
.doc.sd .doc-kv td.n { font-weight: 600; }
.doc.sd .doc-box {
  background: #dbe8f6; border: 1px solid #cbdcf0; border-radius: 4px;
  color: #1f4f7a; padding: 7px 10px; font-size: 11.5px;
}
.doc.sd .doc-box b { color: #0f172a; }
.doc.sd .doc-calc td { border-bottom: 1px solid #e6eee8; padding: 4px 6px; }
.doc.sd .doc-calc tr:nth-child(odd) td { background: #f8fbf9; }
.doc.sd .doc-note { color: #7b8a97; font-size: 10.5px; margin-top: 3px; }
/* หน่วย “บาท” ต่อท้ายตัวเลขที่คำนวณ */
.doc.sd i.u {
  font-style: normal; font-size: 9.5px; color: #7b8a97;
  margin-left: 3px; font-weight: 400;
}
/* แถบ “จ่ายสุทธิ” — ต้องเด่นที่สุดในเอกสาร */
.doc.sd .sd-netbar {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  padding: 9px 14px; border-radius: 6px;
  background: linear-gradient(135deg, #0f7a5a, #0d9b70); color: #fff;
}
.doc.sd .sd-netbar span { font-size: 12px; opacity: .9; }
.doc.sd .sd-netbar b { margin-left: auto; font-size: 17px; font-variant-numeric: tabular-nums; }
.doc.sd .sd-netbar i { font-style: normal; font-size: 11px; opacity: .75; }

/* ---------- คีย์ยอด “รายการหัก” จากหน้าสลีป (คลิกแล้วพิมพ์) ---------- */
.doc.sd .sd-ed {
  cursor: pointer; padding: 1px 4px; border-radius: 4px;
  border-bottom: 1px dashed #b9c6e4; font-variant-numeric: tabular-nums;
}
.doc.sd .sd-ed:hover { background: #eef3ff; border-bottom-color: var(--brand); }
.doc.sd .sd-ed.editing { padding: 0; border-bottom-color: transparent; background: transparent; }
.doc.sd .sd-ed-in {
  width: 82px; text-align: right; font: inherit; font-size: 12px; color: var(--ink);
  border: 1px solid #a9bdf0; border-radius: 6px; padding: 2px 5px; outline: 0;
  box-shadow: 0 0 0 3px #eef3ff; background: #fff;
}
.slip-hint {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line);
  font-size: 11.5px; color: var(--ink-3);
}
.slip-hint svg { width: 13px; height: 13px; flex: 0 0 auto; color: var(--brand); }
.slip-hint b { color: var(--ink-2); }
@media print { .doc.sd .sd-ed { border-bottom: 0; padding: 0; } }

/* ---------- ข้อความอธิบายต่อท้าย หนี้สูญ/เครื่องถอด/หักอื่นๆ (คลิกแล้วพิมพ์เอง) ---------- */
.doc.sd .sd-et {
  cursor: text; margin-left: 5px; padding: 0 4px; border-radius: 4px;
  font-weight: 400; font-size: 10.5px; color: #1e3a8a;
  border-bottom: 1px dotted #b9c6e4;
}
.doc.sd .sd-et:hover { background: #eef3ff; border-bottom-color: var(--brand); }
.doc.sd .sd-et .ph { font-style: normal; color: #a9b6c9; font-size: 10px; }
.doc.sd .sd-et.editing { padding: 0; border-bottom-color: transparent; background: transparent; }
.doc.sd .sd-et-in {
  width: 200px; font: inherit; font-size: 11px; color: var(--ink);
  border: 1px solid #a9bdf0; border-radius: 5px; padding: 1px 6px; outline: 0;
  box-shadow: 0 0 0 3px #eef3ff; background: #fff;
}
@media print {
  .doc.sd .sd-et { border-bottom: 0; padding: 0; margin-left: 4px; color: #1e3a8a; }
  .doc.sd .sd-et .ph { display: none; }
}

/* ---------- รายการลดยอดเพิ่มเติมของสลีป Area Manager ---------- */
.doc.sd .sd-xrow .sd-xl { font-size: 11.5px; color: var(--ink); font-weight: 400; }
.doc.sd .sd-xadd {
  margin: 3px 0 1px; padding: 2px 10px; cursor: pointer;
  font: inherit; font-size: 11px; color: #1d4ed8;
  background: #f2f7ff; border: 1px dashed #a9bdf0; border-radius: 999px;
}
.doc.sd .sd-xadd:hover { background: #e6f0ff; border-color: var(--brand); }
.doc.sd .sd-xdel {
  margin-left: 2px; padding: 0 3px; cursor: pointer; line-height: 1;
  font: inherit; font-size: 11px; color: #c2410c;
  background: transparent; border: 0;
}
.doc.sd .sd-xdel:hover { color: #dc2626; }
tr.sd-xadd-row > td { border: 0 !important; background: transparent; padding: 2px 4px; }
@media print {
  .sd-xadd-row, .doc.sd .sd-xdel { display: none !important; }
  .doc.sd .sd-xrow .sd-xl { font-size: 11px; color: #0f172a; }
}

/* ช่องที่ระบบคำนวณให้ (เช่น ฝากทรัพย์ ฝากออม 3% ของคงเหลือ) */
table.grid tbody td.auto-val { color: #8ea0b5; font-style: italic; }

#printArea { display: none; }
@media print {
  body.printing .app, body.printing .sidebar, body.printing .topbar { display: none !important; }
  body.printing #printArea { display: block; }
  body.printing #printArea .doc { page-break-after: always; break-after: page; }
  body.printing #printArea .doc:last-child { page-break-after: auto; break-after: auto; }
  /* สลีปผู้จัดการ: ไม่พิมพ์คอลัมน์คำอธิบาย (คีย์เอง / รวมทีม A-E อัตโนมัติ / คำนวณให้ / สูตร) */
  .doc-calc.mgr-block td.q { display: none !important; }
}

/* ============================== dashboard ============================ */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex: 0 0 168px; }
.donut .dt-v { font-size: 25px; font-weight: 700; fill: #0f172a; }
.donut .dt-k { font-size: 11px; fill: #8494ad; }
.legend { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 6px; }
.lg { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.lg .sw { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.lg .lgl { flex: 1; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg b { font-variant-numeric: tabular-nums; }
.lg i { font-style: normal; color: var(--ink-3); font-size: 11px; width: 46px; text-align: right; }
.hbar { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.hbar .i { width: 24px; color: var(--ink-3); font-size: 11.5px; }
.hbar .nm { width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { flex: 1; height: 9px; background: #eef2fa; border-radius: 99px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6b8cff, #3b5bfd); }
.hbar .fill.alt { background: linear-gradient(90deg, #22d3ee, #0ea5e9); }
.hbar .fill.alt2 { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.hbar b { width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.mini-chart { display: flex; gap: 8px; align-items: flex-end; height: 120px; margin-top: 12px; }
.mc { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1; }
.mc .bar { width: 100%; max-width: 26px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #7f9cff, #3b5bfd); }
.mc i { font-size: 10px; color: var(--ink-3); font-style: normal; white-space: nowrap; }
.dash-sub { margin-top: 16px; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.alert-list { margin: 0; padding-left: 18px; line-height: 1.9; font-size: 12.5px; color: var(--ink-2); }
table.simple.pay td.strong { font-weight: 700; color: #0b3f70; }

/* employee picker */
.pick-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; font-size: 13px; cursor: pointer;
}
.pick-row:hover { background: #f6f9ff; }
.pick-row span { flex: 1; }
.pick-row em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.pick-row input { accent-color: var(--brand); width: 15px; height: 15px; }

/* ================================ print ============================== */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .page-head, .no-print, .modal-backdrop, #toasts, .slip-bar { display: none !important; }
  .app, .main { display: block; }
  .view { padding: 0; }
  .doc-wrap { padding: 0; }
  .doc { width: auto; max-width: 100%; border: 0; box-shadow: none; border-radius: 0; padding: 0; }
  @page { size: A4; margin: 12mm; }
}

@media (max-width: 1180px) {
  .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crit-grid { grid-template-columns: 1fr; }
  .crumb { display: none; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 76px; }
  .brand-txt, .nav-item span.t, .nav-label, .sidebar-note { display: none; }
  .nav-item { justify-content: center; }
  .view { padding: 18px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 12px 16px; gap: 8px; }
  .period-box input[type="month"] { width: 116px; }
  #btnSave { display: none; }
  .doc-two, .dash-grid { grid-template-columns: 1fr; }
  .doc { padding: 20px 18px; }
}

/* ---- print overrides (ต้องอยู่ท้ายไฟล์ เพื่อชนะ media query ของหน้าจอ) ---- */
@media print {
  @page { size: A4 portrait; margin: 5mm 6mm 6mm; }
  .app, .main { display: block; }
  .view { padding: 0; }
  .doc-wrap { display: block; padding: 0; }
  .doc, .doc.sd, #printArea .doc {
    width: 100% !important; max-width: none; border: 0; box-shadow: none; border-radius: 0; padding: 0;
  }
  /* A4 กว้าง ~794px จึงเข้าเงื่อนไข max-width:900px ทําให้ grid ยุบเหลือคอลัมน์เดียว */
  .doc-two { grid-template-columns: 1fr 1fr !important; }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  /* อย่าให้แถบหัวข้อ (เช่น “ค่าดำเนินการถอดหรือยึดสินค้า”) ค้างท้ายหน้าแล้วตารางไปอยู่หน้าถัดไป
     — ถ้าทั้งบล็อกไม่พอดี ให้ยกทั้งบล็อกไปหน้าใหม่ */
  .doc.sd .doc-sec, .doc.sd .doc-box, .doc.sd .doc-total, .doc.sd .sd-netbar,
  .doc.sd .sd-head, .doc.sd .sd-info {
    break-inside: avoid; page-break-inside: avoid;
  }
  .doc.sd .doc-sec h5 { break-after: avoid; page-break-after: avoid; }
  .doc.sd .doc-calc tr, .doc.sd .doc-kv tr { break-inside: avoid; page-break-inside: avoid; }
  /* ให้สีพื้น/แถบสีติดไปกับ PDF */
  .doc.sd, .doc.sd * {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

/* ตารางเนื้อหาสลีป: หัวบรรทัด “ชื่อผู้รับเงิน” (thead) พิมพ์ซ้ำทุกหน้า — บนจอไม่แสดง */
table.sd-rep { width: 100%; border-collapse: collapse; }
table.sd-rep > thead { display: none; }
table.sd-rep > thead > tr > th {
  padding: 0 0 3px; text-align: right; font-size: 8pt; font-weight: 700;
  color: #3b4a63; border: 0; background: #fff;
}
table.sd-rep > tbody > tr > td { padding: 0; border: 0; vertical-align: top; }
@media print {
  table.sd-rep > thead { display: table-header-group; }
}
/* ---------- ผู้ใช้ / สิทธิ์ ---------- */
.user-chip { display:inline-flex; align-items:center; gap:8px; padding:6px 10px; border:1px solid var(--line);
  border-radius:10px; background:#fff; font-size:12.5px; color:var(--ink-2); }
.user-chip svg { width:15px; height:15px; color:var(--ink-3); }
.user-chip b { color:var(--ink); font-weight:600; }
.user-chip em { font-style:normal; font-size:11px; color:var(--ink-3); }
.user-chip button { border:0; background:none; color:var(--brand); font-size:12px; cursor:pointer; padding:2px 4px; }
.user-chip button:hover { text-decoration:underline; }

/* ชิปผู้ใช้ที่มุมบนซ้าย ใต้ “Commission Suite” (ในแถบด้านข้างสีเข้ม) */
.sidebar .user-chip {
  position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px;
  margin: 0 14px 12px; padding: 10px 12px; width: auto;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 14px; color: #cbd6e8; font-size: 12.5px;
  box-shadow: 0 10px 22px -18px rgba(0, 0, 0, .8);
}
.sidebar .user-chip > svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; color: #8fb0ff; }
.sidebar .user-chip .uc-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 0; min-width: 0; }
.sidebar .user-chip .uc-main b {
  color: #fff; font-weight: 600; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar .user-chip .uc-main em { font-style: normal; font-size: 11px; color: #93a5c2; }
.sidebar .user-chip .uc-main .badge-warn { margin: 4px 0 0; align-self: flex-start; }
.sidebar .user-chip .uc-actions { display: flex; gap: 6px; width: 100%; }
.sidebar .user-chip .uc-actions button {
  flex: 1 1 0; min-width: 0; padding: 6px 8px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid rgba(255, 255, 255, .10); background: rgba(255, 255, 255, .05);
  color: #c7d5ea; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
.sidebar .user-chip .uc-actions button svg { width: 14px; height: 14px; flex: 0 0 14px; opacity: .9; }
.sidebar .user-chip .uc-actions button:hover { background: rgba(255, 255, 255, .13); color: #fff; text-decoration: none; }
.sidebar .user-chip #uChipOut:hover { border-color: rgba(251, 113, 133, .45); color: #ffe4e8; background: rgba(225, 29, 72, .22); }
.login-list { display:flex; flex-direction:column; gap:8px; max-height:44vh; overflow:auto; }
.login-row { display:flex; gap:10px; align-items:center; padding:10px 12px; border:1px solid var(--line);
  border-radius:10px; cursor:pointer; }
.login-row:hover { border-color:#a9bdf0; background:#f7faff; }
.login-row .dot { width:8px; height:8px; border-radius:50%; background:#cbd5e1; }
.login-row.on { border-color:#a9bdf0; background:#eef3ff; }
.login-row.on .dot { background:var(--brand); }
.role-tag { font-size:11px; padding:2px 8px; border-radius:999px; background:#eef2f8; color:#475569; font-weight:600; }
.role-tag.admin { background:#e8efff; color:#2447b8; }
.role-tag.editor { background:#e9f8ef; color:#166534; }
.role-tag.viewer { background:#f5f1e8; color:#92400e; }
/* ---------- คู่มือการใช้งาน ---------- */
.manual { display:flex; flex-direction:column; gap:18px; }
.manual-sec { background:#fff; border:1px solid var(--line); border-radius:14px; padding:16px 18px; }
.manual-sec h2 { font-size:15px; margin:0 0 10px; color:var(--ink); }
.manual-sec figure { margin:0 0 12px; }
.manual-sec img { width:100%; border:1px solid var(--line-2); border-radius:10px; display:block; background:#f8fafc; }
.manual-sec figcaption { font-size:11.5px; color:var(--ink-3); margin-top:6px; }
.manual-sec ul { margin:0; padding-left:18px; font-size:13px; line-height:1.85; color:var(--ink-2); }
.manual-sec ul b { color:var(--ink); }
@media print {
  body.printing-manual .sidebar, body.printing-manual .topbar, body.printing-manual .ro-bar,
  body.printing-manual .head-actions, body.printing-manual #toasts { display:none !important; }
  body.printing-manual .app { display:block !important; }
  body.printing-manual .main { padding:0 !important; }
  body.printing-manual .view { padding:0 !important; }
  body.printing-manual .manual { gap:0 !important; }
  body.printing-manual .manual-sec { border:0; border-radius:0; padding:0; margin:0 0 10mm; page-break-inside:avoid; break-inside:avoid; }
  body.printing-manual .manual-sec img { max-height:120mm; object-fit:contain; }
  body.printing-manual .manual-sec h2 { font-size:14pt; }
  body.printing-manual .manual-sec ul { font-size:10.5pt; }
}

/* ===================== หน้าจอเข้าสู่ระบบ (Login) ===================== */
.auth-wrap {
  display: none; position: fixed; inset: 0; z-index: 60;
  align-items: center; justify-content: center; padding: 24px; overflow: auto;
  background:
    radial-gradient(1100px 560px at 12% -10%, #e6edff 0%, rgba(230,237,255,0) 62%),
    radial-gradient(900px 520px at 92% 108%, #e2fbff 0%, rgba(226,251,255,0) 60%),
    #f4f6fb;
}
body.auth-locked .auth-wrap { display: flex; }
body.auth-locked .app { display: none !important; }
body.auth-locked { overflow: hidden; }

.auth-card {
  width: 100%; max-width: 408px; margin: auto; background: #fff;
  border: 1px solid var(--line); border-radius: 18px; padding: 26px 26px 20px;
  box-shadow: 0 26px 64px -28px rgba(20, 40, 90, .30), 0 2px 8px rgba(20, 40, 90, .05);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
.auth-brand .brand-mark svg { width: 23px; height: 23px; }
.auth-brand .brand-txt { display: flex; flex-direction: column; line-height: 1.25; }
.auth-brand .brand-txt strong { font-size: 13.5px; color: var(--ink); }
.auth-brand .brand-txt span { font-size: 11.5px; color: var(--ink-3); }

.auth-card h1 { font-size: 19px; margin: 0 0 5px; color: var(--ink); }
.auth-sub { font-size: 12.5px; color: var(--ink-3); margin: 0 0 16px; line-height: 1.6; }
.auth-card .field { margin-bottom: 12px; }

.auth-pw { position: relative; }
.auth-pw input { padding-right: 44px; }
.auth-eye {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; background: none; color: var(--ink-3); cursor: pointer; border-radius: 8px;
}
.auth-eye:hover { background: #f1f4fa; color: var(--ink); }
.auth-eye svg { width: 17px; height: 17px; }

.auth-remember {
  display: flex; gap: 10px; align-items: flex-start; margin: 2px 0 14px;
  padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px;
  background: #fafcff; cursor: pointer;
}
.auth-remember:hover { border-color: #c3d2f5; background: #f6f9ff; }
.auth-remember input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--brand); flex: 0 0 auto; }
.auth-remember b { display: block; font-size: 12.5px; color: var(--ink); font-weight: 600; }
.auth-remember em {
  display: block; font-style: normal; font-size: 11px; color: var(--ink-3);
  line-height: 1.55; margin-top: 3px;
}

.auth-msg { min-height: 18px; font-size: 12px; color: var(--bad); margin-bottom: 8px; line-height: 1.55; font-weight: 600; }
.auth-msg.ok { color: #166534; }
.auth-go { width: 100%; justify-content: center; padding: 11px 16px; font-size: 13.5px; }
.auth-go[disabled] { opacity: .6; cursor: progress; }

.auth-note {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: #fffaeb; border: 1px solid #f2e2b4; color: #7a5b12;
  font-size: 11.5px; line-height: 1.65;
}
.auth-note b { color: #6b4d06; }
.auth-note.hidden { display: none; }
.auth-foot { margin-top: 14px; font-size: 11px; color: var(--ink-3); line-height: 1.65; text-align: center; }

@keyframes authshake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.auth-card.shake { animation: authshake .32s ease-in-out; }

/* มาตรวัดความแข็งแรงของรหัสผ่าน */
.pw-meter { margin: 6px 0 2px; }
.pw-bars { display: flex; gap: 4px; }
.pw-bars i { flex: 1; height: 4px; border-radius: 3px; background: #e7ecf5; }
.pw-bars.l1 i.on { background: #e11d48; }
.pw-bars.l2 i.on { background: #f59e0b; }
.pw-bars.l3 i.on { background: #0ea5e9; }
.pw-bars.l4 i.on { background: #16a34a; }
.pw-meter span { display: block; font-size: 11px; color: var(--ink-3); margin-top: 4px; }

/* กล่องเปลี่ยนรหัสผ่าน */
.pw-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.7; margin: 4px 0 0; }
.pw-hint b { color: var(--ink-2); }
.pw-force-note {
  padding: 10px 12px; border-radius: 10px; background: #fff5e9; border: 1px solid #f6dcb8;
  color: #8a4b0f; font-size: 12px; line-height: 1.6; margin-bottom: 14px;
}
.modal.locked .modal-h .x { display: none; }

/* ตารางผู้ใช้ */
.usr-name { font-weight: 600; color: var(--ink); }
.usr-sub { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.badge-lock { font-size: 10.5px; font-weight: 700; color: #b91c1c; background: #fee2e2;
  border-radius: 999px; padding: 2px 8px; margin-left: 6px; white-space: nowrap; }
.badge-warn { font-size: 10.5px; font-weight: 700; color: #92400e; background: #fef3c7;
  border-radius: 999px; padding: 2px 8px; margin-left: 6px; white-space: nowrap; }

@media print { .auth-wrap { display: none !important; } }

/* ---- ชิปผู้ใช้ในแถบซ้าย: จอแคบ (แถบเหลือ 76px) ให้เหลือแค่ปุ่ม ---- */
@media (max-width: 900px) {
  .sidebar .user-chip { margin: 0 8px 10px; padding: 8px 6px; justify-content: center; gap: 6px; }
  .sidebar .user-chip > svg { display: none; }
  .sidebar .user-chip .uc-main { display: none; }
  .sidebar .user-chip .uc-actions { flex-direction: column; gap: 5px; }
  .sidebar .user-chip .uc-actions button { font-size: 10px; padding: 5px 2px; }
  .sidebar .user-chip .uc-actions button > span { display: none; }
  /* ปุ่มย้อนกลับ/ทำซ้ำ: เหลือแค่ไอคอนบนจอแคบ */
  #btnUndo .btn-txt, #btnRedo .btn-txt { display: none; }
  #btnUndo, #btnRedo { padding: 6px 8px; }
  /* ปุ่มยุบเมนู: เหลือแต่ไอคอน */
  body .sidebar .nav-toggle { margin: 0 8px 12px; padding: 8px 0; justify-content: center; }
  body .sidebar .nav-toggle .t { display: none; }
}

/* ================= ยุบ/ขยายแถบเมนู + ป๊อปอัปชื่อเมนู ================= */
.sidebar .nav-toggle {
  position: relative; z-index: 1;
  margin: 0 14px 12px; padding: 8px 10px; width: auto;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid rgba(255, 255, 255, .09); border-radius: 10px;
  background: rgba(255, 255, 255, .05); color: #c7d5ea;
  font-size: 12px; font-weight: 600; cursor: pointer; text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar .nav-toggle:hover { background: rgba(255, 255, 255, .13); color: #fff; border-color: rgba(255, 255, 255, .16); }
.sidebar .nav-toggle svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .9; }
.sidebar .nav-toggle .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.nav-collapsed .sidebar .nav-toggle { margin: 0 8px 12px; padding: 8px 0; justify-content: center; }
body.nav-collapsed .sidebar .nav-toggle .t { display: none; }

body.nav-collapsed { --sidebar-w: 78px; }
body.nav-collapsed .brand { justify-content: center; padding: 20px 10px 14px; }
body.nav-collapsed .brand-txt,
body.nav-collapsed .nav-label,
body.nav-collapsed .nav-item span.t,
body.nav-collapsed .nav-item .num,
body.nav-collapsed .sidebar-note { display: none; }
body.nav-collapsed .nav { padding: 4px 10px 16px; }
body.nav-collapsed .nav-item { justify-content: center; padding: 11px 8px; }
body.nav-collapsed .nav-item svg { width: 20px; height: 20px; flex: 0 0 20px; opacity: .9; }
body.nav-collapsed .sidebar-foot { padding: 10px; }
body.nav-collapsed .sidebar .user-chip { margin: 0 8px 10px; padding: 8px 6px; justify-content: center; gap: 6px; }
body.nav-collapsed .sidebar .user-chip > svg { display: none; }
body.nav-collapsed .sidebar .user-chip .uc-main { display: none; }
body.nav-collapsed .sidebar .user-chip .uc-actions { flex-direction: column; gap: 5px; }
body.nav-collapsed .sidebar .user-chip .uc-actions button { font-size: 10px; padding: 5px 2px; }
body.nav-collapsed .sidebar .user-chip .uc-actions button > span { display: none; }
body.nav-collapsed .sidebar .user-chip .uc-actions button svg { width: 15px; height: 15px; flex: 0 0 15px; }

/* ป๊อปอัปชื่อเมนู (แสดงเมื่อยุบแถบเมนู) */
.nav-tip {
  position: fixed; z-index: 120; transform: translateY(-50%);
  background: #0f172a; color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .65);
}
.nav-tip.on { opacity: 1; }
.nav-tip::before {
  content: ''; position: absolute; left: -5px; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent; border-left: 0; border-right-color: #0f172a;
}
@media print { .nav-tip { display: none !important; } }

/* ---------- Dashboard: ตารางเทียบย้อนหลัง ---------- */
.card-h .sel-sm {
  margin-left: auto; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px;
  font-size: 12px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 600;
}
.card-h .sel-sm:focus { outline: 0; border-color: #a9bdf0; box-shadow: 0 0 0 3px #eef3ff; }
.cmp-sum { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.cmp-sum .cs { flex: 1 1 160px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fbfcff; }
.cmp-sum .cs .k { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.cmp-sum .cs .v { font-size: 17px; font-weight: 700; color: var(--ink); margin: 3px 0 2px; }
table.cmp th, table.cmp td { white-space: nowrap; }
table.cmp th.r, table.cmp td.r { text-align: right; font-variant-numeric: tabular-nums; }
.dlt { font-weight: 700; font-size: 12.5px; }
.dlt.up { color: #0f8a5f; }
.dlt.down { color: var(--bad); }
.dlt.flat { color: var(--ink-3); }
.dltp { font-style: normal; font-size: 11px; color: var(--ink-3); margin-left: 6px; }

/* ---------- การ์ดผู้ใช้ที่มุมบนขวา (อยู่ใน .topbar) ---------- */
.sidebar-foot .sidebar-note { margin-top: 0; }
.topbar .user-chip {
  display: inline-flex; align-items: center; gap: 9px;
  margin: 0; padding: 5px 6px 5px 5px; flex: 0 0 auto;
  background: #fff; border: 1px solid var(--line); border-radius: 13px;
  box-shadow: var(--shadow-s);
  font-size: 12.5px; color: var(--ink-2);
}
.topbar .user-chip > svg {
  width: 32px; height: 32px; flex: 0 0 32px; padding: 7px; border-radius: 10px;
  color: #fff; background: linear-gradient(140deg, #3b5bfd, #22d3ee);
  box-shadow: 0 6px 14px -8px rgba(59, 91, 253, .95);
}
.topbar .user-chip .uc-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.topbar .user-chip .uc-main b {
  color: var(--ink); font-weight: 700; font-size: 12.5px; line-height: 1.15;
  max-width: 138px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .user-chip .uc-main em { font-style: normal; font-size: 10.5px; color: #6f80a0; line-height: 1.1; }
.topbar .user-chip .uc-main .badge-warn { margin: 3px 0 0; align-self: flex-start; font-size: 9.5px; padding: 1px 6px; }
.topbar .user-chip .uc-actions {
  display: flex; align-items: center; gap: 4px;
  padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--line-2);
}
.topbar .user-chip .uc-actions button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 8px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.topbar .user-chip .uc-actions button svg { width: 14px; height: 14px; flex: 0 0 14px; opacity: .95; }
.topbar .user-chip #uChipPwd:hover { background: var(--brand-soft); color: var(--brand); border-color: #dbe4ff; }
.topbar .user-chip #uChipOut:hover { background: var(--bad-soft); color: var(--bad); border-color: #ffd9e1; }
@media (max-width: 1440px) {
  .topbar .user-chip .uc-actions button { padding: 6px; }
  .topbar .user-chip .uc-actions button > span { display: none; }
}
@media (max-width: 1240px) {
  .topbar { gap: 10px; padding: 12px 18px; }
  .topbar .top-actions { gap: 8px; }
  .topbar .top-actions .btn-txt { display: none; }
  .topbar .period-box input[type="month"] { width: 118px; }
  .topbar .user-chip { padding: 5px; gap: 5px; }
  .topbar .user-chip .uc-main { display: none; }
}
/* ปุ่ม “สำรอง Excel อัตโนมัติ” — โชว์ข้อความเมื่อจอกว้างพอ แล้วย่อเหลือไอคอน */
#btnAutoXls .axl { display: inline; }
@media (max-width: 1240px) {
  #btnAutoXls .axl { display: none; }
}
@media (max-width: 1180px) {
  .topbar .user-chip .uc-main em { display: none; }
  .topbar .user-chip .uc-main b { max-width: 96px; }
}
@media (max-width: 1024px) {
  .topbar { padding: 12px 12px; gap: 8px; }
  .topbar .top-actions { gap: 6px; }
  .topbar .top-actions .btn { padding-left: 10px; padding-right: 10px; }
  .topbar .period-box { padding: 5px 8px 5px 10px; gap: 6px; }
  .topbar .period-box input[type="month"] { width: 104px; font-size: 12.5px; }
  .topbar .user-chip { padding: 4px; gap: 4px; }
  .topbar .user-chip .uc-actions { padding-left: 5px; gap: 2px; }
}

/* ================= รายงานผู้บริหาร (Executive view) ================= */
.exec-wrap { display: none; position: fixed; inset: 0; z-index: 55; overflow: auto; background: #f3f6fc; }
body.exec-mode .exec-wrap { display: block; }
body.exec-mode .app, body.exec-mode .auth-wrap { display: none !important; }
body.exec-mode { overflow: hidden; }

.exec-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 22px;
  background: rgba(243, 246, 252, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.exec-top .ttl { font-weight: 700; font-size: 13.5px; }
.exec-top .sub { font-size: 11.5px; color: var(--ink-3); }

.exec-body { max-width: 1180px; margin: 0 auto; padding: 20px 22px 60px; display: flex; flex-direction: column; gap: 14px; }
.exec-hero {
  background: linear-gradient(120deg, #0b1526, #16305c 58%, #0d223d); color: #fff;
  border-radius: 18px; padding: 22px 24px; box-shadow: var(--shadow);
}
.exec-hero h1 { font-size: 20px; margin: 0 0 4px; }
.exec-hero .sub { color: #a9bcd8; font-size: 12.5px; }
.exec-hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.5px; margin-top: 10px; }
.exec-hero .big span { font-size: 13px; font-weight: 600; color: #9fb4d6; margin-left: 8px; }
.exec-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.exec-kpi { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px; padding: 10px 12px; }
.exec-kpi .k { font-size: 11.5px; color: #a9bcd8; }
.exec-kpi .v { font-size: 17px; font-weight: 700; margin-top: 3px; }
.exec-sec h2 { font-size: 15px; }
.badge-goal { display: inline-block; font-size: 11px; font-weight: 700; color: #0f8a5f; background: #e7f8f1; border-radius: 999px; padding: 2px 9px; }
.exec-note { white-space: pre-wrap; font-size: 13px; color: var(--ink-2); line-height: 1.7; }

@media (max-width: 820px) {
  .exec-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exec-hero .big { font-size: 28px; }
}
@media print {
  body.exec-mode { overflow: visible; }
  .exec-wrap { position: static; }
  .exec-top { position: static; background: none; border: 0; padding: 0 0 10px; }
  .exec-top .no-print { display: none !important; }
  .exec-body { padding: 0; max-width: none; }
  .exec-hero { background: #0b1526 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .exec-body .card { break-inside: avoid; page-break-inside: avoid; box-shadow: none; }
  .badge-goal { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
/* ---------- สรุปติดตามหนี้ (Debt tracking) ---------- */
.tk-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.tk-bar .field { min-width: 190px; }
.tk-hint { font-size: 11.5px; color: var(--ink-3); padding-bottom: 6px; max-width: 420px; line-height: 1.6; }
.tk-chart { width: 100%; height: auto; display: block; }
.tk-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.tk-legend span { display: inline-flex; align-items: center; gap: 7px; }
.tk-legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
table.tk-t td, table.tk-t th { white-space: nowrap; }
table.tk-t .tk-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }
.tk-pct { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; min-width: 130px; }
.tk-pct .track { flex: 1 1 70px; height: 7px; border-radius: 99px; background: #e8eefb; overflow: hidden; }
.tk-pct .fill { display: block; height: 100%; background: linear-gradient(90deg, #3b5bfd, #22d3ee); }
.tk-pct b { font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; font-weight: 600; }
.tk-auto { font-style: normal; color: var(--ink-3); margin-left: 2px; cursor: help; }
.tk-note { font-size: 11.5px; line-height: 1.7; padding: 8px 12px 12px; }
.drop.over { border-color: var(--brand); background: #eef3ff; }
@media (max-width: 900px) { .tk-bar .field { min-width: 140px; flex: 1 1 140px; } }
/* ---------- แดชบอร์ดตามชั้นหนี้ (สรุปติดตามหนี้) — 07/11/69 ---------- */
.tk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 4px; }
.tk-card { position: relative; border: 1px solid #e5eaf5; border-radius: 14px; background: #fff; padding: 12px 14px 11px 16px; overflow: hidden; }
.tk-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, #3b5bfd); }
.tk-card-h { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.tk-card-h .tk-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.tk-big { display: flex; align-items: flex-start; gap: 8px; margin: 9px 0 11px; }
.tk-cell { min-width: 0; flex: 1 1 0; }
.tk-cell-got { flex: 0 0 auto; text-align: center; }
.tk-num { font-size: 21px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.tk-num i { font-style: normal; font-size: 10.5px; font-weight: 600; color: var(--ink-3); margin-left: 5px; }
.tk-sub { font-size: 10.5px; color: var(--ink-3); margin: 2px 0 0; }
/* กลางการ์ด: ติดตามได้ */
.tk-cell-got { flex: 1 1 auto; text-align: center; }
.tk-cell-got .tk-num, .tk-cell-got .tk-sub { color: #0f9d58; }
.tk-cell-got .tk-e { border-bottom: 1px dashed #9ed9b8; }
.tk-cell-got .tk-e:hover { background: #effaf3; }
.tk-cell-got .tk-auto { color: #0f9d58; }
.tk-cell-got .tk-in { font-size: 15px; width: 112px; }
/* ขวาสุด: % เก็บเงิน */
.tk-cell-pc { text-align: right; }
.tk-cell-pc .tk-pc { font-style: normal; font-size: 21px; font-weight: 800; color: #2a4bd0; letter-spacing: -.6px; }
.tk-cell-pc .tk-sub { color: #2a4bd0; font-weight: 700; white-space: nowrap; }
.tk-prog { height: 8px; border-radius: 99px; background: #eef2fa; overflow: hidden; }
.tk-prog > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3b5bfd, #22d3ee); }
.tk-rows { margin-top: 9px; display: grid; gap: 4px; font-size: 11.5px; }
.tk-rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: var(--ink-3); }
.tk-rows b { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.tk-e { border-bottom: 1px dashed #c9d6ea; cursor: text; padding: 0 1px; }
.tk-e:hover { background: #f2f7ff; }
.tk-e.editing { border-bottom: 0; }
.tk-in { width: 104px; max-width: 100%; font: inherit; font-size: 11.5px; color: var(--ink); text-align: right; padding: 1px 5px; border: 1px solid #93b4ff; border-radius: 6px; outline: none; }
.tk-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: #f3f7fd; }
.tk-total > span { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-right: auto; }
.tk-total b { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink); }
.tk-total i { font-style: normal; font-size: 10.5px; color: var(--ink-3); margin-left: -6px; }
.tk-d { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 2px; }
.tk-dl { margin-top: 3px; font-size: 10.5px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.tk-dl .tk-d { display: inline-block; }
.tk-d.up { color: #0f9d58; }
.tk-d.down { color: #d64545; }
.tk-d.flat { color: var(--ink-3); }
.tk-man { margin-left: auto; font-size: 9.5px; font-weight: 700; color: #2a4bd0; background: #eef3ff; border-radius: 99px; padding: 2px 7px; }
@media (max-width: 1100px) { .tk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .tk-grid { grid-template-columns: 1fr; } }
/* การ์ดแคบ (2 คอลัมน์) — ให้ตัวเลขขึ้นบรรทัดใหม่แทนการล้นทับกัน (5 ชั้นหนี้ + การ์ดช่องทาง) */
@media (max-width: 1180px) {
  .tk-big { flex-wrap: wrap; gap: 4px 10px; }
  .tk-big > .tk-cell:first-child { flex: 1 1 100%; }
  .tk-cell-got { text-align: left; }
  .tk-num, .tk-cell-pc .tk-pc { font-size: 17px; }
  .tk-num i { font-size: 9.5px; margin-left: 3px; }
}
@media (max-width: 720px) {
  .tk-big { flex-wrap: nowrap; gap: 14px; }
  .tk-big > .tk-cell:first-child { flex: 1 1 0; }
  .tk-cell-got { text-align: center; }
  .tk-num, .tk-cell-pc .tk-pc { font-size: 20px; }
  .tk-num i { font-size: 10.5px; margin-left: 5px; }
}
/* ================= แดชบอร์ดสรุปติดตามหนี้ — ธีมผู้บริหาร (07/11/69) ================= */
.tkd { display: flex; flex-direction: column; gap: 16px; }
/* --- hero --- */
.tkd-hero { position: relative; overflow: hidden; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 20px 22px; border-radius: 20px; color: #e8f0ff;
  background: radial-gradient(130% 170% at 0% 0%, #1b3a8f 0%, #142a63 45%, #0a1733 100%);
  box-shadow: 0 22px 48px -28px rgba(10, 23, 51, .85); }
.tkd-hero::before { content: ''; position: absolute; right: -70px; top: -90px; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, .32), rgba(34, 211, 238, 0) 62%); }
.tkd-hero::after { content: ''; position: absolute; right: 90px; bottom: -110px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 91, 253, .32), rgba(59, 91, 253, 0) 62%); }
.tkd-hero > * { position: relative; z-index: 1; }
.tkd-badge { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b5bfd, #22d3ee); box-shadow: 0 14px 30px -14px rgba(34, 211, 238, .95); }
.tkd-badge svg { width: 27px; height: 27px; color: #fff; }
.tkd-hero-txt { flex: 1 1 320px; min-width: 0; }
.tkd-hero-txt h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .2px; color: #fff; line-height: 1.3; }
.tkd-hero-txt p { margin: 5px 0 0; font-size: 12.5px; color: rgba(214, 228, 255, .72); }
.tkd-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.tkd-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 99px;
  font-size: 11.5px; font-weight: 700; color: #d9e6ff; background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .16); }
.tkd-chip b { color: #fff; font-weight: 800; }
.tkd-chip.ok { color: #b8f2d8; background: rgba(15, 157, 88, .18); border-color: rgba(15, 157, 88, .38); }
.tkd-chip.ok b { color: #d6ffe9; }
.tkd-hero .head-actions { margin-left: auto; }
.tkd-hero .btn { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .22); color: #eaf1ff; }
.tkd-hero .btn:hover { background: rgba(255, 255, 255, .17); }
.tkd-hero .btn.primary { background: linear-gradient(135deg, #3b5bfd, #22d3ee); border-color: transparent; color: #fff;
  box-shadow: 0 12px 26px -14px rgba(34, 211, 238, .95); }
.tkd-hero .btn.danger { background: rgba(214, 69, 69, .18); border-color: rgba(214, 69, 69, .45); color: #ffd9d9; }
/* --- แถบตัวกรอง --- */
.tkd-bar { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; padding: 14px 16px; border-radius: 16px;
  background: #fff; border: 1px solid #e7edf8; box-shadow: 0 12px 28px -24px rgba(15, 31, 61, .7); }
.tkd-bar .field label { font-size: 11.5px; font-weight: 700; color: #64748b; }
.tkd-bar .field select { min-width: 190px; }
.tkd-bar .tk-hint { flex: 1 1 260px; font-size: 11.5px; color: #7b8aa3; line-height: 1.55; padding-bottom: 3px; }
/* --- KPI --- */
.tkd-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.tkd-kpi { position: relative; overflow: hidden; padding: 14px 15px 13px; border-radius: 16px; background: #fff;
  border: 1px solid #e7edf8; box-shadow: 0 14px 30px -26px rgba(15, 31, 61, .8); }
.tkd-kpi::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, #3b5bfd, #22d3ee); }
.tkd-kpi.ok::before { background: linear-gradient(90deg, #0ea5e9, #0f9d58); }
.tkd-kpi.bad::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.tkd-kpi-k { font-size: 11px; font-weight: 700; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tkd-kpi-v { margin-top: 6px; font-size: 22px; font-weight: 800; letter-spacing: -.5px; color: #0f1f3d;
  font-variant-numeric: tabular-nums; }
.tkd-kpi-v small { font-size: 12.5px; font-weight: 700; color: #64748b; margin-left: 2px; }
.tkd-kpi-s { margin-top: 5px; font-size: 10.8px; color: #8896ad; }
@media (max-width: 1280px) { .tkd-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .tkd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* --- การ์ดหัวข้อ --- */
.tkd-card { border-radius: 18px; background: #fff; border: 1px solid #e7edf8;
  box-shadow: 0 16px 36px -30px rgba(15, 31, 61, .9); overflow: hidden; }
.tkd-card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 13px 18px;
  border-bottom: 1px solid #eef2fa; background: linear-gradient(180deg, #fbfdff, #f7faff); }
.tkd-card-h h2 { margin: 0; font-size: 14px; font-weight: 800; color: #0f1f3d; display: flex; align-items: center; gap: 8px; }
.tkd-card-h h2 svg { width: 17px; height: 17px; color: #2a4bd0; }
.tkd-card-h .sub { margin-left: auto; font-size: 11.5px; color: #7b8aa3; }
.tkd-card-b { padding: 16px 18px 18px; }
/* --- การ์ดชั้นหนี้ (ยกระดับ) --- */
.tkd .tk-grid { gap: 14px; }
.tkd .tk-card { border-radius: 16px; border: 1px solid #e7edf8; background: linear-gradient(180deg, #fff, #fcfdff);
  padding: 15px 15px 13px 18px; box-shadow: 0 14px 30px -26px rgba(15, 31, 61, .85);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.tkd .tk-card:hover { transform: translateY(-3px); border-color: #d7e2f5; box-shadow: 0 22px 40px -26px rgba(15, 31, 61, .8); }
.tkd .tk-card::before { width: 5px; background: var(--c); }
.tkd .tk-card-h { font-size: 12.5px; color: #334155; letter-spacing: .1px; }
.tkd .tk-card-h .tk-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(59, 91, 253, .10); }
.tkd .tk-num { letter-spacing: -.6px; }
.tkd .tk-prog { height: 9px; background: #eef3fb; box-shadow: inset 0 1px 2px rgba(15, 31, 61, .06); }
.tkd .tk-prog > span { background: var(--c, #3b5bfd); }
.tkd .tk-rows { border-top: 1px dashed #eef2fa; padding-top: 8px; margin-top: 11px; }
.tkd .tk-man { background: #eef3ff; }
/* --- สัดส่วนยอดติดตามได้ --- */
.tkd-share { margin-top: 18px; }
.tkd-share-h { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; font-weight: 700;
  color: #64748b; margin-bottom: 7px; }
.tkd-sbar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: #eef3fb;
  box-shadow: inset 0 1px 2px rgba(15, 31, 61, .06); }
.tkd-sbar > span { height: 100%; transition: filter .15s ease; }
.tkd-sbar > span:hover { filter: brightness(1.08); }
.tkd-slegend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 11.5px; color: #475569; }
.tkd-slegend span { display: inline-flex; align-items: center; gap: 6px; }
.tkd-slegend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.tkd-slegend b { color: #0f1f3d; font-variant-numeric: tabular-nums; }
/* ---------- การ์ดค่าตอบแทน + ตัวกรอง (07/11/69) ---------- */
.tkd-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tkd-tab { display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 999px; cursor: pointer;
  border: 1px solid #e3e9f4; background: #fff; color: #46536b; font: 700 12px/1 inherit; transition: all .15s ease; }
.tkd-tab:hover { border-color: #c9d7f2; background: #f7faff; }
.tkd-tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #3b5bfd); }
.tkd-tab .amt { color: #0f1f3d; font-variant-numeric: tabular-nums; }
.tkd-tab.on { color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #1b3a8f, #2a5bd7); box-shadow: 0 12px 24px -16px rgba(27, 58, 143, .95); }
.tkd-tab.on .amt { color: #fff; }
.tkd-panel { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start;
  padding: 16px; border: 1px solid #eef2f9; border-radius: 14px; background: linear-gradient(180deg, #fcfdff, #f8fbff); }
@media (max-width: 1080px) { .tkd-panel { grid-template-columns: 1fr; gap: 14px; } }
.tkd-bignum { font-size: 34px; font-weight: 800; letter-spacing: -.8px; color: #0f1f3d; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tkd-bignum i { font-style: normal; font-size: 13px; font-weight: 700; color: #94a3b8; margin-left: 4px; }
.tkd-pmeta { margin-top: 8px; font-size: 11.5px; color: #64748b; line-height: 1.75; }
.tkd-pmeta b { color: #0f1f3d; }
.tkd-bars { display: grid; gap: 8px; }
.tkd-bar-row { display: grid; grid-template-columns: 250px minmax(0, 1fr) 104px; gap: 12px; align-items: center;
  font-size: 11.5px; color: #46536b; }
.tkd-bar-row .nm { font-weight: 700; color: #334155; line-height: 1.35; overflow-wrap: anywhere; }
.tkd-bar-row .tr { height: 9px; border-radius: 99px; background: #e9eff9; overflow: hidden; box-shadow: inset 0 1px 2px rgba(15, 31, 61, .06); }
.tkd-bar-row .tr > span { display: block; height: 100%; border-radius: 99px; }
.tkd-bar-row .vl { text-align: right; font-weight: 800; color: #0f1f3d; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .tkd-bar-row { grid-template-columns: 150px minmax(0, 1fr) 88px; } }
/* --- แถบสรุปรวม (เข้ม) --- */
.tkd-total { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 18px; padding: 16px 18px;
  border-radius: 16px; color: #fff;
  background: linear-gradient(120deg, #0f2a5e, #173a7d 55%, #1d4fa8);
  box-shadow: 0 20px 44px -30px rgba(9, 20, 45, .95); }
.tkd-total > span { margin-right: auto; font-size: 12px; font-weight: 700; color: #c6d6f6; }
.tkd-total .tv { display: flex; align-items: baseline; gap: 6px; }
.tkd-total b { font-size: 18px; font-weight: 800; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.tkd-total i { font-style: normal; font-size: 10.5px; color: rgba(198, 214, 246, .8); }
.tkd-total .sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .18); }
@media (max-width: 900px) { .tkd-total .sep { display: none; } }
/* --- หมายเหตุ --- */
.tkd-note { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #e6ecf7; font-size: 11px; line-height: 1.65;
  color: #7b8aa3; }
/* ---------- สรุปติดตามหนี้ฝ่าย (Dept) ---------- */
/* พิมพ์/บันทึกเป็น PDF ของแดชบอร์ดสรุปติดตามหนี้ — ให้สีเหมือนตอนดูบนจอ (07/11/69) */
@media print {
  .tkd, .tkd *, .dp-head, .dp-head *, .dp-stats, .dp-stats *,
  .dp-share, .dp-share *, .dp-t, .dp-t *, .dp-foot, .dp-legend, .dp-legend *,
  .tk-grid, .tk-grid *, .tk-card, .tk-card *, .tk-total, .tk-total *,
  .tk-d, .dlt, .tk-legend, .tk-legend *, .h2-ico, .tk-ico {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
.tk-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .tk-grid-2 { grid-template-columns: 1fr; } }
.tk-man-src { color: #0f766e; background: #e6fffa; }
.dp-split { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: #eef2fa; margin-top: 0; }
.dp-share { margin: 18px 0 6px; }
.dp-stats { margin-bottom: 0; }
.dp-foot { margin-top: 10px; padding-top: 9px; border-top: 1px dashed #e6edf9; font-size: 11px; color: var(--ink-3); }
.dp-foot a { color: #2a4bd0; font-weight: 700; text-decoration: none; }
.dp-foot a:hover { text-decoration: underline; }
table.simple.dp-t { margin-top: 10px; }
table.simple.dp-t th, table.simple.dp-t td { padding: 9px 12px; text-align: right; }
table.simple.dp-t th:first-child, table.simple.dp-t td:first-child { text-align: left; color: var(--ink-2); }
table.simple.dp-t thead th { background: #f5f9ff; color: var(--ink-2); font-size: 11.5px; }
table.simple.dp-t td.tot { font-weight: 800; color: var(--ink); background: #fbfdff; }
table.simple.dp-t th:last-child { background: #eef4ff; color: #2a4bd0; }
/* ---------- ไอคอนของหน้า สรุปติดตามหนี้ฝ่าย ---------- */
.dp-head { display: flex; gap: 14px; align-items: flex-start; }
.dp-head .dp-badge { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(135deg, #3b5bfd, #22d3ee); color: #fff; box-shadow: 0 8px 18px rgba(59, 91, 253, .22); }
.dp-head .dp-badge svg { width: 24px; height: 24px; }
.dp-head h1 { margin: 0; }
.tk-card-h .tk-ico { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; }
.tk-card-h .tk-ico svg { width: 15px; height: 15px; }
.tk-card-h .tk-lbl { min-width: 0; }
.card-h h2 .h2-ico { width: 16px; height: 16px; margin-right: 7px; vertical-align: -3px; color: var(--brand, #3b5bfd); }
.dp-split .a { background: linear-gradient(90deg, #22d3ee, #0ea5e9); }
.dp-split .b { background: linear-gradient(90deg, #6b8cff, #3b5bfd); }
.dp-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; font-size: 11.5px; color: var(--ink-2); }
.dp-legend span { display: inline-flex; align-items: center; gap: 7px; }
.dp-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
/* (11/11/69) หมายเหตุ “ไม่นับรวมเก็บค่างวดชำระบางส่วน” + ช่องคีย์ยอดเอง (ต่อท้ายแถบสัดส่วน) */
.dp-partial { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 7px;
  font-size: 11.5px; color: var(--ink-3); }
.dp-partial .tk-e { font-weight: 800; color: var(--ink); border-bottom: 1px dashed #c9d6ea; }
.dp-partial .tk-e.empty { font-weight: 500; color: #97a5bd; }
.dp-partial .tk-e .tmp-ph { font-style: normal; font-size: 11px; }
.dp-partial .u { font-style: normal; font-size: 10.5px; color: #93a1b8; }
.dp-partial .tk-in { width: 104px; font-size: 12.5px; padding: 2px 6px; }
@media print { .dp-partial .tk-e { border-bottom: 0; } }
@media print { .tk-e { border-bottom: 0; } }

/* =====================================================================
   “ยอดเงินเข้า (Money-In)” — คีย์เอง 4 ช่อง บนการ์ดภาพรวมบริหารลูกหนี้ทุกชั้นหนี้ (12/11/69)
   ธีมหรู navy + ทอง · ตัวเลขใหญ่ชัด · สีประจำช่อง + แถบสัดส่วน + เทียบงวดก่อน
   ===================================================================== */
.mi { margin-top: 18px; border: 1px solid #e3eaf6; border-radius: 18px; overflow: hidden; background: #fff;
  box-shadow: 0 22px 46px -40px rgba(15, 31, 61, .6); }
.mi-head { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: linear-gradient(120deg, #0f2a5e, #173a7d 58%, #1d4fa8); color: #eaf1ff; }
.mi-head::after { content: ""; position: absolute; right: -70px; top: -90px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, .34), rgba(212, 175, 55, 0) 64%); }
.mi-head > * { position: relative; z-index: 1; }
.mi-badge { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(135deg, #f0d27a, #a9822a); color: #221a05;
  box-shadow: 0 10px 20px -12px rgba(212, 175, 55, .95); }
.mi-badge svg { width: 19px; height: 19px; }
.mi-tt strong { display: block; font-size: 13.5px; font-weight: 800; letter-spacing: .2px; }
.mi-tt small { display: block; margin-top: 2px; font-size: 10.5px; color: #b9cdf0; }
.mi-tag { margin-left: auto; font-size: 9.5px; font-weight: 800; letter-spacing: .05em; color: #ffe9b0; white-space: nowrap;
  background: rgba(212, 175, 55, .16); border: 1px solid rgba(212, 175, 55, .5); border-radius: 99px; padding: 3px 10px; }
.mi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px 16px 2px; }
.mi-cell { position: relative; border: 1px solid #e8eef8; border-radius: 14px; padding: 14px 14px 12px;
  background: linear-gradient(180deg, #fff, #fbfdff); overflow: hidden; }
.mi-cell::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--c), rgba(255, 255, 255, .25)); }
.mi-top { display: flex; align-items: flex-start; gap: 8px; }
.mi-ico { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--ct, #eef3ff); color: var(--c, #3b5bfd); }
.mi-ico svg { width: 15px; height: 15px; }
.mi-k { font-size: 11px; font-weight: 800; color: #475569; line-height: 1.4; padding-top: 3px; min-width: 0; padding-right: 2px; }
.mi-auto { margin-left: auto; flex: 0 0 auto; font-size: 9px; font-weight: 800; color: #0f9d58; white-space: nowrap;
  background: #e8f7ef; border: 1px solid #cceedd; border-radius: 99px; padding: 2px 7px; }
.mi-cell-auto { background: linear-gradient(180deg, #fbfffd, #f4fcf7); }
.mi-ro { display: inline-block; }
.mi-v { margin-top: 10px; display: flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.mi-v b { font-size: clamp(18px, 1.5vw, 23px); font-weight: 900; color: #0f1f3d; letter-spacing: -.8px; line-height: 1.1; }
.mi-v i { font-style: normal; font-size: 10.5px; font-weight: 700; color: #94a3b8; }
.mi-e { display: inline-block; border-bottom: 1px dashed #c9d6ea; cursor: text; padding: 0 1px; }
.mi-e:hover { background: #f2f7ff; }
.mi-e.editing { border-bottom: 0; }
.mi-e .mi-ph { font-size: 12px; font-weight: 800; color: #a9b6ca; }
.mi-sub { margin-top: 5px; font-size: 10.5px; color: #8494ad; line-height: 1.45; }
.mi-sub b { color: #334155; font-weight: 800; font-variant-numeric: tabular-nums; }
.mi-bar { margin-top: 10px; height: 5px; border-radius: 99px; background: #eef2fa; overflow: hidden; }
.mi-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.mi-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin: 12px 16px 16px; padding: 11px 14px;
  border-radius: 12px; color: #dbe7ff; font-size: 11px;
  background: linear-gradient(120deg, #0f2a5e, #173a7d 58%, #1d4fa8);
  box-shadow: 0 16px 32px -30px rgba(9, 20, 45, .9); }
.mi-foot .it { display: inline-flex; align-items: baseline; gap: 6px; }
.mi-foot .it span { font-size: 10px; color: #a8bfe6; }
.mi-foot .it b { font-size: 13px; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }
.mi-foot .it.gold b { font-size: 17px; color: #ffe9b0; }
.mi-foot .sep { width: 1px; height: 16px; background: rgba(255, 255, 255, .16); }
.mi-foot .mi-note { margin-left: auto; font-size: 10px; color: #9db3d9; }
@media (max-width: 1279px) { .mi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .mi-grid { grid-template-columns: 1fr; }
  .mi-tag { display: none; }
  .mi-foot .mi-note { margin-left: 0; }
}
@media print {
  .mi, .mi *, .mi-cell::before {
    -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
  }
  .mi-e { border-bottom: 0 !important; }
  .mi-tag, .mi-foot .mi-note { display: none; }
}

/* =====================================================================
   เมนู “สรุปผลงาน” (perf) — ผลงานเร่งรัดหนี้สินภาคสนาม
   · ธีมผู้บริหาร: navy + ทอง (หรูหรา) · การ์ด KPI · ตารางตรึงหัว/ตรึงคอลัมน์ซ้าย
   · พิมพ์/PDF แนวนอน A4 (named page: pfLandscape)
   ===================================================================== */
.pf {
  --pf-navy: #0e1f49; --pf-navy2: #16306f; --pf-gold: #d4af37; --pf-cyan: #22d3ee;
  display: flex; flex-direction: column; gap: 16px;
}
/* ---------- hero ---------- */
.pf-hero { position: relative; overflow: hidden; border-radius: 20px; padding: 24px 28px 22px; color: #eaf1ff;
  background: radial-gradient(125% 165% at 0% 0%, #16306f 0%, #0e1f49 46%, #070f26 100%);
  box-shadow: 0 30px 60px -42px rgba(7, 15, 38, .95); }
.pf-hero:before { content: ""; position: absolute; right: -90px; top: -120px; width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, .26), rgba(34, 211, 238, 0) 62%); }
.pf-hero:after { content: ""; position: absolute; left: -70px; bottom: -140px; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, .26), rgba(212, 175, 55, 0) 66%); }
.pf-hero > * { position: relative; z-index: 1; }
.pf-brand { display: flex; align-items: center; gap: 9px; font-size: 10.5px; font-weight: 800; letter-spacing: 2.4px;
  color: #d9bd72; text-transform: uppercase; }
.pf-brand .mk { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #d4af37, #8a6d1f); color: #221a05; font-size: 10px; font-weight: 900; letter-spacing: 0; }
.pf-rule { height: 2px; margin: 12px 0 16px;
  background: linear-gradient(90deg, #d4af37, rgba(212, 175, 55, .5) 35%, rgba(212, 175, 55, 0) 80%); }
.pf-hero-row { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.pf-title { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 900; letter-spacing: -.4px; color: #f4f8ff; }
.pf-gold { background: linear-gradient(180deg, #fffbe8 0%, #ffe6a3 30%, #d9ae3d 60%, #fff4cd 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .25)); }
.pf-sub { margin: 8px 0 0; font-size: 12.5px; color: #b9cdf0; }
.pf-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pf-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px;
  font-size: 11.5px; color: #dbe7ff; background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .16); }
.pf-chip b { color: #fff; font-variant-numeric: tabular-nums; }
.pf-chip-gold { background: rgba(212, 175, 55, .16); border-color: rgba(212, 175, 55, .45); color: #ffe9b0; }
.pf-chip-gold b { color: #ffe9b0; }
.pf-chip-auto { background: rgba(15, 157, 88, .18); border-color: rgba(120, 230, 180, .45); color: #c8f6de; }
.pf-chip-auto b { color: #eafff4; }
.pf-acts { display: flex; gap: 9px; margin-left: auto; flex-wrap: wrap; }
.pf-btn { background: rgba(255, 255, 255, .12) !important; border-color: rgba(255, 255, 255, .28) !important;
  color: #eaf1ff !important; }
.pf-btn:hover { background: rgba(255, 255, 255, .2) !important; }
.pf-btn.p { background: linear-gradient(135deg, #3b5bfd, #22d3ee) !important; border-color: transparent !important;
  color: #fff !important; box-shadow: 0 12px 26px -14px rgba(34, 211, 238, .85); }
.pf-btn.g { background: linear-gradient(135deg, #d4af37, #8a6d1f) !important; border-color: transparent !important;
  color: #1b1403 !important; font-weight: 800; box-shadow: 0 12px 26px -14px rgba(212, 175, 55, .9); }
/* ---------- KPI ---------- */
.pf-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.pf-kpi { position: relative; border: 1px solid #e6ecf6; border-radius: 16px; padding: 14px 16px 13px;
  background: linear-gradient(180deg, #fff, #fbfdff); overflow: hidden; box-shadow: 0 16px 32px -28px rgba(15, 31, 61, .5); }
.pf-kpi:before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, #94a8c8, #5b6f92); }
.pf-kpi.g:before { background: linear-gradient(90deg, #0ea5e9, #0f9d58); }
.pf-kpi.b:before { background: linear-gradient(90deg, #3b5bfd, #22d3ee); }
.pf-kpi.w:before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.pf-kpi .k { font-size: 11px; font-weight: 800; color: #64748b; }
.pf-kpi .v { margin-top: 7px; font-size: 23px; font-weight: 800; letter-spacing: -.7px; color: #0f1f3d;
  font-variant-numeric: tabular-nums; }
.pf-kpi .v i { font-style: normal; font-size: 11.5px; font-weight: 700; color: #94a3b8; margin-left: 4px; }
.pf-kpi .s { margin-top: 4px; font-size: 10.5px; color: #94a3b8; }
/* ---------- cards ---------- */
.pf-grid { display: grid; grid-template-columns: 1.15fr 1fr .9fr; gap: 14px; }
.pf-card { border: 1px solid #e6ecf6; border-radius: 18px; background: #fff; overflow: hidden;
  box-shadow: 0 22px 46px -40px rgba(15, 31, 61, .6); }
.pf-ch { display: flex; align-items: center; gap: 8px; padding: 14px 18px 12px; border-bottom: 1px solid #eef3fa; }
.pf-ch h2 { margin: 0; font-size: 13.5px; font-weight: 800; color: #14213d; }
.pf-ch .h2-ico { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; color: #3b5bfd; }
.pf-chsub { margin-left: auto; font-size: 10.5px; color: #93a2b8; }
.pf-card-b { padding: 14px 18px 16px; }
.pf-card-flat { padding: 0; }
/* ---------- ชั้นหนี้ ---------- */
.pf-lay { margin-bottom: 13px; }
.pf-lay:last-child { margin-bottom: 0; }
.pf-lay-h { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #334155; }
.pf-lay-h b { font-weight: 800; color: #14213d; }
.pf-tag { font-size: 9.5px; font-weight: 800; color: #0f766e; background: #e6fffa; border-radius: 6px; padding: 1px 6px; }
.pf-lay-pct { margin-left: auto; font-weight: 900; color: var(--lc); font-variant-numeric: tabular-nums; }
.pf-lay-bars { position: relative; height: 9px; margin: 6px 0 4px; border-radius: 99px; background: #eef2fa; overflow: hidden; }
.pf-lay-bars span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; }
.pf-lay-bars .b1 { background: linear-gradient(90deg, #a9bcd8, #7f93b8); }
.pf-lay-bars .b2 { background: linear-gradient(90deg, var(--lc), #22d3ee); }
.pf-lay-v { display: flex; justify-content: space-between; font-size: 10.5px; color: #8494ad; }
.pf-lay-v b { color: #14213d; font-variant-numeric: tabular-nums; }
.pf-lay-v b.g { color: #0f9d58; }
/* ---------- ทีม ---------- */
.pf-team { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px dashed #eef3fa; }
.pf-team:last-child { border-bottom: 0; }
.pf-tm { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto;
  font-size: 11.5px; font-weight: 900; color: #1e3a8a; background: #eaf1ff; }
.pf-tn { min-width: 0; width: 132px; display: flex; flex-direction: column; }
.pf-tn b { font-size: 11.5px; color: #14213d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-tn i { font-style: normal; font-size: 9.5px; color: #93a2b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-ttr { flex: 1; min-width: 24px; height: 7px; border-radius: 99px; background: #eef2fa; overflow: hidden; }
.pf-ttr i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3b5bfd, #22d3ee); }
.pf-tp { width: 64px; text-align: right; font-size: 12.5px; font-weight: 900; color: #0f1f3d; font-variant-numeric: tabular-nums; }
.pf-tp i { font-style: normal; font-size: 9.5px; color: #8ea0b5; margin-left: 1px; }
/* ---------- อันดับ ---------- */
.pf-top { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px dashed #eef3fa; }
.pf-top:last-child { border-bottom: 0; }
.pf-rk { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex: 0 0 auto;
  font-size: 10.5px; font-weight: 900; color: #7a5a12; background: linear-gradient(135deg, #ffe9a8, #d4af37); }
.pf-tpn { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 11.5px; font-weight: 700; color: #14213d; }
.pf-tpn i { font-style: normal; font-size: 9.5px; color: #93a2b8; font-weight: 600; }
.pf-top > b { font-size: 12.5px; font-weight: 900; color: #0f766e; font-variant-numeric: tabular-nums; }
.pf-top > b i { font-style: normal; font-size: 9.5px; color: #8ea0b5; }
/* ---------- ตาราง ---------- */
.pf-twrap { overflow: auto; max-height: 70vh; }
.pf-t { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; min-width: 100%;
  font-size: 11.5px; }
.pf-t th, .pf-t td { box-sizing: border-box; padding: 6px 8px; border-bottom: 1px solid #eef3fa; white-space: nowrap; }
.pf-t thead th { background: #f4f8ff; color: #2c3e63; font-weight: 800; text-align: center; font-size: 10.5px;
  border-bottom: 1px solid #dbe6f7; }
.pf-t thead tr.pf-h1 th { position: sticky; top: 0; z-index: 3; }
.pf-t thead tr.pf-h2 th { position: sticky; top: 33px; z-index: 3; }
.pf-t thead th.pf-g { background: linear-gradient(180deg, #e9f1fd, #dbe8f8); color: #12295c; font-size: 11px;
  border-left: 2px solid #fff; box-shadow: inset 0 -2px 0 var(--lc, #3b5bfd); }
.pf-t thead th.pf-gtot { --lc: #d4af37; }
.pf-t thead th.pf-g2 i { display: block; font-style: normal; font-size: 9px; font-weight: 700; color: #93a2b8; }
.pf-t thead th.pf-b { color: #12295c; }
.pf-t thead th.pf-got { color: #0f7a52; }
.pf-t thead th.pf-gtot { color: #0e1f49; }
/* ตรึง 4 คอลัมน์ซ้าย */
.pf-t th.pf-s1, .pf-t td.pf-s1 { position: sticky; left: 0; z-index: 2; background: #fff; }
.pf-t th.pf-s2, .pf-t td.pf-s2 { position: sticky; left: 40px; z-index: 2; background: #fff; }
.pf-t th.pf-s3, .pf-t td.pf-s3 { position: sticky; left: 98px; z-index: 2; background: #fff; }
.pf-t th.pf-s4, .pf-t td.pf-s4 { position: sticky; left: 288px; z-index: 2; background: #fff;
  box-shadow: 2px 0 0 #e8eefa; }
.pf-t thead th.pf-s1, .pf-t thead th.pf-s2, .pf-t thead th.pf-s3, .pf-t thead th.pf-s4 { z-index: 4; background: #f4f8ff; }
.pf-t td.pf-n { text-align: right; font-variant-numeric: tabular-nums; }
.pf-t td.pf-c { text-align: center; color: #56688a; }
.pf-t td.pf-s3 { font-weight: 700; color: #14213d; overflow: hidden; text-overflow: ellipsis; }
.pf-t td.pf-b { color: #12295c; font-weight: 800; }
.pf-t td.pf-got { color: #0f9d58; font-weight: 800; }
.pf-t tr.pf-r:hover td { background: #f8fbff; }
.pf-z { color: #cbd5e1; }
.pf-pc { font-style: normal; font-size: 9.5px; color: #94a3b8; margin-left: 1px; }
/* ช่องคีย์เองของชั้น ประจำ / ย้าย */
.pf-t .pf-e { border-bottom: 1px dotted #a9bdf0; border-radius: 3px; padding: 0 2px; cursor: pointer; }
.pf-t .pf-e:hover { background: #eef3ff; border-bottom-color: #3b5bfd; }
.pf-t .pf-e.pf-auto { color: #93a2b8; font-style: italic; }
.pf-t .pf-e.pf-ovr { box-shadow: inset 0 -2px 0 currentColor; }
.pf-t tr.pf-tot .pf-e { color: inherit; border-bottom-color: #9db8e6; }
.pf-t tr.pf-tot .pf-e:hover { background: #dbe7fa; border-bottom-color: #3b5bfd; }
.pf-t tr.pf-tot .pf-e.pf-ovr { color: #a16207; }
.pf-t tr.pf-tot .pf-e-in { color: #0f1f3d; }
.pf-t .pf-e.editing { padding: 0; border-bottom-color: transparent; background: transparent; }
.pf-e-in { width: 82px; font: inherit; font-size: 11px; text-align: right; color: #0f1f3d;
  border: 1px solid #a9bdf0; border-radius: 5px; padding: 1px 4px; outline: 0;
  box-shadow: 0 0 0 3px #eef3ff; background: #fff; }
.pf-e-in::placeholder { color: #b6c2d4; font-style: italic; }
.pf-auto-tip { font-style: italic; color: #93a2b8; font-size: 10.5px; margin: 0 2px; }
.pf-dupe { font-size: 8.5px; font-weight: 800; color: #b45309; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 5px; padding: 0 4px; vertical-align: 1px; }
.pf-t tr.pf-sub td { background: #f2f7ff; font-weight: 800; color: #12295c; border-top: 1px solid #d7e3f7;
  border-bottom: 1px solid #d7e3f7; }
.pf-t tr.pf-sub td.pf-s1, .pf-t tr.pf-sub td.pf-s2, .pf-t tr.pf-sub td.pf-s3, .pf-t tr.pf-sub td.pf-s4 { background: #f2f7ff; }
.pf-t tr.pf-tot td { background: #e9effb; color: #0f1f3d; font-weight: 800; border-top: 1px solid #c8d8f0;
  border-bottom: 0; }
.pf-t tr.pf-tot td.pf-s1, .pf-t tr.pf-tot td.pf-s2, .pf-t tr.pf-tot td.pf-s3, .pf-t tr.pf-tot td.pf-s4 {
  background: #e9effb; color: #0f1f3d; }
.pf-t tr.pf-tot .pf-z { color: #94a3b8; }
.pf-t tr.pf-tot .pf-pc { color: #7b8aa3; }
.pf-t tr.pf-tot td.pf-b { color: #12295c; }
.pf-t tr.pf-tot td.pf-got { color: #0f7a52; }
.pf-totlbl { letter-spacing: .2px; }
/* ---------- ท้ายหน้า ---------- */
.pf-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 11px; color: #7b8aa3;
  padding: 2px 4px 6px; line-height: 1.6; }
.pf-foot #pfSavedChip { font-weight: 800; color: #2a4bd0; }
.pf-foot a { color: #2a4bd0; font-weight: 700; text-decoration: none; }
.pf-foot a:hover { text-decoration: underline; }
.pf-sep { width: 1px; height: 12px; background: #dbe4f2; }
/* ---------- responsive ---------- */
@media (max-width: 1440px) {
  .pf-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pf-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1100px) {
  .pf-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-grid { grid-template-columns: 1fr; }
  .pf-acts { margin-left: 0; width: 100%; }
  .pf-title { font-size: 24px; }
}
/* ---------- เปรียบเทียบรายเดือน (19/11/69) ---------- */
.pf-cmpcard { margin-top: 14px; }
.pf-cmpact { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pf-cmpbtn { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800;
  padding: 6px 12px; border-radius: 10px; border: 1px solid #cfdcf3; color: #1e3a8a; background: #f7faff;
  cursor: pointer; transition: .15s; }
.pf-cmpbtn svg { width: 14px; height: 14px; }
.pf-cmpbtn:hover { background: #eaf2ff; border-color: #9dbcf0; }
.pf-cmpload, .pf-cmpempty { font-size: 12px; color: #8a99b0; padding: 14px 2px; line-height: 1.65; }
.pf-cmpgrid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, .6fr); gap: 16px; align-items: start; }
.pf-cmpcol { min-width: 0; }
.pf-cmpt { font-size: 11.5px; font-weight: 800; color: #334155; margin-bottom: 2px; }
.pf-cmpchart svg { display: block; width: 100%; height: auto; }
.pf-cmplegend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 10.5px;
  color: #7b8aa3; margin-top: 4px; }
.pf-cmplegend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px;
  vertical-align: -1px; }
.pf-cmpsrc { margin-left: auto; }
.pf-cmpkpis { display: grid; gap: 9px; }
.pf-cmpk { border: 1px solid #e6ecf6; border-left: 4px solid #3b5bfd; border-radius: 13px;
  padding: 9px 12px 10px; background: #fbfdff; }
.pf-cmpk > span { display: block; font-size: 10.5px; font-weight: 800; color: #64748b; }
.pf-cmpk > b { display: block; margin-top: 3px; font-size: 19px; font-weight: 900; color: #0f1f3d;
  font-variant-numeric: tabular-nums; letter-spacing: -.4px; }
.pf-cmpk > b i { font-style: normal; font-size: 11px; font-weight: 700; color: #94a3b8; margin-left: 4px; }
.pf-cmpd { margin-top: 3px; font-size: 11.5px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pf-cmpprev { font-style: normal; font-size: 10.5px; color: #94a3b8; }
.pf-ct { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 12px; }
.pf-ctwrap { overflow-x: auto; }
.pf-ctwrap .pf-ct { min-width: 640px; }
.pf-ct th, .pf-ct td { padding: 6px 8px; border-bottom: 1px solid #eef3fa; text-align: right;
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.pf-ct th:first-child, .pf-ct td:first-child { text-align: left; }
.pf-ct thead th { background: #f4f8ff; color: #2c3e63; font-size: 11px; font-weight: 800; text-align: right; }
.pf-ct thead th:first-child { text-align: left; }
.pf-ct thead th i.pf-ctu { display: block; font-style: normal; font-size: 9px; font-weight: 700; color: #93a2b8; }
.pf-ct tbody tr:hover td { background: #f8fbff; }
.pf-ct tr.pf-ctcur td { background: #f2f7ff; font-weight: 800; color: #12295c; }
.pf-ct td.pf-ctgot { color: #0f9d58; font-weight: 800; }
.pf-cttag { font-size: 9px; font-weight: 800; color: #1e3a8a; background: #e8effd; border-radius: 5px;
  padding: 0 5px; }
.pf-ctdot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; }
.pf-cmpsub { margin-top: 16px; font-size: 11.5px; font-weight: 800; color: #334155; }
.pf-cmpnote { margin-top: 9px; font-size: 10.5px; color: #8494ad; line-height: 1.65; }
.pf-up { color: #15803d; font-weight: 800; }
.pf-down { color: #dc2626; font-weight: 800; }
.pf-flat { color: #94a3b8; font-weight: 700; }
.pf-dl-u { font-style: normal; font-size: 9.5px; margin-left: 1px; }
.pf-dl-r { font-style: normal; font-size: 10px; margin-left: 3px; opacity: .85; }
/* modal “กำหนดช่วง” */
.pf-pk-quick { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.pf-pk-q { font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 9px; }
.pf-pk-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px;
  max-height: 46vh; overflow: auto; padding: 2px; }
.pf-pk-i { display: flex; align-items: center; gap: 8px; border: 1px solid #e6ecf6; border-radius: 10px;
  padding: 7px 9px; cursor: pointer; background: #fbfdff; font-size: 12px; }
.pf-pk-i:hover { border-color: #a9bdf0; background: #f4f8ff; }
.pf-pk-i input { width: 15px; height: 15px; accent-color: #3b5bfd; }
.pf-pk-l { flex: 1; min-width: 0; font-weight: 800; color: #14213d; }
.pf-pk-l i { display: block; font-style: normal; font-size: 9.5px; font-weight: 600; color: #93a2b8; }
.pf-pk-tag { font-size: 9px; font-weight: 800; border-radius: 5px; padding: 1px 5px; background: #eef2fa;
  color: #64748b; }
.pf-pk-tag.live { background: #e8effd; color: #1e3a8a; }
.pf-pk-tag.saved { background: #dcfce7; color: #15803d; }
.pf-pk-tag.arc { background: #fef3c7; color: #92400e; }
.pf-pk-note { margin-top: 10px; font-size: 10.5px; color: #8494ad; line-height: 1.6; }
@media (max-width: 1100px) { .pf-cmpgrid { grid-template-columns: 1fr; } }
/* ---------- พิมพ์ / บันทึก PDF (แนวนอน A4) ---------- */
@page pfLandscape { size: A4 landscape; margin: 6mm 6mm 7mm; }
.pfp-head { padding: 0 0 6px; }
.pfp-brand { display: flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 800; letter-spacing: 1.6px;
  color: #8a6d1f; text-transform: uppercase; }
.pfp-brand .mk { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  background: linear-gradient(135deg, #d4af37, #8a6d1f); color: #221a05; font-size: 8.5px; font-weight: 900; letter-spacing: 0; }
.pfp-head h1 { margin: 7px 0 3px; font-size: 20px; font-weight: 900; color: #0e1f49; letter-spacing: -.2px; }
.pfp-sub { font-size: 10.5px; color: #64748b; }
.pfp-rule { height: 2px; margin: 8px 0 10px;
  background: linear-gradient(90deg, #d4af37, rgba(212, 175, 55, .55) 40%, rgba(212, 175, 55, 0) 85%); }
.pfp-kpis { display: flex; gap: 8px; margin-bottom: 10px; }
.pfp-kpis > div { flex: 1; border: 1px solid #e2e8f4; border-radius: 8px; padding: 6px 9px; background: #f8fbff; }
.pfp-kpis span { display: block; font-size: 8.5px; font-weight: 800; color: #64748b; }
.pfp-kpis b { font-size: 14px; font-weight: 900; color: #0e1f49; font-variant-numeric: tabular-nums; }
.pfp-kpis i { font-style: normal; font-size: 8.5px; color: #94a3b8; margin-left: 3px; }
.pfp-foot { margin-top: 8px; padding-top: 7px; border-top: 1px dashed #cbd5e1; font-size: 8.5px; color: #7b8aa3; }
@media print {
  body.pf-printing #printArea .pf-print { page: pfLandscape; }
  body.pf-printing #printArea .pf-print,
  body.pf-printing #printArea .pf-print * {
    -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
  }
  .pf-print { display: block; background: #fff; }
  .pf-print .pf-op { display: none !important; }
  /* A4 แนวนอนพิมพ์ได้ 25 คอลัมน์: ซ่อน “ฐานรับ” (เหลือ ฐานสุทธิ/เก็บได้/%) เพื่อให้อ่านชัด */
  .pf-print .pf-base { display: none !important; }
  .pf-print .pf-twrap { overflow: visible; max-height: none; }
  .pf-print .pf-t { width: 100%; table-layout: auto; font-size: 7px; }
  .pf-print .pf-t col { width: auto !important; }
  .pf-print .pf-t th, .pf-print .pf-t td { padding: 1.5px 2.5px; position: static !important; box-shadow: none !important;
    white-space: normal; overflow: hidden; }
  .pf-print .pf-t td.pf-s3, .pf-print .pf-t th.pf-s3 { white-space: normal; word-break: keep-all; min-width: 58px; }
  .pf-print .pf-t td.pf-s2, .pf-print .pf-t th.pf-s2 { white-space: nowrap; }
  .pf-print .pf-t thead { display: table-header-group; }
  .pf-print .pf-t thead th { font-size: 6.9px; }
  .pf-print .pf-t thead th.pf-g { font-size: 7.4px; }
  .pf-print .pf-t thead th.pf-g2 i { display: inline; font-size: 6.2px; }
  .pf-print .pf-t tr { break-inside: avoid; page-break-inside: avoid; }
  .pf-print .pf-t tr.pf-r td { background: #fff !important; }
  .pf-print .pf-t tr.pf-sub td { background: #f2f7ff !important; }
  .pf-print .pf-t tr.pf-tot td { background: #e9effb !important; color: #0f1f3d !important; }
  .pf-print .pf-pc { font-size: 6.4px; }
  .pf-print .pf-dupe { display: none; }
  .pf-print .pf-e { border: 0 !important; padding: 0; font-style: normal !important; color: inherit !important; }
}

/* =====================================================================
   คำนวณ — สีสัน / หน้าตา (scoped ด้วย .calc-page)
   ===================================================================== */
.calc-page {
  --c-blue: #2563eb;  --c-indigo: #3b5bfd; --c-violet: #7c3aed;
  --c-teal: #0d9488;  --c-amber: #d97706;  --c-cyan: #0891b2;
  --c-rose: #e11d48;  --c-fuchsia: #a21caf; --c-green: #059669;
}

/* ---------- hero header ---------- */
.calc-page .calc-head {
  position: relative; overflow: hidden;
  background:
    radial-gradient(760px 200px at 86% -50%, rgba(34, 211, 238, .34), transparent 68%),
    radial-gradient(560px 260px at -8% 120%, rgba(124, 58, 237, .42), transparent 70%),
    linear-gradient(120deg, #111f45 0%, #22316b 46%, #3b5bfd 100%);
  border: 1px solid rgba(59, 91, 253, .28);
  border-radius: 20px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 22px 44px -26px rgba(17, 31, 69, .85);
}
.calc-page .calc-head::after {
  content: ""; position: absolute; right: -70px; bottom: -120px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(125, 211, 252, .38), transparent 62%);
  pointer-events: none;
}
.calc-head-txt { display: flex; gap: 14px; align-items: flex-start; position: relative; z-index: 1; }
/* .page-head > div:first-child ตั้ง flex-basis 380px ไว้ (เหมาะกับการ์ดแนวนอน)
   — พอหัวการ์ดกลายเป็นคอลัมน์บนจอแคบ จะกลายเป็น “ความสูง 380px” ต้องรีเซ็ต */
.calc-page .calc-head > .calc-head-txt { flex: 1 1 380px; min-width: 0; }
.calc-head-ico {
  width: 48px; height: 48px; flex: 0 0 48px; border-radius: 15px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, .07));
  border: 1px solid rgba(255, 255, 255, .30);
  box-shadow: 0 10px 22px -14px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .07);
}
.calc-head-ico svg { width: 25px; height: 25px; color: #fff; }
.calc-head-body { min-width: 0; }
.calc-page .calc-head h1 {
  color: #fff; font-size: 22px; letter-spacing: -.3px;
  text-shadow: 0 1px 14px rgba(0, 0, 0, .22);
}
/* ไม่มีข้อความอธิบายใต้หัวข้อแล้ว — จัดระยะให้หัวข้อกับป้ายชิดกันพอดี */
.calc-page .calc-head-body h1 { margin: 2px 0 0; }
.calc-page .calc-head-body .calc-tags { margin-top: 10px; }
.calc-page .calc-head p { color: rgba(219, 232, 255, .84); font-size: 12.5px; max-width: 680px; margin-top: 6px; }
.calc-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.calc-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; line-height: 1.2;
  color: #e6eeff; background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px; padding: 4px 11px;
  backdrop-filter: blur(3px);
}
.calc-tag svg { width: 13px; height: 13px; opacity: .9; }
.calc-tag .dot { width: 7px; height: 7px; border-radius: 50%; background: #a5b4fc; box-shadow: 0 0 0 3px rgba(165, 180, 252, .22); }
.calc-tag.tag-auto .dot { background: #22d3ee; box-shadow: 0 0 0 3px rgba(34, 211, 238, .24); }
.calc-tag.tag-cnt { background: rgba(34, 211, 238, .20); border-color: rgba(34, 211, 238, .46); color: #e0fbff; }
.calc-page .calc-head .head-actions { position: relative; z-index: 1; gap: 8px; }
#view .calc-page .calc-head .btn {
  background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .26);
  color: #f3f7ff; box-shadow: none; backdrop-filter: blur(4px);
}
#view .calc-page .calc-head .btn:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .48); }
#view .calc-page .calc-head .btn.ghost { background: rgba(255, 255, 255, .04); }
#view .calc-page .calc-head .btn.primary {
  background: linear-gradient(135deg, #9ae6ff, #ffffff 92%);
  color: #0b2545; border-color: transparent; font-weight: 700;
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .7);
}
#view .calc-page .calc-head .btn.primary:hover { box-shadow: 0 14px 26px -14px rgba(0, 0, 0, .8); }

/* ---------- stat cards ---------- */
.calc-stats { gap: 12px; }
.calc-stats .stat {
  border-radius: 15px; padding: 15px 16px; border: 1px solid var(--line);
  background: linear-gradient(150deg, var(--tint, #f6f9ff), #fff 72%);
  box-shadow: var(--shadow-s);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.calc-stats .stat:hover {
  transform: translateY(-2px); border-color: var(--tone, #3b5bfd);
  box-shadow: 0 16px 28px -20px var(--tone, #3b5bfd);
}
.calc-stats .stat::before { width: 4px; background: linear-gradient(180deg, var(--tone, #3b5bfd), var(--tone2, #22d3ee)); opacity: 1; }
.calc-stats .stat .stat-ico {
  position: absolute; right: 13px; top: 13px;
  width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  background: #fff; color: var(--tone, #3b5bfd);
  border: 1px solid var(--line);
  box-shadow: 0 6px 14px -10px var(--tone, #3b5bfd);
}
.calc-stats .stat .stat-ico svg { width: 16px; height: 16px; }
.calc-stats .stat .k { font-weight: 700; color: var(--tone, #3b5bfd); padding-right: 36px; }
.calc-stats .stat .v { color: #0f172a; font-size: 21px; margin-top: 7px; }
.calc-stats .stat .s { color: var(--ink-3); }
.calc-stats .tone-blue   { --tone: #2563eb; --tone2: #0ea5e9; --tint: #eef5ff; }
.calc-stats .tone-violet { --tone: #7c3aed; --tone2: #c026d3; --tint: #f5edff; }
.calc-stats .tone-amber  { --tone: #d97706; --tone2: #f59e0b; --tint: #fff6e8; }
.calc-stats .tone-green  { --tone: #059669; --tone2: #22d3ee; --tint: #ecfbf4; }
.calc-stats .tone-rose   { --tone: #e11d48; --tone2: #f97316; --tint: #fff0f4; }

/* ---------- group filter chips ---------- */
.calc-chipbar { background: linear-gradient(180deg, #fbfcff, #f4f7fe 78%); }
.calc-chips { gap: 7px; }
.calc-page .chip-g { --chip: #94a3b8; --chip-tint: #f1f5f9; --chip-ink: #334155; }
.calc-page .chip-g .dot { background: var(--chip); width: 8px; height: 8px; box-shadow: 0 0 0 3px var(--chip-tint); }
.calc-page .chip-g.on {
  background: var(--chip-tint); border-color: var(--chip); color: var(--chip-ink);
  box-shadow: 0 6px 14px -10px var(--chip);
}
.calc-page .chip-g:hover { border-color: var(--chip); }
.calc-page .chip-id    { --chip: #3b5bfd; --chip-tint: #e9eeff; --chip-ink: #1e3a8a; }
.calc-page .chip-g26   { --chip: #2563eb; --chip-tint: #e8f0ff; --chip-ink: #1d4ed8; }
.calc-page .chip-gcard { --chip: #7c3aed; --chip-tint: #f2e9ff; --chip-ink: #6d28d9; }
.calc-page .chip-g78   { --chip: #0d9488; --chip-tint: #ddf6f0; --chip-ink: #0f766e; }
.calc-page .chip-g9    { --chip: #d97706; --chip-tint: #fff2df; --chip-ink: #b45309; }
.calc-page .chip-ghyb  { --chip: #0891b2; --chip-tint: #def5fd; --chip-ink: #0e7490; }
.calc-page .chip-gse   { --chip: #e11d48; --chip-tint: #ffe6ed; --chip-ink: #be123c; }
.calc-page .chip-gchk  { --chip: #a21caf; --chip-tint: #fbe6fb; --chip-ink: #86198f; }
.calc-page .chip-gsum  { --chip: #059669; --chip-tint: #dff7ec; --chip-ink: #047857; }

/* ---------- table card + group header colors ---------- */
.calc-page .calc-table-card { border-color: #dde6f7; box-shadow: 0 18px 40px -30px rgba(15, 23, 42, .55); }
#view .calc-page .calc-table-card > .card-h {
  background: linear-gradient(90deg, rgba(59, 91, 253, .07), rgba(34, 211, 238, .05) 55%, transparent);
  border-bottom: 1px solid #e2e9f7;
}
.calc-page .calc-table-card > .card-h h2 { display: flex; align-items: center; color: #16264a; }
.calc-page .calc-table-card > .card-h .h2-ico { color: var(--c-indigo); }
.calc-page .calc-table-card > .card-h .sub {
  background: rgba(59, 91, 253, .08); color: #2b3a66;
  border-radius: 999px; padding: 3px 10px; font-weight: 600;
}

.calc-page table.grid thead tr.grp th { border-right: 1px solid rgba(255, 255, 255, .75); }
.calc-page table.grid thead tr.grp th.gh-id {
  background: linear-gradient(180deg, #e9eeff, #dbe5ff); color: #1e3a8a;
  box-shadow: inset 0 -2px 0 var(--c-indigo);
}
.calc-page table.grid thead tr.grp th.gh-g26 {
  background: linear-gradient(180deg, #e8f0ff, #d7e5ff); color: #1d4ed8;
  box-shadow: inset 0 -2px 0 var(--c-blue);
}
.calc-page table.grid thead tr.grp th.gh-gcard {
  background: linear-gradient(180deg, #f2e9ff, #e7dbff); color: #6d28d9;
  box-shadow: inset 0 -2px 0 var(--c-violet);
}
.calc-page table.grid thead tr.grp th.gh-g78 {
  background: linear-gradient(180deg, #e0faf4, #d0f3ea); color: #0f766e;
  box-shadow: inset 0 -2px 0 var(--c-teal);
}
.calc-page table.grid thead tr.grp th.gh-g9 {
  background: linear-gradient(180deg, #fff2df, #ffe7c9); color: #b45309;
  box-shadow: inset 0 -2px 0 var(--c-amber);
}
.calc-page table.grid thead tr.grp th.gh-ghyb {
  background: linear-gradient(180deg, #dff6fd, #cdeefb); color: #0e7490;
  box-shadow: inset 0 -2px 0 var(--c-cyan);
}
.calc-page table.grid thead tr.grp th.gh-gse {
  background: linear-gradient(180deg, #ffe6ed, #ffd6e1); color: #be123c;
  box-shadow: inset 0 -2px 0 var(--c-rose);
}
.calc-page table.grid thead tr.grp th.gh-gchk {
  background: linear-gradient(180deg, #fbe6fb, #f6d9f8); color: #86198f;
  box-shadow: inset 0 -2px 0 var(--c-fuchsia);
}
.calc-page table.grid thead tr.grp th.gh-gsum {
  background: linear-gradient(180deg, #e2f8ee, #d1f2e2); color: #047857;
  box-shadow: inset 0 -2px 0 var(--c-green);
}

.calc-page table.grid tbody tr:hover td { background: #f2f7ff; }
.calc-page table.grid tbody tr:hover td.calc { background: #e4f0ff; }
.calc-page table.grid tfoot td {
  background: linear-gradient(180deg, #182747, #101c33);
  color: #eaf1ff; border-top: 0;
  box-shadow: inset 0 1px 0 rgba(125, 211, 252, .35);
}
.calc-page table.grid tfoot td.calc { color: #7fe3ff; }
.calc-page table.grid tfoot td.s0,
.calc-page table.grid tfoot td.s1,
.calc-page table.grid tfoot td.s2 { background: linear-gradient(180deg, #1b2a4d, #101c33); }

/* เส้นแบ่งกลุ่มคอลัมน์แบบมีสี (เดิม selector .gstart ไม่ทำงานเพราะเขียนเป็น descendant) */
.calc-page table.grid .c-id    { --gl: #c7d4ee; }
.calc-page table.grid .c-g26   { --gl: #bcd2f9; }
.calc-page table.grid .c-gcard { --gl: #d6c4f7; }
.calc-page table.grid .c-g78   { --gl: #a9e3d6; }
.calc-page table.grid .c-g9    { --gl: #f8d49a; }
.calc-page table.grid .c-ghyb  { --gl: #a5e0f2; }
.calc-page table.grid .c-gse   { --gl: #f7bfcd; }
.calc-page table.grid .c-gchk  { --gl: #edb9ef; }
.calc-page table.grid .c-gsum  { --gl: #a8e2c6; }
.calc-page table.grid thead tr.lbl th.gstart,
.calc-page table.grid tbody td.gstart,
.calc-page table.grid tfoot td.gstart { border-left: 2px solid var(--gl, #dfe7f4); }

/* ---------- archive card ---------- */
#view .calc-page .calc-arch-card > .card-h {
  background: linear-gradient(90deg, rgba(5, 150, 105, .07), rgba(34, 211, 238, .05) 60%, transparent);
}
.calc-page .calc-arch-card > .card-h h2 { display: flex; align-items: center; color: #123b2e; }
.calc-page .calc-arch-card > .card-h .h2-ico { color: var(--c-green); }

/* ---------- empty state ---------- */
.calc-page .empty {
  border-radius: 0 0 var(--radius) var(--radius);
  background:
    radial-gradient(420px 180px at 50% -30%, rgba(59, 91, 253, .10), transparent 70%),
    linear-gradient(180deg, #fbfdff, #f5f9ff);
}
.calc-page .empty .ico {
  background: linear-gradient(140deg, rgba(59, 91, 253, .16), rgba(34, 211, 238, .18));
  color: var(--c-indigo);
}

@media (max-width: 860px) {
  .calc-page .calc-head { flex-direction: column; padding: 18px; }
  .calc-page .calc-head > .calc-head-txt { flex: 0 0 auto; }
  .calc-page .calc-head .head-actions { margin-left: 0; width: 100%; }
  .calc-page .calc-head .btn { flex: 1 1 auto; justify-content: center; }
  .calc-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .calc-chips .chip { flex: 0 0 auto; }
}

/* =====================================================================
   สีประจำเมนู — ทุกหน้าอ่านค่า --pg (สีหลัก), --pg-2 (สีรอง),
   --pg-soft (พื้นอ่อน), --pg-line (เส้นขอบ), --pg-glow (แสงเรือง)
   ตั้งค่าที่ #view.v-<ชื่อเมนู> · ใช้ร่วมกับ decoratePageHead() ใน app.js
   ===================================================================== */
#view {
  --pg: #3b5bfd; --pg-2: #22d3ee; --pg-soft: #eef2ff;
  --pg-line: #cfd9ff; --pg-glow: rgba(59, 91, 253, .20);
}
#view.v-merge     { --pg: #0d9488; --pg-2: #34d399; --pg-soft: #ecfdf8; --pg-line: #bde9e1; --pg-glow: rgba(13, 148, 136, .22); }
#view.v-splitbase { --pg: #4f46e5; --pg-2: #818cf8; --pg-soft: #f0efff; --pg-line: #d3d1fb; --pg-glow: rgba(79, 70, 229, .22); }
#view.v-seizure   { --pg: #ea580c; --pg-2: #fbbf24; --pg-soft: #fff4ec; --pg-line: #fbd8bf; --pg-glow: rgba(234, 88, 12, .22); }
#view.v-paid      { --pg: #059669; --pg-2: #34d399; --pg-soft: #ecfdf3; --pg-line: #bfe8d2; --pg-glow: rgba(5, 150, 105, .22); }
#view.v-hybrid    { --pg: #0891b2; --pg-2: #22d3ee; --pg-soft: #ecfbfe; --pg-line: #bde9f4; --pg-glow: rgba(8, 145, 178, .22); }
#view.v-calc      { --pg: #3b5bfd; --pg-2: #22d3ee; --pg-soft: #eef2ff; --pg-line: #cfd9ff; --pg-glow: rgba(59, 91, 253, .22); }
#view.v-slip      { --pg: #7c3aed; --pg-2: #a78bfa; --pg-soft: #f6f1ff; --pg-line: #ded0fb; --pg-glow: rgba(124, 58, 237, .22); }
#view.v-slipam    { --pg: #a21caf; --pg-2: #e879f9; --pg-soft: #fdf1fe; --pg-line: #f2cff5; --pg-glow: rgba(162, 28, 175, .22); }
#view.v-mgr       { --pg: #b45309; --pg-2: #f59e0b; --pg-soft: #fff8eb; --pg-line: #f7ddb4; --pg-glow: rgba(180, 83, 9, .22); }
#view.v-payout    { --pg: #2563eb; --pg-2: #38bdf8; --pg-soft: #eff5ff; --pg-line: #c9dcfd; --pg-glow: rgba(37, 99, 235, .22); }
#view.v-acct      { --pg: #0f766e; --pg-2: #2dd4bf; --pg-soft: #effbf8; --pg-line: #c4e9e2; --pg-glow: rgba(15, 118, 110, .22); }
#view.v-track     { --pg: #0284c7; --pg-2: #22d3ee; --pg-soft: #eff9ff; --pg-line: #c2e6f8; --pg-glow: rgba(2, 132, 199, .22); }
#view.v-dept      { --pg: #e11d48; --pg-2: #fb7185; --pg-soft: #fff2f5; --pg-line: #f8c9d4; --pg-glow: rgba(225, 29, 72, .20); }
#view.v-perf      { --pg: #9333ea; --pg-2: #c084fc; --pg-soft: #f9f2ff; --pg-line: #e6d3fa; --pg-glow: rgba(147, 51, 234, .22); }
#view.v-dashboard { --pg: #4338ca; --pg-2: #22d3ee; --pg-soft: #f0f1ff; --pg-line: #cfd3f8; --pg-glow: rgba(67, 56, 202, .22); }
#view.v-criteria  { --pg: #0f766e; --pg-2: #2dd4bf; --pg-soft: #effbf8; --pg-line: #c4e9e2; --pg-glow: rgba(15, 118, 110, .22); }
#view.v-history   { --pg: #0ea5e9; --pg-2: #67e8f9; --pg-soft: #f0faff; --pg-line: #c6e9fb; --pg-glow: rgba(14, 165, 233, .22); }
#view.v-users     { --pg: #475569; --pg-2: #94a3b8; --pg-soft: #f8fafc; --pg-line: #dbe3ec; --pg-glow: rgba(71, 85, 105, .18); }
#view.v-manual    { --pg: #64748b; --pg-2: #94a3b8; --pg-soft: #f8fafc; --pg-line: #dbe3ec; --pg-glow: rgba(100, 116, 139, .18); }

/* ---------- หัวเรื่องแบบการ์ดสี + ไอคอนประจำเมนู ---------- */
#view .page-head:not(.calc-head) {
  position: relative;
  padding: 17px 20px;
  border-radius: 18px;
  border: 1px solid var(--pg-line);
  border-left: 4px solid var(--pg);
  background:
    radial-gradient(560px 160px at 88% -40%, var(--pg-glow), transparent 72%),
    linear-gradient(120deg, var(--pg-soft) 0%, #ffffff 74%);
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, .85);
}
#view .page-head.pg-hasico { padding-left: 78px; }
#view .page-head .pg-ico {
  position: absolute; left: 20px; top: 18px;
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--pg), var(--pg-2));
  color: #fff;
  box-shadow: 0 12px 22px -14px var(--pg), inset 0 0 0 1px rgba(255, 255, 255, .28);
}
#view .page-head .pg-ico svg { width: 23px; height: 23px; }
#view .page-head:not(.calc-head) h1 { font-size: 22px; }
#view .page-head:not(.calc-head) p { color: var(--ink-2); }

/* ---------- ปุ่มหลักใช้สีประจำเมนู ---------- */
#view .btn.primary {
  background: linear-gradient(135deg, var(--pg), var(--pg-2));
  border-color: transparent;
  box-shadow: 0 8px 20px -10px var(--pg);
}
#view .btn.primary:hover { box-shadow: 0 12px 26px -10px var(--pg); }

/* ---------- การ์ดสถิติ ---------- */
#view .stats:not(.calc-stats) .stat {
  background: linear-gradient(150deg, var(--pg-soft) 0%, #ffffff 64%);
  border-color: var(--pg-line);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
#view .stats:not(.calc-stats) .stat:hover {
  transform: translateY(-2px);
  border-color: var(--pg-line);
  box-shadow: 0 16px 30px -24px var(--pg);
}
#view .stats:not(.calc-stats) .stat:not(.ok):not(.warn):not(.bad)::before { background: var(--pg); }
#view .stats:not(.calc-stats) .stat .v { color: #0f172a; }

/* ---------- หัวการ์ด + หัวตาราง ---------- */
#view .card-h { background: linear-gradient(90deg, var(--pg-soft), rgba(255, 255, 255, 0) 58%); }
#view .card-h h2 { color: #14203c; }
#view table.simple thead th { background: var(--pg-soft); color: #3c4b66; }

/* ---------- กล่องลากไฟล์ / สถานะว่าง / ไอคอนไฟล์ ---------- */
#view .drop {
  border-color: var(--pg-line);
  background: linear-gradient(180deg, #ffffff, var(--pg-soft));
}
#view .drop.hot { border-color: var(--pg); background: var(--pg-soft); }
#view .drop .big { background: linear-gradient(135deg, #fff, var(--pg-soft)); color: var(--pg); }
#view .empty .ico { background: linear-gradient(135deg, #ffffff, var(--pg-soft)); color: var(--pg); }
#view .seg button.on { background: var(--pg-soft); color: var(--pg); }

/* ---------- ไอคอนเมนูด้านซ้ายให้มีสีประจำเมนู ---------- */
.nav-item { --ni: #8fb0ff; }
.nav-item[data-view="merge"]     { --ni: #2dd4bf; }
.nav-item[data-view="splitbase"] { --ni: #a5b4fc; }
.nav-item[data-view="seizure"]   { --ni: #fdba74; }
.nav-item[data-view="paid"]      { --ni: #6ee7b7; }
.nav-item[data-view="hybrid"]    { --ni: #67e8f9; }
.nav-item[data-view="calc"]      { --ni: #93c5fd; }
.nav-item[data-view="slip"]      { --ni: #c4b5fd; }
.nav-item[data-view="slipam"]    { --ni: #f0abfc; }
.nav-item[data-view="mgr"]       { --ni: #fcd34d; }
.nav-item[data-view="payout"]    { --ni: #7dd3fc; }
.nav-item[data-view="acct"]      { --ni: #5eead4; }
.nav-item[data-view="track"]     { --ni: #5eead4; }
.nav-item[data-view="dept"]      { --ni: #fda4af; }
.nav-item[data-view="perf"]      { --ni: #d8b4fe; }
.nav-item[data-view="dashboard"] { --ni: #818cf8; }
.nav-item[data-view="criteria"]  { --ni: #94a3b8; }
.nav-item[data-view="history"]   { --ni: #38bdf8; }
.nav-item[data-view="users"]     { --ni: #fbbf24; }
.nav-item[data-view="manual"]    { --ni: #cbd5e1; }
.nav-item svg { color: var(--ni, #8fb0ff); opacity: .85; }
.nav-item:hover svg, .nav-item.on svg { color: var(--ni, #8fb0ff); opacity: 1; }

@media (max-width: 640px) {
  #view .page-head:not(.calc-head) { padding: 15px 16px; }
  #view .page-head .pg-ico { display: none; }
}

/* =====================================================================
   เมนู “สรุปส่งบัญชี” (acct) — 18/11/69
   ===================================================================== */
.ac-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.ac-meta .f { display: flex; flex-direction: column; gap: 5px; }
.ac-meta .f > span { font-size: 11.5px; font-weight: 700; color: #64748b; }
.ac-meta .f input { border: 1px solid #dbe3ec; border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13px; background: #fff; }
.ac-meta .f input:focus { outline: 2px solid var(--pg-line, #c4e9e2); outline-offset: 1px; border-color: var(--pg, #0f766e); }
.ac-meta .f.ro b { font-size: 13px; font-weight: 800; color: #0f172a; padding-top: 6px; }

.ac-recon { display: flex; gap: 10px; flex-wrap: wrap; }
.ac-recon span { font-size: 12px; font-weight: 700; padding: 7px 11px; border-radius: 10px; }
.ac-recon .ok { background: #ecfdf3; color: #0f7a45; border: 1px solid #bfe8d2; }
.ac-recon .bad { background: #fff7ed; color: #b45309; border: 1px solid #f7ddb4; }

.ac-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.ac-g { border: 1px solid #e6edf7; border-radius: 14px; padding: 12px 14px; background: #fff; min-width: 0; }
.ac-g-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ac-g-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--c); color: #fff; flex: 0 0 auto; }
.ac-g-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.ac-g-tt { flex: 1 1 130px; min-width: 0; }
.ac-g-tt b { display: block; font-size: 13.5px; color: #0f172a; overflow-wrap: anywhere; }
.ac-g-tt i { font-style: normal; font-size: 11px; color: #7b8aa3; overflow-wrap: anywhere; }
.ac-g-pay { text-align: right; white-space: nowrap; }
.ac-g-pay b { font-size: 16px; font-weight: 900; color: #0f172a; font-variant-numeric: tabular-nums; }
.ac-g-pay i { font-style: normal; font-size: 10.5px; color: #94a3b8; margin-left: 3px; }
.ac-g-n { font-size: 11px; color: #7b8aa3; min-width: 50px; text-align: right; }
.ac-bar { display: block; height: 7px; border-radius: 99px; background: #eef3fb; margin: 9px 0 6px; overflow: hidden; }
.ac-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.ac-g-f { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; font-size: 11.5px; color: #64748b; }
.ac-g-f span { flex: 1 1 150px; min-width: 0; overflow-wrap: anywhere; }
.ac-g-f b { color: #0f172a; white-space: nowrap; }
.ac-det { margin-top: 8px; border-top: 1px dashed #e6edf7; padding-top: 6px; }
.ac-det summary { cursor: pointer; font-size: 11.5px; font-weight: 700; color: #2563eb; }
.ac-det ul { list-style: none; margin: 6px 0 0; padding: 0; }
.ac-det li { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; padding: 2px 0; color: #475569; }
.ac-det li b { font-variant-numeric: tabular-nums; color: #0f172a; }

.ac-tw { overflow: auto; max-height: calc(100vh - 300px); }
table.ac-t { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; white-space: nowrap; }
table.ac-t th, table.ac-t td { padding: 6px 8px; border-bottom: 1px solid #eef3fa; }
table.ac-t thead th { position: sticky; top: 0; z-index: 2; background: #f1f5fb; font-size: 11.5px;
  text-align: left; color: #334155; font-weight: 800; }
table.ac-t thead th.ac-gh { box-shadow: inset 0 -2px 0 var(--c); text-align: right; }
table.ac-t th.c, table.ac-t td.c { text-align: center; }
table.ac-t .num { text-align: right; font-variant-numeric: tabular-nums; }
table.ac-t tbody tr:nth-child(even) td { background: #fbfdff; }
table.ac-t tbody tr:hover td { background: #f2f8ff; }
table.ac-t .strong { font-weight: 800; }
table.ac-t .ac-net { color: #0f7a45; }
table.ac-t tfoot td { position: sticky; bottom: 0; background: #0f172a; color: #fff; font-weight: 800; }
table.ac-t tfoot td.ac-net { color: #6ee7b7; }

.ac-two { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; margin-top: 14px; }
@media (max-width: 1100px) { .ac-two { grid-template-columns: 1fr; } }
table.ac-team { width: 100%; }
table.ac-team th.c, table.ac-team td.c { text-align: center; }

.ac-ob { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ac-ob-c { border: 1px solid #e6edf7; border-left: 4px solid var(--c); border-radius: 12px; padding: 10px 12px; background: #fbfdff; }
.ac-ob-c span { display: block; font-size: 11px; font-weight: 700; color: #64748b; }
.ac-ob-c b { font-size: 16px; font-weight: 900; color: #0f172a; font-variant-numeric: tabular-nums; }
.ac-ob-c b i { font-style: normal; font-size: 10.5px; color: #94a3b8; margin-left: 3px; }
.ac-ob-c .n { display: block; font-style: normal; font-size: 11px; color: #7b8aa3; }
@media (max-width: 900px) { .ac-ob { grid-template-columns: 1fr; } }

/* ---------- พิมพ์ / บันทึก PDF (แนวนอน A4) ---------- */
@page acLandscape { size: A4 landscape; margin: 6mm; }
@media print {
  body.ac-printing #printArea .ac-print { page: acLandscape; }
  body.ac-printing #printArea .ac-print,
  body.ac-printing #printArea .ac-print * {
    -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
  }
  .ac-print h1 { font-size: 13px; margin: 0 0 2px; letter-spacing: .4px; }
  .ac-print h2 { font-size: 11.5px; margin: 0 0 4px; color: #0f172a; }
  .ac-print .ac-pmeta { font-size: 8.5px; color: #475569; margin-bottom: 7px; }
  .ac-print table { width: 100%; border-collapse: collapse; font-size: 7.6px; margin-bottom: 8px; }
  .ac-print caption { text-align: left; font-weight: 800; font-size: 8px; padding: 0 0 2px; }
  .ac-print th, .ac-print td { border: 1px solid #cbd5e1; padding: 1.6px 3px; }
  .ac-print th { background: #eef3fb; }
  .ac-print .n { text-align: right; font-variant-numeric: tabular-nums; }
  .ac-print .c { text-align: center; }
  .ac-print .b { font-weight: 800; }
  .ac-print tfoot td { background: #f1f5f9; font-weight: 800; }
  .ac-print table.ac-p2 { font-size: 6.9px; }
  .ac-print .ac-psig { display: flex; gap: 26px; margin-top: 18px; font-size: 8.5px; }
  .ac-print .ac-psig > div { flex: 1; text-align: center; }
  .ac-print .ac-psig .line { display: block; border-top: 1px dotted #64748b; margin: 0 18px 3px; }
  .ac-print .ac-psig i { display: block; font-style: normal; font-size: 7.5px; color: #64748b; }
  .ac-print tr, .ac-print table { break-inside: avoid; }
}

