/* Dashboard บริษัท — WCAG 2.2 AA: contrast ≥ 4.5:1, focus เห็นชัด, ปุ่ม ≥ 44px, ไม่สื่อด้วยสีอย่างเดียว */
:root {
  --bg: #f4f6f9; --surface: #fff; --surface-2: #eef2f7; --text: #161a20; --muted: #47505e;
  --border: #c9d1dc; --primary: #0b5cad; --on-primary: #fff;
  --good: #146c2e; --good-bg: #e3f4e8; --bad: #b3261e; --bad-bg: #fde8e6; --na: #47505e; --na-bg: #eceff3;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --surface: #1a1f26; --surface-2: #232a33; --text: #eef1f5; --muted: #b6bfcb;
    --border: #3a4552; --primary: #7cb7ff; --on-primary: #0b1a2c;
    --good: #7ad79a; --good-bg: #173322; --bad: #ff9a90; --bad-bg: #3a1a18; --na: #b6bfcb; --na-bg: #262d36;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.6;
  font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Segoe UI", system-ui, sans-serif; }
h1, h2 { line-height: 1.3; margin: 0 0 .5rem; } h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; }
p { margin: 0 0 .5rem; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--primary); color: var(--on-primary); padding: .6rem 1rem; border-radius: 8px; z-index: 10; }
.skip-link:focus { top: 8px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; gap: 10px; align-items: center; font-size: 1.6rem; }
.brand-name { font-weight: 700; font-size: 1rem; margin: 0; } .brand-sub { color: var(--muted); font-size: .85rem; margin: 0; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
main:focus { outline: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.stack > * + * { margin-top: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: .2rem; }
.field.inline { display: flex; gap: 8px; align-items: center; } .field.inline label { margin: 0; }
input, select { font: inherit; min-height: 44px; padding: .5rem .75rem; border: 1px solid var(--muted); border-radius: 10px;
  background: var(--surface); color: var(--text); width: 100%; }
.field.inline select { width: auto; }
.field-err { color: var(--bad); font-weight: 600; margin: .25rem 0 0; } .field-err:empty { display: none; }
.hint { color: var(--muted); font-size: .92rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.btn { font: inherit; font-weight: 600; min-height: 44px; min-width: 44px; padding: .5rem 1rem; border-radius: 10px;
  border: 2px solid var(--primary); background: var(--surface); color: var(--primary); cursor: pointer; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: .35rem .8rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; margin: 12px 0; border-bottom: 2px solid var(--border); }
.tabs [role=tab] { font: inherit; font-weight: 600; min-height: 44px; padding: .5rem 1rem; border: 0; background: none; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; }
.tabs [role=tab][aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 0 0 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-size: 1.6rem; font-weight: 700; display: block; } .kpi .k { color: var(--muted); font-size: .92rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { border-bottom: 1px solid var(--border); padding: .5rem .45rem; text-align: left; vertical-align: middle; }
thead th { color: var(--muted); font-weight: 600; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-weight: 600; font-size: .88rem; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.na { background: var(--na-bg); color: var(--na); }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.sw.good { background: var(--good); } .sw.bad { background: repeating-linear-gradient(45deg, var(--bad) 0 3px, var(--bad-bg) 3px 6px); border: 1px solid var(--bad); }
.message { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; max-width: 92vw; margin: 0;
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; }
.message:empty { display: none; }
.danger-zone summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
code { background: var(--surface-2); padding: 0 .3rem; border-radius: 4px; }
