:root { --bg:#f5f7fb; --card:#fff; --ink:#1f2937; --muted:#6b7280; --brand:#0f5fd7; --brand-dark:#0b3f91; --line:#e5e7eb; --ok:#15803d; --bad:#b91c1c; --side:248px; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { margin:0; font-family:'Sarabun',system-ui,sans-serif; background:var(--bg); color:var(--ink); font-size:16px; }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; }
a { color: var(--brand); }

/* ---------- Layout: left sidebar tabs ---------- */
.shell { display:grid; grid-template-columns: var(--side) 1fr; min-height:100vh; }
.sidebar { background:var(--brand-dark); color:#fff; display:flex; flex-direction:column; padding:20px 12px; position:sticky; top:0; height:100vh; }
.brand { font-weight:700; font-size:1.2rem; padding:0 10px 18px; line-height:1.2; }
.brand small { font-weight:400; opacity:.75; font-size:.85rem; }
.tabs { display:flex; flex-direction:column; gap:4px; }
.tabs [role=tab] { display:flex; align-items:center; gap:10px; width:100%; text-align:left; background:transparent; color:#dbe6ff; border:0; border-radius:10px; padding:11px 12px; font-weight:600; }
.tabs [role=tab]:hover { background:rgba(255,255,255,.08); color:#fff; }
.tabs [role=tab][aria-selected=true] { background:#fff; color:var(--brand-dark); }
.tabs [role=tab]:focus-visible { outline:2px solid #fff; outline-offset:2px; }
.tab-icon { display:inline-grid; place-items:center; width:26px; height:26px; border-radius:7px; background:rgba(255,255,255,.15); font-size:.95rem; }
[aria-selected=true] .tab-icon { background:var(--brand); color:#fff; }
.badge { margin-left:auto; font-size:.8rem; opacity:.8; }
.sidebar-user { margin-top:auto; display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:12px 8px 0; border-top:1px solid rgba(255,255,255,.15); font-size:.9rem; }
.sidebar-user .ghost { color:#fff; border-color:rgba(255,255,255,.5); }
#avatar { width:30px; height:30px; border-radius:50%; }
.content { padding:24px 28px 40px; min-width:0; max-width:1100px; }
.panel-head { margin-bottom:14px; }
.tag { display:inline-block; margin-left:8px; background:#e0ecff; color:var(--brand-dark); border-radius:999px; padding:1px 10px; font-size:.85rem; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position:static; height:auto; flex-direction:row; flex-wrap:wrap; align-items:center; gap:8px; padding:10px; }
  .brand { padding:0 6px; font-size:1rem; }
  .brand br, .brand small { display:none; }
  .tabs { flex-direction:row; flex:1; }
  .tabs [role=tab] { padding:8px 10px; }
  .sidebar-user { margin:0; border:0; padding:0; width:100%; }
  .content { padding:16px; }
}

/* ---------- Components ---------- */
.card { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px 20px; margin-bottom:14px; }
.center { text-align:center; max-width:480px; margin:60px auto; }
summary { font-weight:700; font-size:1.05rem; cursor:pointer; }
.fields { display:grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap:14px 20px; margin-top:14px; }
.field { display:flex; flex-direction:column; gap:4px; }
.field.check { flex-direction:row-reverse; justify-content:flex-end; align-items:center; gap:10px; }
.field small { color:var(--muted); font-size:.85rem; }
.label { font-weight:600; }
input[type=text], input[type=number], select { font:inherit; padding:9px 11px; border:1px solid #cbd5e1; border-radius:8px; background:#fff; }
input[data-money] { text-align:right; }
input:focus, select:focus { outline:2px solid var(--brand); outline-offset:1px; }
input[type=checkbox] { width:20px; height:20px; }
button { font:inherit; border-radius:8px; padding:10px 18px; cursor:pointer; border:1px solid transparent; }
button:disabled { opacity:.6; cursor:wait; }
.primary { background:var(--brand); color:#fff; font-weight:700; }
.ghost { background:transparent; border-color:#cbd5e1; color:var(--ink); }
.small { padding:5px 10px; font-size:.9rem; }
.danger { color:var(--bad); border-color:#f3c4c4; }
.google { display:inline-flex; align-items:center; gap:10px; background:#fff; border-color:#cbd5e1; font-weight:600; }
.actions { display:flex; flex-wrap:wrap; gap:10px; margin: 6px 0 14px; }
.save-box { display:flex; flex-direction:column; gap:8px; }
.save-row { display:flex; flex-wrap:wrap; gap:10px; }
.save-row input { flex:1; min-width:220px; }
.error { color:var(--bad); min-height:1.2em; }
.muted { color:var(--muted); font-size:.9rem; margin:0; }
code { background:var(--bg); padding:4px 8px; border-radius:6px; font-size:.85rem; word-break:break-all; }

/* ---------- Result & tables ---------- */
.summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:10px; margin:12px 0; }
.summary div { background:var(--bg); border-radius:10px; padding:10px 12px; display:flex; flex-direction:column; }
.summary span, .summary small { color:var(--muted); font-size:.85rem; }
.summary b { font-size:1.25rem; }
.summary .pay b, .bad { color:var(--bad); }
.summary .refund b, .good { color:var(--ok); }
.note { background:#fff7ed; padding:8px 12px; border-radius:8px; }
table { width:100%; border-collapse:collapse; font-size:.95rem; margin-bottom:12px; }
th, td { padding:7px 8px; border-bottom:1px solid var(--line); text-align:left; }
th:not(:first-child) { text-align:right; }
.num { text-align:right; white-space:nowrap; }
tfoot td { font-weight:700; }
.records td { vertical-align:middle; }
.row-actions { text-align:right; white-space:nowrap; }
.row-actions button + button { margin-left:6px; }
.records th:nth-child(2) { text-align:left; }
footer { color:var(--muted); font-size:.85rem; text-align:center; margin-top:24px; }
@media (max-width: 760px) { .records { display:block; overflow-x:auto; } }
.landing-title { font-size:1.8rem; color:var(--brand-dark); margin-bottom:8px; }

/* ---------- Tax page: record header + section tabs ---------- */
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.record-head { display:flex; flex-direction:column; gap:8px; }
.record-head .actions { margin:0; }
.record-head .error, .record-head .muted { margin:0; min-height:0; }
.eyebrow { margin:0; color:var(--muted); font-size:.9rem; }
.record-title { font:inherit; font-size:1.5rem; font-weight:700; color:var(--ink); border:1px solid transparent; border-radius:8px; padding:4px 8px; margin-left:-8px; background:transparent; }
.record-title:hover { border-color:var(--line); }
.record-title:focus { border-color:#cbd5e1; background:#fff; outline:2px solid var(--brand); outline-offset:1px; }
.primary.alt { background:#15803d; }
.subtabs { display:flex; flex-wrap:wrap; gap:2px 4px; border-bottom:2px solid var(--line); margin:4px 0 14px; }
.subtabs [role=tab] { flex:none; display:flex; align-items:center; gap:6px; font-size:.95rem; background:transparent; border:0; border-bottom:3px solid transparent; border-radius:8px 8px 0 0; margin-bottom:-2px; padding:9px 11px; color:var(--muted); font-weight:600; white-space:nowrap; }
.subtabs [role=tab]:hover { color:var(--ink); background:#eef3ff; }
.subtabs [role=tab][aria-selected=true] { color:var(--brand-dark); border-bottom-color:var(--brand); background:#fff; }
.subtabs [role=tab]:focus-visible { outline:2px solid var(--brand); outline-offset:-2px; }
.subtabs .num { display:inline-grid; place-items:center; width:20px; height:20px; border-radius:50%; background:var(--line); color:var(--ink); font-size:.75rem; }
.subtabs [aria-selected=true] .num { background:var(--brand); color:#fff; }
.subpanel h2 { margin:0 0 4px; }
.empty { color:var(--muted); text-align:center; padding:32px 20px; }

/* ---------- Sliders ---------- */
.field.slider { gap:6px; }
.range-row { display:grid; grid-template-columns: 1fr 140px; gap:10px; align-items:center; }
.range-row input[type=range] { width:100%; accent-color:var(--brand); height:6px; cursor:pointer; }
.range-row input[type=range]:disabled { opacity:.4; cursor:not-allowed; }
.range-row input[type=text] { width:100%; }
.cap { color:var(--brand-dark) !important; }

/* ---------- Spider chart ---------- */
.headroom { display:grid; grid-template-columns: 1fr; gap:8px; }
.headroom .radar { max-width:480px; margin:0 auto; display:block; }
.radar { width:100%; height:auto; }
.radar-ring { fill:none; stroke:var(--line); }
.radar-axis { stroke:var(--line); }
.radar-max { fill:rgba(15,95,215,.04); stroke:#9db7e6; stroke-dasharray:4 3; }
.radar-used { fill:rgba(21,128,61,.25); stroke:#15803d; stroke-width:2; }
.radar-dot { fill:#15803d; } .radar-used { stroke-width:2.5; }
.radar-tick { font-size:12px; fill:var(--muted); }
.radar-label { font-size:17px; font-weight:600; fill:var(--ink); }
.radar-pct { font-size:15px; font-weight:400; fill:var(--muted); }

/* ---------- Tax saved by deductions ---------- */
.savings { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:10px; margin:6px 0 4px; }
.savings > div { border-radius:10px; padding:12px 14px; display:flex; flex-direction:column; gap:2px; }
.saving-main { background:#ecfdf3; border:1px solid #bbf7d0; }
.saving-more { background:#eff6ff; border:1px solid #bfdbfe; }
.savings span, .savings small { color:var(--muted); font-size:.88rem; }
.saving-main b { color:var(--ok); font-size:1.5rem; }
.saving-more b { color:var(--brand-dark); font-size:1.5rem; }

/* ---------- Money field calculator ---------- */
.money-wrap { position:relative; display:flex; }
.money-wrap input { flex:1; min-width:0; padding-right:38px; }
.calc-btn { position:absolute; right:4px; top:50%; transform:translateY(-50%); padding:5px 6px; line-height:0; background:transparent; border:0; color:var(--muted); border-radius:6px; }
.calc-btn:hover, .calc-btn:focus-visible { color:var(--brand); background:#eef3ff; }
input.invalid { border-color:var(--bad); outline-color:var(--bad); }
.range-row { grid-template-columns: 1fr 170px; }
.calcpad { position:absolute; z-index:50; width:264px; background:#fff; border:1px solid var(--line); border-radius:12px; box-shadow:0 12px 32px rgba(15,23,42,.18); padding:10px; display:flex; flex-direction:column; gap:6px; }
.calc-display { font:inherit; font-size:1.1rem; text-align:right; padding:8px 10px; border:1px solid #cbd5e1; border-radius:8px; }
.calc-preview { text-align:right; color:var(--brand-dark); font-weight:700; min-height:1.3em; }
.calc-keys { display:grid; grid-template-columns:repeat(4, 1fr); gap:6px; }
.calc-keys button { padding:9px 0; background:var(--bg); border:1px solid var(--line); font-weight:600; }
.calc-keys button:hover { background:#e7eefc; }
.calc-keys [data-k="÷"], .calc-keys [data-k="×"], .calc-keys [data-k="−"], .calc-keys [data-k="+"] { color:var(--brand-dark); }
.calc-foot { display:flex; justify-content:space-between; gap:6px; }
.calc-foot button { flex:1; padding:8px 0; }

/* ---------- Live simulation bar ---------- */
.livebar { position:sticky; bottom:12px; z-index:20; display:flex; flex-wrap:wrap; align-items:center; gap:10px 18px; margin-top:14px; padding:10px 16px; background:#0b3f91; color:#fff; border-radius:12px; box-shadow:0 8px 24px rgba(11,63,145,.3); transition:opacity .2s; }
.livebar.stale { opacity:.75; }
.live-tag { font-size:.8rem; background:rgba(255,255,255,.18); border-radius:999px; padding:2px 10px; }
.live-item { display:flex; flex-direction:column; line-height:1.15; }
.live-item small { opacity:.8; font-size:.78rem; }
.live-item b { font-size:1.15rem; }
.live-item.refund b { color:#86efac; }
.live-item.pay b { color:#fca5a5; }
.live-delta { font-size:.9rem; font-weight:700; border-radius:8px; padding:3px 8px; }
.live-delta.up { background:rgba(134,239,172,.2); color:#bbf7d0; }
.live-delta.down { background:rgba(252,165,165,.2); color:#fecaca; }
.livebar .ghost { margin-left:auto; color:#fff; border-color:rgba(255,255,255,.5); }
