/* BCI Account — layout: sidebar ledger + work surface; print = black on white A4 */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --sunken: #f5f7f9;
  --ink: #18212c;
  --muted: #5a6776;
  --line: #d6dde5;
  --accent: #1f4e86;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecf7;
  --ok: #1d7a4a;
  --warn: #9a6200;
  --void: #b3261e;
  --void-soft: #fbe9e7;
  --side: #17283d;
  --side-ink: #c9d6e6;
  --side-active: #ffffff;
  --f-ui: "IBM Plex Sans Thai", "Noto Sans Thai", Tahoma, sans-serif;
  --f-doc: "Sarabun", "TH Sarabun New", Tahoma, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --surface: #17202a; --sunken: #121a22; --ink: #e4eaf1; --muted: #93a1b2; --line: #2a3644;
    --accent: #7fb0eb; --accent-ink: #0d1722; --accent-soft: #1c2f46; --ok: #5cc48b; --warn: #e0a84a; --void: #ff8a80; --void-soft: #3a1f1e;
    --side: #0b1118; --side-ink: #9fb0c4; --side-active: #ffffff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --surface: #17202a; --sunken: #121a22; --ink: #e4eaf1; --muted: #93a1b2; --line: #2a3644;
  --accent: #7fb0eb; --accent-ink: #0d1722; --accent-soft: #1c2f46; --ok: #5cc48b; --warn: #e0a84a; --void: #ff8a80; --void-soft: #3a1f1e;
  --side: #0b1118; --side-ink: #9fb0c4; --side-active: #ffffff; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--f-ui); }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.3; }
