/* app.css — หน้าตาทั้งเว็บ ยึดตามไฟล์ต้นแบบ prototype.html (สี ฟอนต์ ระยะ การ์ด เงา ปุ่ม ตาราง) */
:root {
  --bg: #f3f6fb; --surface: #ffffff; --sunk: #f4f7fc; --line: #e5eaf3; --field: #b9c2d3; --field-bg: #ffffff; --ink: #18213a; --muted: #69738a;
  --accent: #0b7fc1; --accent-2: #2fb3e8; --accent-soft: #eaf1ff; --accent-ink: #ffffff;
  --good: #16a34a; --good-soft: #e8f7ee; --warn: #d97706; --warn-soft: #fff3df; --bad: #e5484d; --bad-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --f-display: "Prompt", "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1422; --surface: #171d2e; --sunk: #131929; --line: #273049; --field: #46526f; --field-bg: #121828; --ink: #e7ebf5; --muted: #9aa4bd;
    --accent: #5b8cff; --accent-2: #38bdf8; --accent-soft: #1d2a4d; --accent-ink: #0b1020;
    --good: #4ade80; --good-soft: #15301f; --warn: #fbbf24; --warn-soft: #352a12; --bad: #f87171; --bad-soft: #3a1b1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
p { margin: 0; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.legend, .muted { color: var(--muted); }
.legend { font-size: 13px; }
.mono { font-family: var(--f-mono); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- โครงหน้า: แถบเมนูซ้าย (rail) + เนื้อหา ---------- */
.app { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100%; }
.rail {
  background: var(--surface); border-right: 1px solid var(--line); padding: 22px 16px;
  display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand-logo { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 4px 8px; text-decoration: none; }
.brand-logo img { height: 46px; width: auto; display: block; background: #fff; border-radius: 10px; padding: 4px 6px; box-sizing: content-box; } /* สูง 46px เท่าหัวหน้าเลือกโปรแกรมและเครื่องมือ */
.brand-logo small { color: var(--muted); font-size: 12px; padding-left: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav h6 { margin: 14px 12px 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.nav a {
  padding: 9px 12px; border-radius: 12px; display: flex; align-items: center; gap: 12px;
  font-weight: 500; color: var(--ink); text-decoration: none;
}
.nav a svg.i { color: var(--muted); }
.nav a:hover { background: var(--sunk); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a[aria-current="page"] svg.i { color: var(--accent); }
.nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.main { padding-block: 22px 56px; padding-inline: 32px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }

/* แถบด้านบน: ปีทำงาน + ผู้ใช้ */
.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.ws { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: 14px; padding: 8px 14px 8px 10px; box-shadow: var(--shadow); margin: 0; }
.ws::before {
  content: ""; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b7fc1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='2'/%3E%3Cpath d='M8 2v4M16 2v4M3 10h18'/%3E%3C/svg%3E") center/18px no-repeat;
}
.ws label { display: flex; flex-direction: column; }
.ws small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.ws select { background: transparent; border: 0; font-weight: 600; padding: 0 22px 0 0; cursor: pointer; font-family: var(--f-display); height: auto; background-position: right 0 center; }
.who { margin-left: auto; display: flex; gap: 10px; align-items: center; background: var(--surface); border-radius: 14px; padding: 6px 8px 6px 6px; box-shadow: var(--shadow); }
.who b { display: block; font-size: 14px; line-height: 1.2; font-weight: 600; }
.who small { color: var(--muted); font-size: 12px; }
.who form { margin: 0; }
.who-actions { display: flex; gap: 6px; margin-left: 6px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: grid; place-items: center; font-family: var(--f-display); font-weight: 600;
}

/* หัวเรื่องของหน้า */
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.head h1 { font-family: var(--f-display); font-weight: 600; font-size: 26px; margin: 0; line-height: 1.25; }
.head p { margin: 4px 0 0; color: var(--muted); }

/* แบนเนอร์ทักทาย */
.hero {
  border-radius: 20px; padding: 30px 32px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 100%);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 18px;
  box-shadow: 0 14px 30px rgba(11, 127, 193, .22);
}
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.hero::before { content: ""; position: absolute; right: 120px; bottom: -120px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-family: var(--f-display); font-size: 28px; margin: 0; font-weight: 600; line-height: 1.25; }
.hero p { margin: 6px 0 0; opacity: .9; }

/* ---------- การ์ด (panel) ---------- */
.panel {
  background: var(--surface); border-radius: var(--r); padding: 22px 24px; min-width: 0;
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); margin: 0;
}
.panel h2 { font-family: var(--f-display); font-weight: 600; font-size: 18px; margin: 0; }
.panel .sub { color: var(--muted); font-size: 13px; margin-top: -10px; }
.panel.narrow { max-width: 520px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.stack { display: flex; flex-direction: column; gap: 20px; }

.roles { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.roles div { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 2px 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--sunk); }
.roles .ic { grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.roles dt { font-weight: 600; }
.roles dd { margin: 0; color: var(--muted); font-size: 13.5px; }

/* แท็บ (หลังบ้าน) */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; background: var(--surface); padding: 6px; border-radius: 14px; box-shadow: var(--shadow); align-self: flex-start; }
.tabs a { border-radius: 10px; padding: 8px 16px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a:hover { color: var(--accent); }
.tabs a[aria-current="page"] { background: var(--accent); color: #fff; }

/* ---------- ปุ่ม ---------- */
.btn {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 12px; padding: 9px 16px; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 6px 14px rgba(11, 127, 193, .25); }
.btn.primary:hover { color: #fff; transform: translateY(-1px); }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hero .btn { background: #fff; color: var(--accent); border-color: #fff; }

/* ---------- ฟอร์ม ---------- */
select, input, textarea { background: var(--field-bg); border: 1px solid var(--field); border-radius: 12px; padding: 9px 12px; }
select:hover, input:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2369738a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:disabled { opacity: .6; cursor: not-allowed; }
input::placeholder { color: var(--muted); opacity: .75; }
/* ช่องติ๊ก: แบบเดียวทั้งระบบ (หัวตาราง/แถว/ฟอร์ม) — ห้ามตั้งขนาดเฉพาะหน้า */
input[type=checkbox] { width: 18px; height: 18px; min-width: 18px; max-width: 18px; min-height: 18px; flex: 0 0 18px; accent-color: var(--accent); padding: 0; vertical-align: middle; cursor: pointer; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form .f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form .f > label, .form .f > span { font-size: 13.5px; font-weight: 500; color: var(--ink); opacity: .82; }
.form .wide { grid-column: 1 / -1; }
.form.form-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form .span-2 { grid-column: span 2; }
.form .span-3 { grid-column: span 3; }
.form .span-4 { grid-column: 1 / -1; }
.rd-btn { margin-top: 6px; align-self: flex-start; }
.rd-msg { margin: 0; min-height: 1em; }
.form .pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
.form .checks { flex-direction: row; flex-wrap: wrap; gap: 8px 20px; align-items: center; align-self: end; padding-bottom: 8px; }
.form-section { border-top: 1px dashed var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.form-section h3 { font-family: var(--f-display); font-weight: 600; font-size: 16px; margin: 0; }
form.inline { display: inline; margin: 0; }
.copy-wrap { position: relative; }
.copy-wrap input { width: 100%; padding-right: 48px; }
.copy-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 36px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 10px; color: var(--muted); cursor: pointer;
}
.copy-btn:hover { color: var(--accent); background: var(--accent-soft); }
.copy-btn.done { color: var(--good); background: var(--good-soft); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); }
.extras { display: flex; flex-direction: column; gap: 10px; }
.extra-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: center; }
.extra-row.add { border-top: 1px dashed var(--line); padding-top: 14px; }
.extra-row .row-actions { display: flex; gap: 6px; align-items: center; }
.extra-row .row-actions select { padding-block: 5px; }
@media (max-width: 760px) { .extra-row { grid-template-columns: minmax(0, 1fr); } }
td.actions form.inline + form.inline { margin-left: 6px; }
td input:not([type=checkbox]):not([type=radio]) { width: 100%; min-width: 140px; }
.plain { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; }
/* การ์ดสรุป: ไอคอนวงกลม + ตัวเลข + คำอธิบาย */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { background: var(--surface); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); display: flex; gap: 16px; align-items: center; min-width: 0; }
.kpi .n { font-family: var(--f-display); font-weight: 600; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 14px; }
.kpi .s { color: var(--muted); font-size: 12.5px; opacity: .85; }
.ic { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; }
.ic svg.i { width: 24px; height: 24px; }
.ic.blue { background: var(--accent-soft); color: var(--accent); }
.ic.green { background: var(--good-soft); color: var(--good); }
.ic.violet { background: #f1eafe; color: #7c3aed; }
.ic.amber { background: #fff6e3; color: #f59e0b; }
.ic.red { background: var(--bad-soft); color: var(--bad); }
@media (prefers-color-scheme: dark) { .ic.violet { background: #2a2147; color: #a78bfa; } .ic.amber { background: #33290f; color: #fbbf24; } }
.pill.blue { background: var(--accent-soft); color: var(--accent); }
.btn.icon-btn { padding: 6px; width: 34px; height: 34px; }
.btn.icon-btn:disabled { opacity: .4; cursor: default; }
.btn svg.i { width: 18px; height: 18px; }
.btn.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.soft:hover { border-color: var(--accent); }
.task-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check.chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 10px; background: var(--surface); }
.check.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.bank-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: center; }
.bank-row .bk-wide { grid-column: span 2; }
.bank-row .row-actions { grid-row: span 2; align-self: start; }
.bank-row.add { border-top: 1px dashed var(--line); padding-top: 14px; }
.bank-row .row-actions { display: flex; gap: 6px; }
@media (max-width: 900px) { .bank-row { grid-template-columns: minmax(0, 1fr); } .bank-row .bk-wide { grid-column: auto; } .bank-row .row-actions { grid-row: auto; } }
/* ปุ่มสถานะในตาราง (กด = ลงวันที่) */
.step {
  cursor: pointer; border: 1px solid #c7d2e3; background: var(--surface); border-radius: 999px;
  padding: 5px 12px; min-width: 96px; font-size: 13px; color: #4a5470; text-decoration: none;
  display: inline-flex; justify-content: center; white-space: nowrap; font: inherit; font-size: 13px;
}
.step:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.step:disabled { cursor: default; }
.step.done { border-style: solid; border-color: transparent; background: var(--good-soft); color: var(--good); font-weight: 600; }
.step.doing { border-style: solid; border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.step.wait { border-style: solid; border-color: transparent; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.step.late { border-style: solid; border-color: var(--bad); color: var(--bad); background: var(--bad-soft); font-weight: 600; }
.step:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi .step { margin-top: 6px; }
.by { display: block; margin-top: 3px; padding-left: 4px; color: var(--muted); font-size: 12px; }
/* รายการงานในหน้ารายละเอียด */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 150px) minmax(0, 120px) minmax(0, 1fr) minmax(0, 170px); gap: 12px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--sunk); }
.task-row.is-done { background: var(--good-soft); }
.task-row.task-head { background: none; padding-block: 0; font-size: 12.5px; }
.w-num { max-width: 90px; }
@media (max-width: 760px) { .task-row { grid-template-columns: minmax(0, 1fr); } }
textarea { width: 100%; resize: vertical; }
.deadlines { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.deadlines svg.i { width: 16px; height: 16px; }
@media (prefers-color-scheme: dark) { .step { border-color: #3a4766; color: #c3cbe0; } }
.section-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: -8px; }
.section-title h2 { font-family: var(--f-display); font-size: 18px; margin: 0; }
.grid-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 860px) { .grid-2col { grid-template-columns: minmax(0, 1fr); } }
.due-list { display: flex; flex-direction: column; gap: 8px; }
.due-list > div { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.due-list .pill { min-width: 92px; text-align: center; }
/* ปิดงบการเงิน */
.annual-table th.c, .annual-table td.c { text-align: center; }
.annual-table th { white-space: normal; min-width: 92px; line-height: 1.3; }
.annual-table td.c .by { text-align: center; padding-left: 0; }
.due-late { color: var(--bad); }
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--bad-soft); color: var(--ink); text-decoration: none; }
.alert-row:hover { outline: 1px solid var(--bad); }
.block { display: block; margin-top: 4px; }
.fee-total td { background: var(--sunk); font-weight: 600; }
.fee-total td.legend { font-weight: 400; }
.task-row.annual-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr) minmax(0, 160px) minmax(0, 130px) minmax(0, 1fr); }
@media (max-width: 760px) { .task-row.annual-row { grid-template-columns: minmax(0, 1fr); } }
.rule-builder { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 12px; background: var(--sunk); }
.rule-builder .sentence { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-left: 26px; }
.rule-builder .sentence select { width: auto; min-width: 90px; }
.rule-builder[data-mode="rel"] .sentence.fixed, .rule-builder[data-mode="fixed"] .sentence.rel { opacity: .4; pointer-events: none; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
th.pick, td.pick { width: 1%; padding-right: 0; }
.annual-table td.cname { min-width: 170px; }
/* ตารางปิดงบ: บีบช่องให้เห็นครบทุกงานในจอเดียว (จอเล็กยังเลื่อนได้) */
.annual-table th, .annual-table td { padding: 10px 6px; }
.annual-table th:first-child, .annual-table td:first-child { padding-left: 16px; }
.annual-table th { min-width: 0; font-size: 12px; }
.annual-table .step { min-width: 0; padding: 4px 9px; font-size: 12.5px; }
.annual-table .by { font-size: 11.5px; }
.settings-table td { padding: 10px 10px; vertical-align: top; }
.settings-table td input { min-width: 0; }
.settings-table input[name=name] { width: 190px; }
.settings-table select { width: 175px; }
.settings-table .w-num { width: 64px; }
.settings-table .small-check { display: flex; white-space: nowrap; }
.mini-checks { display: grid; grid-template-columns: repeat(2, max-content); gap: 4px 12px; }
.check.mini { font-size: 13px; gap: 6px; }
.check.mini input { width: 16px; height: 16px; }
.small-check { font-size: 12.5px; margin-top: 6px; color: var(--muted); }
.align-end { align-self: end; padding-bottom: 10px; }
/* แถบค้นหา/กรอง ด้านบนตาราง */
.table-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 360px; }
.search svg.i { position: absolute; left: 12px; color: var(--muted); width: 18px; height: 18px; }
.search input { width: 100%; padding-left: 38px; background: var(--sunk); border-color: transparent; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar input:not([type=checkbox]) { min-width: 240px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.form .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.toolbar label { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

/* ช่องรหัสผ่าน + ปุ่มรูปตา */
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 48px; }
.eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 36px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 10px; color: var(--muted); cursor: pointer;
}
.eye:hover { color: var(--accent); background: var(--accent-soft); }
.eye:focus-visible { outline: 2px solid var(--accent); }
.eye .i-hide, .eye[aria-pressed="true"] .i-show { display: none; }
.eye[aria-pressed="true"] .i-hide { display: inline-flex; }

/* ข้อความแจ้ง */
.err { color: var(--bad); background: var(--bad-soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.ok { color: var(--good); background: var(--good-soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.issued { border: 1px solid var(--accent); }
.issued .pw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.issued .pw-row span { min-width: 96px; color: var(--muted); font-size: 14px; }
.issued code { font-family: var(--f-mono); font-size: 16px; background: var(--sunk); padding: 4px 12px; border-radius: 10px; }

.pill { display: inline-block; border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.muted { background: var(--sunk); color: var(--muted); }
.empty { color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; }

/* ---------- ตาราง ---------- */
.tablewrap { overflow-x: auto; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); position: relative; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 500; background: var(--sunk); white-space: nowrap; }
tbody tr:hover td { background: var(--sunk); }
tr:last-child td { border-bottom: 0; }
th.actions, td.actions { text-align: right; white-space: nowrap; width: 1%; }
.cname b { display: block; font-weight: 600; }
.cname small { color: var(--muted); }
tr.off td { opacity: .5; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input { width: 19px; height: 19px; }
.table-foot { display: flex; justify-content: flex-end; padding: 14px 16px; border-top: 1px solid var(--line); }

/* ---------- หน้าล็อกอิน ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); background: var(--bg); }
.login-art {
  background: linear-gradient(150deg, #1d4f9c 0%, #0b86c6 100%); color: #fff; padding: 48px 56px;
  display: flex; align-items: center; justify-content: center; min-width: 0; position: relative; overflow: hidden;
}
.login-art::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; right: -140px; top: -120px; background: rgba(255, 255, 255, .12); }
.login-art::before { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; left: -100px; bottom: -120px; background: rgba(255, 255, 255, .08); }
.login-art > * { position: relative; z-index: 1; }
.logo-card { background: #fff; border-radius: 28px; padding: 44px 52px; width: min(440px, 100%); box-shadow: 0 24px 60px rgba(8, 30, 70, .28); }
.logo-card img { display: block; width: 100%; height: auto; }
.login-card {
  background: var(--surface); padding: 48px clamp(20px, 6vw, 80px);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; min-width: 0;
}
.login-card h1 { font-family: var(--f-display); font-weight: 600; font-size: 30px; margin: 0; text-align: center; }
.login-card .sub { color: var(--muted); text-align: center; margin: -8px 0 10px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 400px; }
.login-card input[type=email], .login-card input[type=password], .login-card .pw-wrap input { padding: 13px 16px; font-size: 15px; background: var(--sunk); border-color: transparent; width: 100%; }
.login-card .row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.login-card .btn.primary { padding: 13px; font-size: 16px; margin-top: 6px; width: 100%; }
.login-card .copy { text-align: center; margin-top: 24px; }

.center-page { max-width: 520px; margin: 80px auto; padding: 0 16px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- จอเล็ก / มือถือ ---------- */
@media (max-width: 1000px) { .grid-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) { .kpis, .kpis.kpis-3, .kpis.kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form.form-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { padding: 28px 16px; }
  .logo-card { padding: 22px 28px; width: min(280px, 100%); border-radius: 20px; }
  .login-card { padding: 32px 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .nav h6 { display: none; }
  .nav a { white-space: nowrap; }
  .main { padding-inline: 16px; }
  .who { margin-left: 0; }
}
@media (max-width: 560px) {
  .form, .form.form-4 { grid-template-columns: minmax(0, 1fr); }
  .kpis, .kpis.kpis-3, .kpis.kpis-5 { grid-template-columns: minmax(0, 1fr); }
  .form .span-2, .form .span-3 { grid-column: auto; }
  .toolbar input:not([type=checkbox]) { min-width: 0; width: 100%; }
  .who { width: 100%; flex-wrap: wrap; }
  .who-actions { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .btn { transition: none; transform: none !important; } }

/* ---------- ใบสรุปรายการภาษี (A4) ---------- */
.sheet-tools { max-width: 820px; margin: 24px auto 12px; padding: 0 16px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.sheet {
  max-width: 820px; margin: 0 auto 48px; background: #fff; color: #18213a; border-radius: 16px; box-shadow: var(--shadow);
  padding: 44px 48px; display: flex; flex-direction: column; gap: 22px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 18px; border-bottom: 3px solid #0b7fc1; }
.sheet-logo { width: 170px; height: auto; }
.sheet-title { text-align: right; }
.sheet-title h1 { font-family: var(--f-display); font-size: 22px; margin: 0; font-weight: 600; color: #18213a; }
.sheet-period { display: inline-block; margin-top: 6px; background: linear-gradient(120deg, #0b7fc1, #2fb3e8); color: #fff; border-radius: 999px; padding: 4px 16px; font-weight: 600; font-size: 14px; }
.sheet-client { display: grid; grid-template-columns: 2fr 1.2fr 1fr; gap: 12px; background: #f4f7fc; border-radius: 12px; padding: 14px 18px; }
.sheet-client small { display: block; color: #69738a; font-size: 12px; }
.sheet-client b { font-size: 15px; }
.sheet-group h2 { font-family: var(--f-display); font-size: 16px; margin: 0 0 10px; padding-left: 10px; border-left: 4px solid #0b7fc1; }
.sheet-group.g1 h2 { border-left-color: #16a34a; }
.sheet-group.g2 h2 { border-left-color: #f59e0b; }
.sheet-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 14px; }
.sheet-table th { background: #eaf1ff; color: #2a3a5c; font-weight: 600; font-size: 13px; padding: 9px 10px; border: 0; text-align: left; }
.sheet-group.g1 .sheet-table th { background: #e8f7ee; }
.sheet-group.g2 .sheet-table th { background: #fff6e3; }
.sheet-table td { padding: 9px 10px; border-bottom: 1px solid #e5eaf3; }
.sheet-table tbody tr:hover td { background: none; }
.sheet-table .c { text-align: center; } .sheet-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-table .note { color: #69738a; font-size: 13px; }
.sheet-table tfoot td { border-bottom: 0; font-weight: 600; padding-top: 12px; }
.sheet-table tfoot td.r { border-bottom: 3px double #18213a; font-size: 15px; }
.sheet-due { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; color: #b42318; background: #fdecec; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.sheet-due svg.i { width: 18px; height: 18px; }
.sheet-fee { display: flex; justify-content: space-between; padding: 12px 18px; border: 1px dashed #e5eaf3; border-radius: 12px; }
.sheet-fee em { font-style: normal; color: #16a34a; font-size: 13px; margin-left: 6px; }
.sheet-total {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; border-radius: 12px;
  background: #eaf1ff; border: 1px solid #c9dcf6; color: #0b5f91;
}
.sheet-total span { font-weight: 600; font-size: 15px; }
.sheet-total b { font-family: var(--f-display); font-size: 20px; font-variant-numeric: tabular-nums; color: #0b5f91; }
.sheet-total small { font-size: 13px; font-weight: 500; }
.sheet-empty { color: #69738a; text-align: center; padding: 24px; border: 1px dashed #e5eaf3; border-radius: 12px; }
.sheet-foot { color: #69738a; font-size: 12.5px; text-align: center; border-top: 1px solid #e5eaf3; padding-top: 14px; }
@media (max-width: 700px) { .sheet { padding: 24px 18px; } .sheet-head { flex-direction: column; align-items: flex-start; } .sheet-title { text-align: left; } .sheet-client { grid-template-columns: 1fr; } .sheet-table { font-size: 13px; } }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .sheet { box-shadow: none; border-radius: 0; margin: 0; max-width: none; padding: 0; }
  .sheet-period, .sheet-total, .sheet-table th, .sheet-client, .sheet-due { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- เอกสารสำคัญของลูกค้า ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.doc-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--sunk); min-width: 0; }
.doc-thumb { display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); cursor: zoom-in; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-icon { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer; }
.doc-icon .i { width: 40px; height: 40px; }
.doc-name input { width: 100%; font-weight: 600; }
.doc-meta { font-size: 12px; color: var(--muted); }
.doc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dropzone .drop-area { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 2px dashed var(--line); border-radius: 14px; background: var(--sunk); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.dropzone .drop-area .i { width: 28px; height: 28px; color: var(--accent); }
.dropzone .drop-area input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .drop-area:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.over .drop-area, .dropzone .drop-area:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.dropzone.js .drop-submit { display: none; }
.dropzone .drop-msg:empty { display: none; }
.doc-trash summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.doc-trash table { margin-top: 8px; }
.doc-view { width: min(1100px, 94vw); max-height: 92vh; padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink); }
.doc-view::backdrop { background: rgba(10, 16, 30, .7); }
.doc-view-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.doc-view img { display: block; max-width: 100%; max-height: calc(92vh - 60px); margin: 0 auto; }

/* ---------- ภาพรวมสำนักงาน (แดชบอร์ด) ---------- */
.kpi .grow { flex: 1; min-width: 0; }
.kpi .n .of { font-size: 16px; color: var(--muted); font-weight: 500; }
.kpi .meter { margin-top: 8px; }
.meter { display: block; height: 8px; border-radius: 999px; background: var(--sunk); overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter.good > span { background: var(--good); }
.meter.bad > span { background: var(--bad); }
.prog-list { display: flex; flex-direction: column; gap: 12px; }
.prog-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 14px; align-items: center; }
.prog-row small { display: block; font-size: 12px; }
.alert-row.warn { background: var(--warn-soft); }
.alert-row.warn:hover { outline-color: var(--warn); }
.table-scroll { overflow-x: auto; }
.dash-table { min-width: 0; }
.dash-table th, .dash-table td { padding: 10px 12px; }
.dash-table td.w-meter { width: 30%; }
.fym-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.fym { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 12px; background: var(--sunk); color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.fym .m { font-size: 13px; color: var(--muted); }
.fym b { font-family: var(--f-display); font-size: 22px; line-height: 1.1; }
.fym small { font-size: 11.5px; color: var(--muted); text-align: center; }
.fym:hover { border-color: var(--accent); }
.fym.now { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fym.good { background: var(--good-soft); }
.fym.good small { color: var(--good); }
.fym.bad { background: var(--bad-soft); }
.fym.bad small { color: var(--bad); }
.fym.none { opacity: .45; pointer-events: none; }
.fee-boxes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fee-box { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 12px; background: var(--sunk); color: var(--ink); text-decoration: none; }
.fee-box:hover { outline: 1px solid var(--accent); }
.fee-box .l { font-size: 13px; color: var(--muted); }
.fee-box b { font-family: var(--f-display); font-size: 20px; font-variant-numeric: tabular-nums; }
.fee-box small { color: var(--muted); }
@media (max-width: 760px) {
  .fym-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .prog-row { grid-template-columns: minmax(0, 1fr) auto; }
  .prog-row .meter { grid-column: 1 / -1; grid-row: 2; }
  .fee-boxes { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- เช็กลิสต์ตรวจงานลงบัญชี ---------- */
.rv-list { display: flex; flex-direction: column; gap: 8px; }
.rv-grp { margin: 10px 0 0; font-family: var(--f-display); font-size: 15px; color: var(--accent); }
.rv-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 380px); gap: 12px; align-items: start; padding: 10px 14px; border-radius: 12px; background: var(--sunk); }
.rv-row.is-pass { background: var(--good-soft); }
.rv-row.is-na { opacity: .75; }
.rv-no { font-weight: 600; color: var(--muted); text-align: right; padding-top: 2px; }
.rv-text small { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; }
.rv-act { display: flex; flex-direction: column; gap: 6px; }
.rv-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.rv-opt { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; cursor: pointer; }
.rv-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rv-opt:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.rv-opt.pass:has(input:checked) { background: var(--good); border-color: var(--good); color: #fff; font-weight: 600; }
.rv-opt.na:has(input:checked) { background: var(--muted); border-color: var(--muted); color: #fff; font-weight: 600; }
.rv-opt.none:has(input:checked) { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.warn-box { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
a.pill { text-decoration: none; }
.w-grp { width: 140px; }
.rv-print td small { display: block; color: #555; font-size: 11px; }
.rv-print-grp td { background: #eef4fb; font-weight: 700; }
.rv-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 28px; }
.rv-sign > div { display: flex; flex-direction: column; gap: 6px; }
.rv-sign .line { border-bottom: 1px dotted #888; min-height: 28px; padding-top: 6px; font-weight: 600; }
@media (max-width: 900px) { .rv-row { grid-template-columns: 24px minmax(0, 1fr); } .rv-act { grid-column: 2; } }
@media print { .rv-print-grp td { -webkit-print-color-adjust: exact; print-color-adjust: exact; } .rv-print tr { break-inside: avoid; } }
.round-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.round-chip { display: flex; flex-direction: column; padding: 6px 12px; border-radius: 12px; text-decoration: none; color: var(--ink); background: var(--sunk); border: 1px solid transparent; line-height: 1.35; }
.round-chip small { font-size: 12px; color: var(--muted); }
.round-chip:hover { border-color: var(--accent); }
.round-chip.good { background: var(--good-soft); } .round-chip.good small { color: var(--good); }
.round-chip.bad { background: var(--bad-soft); } .round-chip.bad small { color: var(--bad); font-weight: 600; }
.round-chip.warn { background: var(--warn-soft); } .round-chip.warn small { color: var(--warn); font-weight: 600; }
.rv-text .rv-earlier { color: var(--warn); }
.client-tabs { align-self: stretch; align-items: center; }
.client-tabs a { display: inline-flex; align-items: center; gap: 6px; }
.client-tabs .tabs-note { margin-left: auto; padding-right: 8px; font-size: 13px; }
.tab-badge { font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 1px 8px; background: var(--sunk); color: var(--muted); }
.tab-badge.good { background: var(--good-soft); color: var(--good); }
.tab-badge.bad { background: var(--bad-soft); color: var(--bad); }
.tab-badge.blue { background: var(--accent-soft); color: var(--accent); }
.tabs a[aria-current="page"] .tab-badge { background: rgba(255, 255, 255, .25); color: #fff; }
a.warn-box { text-decoration: none; }
.doc-icon.sheet { color: var(--good); }
.sheet-view { overflow-x: auto; }
.sheet-view table { min-width: 0; font-size: 13px; }
.sheet-view td, .sheet-view th { padding: 6px 10px; white-space: nowrap; border-right: 1px solid var(--line); }
.sheet-view th.rn { position: sticky; left: 0; background: var(--sunk); color: var(--muted); font-weight: 500; text-align: right; width: 1%; }
.sheet-view tr.first td { font-weight: 600; background: var(--sunk); }

/* ---------- ส่งข้อความถึงลูกค้า ---------- */
.msg-tools label { display: inline-flex; align-items: center; gap: 8px; }
.msg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.msg-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; border: 2px solid transparent; }
.msg-card.is-sent { border-color: var(--good-soft); }
.msg-card:target { border-color: var(--accent); }
.msg-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.msg-head small { display: block; }
.msg-card textarea { width: 100%; font-size: 14px; line-height: 1.6; }
.msg-actions, .msg-pay { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.msg-pay { margin-top: 0; padding-top: 8px; border-top: 1px dashed var(--line); }
.msg-warn { font-size: 13px; color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 10px; }
.btn.done { background: var(--good); border-color: var(--good); color: #fff; }
.msg-body summary { cursor: pointer; }
.msg-body pre { white-space: pre-wrap; font: inherit; margin: 8px 0 0; }
@media (max-width: 520px) { .msg-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Post-it ---------- */
.note-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.postit { --nb: #fff6c2; --nl: #e9d77a; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 6px 6px 18px 6px; background: var(--nb); border-top: 6px solid var(--nl); box-shadow: 0 2px 8px rgba(16, 24, 40, .08); color: #2b2a26; min-width: 0; }
.postit-pink { --nb: #ffe1ea; --nl: #f4a3bb; }
.postit-blue { --nb: #dff0ff; --nl: #8cc4f2; }
.postit-green { --nb: #e0f6e6; --nl: #92d3a5; }
.postit-purple { --nb: #ece4ff; --nl: #b9a2f2; }
.postit.is-done { opacity: .55; }
.postit.is-done .note-text { text-decoration: line-through; }
.note-top { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 4px; }
.note-client { font-size: 12.5px; font-weight: 600; color: #2b4a8a; }
.note-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.note-meta { font-size: 12px; color: #6a675d; }
.note-actions { display: flex; gap: 6px; margin-top: auto; }
.note-form { display: flex; flex-direction: column; gap: 10px; }
.note-form textarea { width: 100%; }
.note-form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.note-form-row select, .note-form-row input[type=date] { width: auto; }
.note-colors { display: flex; gap: 6px; }
.note-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--nb); border: 2px solid var(--nl); cursor: pointer; position: relative; }
.note-dot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.note-dot:has(input:checked) { outline: 2px solid var(--accent); outline-offset: 2px; }
.note-dot:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.note-dot.postit-yellow { --nb: #fff6c2; --nl: #e9d77a; }

/* ---------- หน้าเลือกโปรแกรม (/) ---------- */
.hub-top { display: flex; align-items: center; gap: 16px; padding: 12px 28px; background: var(--surface); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 5; }
.hub-logo img { height: 46px; display: block; }
.hub { max-width: 1180px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.hub-hello { border-radius: var(--r); padding: 22px 26px; color: #fff; background: linear-gradient(120deg, #1d4f9c, #0b86c6 60%, #2fb3e8); }
.hub-hello h1 { margin: 0; font-family: var(--f-display); font-size: 24px; font-weight: 600; }
.hub-hello p { margin: 4px 0 0; opacity: .85; }
.hub-grp { font-family: var(--f-display); font-size: 15px; font-weight: 600; color: var(--muted); margin: 6px 0 -6px; }
.apps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.apps.lead { grid-template-columns: 1fr; }
.app-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink); border: 1px solid transparent; transition: transform .15s, border-color .15s; min-height: 190px; }
a.app-card:hover { transform: translateY(-2px); border-color: var(--accent); }
a.app-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-card > b { font-family: var(--f-display); font-weight: 600; font-size: 17px; }
.app-card .d { color: var(--muted); font-size: 13.5px; line-height: 1.5; flex: 1; }
.app-card .foot { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.app-card .foot small { color: var(--muted); font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.app-card.lead { flex-direction: row; align-items: center; min-height: 0; gap: 18px; padding: 20px 26px; }
.app-card.lead .body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.app-card.lead .body b { font-family: var(--f-display); font-weight: 600; font-size: 18px; }
.app-card.lead .body span { color: var(--muted); font-size: 14px; }
.app-card .go { font-weight: 600; color: var(--accent); white-space: nowrap; }
.app-card.soon { opacity: .7; cursor: default; }
.tb-right { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.tb-right .to-hub { text-decoration: none; white-space: nowrap; }
@media (max-width: 900px) { .apps { grid-template-columns: 1fr; } .hub-top { padding: 10px 16px; flex-wrap: wrap; } .hub { padding: 20px 16px 40px; } }
.matrix .cname { white-space: nowrap; }
.extras-block { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; border-top: 1px dashed var(--line); }
.extras-block h3 { margin: 6px 0 0; font-size: 15px; }
.extra-row .extra-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.extra-row .extra-pick select { width: auto; min-width: 0; padding-block: 6px; }
.extra-row.new { background: var(--accent-soft); }
.inline-del { display: inline-flex; gap: 4px; color: var(--bad); }

/* หลังบ้าน: ปุ่มต่อสัญญา / เพิ่มผู้ใช้ แบบกางฟอร์มในแถว */
/* ปุ่มเรียงแถวเดียว · กดแล้วฟอร์มลอยเป็นการ์ดใต้ปุ่ม (ไม่ดันตารางให้เบียด) */
.cfm-row { display: flex; flex-wrap: nowrap; gap: 8px; justify-content: flex-end; align-items: center; }
.tablewrap.pop-ok { overflow: visible; }
@media (max-width: 900px) {
  .cfm-row { flex-wrap: wrap; justify-content: flex-start; }
  .tablewrap.pop-ok { overflow-x: auto; }
  details.cfm[open] > form { position: static; width: 260px; margin-top: 8px; }
}
details.cfm, form.cfm { position: relative; display: inline-block; margin: 0; text-align: left; }
details.cfm > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.cfm > summary::-webkit-details-marker { display: none; }
details.cfm[open] > summary { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
details.cfm[open] > form {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 300px;
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
details.cfm[open] > form input, details.cfm[open] > form .dp { width: 100%; }
details.cfm[open] > form .btn { align-self: flex-end; }

/* หลังบ้าน: รายชื่อผู้ใช้ลูกค้าในแต่ละสัญญา */
.cu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cu-list li { display: flex; align-items: center; gap: 10px; }
.cu-list li + li { padding-top: 10px; border-top: 1px dashed var(--line); }
.cu-list li.off .cu-who, .cu-list li.off .avatar { opacity: .55; }
.cu-act { margin-left: auto; }
.cu-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.cu-who a { font-weight: 600; text-decoration: none; color: var(--ink); }
.cu-who a:hover { color: var(--accent); }
.cu-who small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }

/* ---------- ปฏิทินเลือกวันที่ (public/datepicker.js) ---------- */
.dp { position: relative; display: block; min-width: 0; }
.note-form-row .dp, .cfm-row .dp { display: inline-block; }
.dp-field {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: var(--field-bg); border: 1px solid var(--field); border-radius: 12px; padding: 9px 12px; min-height: 42px;
  transition: border-color .12s, box-shadow .12s;
}
.dp-field svg.i { width: 18px; height: 18px; color: var(--accent); }
.dp-field:hover { border-color: var(--accent); }
.dp-field:focus-visible, .dp-field[aria-expanded="true"] { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.dp-field.empty .dp-text { color: var(--muted); }
.dp-invalid .dp-field { border-color: var(--bad); outline: 3px solid var(--bad-soft); }
.dp-invalid::after { content: 'กรุณาเลือกวันที่'; display: block; color: var(--bad); font-size: 12px; margin-top: 4px; }
.dp-pop {
  position: absolute; z-index: 1000; width: 304px; padding: 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 48px rgba(16, 24, 40, .18);
  font-family: var(--f-body); animation: dp-in .14s ease-out;
}
@keyframes dp-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dp-pop.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
.dp-pop button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 10px; }
.dp-pop button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dp-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.dp-title { flex: 1; font-family: var(--f-display); font-weight: 600; font-size: 15px; padding: 8px; }
.dp-title:hover { background: var(--accent-soft); color: var(--accent); }
.dp-nav { width: 36px; height: 36px; font-size: 20px; line-height: 1; color: var(--muted); }
.dp-nav:hover { background: var(--accent-soft); color: var(--accent); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0 6px; }
.dp-grid button { aspect-ratio: 1; display: grid; place-items: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.dp-grid .we, .dp-dow.we { color: var(--bad); }
.dp-grid button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.dp-grid button.now { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 600; }
.dp-grid button.on, .dp-months button.on { background: var(--accent); color: #fff; font-weight: 600; box-shadow: none; }
.dp-grid button:disabled { opacity: .3; cursor: not-allowed; }
.dp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-months button { padding: 12px 0; font-weight: 500; }
.dp-months button:hover:not(.on) { background: var(--accent-soft); color: var(--accent); }
.dp-months button.now:not(.on) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dp-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.dp-pop .dp-quick button { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.dp-pop .dp-quick button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.dp-foot { display: flex; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.dp-foot button { padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--accent); }
.dp-foot button:hover { background: var(--accent-soft); }
.dp-foot .dp-x { margin-left: auto; color: var(--muted); }

/* ---------- ยื่นและชำระภาษี (src/views/taxboard.ts) ---------- */
.form .f > .checks { display: flex; padding-bottom: 0; }
.tb-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.tb-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.tb-card h3 { margin: 0 0 8px; font: 600 15px var(--f-display); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tb-bar { height: 8px; border-radius: 99px; background: var(--sunk); display: flex; overflow: hidden; margin: 6px 0 8px; }
.tb-bar i { display: block; height: 100%; }
.tb-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.tb-legend.col { flex-direction: column; gap: 6px; font-size: 13px; }
.tb-legend b { color: var(--ink); }
.tb-legend .bad, .tb-legend .bad b { color: var(--bad); }
.tb-table td { vertical-align: middle; }
.tb-table th.pick, .tb-table td.pick { width: 40px; text-align: center; }
.st { border: 0; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
details.stm { position: relative; display: inline-block; }
details.stm > summary { list-style: none; cursor: pointer; }
details.stm > summary::-webkit-details-marker { display: none; }
details.stm > summary::after { content: '▾'; font-size: 10px; opacity: .7; }
details.stm > summary:focus-visible, a.st:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stm-menu { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 240px; display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px rgba(16, 24, 40, .16); }
.stm-menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 6px 8px; border-radius: 8px; cursor: pointer; text-align: left; }
.stm-menu button:hover, .stm-menu button:focus-visible { background: var(--sunk); }
.stm-menu small { margin-left: auto; color: var(--muted); font-size: 12px; }
.stm-link { font-size: 13px; padding: 6px 8px; border-top: 1px solid var(--line); margin-top: 2px; }
.s-na { background: #2f343d; color: #fff; }
.s-todo { background: var(--sunk); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.s-filed { background: var(--accent-soft); color: var(--accent); }
.s-told { background: var(--warn-soft); color: var(--warn); }
.s-zero { background: #ffe7d6; color: #9a4b0b; }
.s-paid { background: var(--good-soft); color: var(--good); }
.s-late { background: var(--bad-soft); color: var(--bad); }
.s-auto { background: #e0f2f1; color: #0f766e; }
.s-year { background: #efe9fd; color: #6d28d9; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; margin: 1px 2px 1px 0; white-space: nowrap; }
.chip.c0 { background: #efe9fd; color: #5b21b6; } .chip.c1 { background: #fde2e1; color: #9b1c1c; } .chip.c2 { background: #fde8d4; color: #9a4b0b; }
.chip.c3 { background: #fdf1c7; color: #8a6100; } .chip.c4 { background: #dcf5e3; color: #13693a; } .chip.c5 { background: #e6f6f4; color: #0f766e; }
.chip.c6 { background: #e1eef6; color: #1f5b84; } .chip.c7 { background: #e3edfd; color: #1d4ed8; }
.chip.pp { background: var(--accent-soft); color: var(--accent); }
select.doc { width: auto; min-width: 0; border: 0; border-radius: 8px; padding: 4px 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.doc.d-none { background: var(--sunk); color: var(--muted); }
.doc.d-no { background: #f1eafe; color: #6d28d9; } .doc.d-wait { background: var(--sunk); color: var(--muted); }
.doc.d-make { background: var(--good-soft); color: var(--good); } .doc.d-ok { background: var(--accent-soft); color: var(--accent); }
.tb-note { min-width: 140px; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 4px 8px; font-size: 13px; color: var(--muted); }
.tb-note:hover, .tb-note:focus { border-color: var(--field); background: var(--field-bg); }
.tb-note.has { color: var(--bad); font-weight: 600; }
.line-st { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.line-st.has { color: #059669; font-weight: 600; }
.btn.line-btn { background: #06c755; border-color: #06c755; color: #fff; }
.btn.line-btn:disabled { opacity: .5; cursor: default; }
@media (prefers-color-scheme: dark) {
  .s-na { background: #e7ebf5; color: #171d2e; }
  .s-zero { background: #3a2614; color: #fdba74; } .s-auto { background: #10302d; color: #5eead4; } .s-year, .doc.d-no { background: #2a1f45; color: #c4b5fd; }
  .chip.c0 { background: #2a1f45; color: #c4b5fd; } .chip.c1 { background: #3a1b1d; color: #fca5a5; } .chip.c2 { background: #3a2614; color: #fdba74; }
  .chip.c3 { background: #352a12; color: #fcd34d; } .chip.c4 { background: #15301f; color: #86efac; } .chip.c5 { background: #10302d; color: #5eead4; }
  .chip.c6 { background: #13283a; color: #93c5fd; } .chip.c7 { background: #1d2a4d; color: #93c5fd; }
  .line-st.has { color: #4ade80; }
}
.tb-table .cname { min-width: 170px; }
.tb-table td .err { margin-top: 4px; padding: 4px 8px; font-size: 12px; border-radius: 8px; }

/* ---------- หนังสือยืนยันยอดธนาคาร (หน้าปิดงบ) ---------- */
.annual-table td.bc-cell { white-space: nowrap; }
.bc-sum { display: block; width: max-content; margin: 4px auto 0; font-size: 11.5px; padding: 2px 8px; text-decoration: none; }
.bk-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.bk-pick select, .bk-pick input { flex: 1 1 120px; min-width: 0; }
.bk-pick .pill { font-size: 11.5px; padding: 2px 8px; }

/* เปลี่ยนหน้า: สลับทันทีแบบคมชัด ไม่กระพริบขาว · ไม่ใช้เอฟเฟกต์ค่อยๆ เลือน (หน้าเก่า-ใหม่ซ้อนกันแล้วดูเบลอ ลายตา) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
