:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --border: #e1e4dd;
  --text: #1d231f;
  --muted: #66706a;
  --accent: #1f7a5a;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --info-soft: #e8eff8;
  --info: #24507f;
  --deduct: #a4462b;
  --chart-gross: #b8c4bc;
  --chart-pending: #efd78a;
  --chart-pending-net: #e0ad1f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .04);
}

/* ธีมมืด: ตามระบบ (prefers-color-scheme) เว้นแต่ผู้ใช้เลือกเองด้วยปุ่มธีม (data-theme บน <html>) */
:root { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111513;
    --surface: #181d1a;
    --surface-2: #1f2521;
    --border: #2c342f;
    --text: #e6ebe7;
    --muted: #97a39b;
    --accent: #4cb98c;
    --accent-ink: #0c1310;
    --accent-soft: #1b3027;
    --danger: #f08b80;
    --danger-soft: #3a1f1c;
    --warn: #e8c06a;
    --warn-soft: #362c16;
    --info-soft: #1c2735;
    --info: #9cc0ea;
    --deduct: #e79a7f;
    --chart-gross: #4a574f;
    --chart-pending: #7d6c38;
    --chart-pending-net: #d9a92a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111513;
  --surface: #181d1a;
  --surface-2: #1f2521;
  --border: #2c342f;
  --text: #e6ebe7;
  --muted: #97a39b;
  --accent: #4cb98c;
  --accent-ink: #0c1310;
  --accent-soft: #1b3027;
  --danger: #f08b80;
  --danger-soft: #3a1f1c;
  --warn: #e8c06a;
  --warn-soft: #362c16;
  --info-soft: #1c2735;
  --info: #9cc0ea;
  --deduct: #e79a7f;
  --chart-gross: #4a574f;
  --chart-pending: #7d6c38;
  --chart-pending-net: #d9a92a;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Thai", "Sarabun", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.deduct { color: var(--deduct); }
.net { color: var(--accent); font-weight: 600; }

/* ---------- layout ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; min-height: 58px;
}
.brand { font-weight: 700; font-size: 1.2rem; letter-spacing: -.2px; color: var(--text); display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand-mark { flex-shrink: 0; display: block; width: 30px; height: 30px; border-radius: 8px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  color: var(--muted); padding: 8px 12px; border-radius: 8px; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.userbox form { margin: 0; }

.container { max-width: 1160px; margin: 0 auto; padding: 24px 16px 12px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.grid { display: grid; gap: 16px; margin-bottom: 20px; }
.grid > .card { margin-bottom: 0; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .nav { order: 3; width: 100%; flex: none; }
  .userbox { margin-left: auto; }
  .userbox .who { display: none; }
}

.stat { padding: 16px 18px; margin: 0; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.45rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
/* จอเล็ก (กล่องสรุป 2 คอลัมน์): ย่อตัวเลขตามความกว้างจอ ยอดหลักล้านไม่ล้นกล่อง */
@media (max-width: 600px) {
  .stat { padding: 14px 12px; min-width: 0; }
  .stat .value { font-size: clamp(.95rem, 4.3vw, 1.45rem); overflow-wrap: anywhere; }
}
.stat .sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
.type-chip {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; margin-bottom: 4px; font-size: .9rem; }
.field { margin-bottom: 16px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 700px) { .row { grid-template-columns: 1fr; } }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 130px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-link { background: none; border: none; color: var(--muted); padding: 6px 8px; cursor: pointer; font: inherit; }
.btn-link:hover { color: var(--text); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pct-group { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.deduct-box { border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface-2); margin-bottom: 16px; }
.deduct-box h3 { margin: 0 0 12px; font-size: .95rem; }
.net-preview {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  border-radius: var(--radius); background: var(--accent-soft); margin-bottom: 16px;
}
.net-preview .value { font-size: 1.4rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.segmented { display: inline-flex; max-width: 100%; border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; background: var(--surface); }
.segmented a { padding: 8px 14px; color: var(--muted); border-right: 1px solid var(--border); white-space: nowrap; }
.segmented a:last-child { border-right: none; }
.segmented a.active { background: var(--accent); color: var(--accent-ink); }
.segmented a:hover { text-decoration: none; }
/* จอเล็ก: แถบตัวเลือกเต็มความกว้าง แบ่งช่องเท่า ๆ กัน ไม่ต้องปัดดู (ยังเลื่อนได้ถ้ายาวเกินจริง ๆ) */
@media (max-width: 600px) {
  .segmented { display: flex; width: 100%; }
  .segmented a { flex: 1 1 auto; text-align: center; padding: 8px 6px; font-size: .88rem; }
}

/* ---------- flash ---------- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 12px; }
.flash-success { background: var(--accent-soft); color: var(--accent); }
.flash-danger { background: var(--danger-soft); color: var(--danger); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }
.flash-info { background: var(--info-soft); color: var(--info); }

/* ---------- auth ---------- */
.auth-wrap { max-width: 420px; margin: 48px auto 12px; padding: 0 16px; }
.auth-wrap .brand { justify-content: center; font-size: 1.35rem; margin-bottom: 20px; }
a.brand:hover { text-decoration: none; }
.landing-flash { padding-top: 16px; }
.landing-flash .flash:last-child { margin-bottom: 0; }

.badge { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.badge-admin { background: var(--info-soft); color: var(--info); }
.badge-off { background: var(--danger-soft); color: var(--danger); }
.badge-on { background: var(--accent-soft); color: var(--accent); }

dialog.modal {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: min(360px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0,0,0,.25);
  text-align: left; white-space: normal;
}
dialog.modal::backdrop { background: rgba(0, 0, 0, .35); }
dialog.modal h3 { margin: 0 0 8px; font-size: 1.05rem; }
dialog.modal p { margin: 0 0 12px; }
.modal-actions { margin-top: 14px; }
.chart-box { position: relative; height: 280px; }

@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ---------- multiple other deductions ---------- */
.others-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.other-row {
  display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
@media (max-width: 700px) {
  .other-row { grid-template-columns: minmax(0, 1fr) auto; }
  .other-row > div { grid-column: 1 / -1; }
}

/* ---------- multiple income lines ---------- */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 4px 0 8px; }
.section-head h3, .others-head h3 { margin: 0; font-size: .95rem; }
.line-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px 12px; align-items: start;
  padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; background: var(--surface);
}
.line-row .line-type { grid-column: 1 / 3; }
.line-row .remove-line { grid-column: 3; grid-row: 1; }
.line-row label.small { margin-bottom: 2px; color: var(--muted); font-weight: 500; }
.line-row .type-desc:empty { display: none; }
@media (max-width: 700px) {
  .line-row { grid-template-columns: minmax(0, 1fr) auto; }
  .line-row .line-type { grid-column: 1; }
  .line-row .remove-line { grid-column: 2; }
  .line-row > div:not(.line-type) { grid-column: 1 / -1; }
}
.net-summary { display: grid; gap: 4px; margin: 0 4px 8px; font-size: .9rem; }
.net-summary > div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.type-list { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }

/* ---------- 2FA ---------- */
.otp-input { font-size: 1.3rem; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.setup-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 22px; }
.setup-steps li { counter-increment: step; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; align-items: start; }
.setup-steps li::before { content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.setup-steps li > div { padding-top: 4px; min-width: 0; }
.qr-box { background: #fff; padding: 8px; border-radius: 10px; width: 216px; max-width: 100%; margin: 10px 0; }
.qr-box svg { display: block; width: 100%; height: auto; aspect-ratio: 1; }
code.secret { font-size: 1rem; letter-spacing: .08em; word-break: break-all; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.recovery-codes { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.recovery-codes code { display: block; text-align: center; font-size: 1.05rem; letter-spacing: .06em; padding: 8px; background: var(--surface-2); border-radius: 8px; }

/* iOS Safari: ช่องวันที่ไม่ยอมหดตาม width จึงล้นขอบ — ปิด appearance แบบ native แล้วกำหนดขนาดเอง */
input[type=date] {
  -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; max-width: 100%; min-height: 44px; text-align: left;
}
input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
tfoot tr.muted td { color: var(--muted); border-top: none; }

/* ---------- reminders ---------- */
.reminder-box { border: 1px solid var(--warn); background: var(--warn-soft); color: var(--text); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.reminder-box > strong { color: var(--warn); }
.reminder-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; margin-top: 8px; border-top: 1px dashed var(--border); }
.reminder-item form { margin: 0; }
.turnstile { min-height: 65px; }

/* ---------- legal pages & footer ---------- */
.site-footer { text-align: center; font-size: .82rem; color: var(--muted); padding: 8px 16px 32px; }
.site-footer a { color: var(--muted); }
.legal { max-width: 760px; margin: 0 auto; line-height: 1.75; }
.legal h1 { margin-bottom: 4px; }
.legal h2 { font-size: 1.05rem; margin: 28px 0 8px; }
.legal ul, .legal ol { padding-left: 1.3em; margin: 6px 0; }
.legal li { margin: 3px 0; }
.legal table { margin: 8px 0; font-size: .92rem; }
.legal .missing { color: var(--warn); font-style: italic; }
.auth-wrap.wide { max-width: 820px; }
.lang-switch { display: inline-flex; gap: 6px; align-items: center; vertical-align: middle; }
.lang-flag { display: inline-flex; padding: 2px; border-radius: 4px; border: 1px solid transparent; opacity: .45; line-height: 0; transition: opacity .15s; }
.lang-flag svg { display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.lang-flag:hover, .lang-flag:focus-visible { opacity: 1; }
.lang-flag.active { opacity: 1; border-color: var(--border); background: var(--surface-2); }
.site-footer .lang-switch { margin-right: 2px; }
.pending-card { border-left: 3px solid var(--warn); }
.auth-lang { display: flex; justify-content: flex-end; margin: -24px 0 12px; }

/* ---------- landing page ---------- */
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.landing { max-width: 1160px; margin: 0 auto; padding: 0 16px 8px; }
.landing-nav { justify-content: center; }
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; align-items: center; padding: 64px 0 56px; }
.hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.45rem); line-height: 1.3; margin: 12px 0 16px; font-weight: 700; }
.hero .lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 28px; max-width: 34em; }
.eyebrow { display: inline-block; font-size: .82rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; }
.hero-preview { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 50px rgba(20, 30, 25, .12); overflow: hidden; }
.preview-bar { display: flex; gap: 6px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.preview-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.preview-body { padding: 18px; }
.preview-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.preview-stats > div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.preview-stats small { display: block; color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-stats strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.preview-stats .accent { color: var(--accent); }
.preview-stats .deduct { color: var(--deduct); }
.preview-chart { display: flex; align-items: flex-end; gap: 6px; height: 110px; margin: 18px 0 14px; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
.preview-chart .bar { flex: 1; height: 100%; display: flex; align-items: flex-end; gap: 2px; }
.preview-chart .stack { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.preview-chart .stack > * { display: block; flex: none; text-decoration: none; }
.preview-chart .stack > * { border-radius: 3px 3px 0 0; }
.preview-chart i { background: var(--chart-gross); }
.preview-chart b { background: var(--accent); }
.preview-chart u { background: var(--chart-pending); }
.preview-chart s { background: var(--chart-pending-net); }
.preview-rows > div { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: .88rem; border-bottom: 1px dashed var(--border); }
.preview-rows > div:last-child { border-bottom: none; }
.preview-rows span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-rows em { font-style: normal; font-variant-numeric: tabular-nums; font-weight: 600; }
.preview-rows .chip { font-size: .72rem; font-weight: 600; color: var(--info); background: var(--info-soft); padding: 1px 8px; border-radius: 999px; }
.preview-note { margin: 10px 0 0; font-size: .72rem; color: var(--muted); text-align: right; }
.landing-section { padding: 40px 0; scroll-margin-top: 70px; }
.section-title { font-size: 1.4rem; font-weight: 700; margin: 0 0 24px; text-align: center; }
/* ฟีเจอร์แบบสไลด์ (carousel): 3 ใบต่อหน้า → 2 ใบ (แท็บเล็ต) → 1 ใบ + เห็นใบถัดไปนิดหนึ่ง (มือถือ) */
.carousel { position: relative; }
.carousel-track { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 32px) / 3); gap: 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; padding: 4px 2px 14px; scrollbar-width: none; }
.carousel-track.two-rows { grid-template-rows: repeat(2, auto); }  /* หน้าแรก: ความสามารถ 2 แถว × 3 = 6 ใบต่อหน้า */
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }
.carousel-item { scroll-snap-align: start; }
.carousel-nav { display: none; align-items: center; justify-content: center; gap: 14px; margin-top: 8px; }
.carousel.ready .carousel-nav { display: flex; }
.carousel.single .carousel-nav { display: none; }
.carousel-item > .article-card { height: 100%; }
.carousel-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.carousel-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.carousel-btn:disabled { opacity: .35; cursor: default; }
.carousel-dots { display: flex; gap: 8px; }
.carousel-dot { width: 9px; height: 9px; padding: 0; border-radius: 999px; border: none; background: var(--border); cursor: pointer; transition: width .2s, background .2s; }
.carousel-dot.active { width: 26px; background: var(--accent); }
@media (max-width: 900px) { .carousel-track { grid-auto-columns: calc((100% - 16px) / 2); } }
@media (max-width: 600px) { .carousel-track { grid-auto-columns: 85%; } }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.feature h3 { font-size: 1rem; margin: 12px 0 6px; }
.feature p { margin: 0; color: var(--muted); font-size: .92rem; }
.feature-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.steps { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0; margin: 0; }
.steps li { counter-increment: step; display: flex; flex-direction: column; gap: 4px; padding: 22px; border-radius: var(--radius); border: 1px dashed var(--border); }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; margin-bottom: 8px; }
.steps span { color: var(--muted); font-size: .92rem; }
.security-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 32px; align-items: center; padding: 32px; margin: 0; }
.security-card .section-title { text-align: left; margin-bottom: 8px; }
.security-card p { margin: 0; }
.security-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.security-list li { display: flex; gap: 12px; align-items: flex-start; }
.security-list svg { flex-shrink: 0; color: var(--accent); margin-top: 1px; }
.landing-cta { text-align: center; padding: 48px 0 0; }
.landing-cta h2 { font-size: 1.4rem; margin-bottom: 20px; }
.landing-cta .btn-group { justify-content: center; margin-bottom: 16px; }
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding: 40px 0; }
  .steps { grid-template-columns: 1fr; }
  .security-card { grid-template-columns: 1fr; gap: 20px; }
  /* จอแคบ: เมนูของหน้าสาธารณะลงไปเป็นแถวเลื่อนได้ใต้โลโก้ */
  .topbar-inner:has(.landing-nav) { flex-wrap: wrap; gap: 4px 8px; padding-top: 8px; padding-bottom: 6px; }
  .landing-nav { order: 3; width: 100%; flex: none; justify-content: flex-start; margin: 0 -8px; }
  .landing-nav a { padding: 6px 10px; font-size: .92rem; }
  .topbar-inner:has(.landing-nav) .userbox { margin-left: auto; }
}
@media (max-width: 600px) {
  .preview-stats strong { font-size: .9rem; }
  .security-card { padding: 22px; }
}
@media (prefers-reduced-motion: no-preference) {
  html:has(main.landing) { scroll-behavior: smooth; }
}

/* ---------- theme toggle ---------- */
.theme-toggle { display: inline-grid; place-items: center; width: 30px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; vertical-align: middle; }
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
.auth-lang { gap: 8px; align-items: center; }

/* ---------- tax calculator ---------- */
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.calc-form .card h2 { margin-bottom: 14px; }
.calc-form .section-head h2 { margin: 0; }
.calc-field { margin-bottom: 14px; }
.calc-field:last-child { margin-bottom: 0; }
.calc-input { display: flex; align-items: center; gap: 8px; }
.calc-input input { flex: 1; min-width: 0; }
.calc-used { color: var(--warn); }
.calc-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.calc-actions .btn { flex: 1; padding: 12px; }
.calc-table td, .calc-table th { padding: 7px 4px; }
.calc-table tr.sub td:first-child { padding-left: 18px; color: var(--muted); }
.calc-table tr.sub td.num { color: var(--deduct); }
.calc-table tr.subtotal td { font-weight: 600; }
.calc-table tr.total td { font-weight: 700; background: var(--surface-2); }
.calc-table tr.grand td { font-weight: 700; font-size: 1.1rem; color: var(--accent); border-bottom: 2px solid var(--accent); }
.calc-subhead { font-size: .95rem; margin: 22px 0 4px; }
.calc-balance { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); font-weight: 600; }
.calc-balance strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.calc-balance.pay { background: var(--danger-soft); color: var(--danger); }
.calc-balance.refund { background: var(--accent-soft); color: var(--accent); }
/* minmax(0, …) ให้คอลัมน์หดตามจอได้ — 1fr เฉย ๆ จะกว้างเท่าเนื้อหาข้างใน (ตารางลองเพิ่มค่าลดหย่อน) จนล้นจอมือถือ */
@media (max-width: 900px) {
  .calc-layout { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .calc-layout { grid-template-columns: minmax(0, 1fr); }
}

/* landing: tax calculator showcase */
.calc-showcase { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 32px; margin: 0; }
.calc-showcase .section-title { text-align: left; margin: 12px 0 16px; }
.calc-mock { background: var(--surface-2); border-radius: var(--radius); padding: 16px 18px; font-size: .9rem; }
.calc-mock > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.calc-mock em { font-style: normal; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-mock .sub span { color: var(--muted); padding-left: 12px; }
.calc-mock .sub em { color: var(--deduct); }
.calc-mock .strong { font-weight: 700; color: var(--accent); border-bottom: 2px solid var(--accent); }
.calc-mock .refund { margin-top: 10px; padding: 10px 12px; border: none; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
@media (max-width: 900px) { .calc-showcase { grid-template-columns: 1fr; gap: 20px; padding: 22px; } }

/* full tax calculator */
.calc-group-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 12px; }
.calc-group-head h2 { margin: 0; }
.calc-section { padding: 0; }
.calc-section > summary { cursor: pointer; list-style: none; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.calc-section > summary::-webkit-details-marker { display: none; }
.calc-section > summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.calc-section:not([open]) > summary::after { transform: rotate(-90deg); }
.calc-section > summary h2 { margin: 0; font-size: 1rem; }
.calc-section[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.calc-section > .calc-field { padding: 0 20px; }
.calc-section > .calc-field:last-child { padding-bottom: 18px; }
.calc-count input { max-width: 110px; flex: none; }
.calc-expense { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.calc-expense select { width: auto; flex: none; }
.calc-expense .calc-rate, .calc-expense .calc-actual { display: inline-flex; align-items: center; gap: 6px; }
.calc-expense .calc-rate input { width: 70px; }
.calc-expense .calc-actual input { width: 160px; }
.calc-expense [hidden] { display: none; }

/* ---------- plans & billing ---------- */
.badge-group-admin { background: var(--info-soft); color: var(--info); }
.badge-group-subscribed { background: var(--accent-soft); color: var(--accent); }
.badge-group-trial { background: var(--warn-soft); color: var(--warn); }
.badge-group-free { background: var(--surface-2); color: var(--muted); }
.plan-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
[data-for-group][hidden] { display: none; }
.plan-chip { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.plan-chip:hover { text-decoration: none; filter: brightness(.97); }
.nav a .lock { font-size: .75em; opacity: .7; margin-left: 2px; }
.pricing { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.price-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.price-card.featured { border: 2px solid var(--accent); }
.price-card h3 { margin: 0; font-size: 1.05rem; }
.price-card .price { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.price-card .price small { font-size: .95rem; font-weight: 500; color: var(--muted); }
.price-card ul { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: .92rem; flex: 1; }
.price-card li { margin: 3px 0; }
.price-card form { margin: 0; }
.price-card .btn { width: 100%; }
.save-tag { display: inline-block; font-size: .75rem; font-weight: 600; background: var(--warn-soft); color: var(--warn); padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
@media (max-width: 800px) { .pricing { grid-template-columns: 1fr; } }
.plan-table th { width: 34%; font-size: .88rem; color: var(--muted); font-weight: 500; white-space: normal; }
.plan-table td, .plan-table th { padding: 10px 4px; }
.plan-table tr:last-child td, .plan-table tr:last-child th { border-bottom: none; }
.preview-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 20px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.preview-banner .small { color: var(--text); opacity: .8; margin-top: 2px; }
.calc-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.calc-fieldset[disabled] input, .calc-fieldset[disabled] select { opacity: .75; cursor: not-allowed; }
.locked-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 150px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); }
.locked-box .lock-icon { font-size: 2rem; line-height: 1; }
.btn:disabled, fieldset:disabled .btn { opacity: .5; cursor: not-allowed; filter: grayscale(.4); }
.btn:disabled:hover, fieldset:disabled .btn:hover { background: inherit; filter: grayscale(.4); }
.btn-primary:disabled:hover, fieldset:disabled .btn-primary:hover { background: var(--accent); }

/* ---------- support / tickets ---------- */
.ticket-open { background: var(--warn-soft); color: var(--warn); }
.ticket-pending { background: var(--info-soft); color: var(--info); }
.ticket-resolved { background: var(--accent-soft); color: var(--accent); }
.ticket-table tr.unread td:first-child a { font-weight: 700; }
.seg-radio { display: inline-flex; margin: 0; cursor: pointer; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { padding: 8px 14px; color: var(--muted); border-right: 1px solid var(--border); }
.seg-radio:last-child span { border-right: none; }
.seg-radio input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.chat { display: flex; flex-direction: column; gap: 14px; }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { max-width: min(640px, 85%); padding: 10px 14px; border-radius: 16px; background: var(--surface-2); }
.bubble-row.mine .bubble { background: var(--accent-soft); border-bottom-right-radius: 4px; }
.bubble-row.theirs .bubble { border-bottom-left-radius: 4px; }
.bubble-meta { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.bubble-body { white-space: pre-wrap; word-break: break-word; }
.chat-reply textarea { width: 100%; resize: vertical; }
.chat-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.chat-actions select { width: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }

/* ---------- ลองเพิ่มค่าลดหย่อน ---------- */
.whatif { margin-top: 20px; }
.whatif-table { width: 100%; font-size: .92rem; }
.whatif-table th, .whatif-table td { padding-left: 6px; padding-right: 6px; }
.whatif-table input.money { width: 100%; min-width: 88px; max-width: 120px; text-align: right; }
/* มือถือ: แต่ละรายการเป็นบล็อก — ชื่อรายการเต็มบรรทัด ตัวเลขเรียงใต้ชื่อพร้อมหัวข้อเล็ก */
@media (max-width: 600px) {
  .whatif-table thead { display: none; }
  .whatif-table, .whatif-table tbody { display: block; }
  .whatif-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .whatif-table td { padding: 0; border: 0; }
  .whatif-table td:first-child, .whatif-table td:has(input) { grid-column: 1 / -1; }
  .whatif-table td.num { text-align: left; }
  .whatif-table td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); }
  .whatif-table input.money { max-width: none; text-align: left; }
}
.whatif-result { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.whatif-result > div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.whatif-result small { display: block; color: var(--muted); }
.whatif-result strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.whatif-result .good strong { color: var(--accent); }

/* ---------- โปรโมชันสมัครใหม่ + ป้ายฟีเจอร์สำหรับสมาชิก ---------- */
.promo-banner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 20px; padding: 16px 20px;
  border-radius: var(--radius); background: var(--warn-soft); border: 1px solid var(--chart-pending-net); color: var(--text); }
.promo-banner > div { flex: 1 1 260px; }
.promo-banner strong { font-size: 1.1rem; }
.promo-banner .small { color: var(--muted); margin-top: 2px; }
.promo-badge { flex: none; display: grid; place-items: center; min-width: 76px; height: 76px; padding: 6px; border-radius: 50%;
  background: var(--chart-pending-net); color: #1d231f; font-weight: 700; text-align: center; line-height: 1.15; }
.promo-note { margin: -4px 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft);
  border: 1px solid var(--chart-pending-net); font-size: .92rem; }
.member-tag { display: inline-block; vertical-align: middle; margin-left: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.calc-mock .tip { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--chart-pending-net); border-radius: 8px; font-weight: 600; }
.calc-mock .tip em { color: var(--accent); }
@media (max-width: 600px) { .promo-badge { min-width: 60px; height: 60px; font-size: .85rem; } }
.promo-admin { margin: 4px 0 24px; padding-top: 4px; }
.promo-admin .promo-banner { margin-top: 0; }
.promo-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
@media (max-width: 700px) { .promo-fields { grid-template-columns: 1fr; } }

/* ---------- แถบเมนูแอดมิน (ใต้เมนูหลัก เห็นเฉพาะแอดมิน) ---------- */
.adminbar { border-top: 1px solid var(--border); background: var(--surface-2); }
.adminbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none; }
.adminbar-inner::-webkit-scrollbar { display: none; }
.adminbar-label { font-size: .75rem; font-weight: 700; letter-spacing: .3px; color: var(--warn); background: var(--warn-soft);
  padding: 2px 8px; border-radius: 999px; margin-right: 8px; white-space: nowrap; }
.adminbar a { padding: 8px 12px; color: var(--muted); font-size: .9rem; white-space: nowrap; border-bottom: 2px solid transparent; }
.adminbar a:hover { color: var(--text); text-decoration: none; }
.adminbar a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.adminbar .nav-count { margin-left: 4px; }

/* ---------- ยังไม่ยืนยันอีเมล ---------- */
.verify-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: -8px 0 16px; padding: 10px 14px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: .92rem; }
.verify-banner form { margin: 0; }

/* ---------- คำนวณภาษีแบบไม่ต้องเข้าสู่ระบบ ---------- */
.public-calc-note { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  margin: 0 0 20px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--border); }
.public-calc-note > div { flex: 1 1 260px; }
.public-calc-note .small { color: var(--muted); margin-top: 2px; }

/* ---------- บทความ ---------- */
.article-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .article-grid { grid-template-columns: 1fr; } }
.article-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; color: var(--text); transition: border-color .15s; }
.article-card:hover { text-decoration: none; border-color: var(--accent); }
.article-card img { width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; background: var(--surface-2); }
.article-card-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.article-card h3 { margin: 0; font-size: 1.05rem; line-height: 1.45; }
.article-card p { margin: 0; color: var(--muted); font-size: .92rem; flex: 1; }
.article { max-width: 780px; margin-left: auto; margin-right: auto; padding: 28px 32px; }
.article h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.35; margin: 4px 0 12px; }
.article .lead { font-size: 1.05rem; margin: 0 0 20px; }
.article-meta { margin: 0; }
.article-cover { width: 100%; border-radius: 10px; margin: 0 0 20px; }
.prose { font-size: 1.02rem; line-height: 1.85; overflow-wrap: break-word; }
.prose h2 { font-size: 1.3rem; margin: 1.8em 0 .5em; }
.prose h3 { font-size: 1.1rem; margin: 1.5em 0 .4em; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre { margin: 0 0 1em; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose blockquote { padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--muted); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose table { display: block; overflow-x: auto; font-size: .95rem; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.prose pre { background: var(--surface-2); padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.article-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
  max-width: 780px; margin: 0 auto 20px; background: var(--accent-soft); }
.article-cta > div:first-child { flex: 1 1 320px; }
.article-cta h2 { margin: 0 0 6px; font-size: 1.15rem; }
.article-cta p { margin: 0; }
.article-editor textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; line-height: 1.6; }
@media (max-width: 600px) { .article { padding: 20px 18px; } }

/* ---------- หน้ารวมบทความแบบบล็อก ---------- */
.blog-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.blog-main { min-width: 0; }
.blog-post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 28px; margin-bottom: 20px; }
.blog-post h2 { margin: 0; font-size: 1.35rem; line-height: 1.4; }
.blog-post h2 a { color: var(--text); }
.blog-post h2 a:hover { color: var(--accent); text-decoration: none; }
.blog-meta { margin: 4px 0 14px; }
.blog-cover { width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; border-radius: 10px; margin-bottom: 14px; background: var(--surface-2); }
.blog-post .prose > :first-child { margin-top: 0; }
.blog-post .prose > :last-child { margin-bottom: 0; }
.blog-more { display: inline-block; margin-top: 12px; font-weight: 600; }
.blog-pager { justify-content: center; align-items: center; }
.blog-side { position: sticky; top: 76px; }
.blog-side .card { margin-bottom: 16px; }
.blog-side h3 { margin: 0 0 8px; font-size: 1rem; }
.blog-side-cta { background: var(--accent-soft); }
.blog-side-cta p { margin: 0 0 12px; }
.blog-recent { list-style: none; margin: 0; padding: 0; }
.blog-recent li { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.blog-recent li:last-child { border-bottom: none; padding-bottom: 0; }
.more-break { margin: 20px 0; padding: 6px 10px; border-top: 2px dashed var(--chart-pending-net); color: var(--warn); font-size: .85rem; text-align: center; }
@media (max-width: 900px) {
  .blog-layout { grid-template-columns: 1fr; }
  .blog-side { position: static; }
}
@media (max-width: 600px) { .blog-post { padding: 18px; } }

/* ---------- เก็บผลคำนวณฟรีเข้าบัญชี ---------- */
.keep-result { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--border); }
.keep-result .small { color: var(--muted); margin: 2px 0 10px; }

/* ---------- ชวนเพื่อน ---------- */
.invite-link { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-link input { flex: 1 1 260px; min-width: 0; font-variant-numeric: tabular-nums; }

/* ---------- ประมาณการภาษีทั้งปี (หน้าภาพรวม) ---------- */
.estimate-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.estimate-head h2 { margin: 0 0 2px; }
.estimate-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.estimate-stats > div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.estimate-stats small { display: block; color: var(--muted); font-size: .8rem; }
.estimate-stats strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.estimate-stats .pay strong { color: var(--danger); }
.estimate-stats .refund strong { color: var(--accent); }
.estimate-tips { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
@media (max-width: 700px) { .estimate-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.invite-name { margin-top: 14px; }
.invite-name label { display: block; margin-bottom: 4px; }
.invite-prefix { align-self: center; white-space: nowrap; }
.invite-name input { flex: 1 1 140px; }

/* ---------- ข้อมูลยื่นภาษี: ขั้นตอนตามระบบยื่นออนไลน์ ---------- */
.filing-step { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 28px 0 6px; }
.filing-step span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .95rem; }
.filing-hint { margin: 0 0 12px; }
.filing-group td { font-weight: 600; background: var(--surface-2); }
.copy-num { font: inherit; color: inherit; background: none; border: 1px dashed transparent; border-radius: 6px; padding: 1px 6px; margin: -2px -6px; cursor: copy; font-variant-numeric: tabular-nums; }
.copy-num:hover { border-color: var(--accent); color: var(--accent); }
.copy-num.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.copy-num.deduct { color: var(--deduct); }
.copy-num.copied { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.copy-num.copied::after { content: " ✓"; }
@media print { .copy-num { border: 0; padding: 0; margin: 0; } .copy-num.copied::after { content: ""; } }

/* ---------- เริ่มต้นใช้งาน (หน้าภาพรวม) ---------- */
.onboarding-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.onboarding-head h2 { margin: 0; }
.onboarding-bar { height: 6px; border-radius: 999px; background: var(--surface-2); margin: 12px 0 14px; overflow: hidden; }
.onboarding-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.onboarding-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.onboarding-steps li { position: relative; padding: 10px 12px 10px 38px; border: 1px solid var(--border); border-radius: 10px; }
.onboarding-steps li::before { content: ""; position: absolute; left: 12px; top: 13px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); }
.onboarding-steps li.done::before { content: "✓"; display: grid; place-items: center; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 700; }
.onboarding-steps li.done span { color: var(--muted); text-decoration: line-through; }
.onboarding-steps a, .onboarding-steps span { font-weight: 600; }
.onboarding-steps small { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }

/* ---------- ปุ่มแชร์บทความ ---------- */
.share-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }
.share-bar > span { margin-right: 4px; }
.share-btn { display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 999px; font: inherit; font-size: .9rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.share-btn:hover { text-decoration: none; border-color: var(--accent); }
.share-line { background: #06c755; border-color: #06c755; color: #fff; }
.share-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.share-line:hover, .share-fb:hover { color: #fff; filter: brightness(1.05); }

/* หน้าแรก: กล่องบันทึกรายได้ผ่าน LINE */
.line-promo { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 32px; margin: 0; }
.line-promo .section-title { text-align: left; margin: 12px 0 16px; }
.btn-line { background: #06c755; border-color: #06c755; color: #fff; font-weight: 600; }
.btn-line:hover { background: #06c755; filter: brightness(1.06); }
.line-chat { background: var(--surface-2); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; }
.line-chat .me { align-self: flex-end; background: #06c755; color: #fff; border-radius: 16px 16px 4px 16px; padding: 8px 12px; max-width: 85%; }
.line-chat .bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; padding: 8px 12px; max-width: 85%; line-height: 1.5; }
.line-chat .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.line-chat .chips span { background: var(--surface); border: 1px solid #06c755; color: #059b45; border-radius: 999px; padding: 2px 10px; font-size: .8rem; }
.line-chat .preview-note { margin: 4px 0 0; text-align: right; }
@media (max-width: 900px) { .line-promo { grid-template-columns: 1fr; gap: 20px; padding: 22px; } }

/* แอดมิน → การแจ้งเตือน: แผงอีเมล / LINE */
.notif-channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.notif-channel { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; background: var(--surface-2); }
.notif-channel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.notif-channel-head strong { font-size: 1.05rem; }
.notif-channel-head .checkbox { margin-left: auto; }
.notif-meter-top { display: flex; justify-content: space-between; align-items: baseline; font-size: .88rem; color: var(--muted); }
.notif-meter-top b { color: var(--text); font-size: 1rem; }
.notif-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 6px 0 14px; }
.notif-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.notif-bar.warn i { background: var(--warn); }
.notif-facts { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0 0 14px; font-size: .88rem; }
.notif-facts dt { color: var(--muted); }
.notif-facts dd { margin: 0; text-align: right; font-weight: 600; }
.notif-channel .field { margin: 0; }
.notif-channel .field input { max-width: 160px; }
.notif-sub { font-size: 1rem; margin: 26px 0 8px; }
.notif-table td .small a { white-space: nowrap; }

/* ตรวจความพร้อมยื่นภาษี */
.ready-score { display: flex; align-items: baseline; gap: 12px; }
.ready-score strong { font-size: 2.2rem; color: var(--accent); }
.ready-score span { color: var(--muted); }
.ready-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.ready-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.ready-list li > div { flex: 1; min-width: 0; }
.ready-list strong { display: block; }
.ready-list small { display: block; color: var(--muted); margin-top: 2px; }
.ready-icon { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.ready-list li.done .ready-icon { background: var(--accent); color: var(--accent-ink); }
.ready-list li.todo .ready-icon { background: var(--warn-soft); color: var(--warn); }
.ready-list li.locked .ready-icon { background: var(--surface-2); }
.ready-list li.done strong { color: var(--muted); }

/* รูปสรุปรายได้ประจำปี */
/* วางรูปซ้าย ตั้งค่าขวา (จอแคบตัดลงบรรทัดเอง) — ขนาดหลักอยู่ใน style ของ template */
.recap-side .card h2 { margin-top: 0; font-size: 1.1rem; }
.recap-side .card + .card { margin-top: 16px; }

/* เครื่องคิดเลขภาษีเฉพาะเรื่อง (/calc) */
.calcpage { max-width: 880px; margin: 0 auto; }
.calcpage h1 { font-size: 1.9rem; line-height: 1.3; margin: 6px 0 10px; }
.calcpage h2 { font-size: 1.25rem; margin: 30px 0 8px; }
.calcpage .crumb a { color: inherit; }
.calcpage-lead { color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.calcpage-lead b { color: var(--text); }
.calcpage-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 18px; }
.calcpage-form .check { display: flex; gap: 8px; align-items: center; margin: 6px 0 12px; }
.calcpage-form .calc-field small { display: block; margin-top: 4px; }
.calcpage-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.calcpage-chips a { font-size: .85rem; border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; color: var(--muted); }
.calcpage-chips a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.calcpage-chips a:hover { text-decoration: none; border-color: var(--accent); }
.calcpage-result { background: var(--accent-soft, rgba(31, 122, 90, .1)); border-radius: 14px; padding: 16px 18px; margin-bottom: 10px; }
.calcpage-result small { color: var(--muted); }
.calcpage-result strong { display: block; font-size: 2.2rem; line-height: 1.2; color: var(--accent); }
.calcpage-result strong span { font-size: 1rem; font-weight: 600; }
.calcpage-result.pay strong { color: var(--danger, #c0392b); }
.calcpage-result div { font-weight: 600; }
.calcpage-rows { width: 100%; border-collapse: collapse; font-size: .95rem; }
.calcpage-rows th { text-align: left; font-weight: 400; color: var(--muted); padding: 6px 0; border-bottom: 1px dashed var(--border); }
.calcpage-rows td { text-align: right; padding: 6px 0 6px 10px; border-bottom: 1px dashed var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
.calcpage-rows tr.b th, .calcpage-rows tr.b td { font-weight: 700; color: var(--text); }
.calcpage-rows tr.refund th { color: var(--accent); }
.calcpage-rows tr.pay th { color: var(--danger, #c0392b); }
.calcpage-table table { width: 100%; }
.calcpage-table td, .calcpage-table th { text-align: right; font-variant-numeric: tabular-nums; }
.calcpage-table td:first-child, .calcpage-table th:first-child { text-align: left; }
.calcpage-table tr.cur td { background: var(--accent-soft, rgba(31, 122, 90, .1)); font-weight: 600; }
.calcpage-faq details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.calcpage-faq summary { font-weight: 600; cursor: pointer; }
.calcpage-faq p { color: var(--muted); margin: 8px 0 0; line-height: 1.65; }
.calcpage-related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.calcpage-related a { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; color: var(--text); }
.calcpage-related a:hover { text-decoration: none; border-color: var(--accent); }
.calcpage-related small { display: block; color: var(--muted); }
.calcpage-levels a { display: inline-block; margin: 4px 8px 0 0; }
.calcpage-promo { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 30px; padding: 20px 24px;
  border-radius: 16px; color: #fff; background: linear-gradient(150deg, #2a8f6a, #155c43); }
.calcpage-promo p { color: #d8f1e6; margin: 4px 0 0; }
.calcpage-promo .btn { background: #ffd966; border-color: #ffd966; color: #16201b; font-weight: 700; white-space: nowrap; }
.calcpage-note { margin-top: 18px; }
@media (max-width: 760px) {
  .calcpage h1 { font-size: 1.5rem; }
  .calcpage-box { grid-template-columns: 1fr; }
  .calcpage-promo { flex-direction: column; align-items: flex-start; }
}
