/* Layout: one column of cards, two-up grids when there is room. */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --fg: #1b2230; --muted: #5d6676; --line: #dfe3ea; --grid: #edf0f4;
  --accent: #1f6feb; --ok: #1a7f4b; --warn: #a15c00; --bad: #c62828; --flag: #fff4e0;
  --s1: #3b82f6; --s2: #f97316; --s3: #10b981;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Khmer", sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --panel: #171b23; --fg: #e6e9ef; --muted: #98a1b2; --line: #2a303c; --grid: #222833;
    --accent: #6ea8fe; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --flag: #2d2412;
    --s1: #60a5fa; --s2: #fb923c; --s3: #34d399;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); }
.kp { max-width: 1280px; margin-inline: auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 20px; }
h1 { margin: 0; font-size: 26px; font-weight: 600; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.head { display: flex; flex-direction: column; gap: 8px; }
.titlerow, .toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
select, .search { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); max-width: 100%; }
.search { width: 16rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 5px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--fg); font-weight: 600; }
button:focus-visible, select:focus-visible, .search:focus-visible, tr[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.meta, .note { margin: 0; font-size: 12px; color: var(--muted); }
.note { max-width: 90ch; }
.banner { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--flag); font-size: 13px; }
.take { margin: 0; max-width: 75ch; }
.take b { font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile .label, .tile .sub { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.grid > .card, .grid > .tablewrap { min-width: 0; }
.tablewrap { overflow: auto; max-height: 30rem; }
.tablewrap.short { max-height: 22rem; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th[aria-sort="ascending"] button::after { content: " ▲"; }
th[aria-sort="descending"] button::after { content: " ▼"; }
td { padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td.wrap { white-space: normal; min-width: 14rem; }
.num { text-align: right; }
tr.flag td { background: var(--flag); }
#score-table tbody tr { cursor: pointer; }
#score-table tbody tr:hover td { background: var(--grid); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); } .muted { color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.chart { position: relative; min-height: 10rem; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 12px; }
.chart text.name { fill: var(--fg); }
.chart .gridline { stroke: var(--grid); }
.tip { position: fixed; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgb(0 0 0 / .15); padding: 6px 10px; font-size: 12px; z-index: 10; min-width: 9rem; }
.tip .h { color: var(--muted); margin-bottom: 2px; }
.tip .r { display: flex; gap: 12px; justify-content: space-between; }
.steps { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.linkbtn { font: inherit; font-size: 13px; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; color: var(--fg); cursor: pointer; }
.empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
@media (max-width: 640px) { .hide-sm { display: none; } .search { width: 100%; } }