h1 { font-size: 1.45rem; font-weight: 600; }
h2 { font-size: 1.1rem; font-weight: 600; }
a { color: var(--accent); }
.num, td.n, th.n { font-family: var(--f-num); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 8px; color: var(--side-active); }
.brand b { font-size: 1.2rem; letter-spacing: .02em; }
.brand span { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--side-ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .grp { all: unset; box-sizing: border-box; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r); color: var(--side-ink); font-weight: 600; margin-top: 2px; }
.nav .grp:hover { background: rgba(255,255,255,.06); color: var(--side-active); }
.nav .grp:focus-visible { outline: 2px solid #7fb0ea; outline-offset: -2px; }
.nav .grp.here { color: var(--side-active); }
.nav .grp .ar { font-size: .65rem; opacity: .7; transition: transform .15s; }
.nav .grp.open .ar { transform: rotate(90deg); }
.nav .sub { margin: 2px 0 6px 16px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.15); display: flex; flex-direction: column; gap: 1px; }
.nav .sub[hidden], .nav-m[hidden] { display: none; }
.nav .sub a { font-size: .92rem; padding: 6px 10px; }
.nav a.top1 { font-weight: 600; }
.nav-m { display: none; }
.crumb { font-size: .8rem; color: var(--muted); padding: 10px 24px 0; }
.crumb:empty { display: none; }
.crumb:not(:empty) + .view { padding-top: 10px; }
.nav a { color: var(--side-ink); text-decoration: none; padding: 7px 10px; border-radius: var(--r); display: block; }
.nav a:hover { background: rgba(255,255,255,.06); color: var(--side-active); }
.nav a.on { background: rgba(255,255,255,.12); color: var(--side-active); font-weight: 600; }
.side .who { margin-top: auto; font-size: .82rem; padding: 0 8px; display: flex; flex-direction: column; gap: 6px; }
.side .who button { align-self: flex-start; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(24px, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar label { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.topbar select, .topbar input { min-width: 0; }
.topbar .co { flex: 1 1 260px; }
.topbar .co select { flex: 1; max-width: 420px; font-weight: 600; color: var(--ink); }
.view { padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(24px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.head .sub { color: var(--muted); font-size: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- controls ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .btn { font: inherit; font-size: .92rem; cursor: pointer; border-radius: var(--r); padding: 7px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--accent); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.danger { color: var(--void); }
.ghost { background: transparent; border-color: transparent; color: inherit; }
.side .ghost { color: var(--side-ink); border: 1px solid rgba(255,255,255,.18); padding: 4px 10px; font-size: .8rem; }
button:disabled { opacity: .5; cursor: default; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; min-width: 0; }
.grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: .8rem; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .76rem; font-weight: 600; color: var(--muted); letter-spacing: .03em; background: var(--sunken); white-space: nowrap; }
tbody tr:hover { background: var(--sunken); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 2px solid var(--line); border-bottom: 0; }
td.act { white-space: nowrap; text-align: right; }
td.act button { padding: 3px 9px; font-size: .82rem; }
tr.void td { color: var(--muted); text-decoration: line-through; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.pill { display: inline-block; font-size: .74rem; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.pill.void { color: var(--void); background: var(--void-soft); border-color: transparent; text-decoration: none; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }

/* ---------- dashboard ---------- */
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.ledger > div { padding: 16px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.ledger .k { font-size: .8rem; color: var(--muted); }
.ledger .v { font: 600 1.35rem/1.3 var(--f-num); font-variant-numeric: tabular-nums; }
.ledger .s { font-size: .8rem; color: var(--muted); }
.ledger .v.pos { color: var(--void); }
.ledger .v.neg { color: var(--ok); }
.cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.deadlines { display: flex; flex-direction: column; gap: 10px; }
.deadlines div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; }

/* ---------- doc form ---------- */
.lines td { padding: 6px; }
.lines input { width: 100%; }
.lines .c-qty { width: 90px; } .lines .c-unit { width: 90px; } .lines .c-price { width: 130px; } .lines .c-amt { width: 130px; }
.lines .c-prod { width: 230px; }
.lines td.amt { font-family: var(--f-num); text-align: right; padding-top: 13px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; max-width: 420px; margin-left: auto; }
.totals .num { font-size: 1rem; }
.totals .grand { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--line); padding-top: 6px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth .panel { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.auth h1 { font-size: 1.6rem; }
.err { color: var(--void); font-size: .9rem; min-height: 1.2em; }

/* ---------- toast / dialog ---------- */
#toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
#toast.bad { background: var(--void); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; background: var(--surface); color: var(--ink); width: min(780px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10,18,28,.45); }
#dlg-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- report screen ---------- */
.paper { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 4px; padding: 28px; overflow-x: auto; font-family: var(--f-doc); }
.paper table th { background: #f2f2f2; color: #111; }
.paper td, .paper th { border: 1px solid #999; color: #111; }
.paper tbody tr:hover { background: transparent; }

/* ---------- print overlay ---------- */
#print { position: fixed; inset: 0; z-index: 40; background: #8a939d; overflow: auto; padding-block: 0 40px; }
#print .bar { position: sticky; top: 0; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); background: #2b3542; }
#print .bar button { background: #fff; color: #111; }
#print .bar .primary { background: #1f4e86; color: #fff; }
.sheet { background: #fff; color: #111; width: 210mm; min-height: 297mm; margin: 20px auto; padding: 18mm 18mm 12mm; font: 14px/1.45 var(--f-doc); box-shadow: 0 4px 20px rgba(0,0,0,.25); }
.sheet.land { width: 297mm; min-height: 210mm; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { border: 1px solid #555; padding: 4px 6px; color: #111; background: transparent; font-size: 13px; letter-spacing: 0; }
.sheet th { background: #eee; text-align: center; font-weight: 600; white-space: normal; }
.sheet .noborder td { border: 0; padding: 1px 0; }
.sheet .n { font-family: var(--f-doc); }
.sheet h1 { font-size: 20px; text-align: center; font-weight: 700; }
.sheet h2 { font-size: 16px; }
.doc-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 8px; }
.doc-co b { font-size: 17px; }
.doc-co { flex: 1 1 auto; min-width: 0; }
.doc-title { text-align: right; flex: 0 0 auto; }
.doc-title .t { font-size: 20px; font-weight: 700; white-space: nowrap; }
.doc-title .copy { display: inline-block; border: 1.5px solid #111; padding: 0 10px; font-weight: 600; margin-top: 4px; }
.doc-meta { display: grid; grid-template-columns: 1fr 230px; gap: 0; border: 1px solid #555; margin: 12px 0; }
.doc-meta > div { padding: 8px 10px; }
.doc-meta > div + div { border-left: 1px solid #555; }
.doc-sum { display: grid; grid-template-columns: 1fr 260px; margin-top: -1px; }
.doc-sum .words { border: 1px solid #555; border-right: 0; padding: 8px 10px; display: flex; align-items: center; font-weight: 600; }
.doc-sum table td { font-size: 13px; }
.signs { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 48px; text-align: center; }
.signs div { border-top: 1px dotted #111; padding-top: 6px; }
.void-stamp { color: #b3261e; border: 3px solid #b3261e; font-size: 28px; font-weight: 700; padding: 2px 20px; display: inline-block; transform: rotate(-8deg); }
.box { display: inline-block; width: 13px; height: 13px; border: 1px solid #111; vertical-align: -2px; margin-right: 4px; text-align: center; line-height: 11px; font-size: 12px; }
.w50 td { vertical-align: middle; }
.rpt-head { text-align: center; margin-bottom: 10px; }
.rpt-head div { font-size: 14px; }
.rpt-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0; font-size: 13px; }
.page-break { break-after: page; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .nav .sub { display: none; }
  .nav a, .nav .grp { white-space: nowrap; margin: 0; border: 1px solid rgba(255,255,255,.2); border-radius: 16px; padding: 6px 12px; font-size: .85rem; }
  .nav .grp .ar { display: none; }
  .nav .grp.open, .nav a.top1.on { background: #fff; color: var(--side); }
  .nav-m { display: flex; gap: 6px; overflow-x: auto; margin: 0 -4px; padding: 2px 4px; }
  .nav-m a { white-space: nowrap; text-decoration: none; padding: 5px 11px; border-radius: 16px; font-size: .82rem; background: var(--accent-soft); color: var(--accent); }
  .nav-m a.on { background: var(--accent); color: #fff; }
  .crumb { padding: 8px 16px 0; }
  .side .who { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 0; }
  .cols, .split { grid-template-columns: 1fr; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .view { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@page { size: A4; margin: 18mm 18mm 12mm; } /* บน / ซ้าย-ขวา / ล่าง */
@page land { size: A4 landscape; margin: 8mm; }
@media print {
  body { background: #fff; }
  #app, #toast, #print .bar { display: none !important; }
  #print { position: static; background: #fff; padding: 0; overflow: visible; }
  .sheet { box-shadow: none; margin: 0; width: auto; max-width: none; min-height: 0; padding: 0 2px; } /* กันเส้นขอบขวาโดนตัด */
  .sheet.land { page: land; }
  .page-break { break-after: page; }
}

/* ---------- ช่องค้นหาแบบพิมพ์แล้วเลือก ---------- */
.suggest { position: fixed; z-index: 60; max-height: min(340px, 55vh); overflow-y: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(10, 20, 35, .18); padding: 4px; }
.sg-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.sg-item.on, .sg-item:hover { background: var(--accent-soft); }
.sg-t { font-weight: 500; }
.sg-s { font-size: .8rem; color: var(--muted); margin-top: 1px; }
.sg-code { font-family: var(--f-num); font-size: .85em; color: var(--muted); }
.sg-empty { padding: 8px 10px; color: var(--muted); font-size: .85rem; }
.sg-foot { padding: 8px 10px; border-top: 1px solid var(--line); margin-top: 4px; color: var(--accent); font-weight: 600; cursor: pointer; border-radius: 0 0 6px 6px; }
.sg-foot:hover { background: var(--accent-soft); }
.suggest mark { background: transparent; color: var(--accent); font-weight: 700; }
.primary:disabled { background: var(--line); border-color: var(--line); color: var(--muted); filter: none; opacity: 1; cursor: not-allowed; }

/* รายการสินค้าในเอกสารพิมพ์: 2 บรรทัด (สินค้า/บริการ + รายละเอียด) */
.sheet tr.ln2 td { vertical-align: top; }
.sheet .ln-d { font-size: 12px; color: #444; padding-left: 10px; }
.sheet.page-break:last-child { break-after: auto; }
/* เลือกหลายรายการเพื่อพิมพ์ */
td.ck, th.ck { width: 34px; text-align: center; }
td.ck input, th.ck input { width: 16px; height: 16px; cursor: pointer; }
tr.sel td { background: var(--accent-soft, rgba(37, 99, 235, .08)); }

/* ตารางรายการในหน้าบันทึกเอกสาร: 2 บรรทัดต่อรายการ */
.lines tr.lr1 td { border-bottom: 0; padding-bottom: 2px; }
.lines tr.lr2 td { padding-top: 0; }
.lines tr.lr2 input { font-size: .92em; color: var(--muted); }
.lines tr.lr2 input:focus { color: inherit; }
.lines tr.lr1 > td[rowspan] { vertical-align: top; padding-top: 13px; }
#toast { white-space: pre-line; }
input.err { border-color: var(--void); box-shadow: 0 0 0 2px var(--void-soft, rgba(200, 40, 40, .15)); }
.sheet td.n { white-space: nowrap; } /* ยอดเงินหลักล้านไม่ตัดบรรทัด คอลัมน์ขยายเองเมื่อจำเป็น */

/* สามเหลี่ยมสีที่มุมขวาบนของกระดาษ 24 มม.: ต้นฉบับ = น้ำเงิน, สำเนา = ส้ม (เอกสารขาย/ซื้อ/ใบเสร็จ)
   ตอนพิมพ์วาดแยก 3 ส่วนในช่องขอบกระดาษรอบมุม จึงชิดขอบกระดาษจริงทุกหน้า ไม่ทับเนื้อหา และพิมพ์ออกแม้ไม่เปิด "กราฟิกพื้นหลัง" */
.sheet.corner { position: relative; page: doc-o; --corner: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24mm' height='24mm' viewBox='0 0 24 24' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%239cc1ea'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%231f4e86'/%3E%3C/svg%3E"); }
.sheet.corner.cp-c { page: doc-c; --corner: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24mm' height='24mm' viewBox='0 0 24 24' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%23f8c08a'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%23c2510c'/%3E%3C/svg%3E"); }
.sheet.corner::before { content: ''; position: absolute; top: 0; right: 0; width: 24mm; height: 24mm; background: var(--corner) no-repeat top right / 100% 100%; pointer-events: none; }
@page doc-o { size: A4; margin: 18mm 18mm 12mm;
  @top-right-corner { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18mm' height='18mm' viewBox='6 0 18 18' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%239cc1ea'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%231f4e86'/%3E%3C/svg%3E"); vertical-align: top; text-align: right; }
  @top-right { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6mm' height='18mm' viewBox='0 0 6 18' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%239cc1ea'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%231f4e86'/%3E%3C/svg%3E"); vertical-align: top; text-align: right; }
  @right-top { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18mm' height='6mm' viewBox='6 18 18 6' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%239cc1ea'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%231f4e86'/%3E%3C/svg%3E"); vertical-align: top; text-align: right; } }
@page doc-c { size: A4; margin: 18mm 18mm 12mm;
  @top-right-corner { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18mm' height='18mm' viewBox='6 0 18 18' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%23f8c08a'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%23c2510c'/%3E%3C/svg%3E"); vertical-align: top; text-align: right; }
  @top-right { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6mm' height='18mm' viewBox='0 0 6 18' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%23f8c08a'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%23c2510c'/%3E%3C/svg%3E"); vertical-align: top; text-align: right; }
  @right-top { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18mm' height='6mm' viewBox='6 18 18 6' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 24,0 24,24' fill='%23f8c08a'/%3E%3Cpolygon points='7,0 24,0 24,17' fill='%23c2510c'/%3E%3C/svg%3E"); vertical-align: top; text-align: right; } }
@media print { .sheet.corner::before { display: none; } }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* ช่องเลขผู้เสียภาษี 13 หลัก: กว้างพอให้เห็นครบทุกหลัก */
input.taxid { min-width: 15.5ch; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.row > input.taxid { flex: 1 1 auto; }
.rd-btn { padding: 6px 10px; flex: 0 0 auto; }

/* รหัสผ่าน: ปุ่มเปิด/ซ่อน, ตัววัดความแข็งแรง, คำแนะนำ */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 40px; min-width: 0; }
.pw-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; padding: 4px 8px; cursor: pointer; font-size: 16px; line-height: 1; }
.pw-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; grid-column: 1 / -1; }
.pw-box > :not(label) { grid-column: 1 / -1; }
@media (max-width: 640px) { .pw-box { grid-template-columns: 1fr; } }
.pw-meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.pw-tips { list-style: none; margin: 0; padding: 0; color: var(--muted); display: grid; gap: 2px; }
.pw-tips li.ok { color: var(--ok); }
.pw-box [data-pwgen] { align-self: flex-start; }

/* ไฟล์แนบ (รูป / PDF) */
.att-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.att { position: relative; width: 120px; height: 150px; border: 1px solid var(--line); border-radius: 6px; background: var(--sunken); overflow: hidden; }
.att > a { display: block; width: 100%; height: 100%; color: var(--ink); text-decoration: none; }
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-pdf { display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 2.2rem; padding: 8px; text-align: center; }
.att-pdf span { font-size: .72rem; line-height: 1.3; word-break: break-all; max-height: 4em; overflow: hidden; }
.att-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; padding: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: 0; line-height: 26px; }
.att.wait { border-style: dashed; opacity: .85; }
.meter { height: 10px; background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-top: 6px; max-width: 480px; }
.meter > span { display: block; height: 100%; }
table.mini { width: auto; border-collapse: collapse; font-size: .9rem; }
table.mini td { padding: 4px 16px 4px 0; border: 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
/* ลูกหนี้/เจ้าหนี้คงค้าง: แถวรายใบ */
tr.sub-row td { font-size: .85rem; color: var(--muted); }
tr.sub-row td a { font-weight: 400; }
/* ระบบบัญชี: ตัวแก้ไขรายการ JV / ยอดยกมา และสรุปกระทบยอดธนาคาร */
.jv-tbl select, .jv-tbl input { width: 100%; min-width: 0; box-sizing: border-box; }
.jv-tbl input.n { text-align: right; }
.jv-tbl td { vertical-align: middle; }
.sum-tbl { width: 100%; max-width: 620px; border-collapse: collapse; }
.sum-tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line, #d6dde5); }
@media (max-width: 700px) { .jv-tbl { min-width: 640px; } }
/* งบการเงิน */
.fin-tbl { width: 100%; max-width: 760px; margin: 0 auto; border-collapse: collapse; }
.fin-tbl td { padding: 5px 8px; border: none !important; }
.fin-tbl td.n { width: 180px; }
.fin-tbl tr.sec td { padding-top: 12px; }
.fin-tbl tr.tot td { border-top: 1px solid #999 !important; font-weight: 600; }
.fin-tbl tr.big td { font-weight: 700; }
.fin-tbl tr.dbl td.n { border-bottom: 3px double #333 !important; }
.fin-tbl .ind, td.ind { padding-left: 22px; display: inline-block; }
/* หลายร้าน: ข้อความแจ้งบนหน้าเข้าสู่ระบบ */
.notice { background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; font-size: .9rem; }
/* ชื่อแอปไม่ตัดคำ: คำอธิบายใต้ชื่อขึ้นบรรทัดใหม่เมื่อแถบเมนูแคบ */
.brand { flex-wrap: wrap; row-gap: 2px; }
.brand b { white-space: nowrap; }
