:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --pri: #1f5fbf; --pri-ink: #fff; --red: #c62828; --green: #2e7d32; --warn: #b26a00; --head: #eef2f8;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 'Sarabun', system-ui, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 6px 0 14px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 16px; margin: 18px 0 8px; }
main { padding: 18px 22px 60px; max-width: 1500px; margin: 0 auto; }
.muted { color: var(--muted); }
.small, small { font-size: 12.5px; }
.red { color: var(--red); }
.ok-text { color: var(--green); }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* top bar */
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #17233a; color: #cfd8e6; padding: 8px 18px; position: sticky; top: 0; z-index: 10; }
.top a { color: #cfd8e6; }
.top .brand a { color: #fff; font-weight: 700; font-size: 16px; }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.top nav a { padding: 6px 10px; border-radius: 6px; }
.top nav a.on, .top nav a:hover { background: #2b3b5c; color: #fff; text-decoration: none; }
.top .me { font-size: 13px; }
.client-switch select { background: #24324f; color: #fff; border: 1px solid #3a4c72; padding: 5px 8px; border-radius: 6px; max-width: 320px; }

/* blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
details.card summary { cursor: pointer; margin-bottom: 6px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; }
.two-col .side .card { margin-bottom: 12px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
.narrow { max-width: 420px; }
.client-badge { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--pri); padding: 6px 12px; border-radius: 6px; margin-bottom: 10px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 10px; background: #e8edf5; color: #34507a; margin-left: 4px; }
.tag.vat { background: #e3f2e5; color: var(--green); }
.tag.red { background: #fde7e7; color: var(--red); }
.flash { padding: 9px 14px; border-radius: 8px; margin-bottom: 10px; background: #e3f2e5; color: #1b5e20; border: 1px solid #c3e1c6; }
.flash.err { background: #fde7e7; color: #8e1c1c; border-color: #f3c2c2; }
.flash.warn { background: #fff4e0; color: #7a4a00; border-color: #f3dcae; }

.with-btn { display: flex; gap: 6px; }
.with-btn input { flex: 1; }
.dbd-out { background: #f3f7ff; border: 1px solid #cfdcf3; border-radius: 8px; padding: 8px 12px; font-size: 13.5px; }
.dbd-out.err { background: #fde7e7; border-color: #f3c2c2; color: #8e1c1c; }
.dbd-out .warn { color: var(--red); font-weight: 700; }

/* stats */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; min-width: 170px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat.bad .n { color: var(--red); }

/* forms */
input, select, textarea { font: inherit; padding: 6px 9px; border: 1px solid #cfd5de; border-radius: 6px; background: #fff; width: 100%; }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8cdf0; border-color: var(--pri); }
input.num { text-align: right; }
label { display: block; font-size: 13.5px; color: #384152; }
label.inline, .checks label, .filing-checks label { display: inline-flex; align-items: center; gap: 6px; }
label small { display: block; color: var(--muted); }
.stack > * + * { margin-top: 10px; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.grid-form .span2 { grid-column: span 2; }
.grid-form .span3 { grid-column: 1 / -1; }
@media (max-width: 800px) { .grid-form { grid-template-columns: 1fr; } .grid-form .span2 { grid-column: auto; } }
.checks { display: flex; gap: 18px; flex-wrap: wrap; padding: 6px 0; }
.filing-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px 14px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; }
.filters label { display: inline-flex; gap: 6px; align-items: center; }
.filters .quick a { margin: 0 4px; font-size: 13px; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
form.inline { display: inline; }

.btn { display: inline-block; font: inherit; font-size: 14px; padding: 6px 13px; border-radius: 6px; border: 1px solid #c6cdd8; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f0f3f8; text-decoration: none; }
.btn.primary { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); }
.btn.primary:hover { background: #184e9e; }
.btn.danger { color: var(--red); border-color: #e6b5b5; }
.btn.sm { padding: 2px 8px; font-size: 13px; }

/* tables */
table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
.grid th, .grid td { padding: 6px 9px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.grid th { background: var(--head); font-weight: 600; font-size: 13.5px; }
.grid tfoot td { font-weight: 600; background: #fafbfc; }
.k-num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.k-center { text-align: center !important; }
.k-date { white-space: nowrap; }
.grid tr.head td { background: #f3f6fb; font-weight: 700; }
.grid tr.grp td { background: #fafbfd; font-weight: 600; border-top: 2px solid var(--line); }
.grid tr.sub td { font-weight: 600; border-top: 1px solid #c9d0db; }
.grid tr.total td { font-weight: 700; border-top: 2px solid #9aa6b8; }
.grid tr.grand td { border-bottom: 3px double #6b7a90; }
.grid tr.warn td { color: var(--red); font-weight: 700; }
.grid tr.muted td { color: var(--muted); }
.grid tr.void td { color: #9aa1ac; text-decoration: line-through; }
.grid tr.void td:last-child { text-decoration: none; }
.grid tr.current td { background: #f0f6ff; }
.grid tr.late td { background: #fff6f6; }
.grid tr.st-done td, .grid tr.st-na td { background: #f5fbf5; }
.grid .empty { text-align: center; color: var(--muted); padding: 22px; }
table.lines td { padding: 4px 6px; }
.filings input, .filings select { padding: 3px 6px; font-size: 13.5px; }
.filings td input + input { margin-top: 3px; }
.autoline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.autoline label { flex: 1 1 220px; }
.autoline small { flex-basis: 100%; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 2px solid var(--line); }
.tabs a { padding: 7px 14px; border-radius: 6px 6px 0 0; color: var(--ink); }
.tabs a.on { background: #fff; border: 1px solid var(--line); border-bottom: 2px solid #fff; margin-bottom: -2px; font-weight: 700; }
.report { background: #fff; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.report-head { text-align: center; margin-bottom: 10px; }
.report table.grid { border: 0; }

/* login */
.login-box { max-width: 380px; margin: 9vh auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px; }
body.bare main { padding-top: 0; }

/* printable documents */
.print-bar { padding: 10px 0; text-align: center; }
.paper { background: #fff; width: 210mm; min-height: 270mm; margin: 0 auto 16px; padding: 14mm 14mm; box-shadow: 0 1px 6px rgba(0,0,0,.12); font-size: 14px; position: relative; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 10px; }
.doc-head .co-name { font-size: 18px; font-weight: 700; }
.doc-title { text-align: right; }
.doc-title h2 { font-size: 22px; }
.void-stamp { color: var(--red); border: 3px solid var(--red); display: inline-block; padding: 2px 16px; font-size: 22px; font-weight: 700; transform: rotate(-8deg); margin-top: 6px; }
table.info { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.info th { text-align: left; width: 16%; font-weight: 600; padding: 3px 6px; vertical-align: top; }
table.info td { padding: 3px 6px; border-bottom: 1px dotted #aaa; }
table.lines-print { width: 100%; border-collapse: collapse; }
.lines-print th, .lines-print td { border: 1px solid #555; padding: 5px 7px; vertical-align: top; }
.lines-print th { background: #eee; }
.lines-print tfoot td { font-weight: 700; }
.signs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 50px; text-align: center; }
.signs .line { border-bottom: 1px dotted #333; height: 30px; margin-bottom: 4px; }
.sign-date { text-align: right; margin-top: 18px; }

.paper.wht { font-size: 13.5px; }
.wht-copy { text-align: right; font-size: 12px; }
.wht-title { text-align: center; font-size: 16px; margin: 6px 0 10px; position: relative; }
.wht-no { position: absolute; right: 0; top: 4px; font-size: 13px; }
.box { border: 1px solid #333; padding: 6px 10px; margin-bottom: -1px; }
.box-h { font-weight: 700; }
.row2 { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mono { letter-spacing: 1px; }
.forms { margin-top: 4px; }
.cb { margin-right: 12px; white-space: nowrap; }
.wht-table { width: 100%; border-collapse: collapse; margin: -1px 0; }
.wht-table th, .wht-table td { border: 1px solid #333; padding: 4px 7px; vertical-align: top; }
.wht-table th { font-weight: 600; font-size: 13px; }
.wht-sign { display: grid; grid-template-columns: 1fr 1.2fr; border: 1px solid #333; }
.wht-sign > div { padding: 8px 10px; }
.wht-sign .warn-text { border-right: 1px solid #333; font-size: 12.5px; }
.wht-sign .sig { text-align: center; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; font-size: 12.5px; }
  .noprint, .top, .flash, .filters, .tabs { display: none !important; }
  main { padding: 0; max-width: none; }
  .report { border: 0; padding: 0; }
  .paper { box-shadow: none; margin: 0; width: auto; min-height: 0; padding: 0; page-break-after: always; }
  .paper:last-child { page-break-after: auto; }
  .grid th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; }
}
