/* เว็บสรุปแอดมิน — "night ledger": dark first, AMD blue / HP magenta identity, status = green/red/orange + icon */
:root {
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --r: 14px; --r-sm: 9px;
  --side: 236px;
  --amd: #3987e5; --hp: #d55181;
  --good: #0ca30c; --good-ink: #3ccf55; --bad: #d03b3b; --bad-ink: #ff7b7b; --check: #ec835a; --check-ink: #f5a27c;
  --warn: #fab219;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12; --bg-glow-a: rgba(57,135,229,.13); --bg-glow-b: rgba(213,81,129,.10);
  --surface: #12161e; --surface-2: #181d27; --surface-3: #202634;
  --line: rgba(255,255,255,.07); --line-2: rgba(255,255,255,.12);
  --ink: #eef0f4; --ink-2: #b9bfcb; --muted: #858c9b;
  --grid: #232836; --axis: #3a4050;
  --good-bg: rgba(12,163,12,.14); --bad-bg: rgba(208,59,59,.16); --check-bg: rgba(236,131,90,.15);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px -18px rgba(0,0,0,.8);
}
html[data-theme="light"] {
  color-scheme: light;
  --amd: #2a78d6; --hp: #c94877;
  --bg: #f4f4f1; --bg-glow-a: rgba(42,120,214,.08); --bg-glow-b: rgba(201,72,119,.07);
  --surface: #ffffff; --surface-2: #f7f7f4; --surface-3: #ecece7;
  --line: rgba(11,11,11,.08); --line-2: rgba(11,11,11,.14);
  --ink: #0f1115; --ink-2: #44474e; --muted: #6d7079;
  --grid: #e6e5df; --axis: #c3c2b7;
  --good-ink: #067a06; --bad-ink: #b42323; --check-ink: #b5521f;
  --good-bg: rgba(12,163,12,.10); --bad-bg: rgba(208,59,59,.10); --check-bg: rgba(236,131,90,.14);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -18px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg);
  background-image: radial-gradient(1200px 500px at -10% -10%, var(--bg-glow-a), transparent 60%),
                    radial-gradient(900px 420px at 110% -5%, var(--bg-glow-b), transparent 60%);
  background-attachment: fixed; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink); }
small { font-size: .82em; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.005em; }
h2 { font-size: 1.02rem; }
h3 { font-size: .92rem; margin: 18px 0 8px; color: var(--ink-2); }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.fine { font-size: .82rem; margin: 8px 2px 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.wrap { white-space: normal; overflow-wrap: anywhere; }
.grow { flex: 1 1 auto; }
.small { font-size: .82rem; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- layout */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 12px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; }
.brand-mark { position: relative; width: 30px; height: 30px; border-radius: 9px; overflow: hidden; display: flex; flex: none;
  box-shadow: 0 0 0 1px var(--line-2), 0 6px 18px -8px var(--amd); transform: rotate(-8deg); }
.brand-mark i { flex: 1; }
.brand-mark i.amd { background: var(--amd); }
.brand-mark i.hp { background: var(--hp); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 1.02rem; }
.brand-text small { color: var(--muted); letter-spacing: .12em; font-size: .7rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; }
.side-nav a:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a.active { background: var(--surface-3); color: var(--ink); box-shadow: inset 3px 0 0 0 var(--amd); }
.side-nav a.active .ic { color: var(--amd); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px; font-size: .8rem; color: var(--muted); }
.sync { display: flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.dot.stale { background: var(--check); }
.linkish { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; display: flex; align-items: center; gap: 7px; padding: 0; }
.linkish:hover { color: var(--ink); }
.linkish .ic { width: 16px; height: 16px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; padding: 14px 28px 12px; display: flex; flex-direction: column; gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar::after { /* the split rail: AMD | HP */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--amd) 0 50%, var(--hp) 50% 100%); opacity: .55;
}
.topbar-row { display: flex; align-items: center; gap: 12px; }
.brand-mobile { display: none; padding: 0; }
.page-title { font-size: 1.35rem; display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; flex-wrap: wrap; }
.page-title small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn, .bell > summary {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); cursor: pointer; position: relative; list-style: none;
}
.bell > summary::-webkit-details-marker { display: none; }
.icon-btn:hover, .bell > summary:hover { color: var(--ink); border-color: var(--line-2); }
html[data-theme="dark"] .i-sun, html[data-theme="light"] .i-moon { display: none; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); }
.bell { position: relative; }
.bell-panel { position: absolute; right: 0; top: 48px; width: min(420px, calc(100vw - 24px)); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: 0 24px 60px -20px rgba(0,0,0,.6); padding: 8px; z-index: 50; }
.bell-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 10px; }
.bell-head form { margin-left: auto; }
.bell-panel ul, .alert-list { list-style: none; margin: 0; padding: 0; }
.al a { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 10px; font-size: .88rem; }
.al a:hover { background: var(--surface-2); }
.al.seen { opacity: .55; }
.al-ic { flex: none; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-weight: 700; font-size: .78rem; }
.al.bad .al-ic { background: var(--bad-bg); color: var(--bad-ink); }
.al.warn .al-ic { background: var(--check-bg); color: var(--check-ink); }
.alert-list .al a { border-bottom: 1px solid var(--line); border-radius: 0; }
.alert-list .tag { margin-left: auto; }
.bell-all { display: block; text-align: center; padding: 10px; color: var(--muted); font-size: .85rem; }

/* ---------- filter bar */
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font: inherit; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.chip .ic { width: 16px; height: 16px; }
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.custom-range { display: none; align-items: center; gap: 6px; flex-wrap: wrap; }
.custom-range.open { display: flex; }
.custom-range label { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.seg-i { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 8px; font-size: .86rem; color: var(--ink-2);
  border: 0; background: none; font-family: inherit; cursor: pointer; white-space: nowrap; }
.seg-i:hover { color: var(--ink); }
.seg-i.on { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.seg-i.on.c-amd { box-shadow: inset 0 -2px 0 var(--amd); }
.seg-i.on.c-hp { box-shadow: inset 0 -2px 0 var(--hp); }
.seg.small .seg-i { height: 26px; font-size: .8rem; }
.cdot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; flex: none; }
.cdot.amd { background: var(--amd); } .cdot.hp { background: var(--hp); }

/* ---------- content */
main { padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 18px; min-width: 0; transition: opacity .2s; }
main.loading { opacity: .6; }
.foot { text-align: center; font-size: .78rem; padding-top: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-h h2 { margin-right: auto; }
.card.empty, .empty { color: var(--muted); text-align: center; padding: 22px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.notice { padding: 11px 14px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); font-size: .9rem; }
.notice.warn { border-color: color-mix(in srgb, var(--check) 50%, transparent); background: var(--check-bg); }
.notice.ok { border-color: color-mix(in srgb, var(--good) 50%, transparent); background: var(--good-bg); }
.notice.info { border-color: var(--line-2); }
.notice a { text-decoration: underline; }
.newpw { margin-top: 8px; } .newpw code { font-size: 1.15rem; padding: 6px 12px; user-select: all; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 18px 15px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; min-width: 0; transition: border-color .15s, transform .15s; }
a.kpi:hover { border-color: var(--line-2); transform: translateY(-1px); }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; background: linear-gradient(90deg, transparent, var(--line-2), transparent); }
.kpi-t { font-size: .84rem; color: var(--muted); font-weight: 500; }
.kpi-v { font-size: clamp(1.45rem, 2.1vw, 2.05rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; overflow-wrap: anywhere; }
.kpi-v small { font-size: .5em; color: var(--muted); font-weight: 500; margin-left: 4px; }
.kpi-v.bad { color: var(--bad-ink); }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.split { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 2px; }
.split i { display: block; min-width: 4px; flex-basis: 0; }
.split i.amd { background: var(--amd); } .split i.hp { background: var(--hp); }
.kpi-split { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kpi-split span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

/* company comparison table */
.cmp-table { display: flex; flex-direction: column; }
.cmp-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) repeat(3, minmax(0, 1fr)); align-items: center; gap: 8px;
  padding: 9px 4px; border-bottom: 1px solid var(--line); }
.cmp-row:has(> :nth-child(3):last-child) { grid-template-columns: minmax(150px, 1.4fr) minmax(0, 1fr); }
.cmp-row.head { font-size: .82rem; color: var(--muted); padding-top: 0; }
.cmp-row.head > :not(:first-child), .cmp-row > a { text-align: right; }
.cmp-row > a { padding: 3px 6px; border-radius: 7px; }
.cmp-row > a:hover { background: var(--surface-2); }
.cmp-row.strong { font-weight: 600; }
.cmp-l { display: flex; flex-direction: column; line-height: 1.25; }
.cmp-l small { color: var(--muted); font-weight: 400; font-size: .74rem; }
.cmp-row .total { color: var(--ink); font-weight: 600; }
.diff.ok { color: var(--good-ink); } .diff.bad { color: var(--bad-ink); font-weight: 600; } .diff.check { color: var(--check-ink); }

/* company chip, tags, status */
.co { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 6px; border-radius: 6px; font-size: .76rem; font-weight: 700;
  letter-spacing: .03em; border: 1px solid; }
.co::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.co.amd { color: var(--amd); border-color: color-mix(in srgb, var(--amd) 40%, transparent); background: color-mix(in srgb, var(--amd) 10%, transparent); }
.co.hp { color: var(--hp); border-color: color-mix(in srgb, var(--hp) 40%, transparent); background: color-mix(in srgb, var(--hp) 10%, transparent); }
.co.none { color: var(--muted); border-color: var(--line-2); }
.tag { display: inline-block; padding: 0 7px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: .76rem; white-space: nowrap; }
.st { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 3px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.st b { width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center; font-size: .68rem; }
.st.ok { background: var(--good-bg); color: var(--good-ink); } .st.ok b { background: var(--good); color: #fff; }
.st.bad { background: var(--bad-bg); color: var(--bad-ink); } .st.bad b { background: var(--bad); color: #fff; }
.st.check { background: var(--check-bg); color: var(--check-ink); } .st.check b { background: var(--check); color: #fff; }
.st.none { background: var(--surface-3); color: var(--muted); padding-left: 9px; }
.mini { display: inline-block; margin: 2px 4px 2px 0; padding: 0 7px; border-radius: 6px; font-size: .74rem; background: var(--surface-3); color: var(--ink-2); }
.mini.bad { background: var(--bad-bg); color: var(--bad-ink); } .mini.check { background: var(--check-bg); color: var(--check-ink); }
.mini.info { background: color-mix(in srgb, var(--amd) 14%, transparent); color: var(--ink-2); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: .8rem; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tbl td a:not(.btn) { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.tbl td a:hover { text-decoration-color: var(--ink-2); }
.tbl.compact td { padding: 7px 8px; }
.tbl tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.tbl tr.row-check td:first-child { box-shadow: inset 3px 0 0 var(--check); }
.tbl .r { text-align: right; }
td.in { color: var(--good-ink); } td.out { color: var(--ink); }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.exports { display: inline-flex; gap: 6px; }
.search { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); }
.search input { border: 0; background: none; outline: none; color: var(--ink); font: inherit; font-size: .9rem; width: 150px; min-width: 0; }
.search.grow input { width: 100%; }
.search .ic { width: 17px; height: 17px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--ink); color: var(--bg); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { opacity: .9; color: var(--bg); }
.btn.tiny { height: 32px; padding: 0 11px; font-size: .82rem; border-radius: 9px; }
.btn.ghost { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--line-2); }
.btn.danger { color: var(--bad-ink); }
.btn.block { width: 100%; height: 46px; font-size: 1rem; }
.btn .ic { width: 16px; height: 16px; }
input, select { font: inherit; font-size: .9rem; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 9px;
  height: 36px; padding: 0 10px; min-width: 0; max-width: 100%; }
input[type=checkbox] { height: 18px; width: 18px; accent-color: var(--amd); }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--amd) 60%, transparent); outline-offset: 1px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inline-form.add { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.inline-form input.short { width: 110px; }
form.inline { display: inline; }
label.check { display: inline-flex; align-items: center; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .84rem; color: var(--ink-2); }
.form-grid label.check { flex-direction: row; }
.search-form, .recon-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; }
.recon-form label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--muted); }
.recon-form .btn { align-self: flex-end; }
.section-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-tools p { margin: 0; font-size: .86rem; }
details.pick summary { cursor: pointer; list-style: none; }
details.pick summary::-webkit-details-marker { display: none; }
details.pick summary::after { content: " ✎"; color: var(--muted); font-size: .8em; }
details.pick form { margin-top: 8px; }
details.pick select { max-width: 260px; }
.summary-pills { display: flex; gap: 12px; flex-wrap: wrap; }
.pill-card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); font-size: .85rem; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.settings-toc { display: flex; gap: 6px; flex-wrap: wrap; }
.settings-toc a { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .84rem; color: var(--ink-2); }
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.src { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.src.off { opacity: .7; border-style: dashed; }
.src p { margin: 0; font-size: .82rem; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.kv { display: grid; gap: 8px; margin: 0 0 6px; }
.kv > div { display: grid; grid-template-columns: 130px 1fr; gap: 10px; }
.kv dt { color: var(--muted); font-size: .85rem; } .kv dd { margin: 0; }
pre.raw, .msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: .88rem; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; max-width: 100%; }
pre.raw.small { font-family: var(--mono); font-size: .74rem; max-height: 420px; overflow: auto; }

/* charts */
.chart-card { display: flex; flex-direction: column; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 380px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--ink-2); margin: -4px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.toggle { margin-bottom: 10px; align-self: flex-start; }

/* shifts */
.shift-block { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 150px; }
.shift-h { display: flex; align-items: center; gap: 12px; }
.shift-h div { display: flex; flex-direction: column; line-height: 1.25; }
.shift-h small { color: var(--muted); }
.shift-no { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--surface-3); border: 1px solid var(--line-2); }
.shift-no.s1 { background: linear-gradient(160deg, #1b2240, #12162a); color: #b9c6ff; }
.shift-no.s2 { background: linear-gradient(160deg, #3b3418, #221f12); color: #ffd98a; }
.shift-no.s3 { background: linear-gradient(160deg, #3b2030, #22131c); color: #ffb3cc; }
html[data-theme="light"] .shift-no.s1 { background: #e3e8ff; color: #2d3a8c; }
html[data-theme="light"] .shift-no.s2 { background: #fff1cf; color: #7a5400; }
html[data-theme="light"] .shift-no.s3 { background: #ffe1ec; color: #8a2346; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--good-ink); background: var(--good-bg); padding: 2px 10px; border-radius: 999px; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.shift-cells { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.shift-cells.n1 { grid-template-columns: minmax(0, 1fr); }
.shift-cell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow); border-top: 2px solid var(--line-2); }
.shift-cell.c-amd { border-top-color: var(--amd); } .shift-cell.c-hp { border-top-color: var(--hp); }
.cell-h { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.people { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .9rem; }
.person .pn { font-weight: 600; }
.person .pt { color: var(--ink-2); font-size: .85rem; }
.person.none { font-size: .85rem; }
.reports { display: flex; flex-wrap: wrap; gap: 8px; font-size: .84rem; }
.rep { padding: 3px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.rep.yes { border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.rep.yes::before { content: "✓ "; color: var(--good-ink); font-weight: 700; }
.rep.no { color: var(--muted); }
.rep a { text-decoration: underline; text-underline-offset: 3px; }
dl.nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--line); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
dl.nums > div { background: var(--surface-2); padding: 8px 10px; min-width: 0; }
dl.nums dt { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
dl.nums dd { margin: 0; font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; }
dl.nums dd a:hover { text-decoration: underline; }
dl.nums.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* attendance */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.pcard { padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.pc-h { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pc-v .big { font-size: 1.7rem; font-weight: 600; }
.pc-s { font-size: .8rem; }

/* messages */
.msg-list { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.msg:hover { border-color: var(--line-2); }
.msg.sample { border-style: dashed; }
.msg-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.msg-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.msg-text { font-size: .84rem; max-height: 140px; overflow: hidden; color: var(--ink-2); }

/* bottom nav (mobile) */
.bottom-nav { display: none; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--amd) 0 50%, var(--hp) 50%); }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--ink-2); }
.login-card input { height: 46px; font-size: 1rem; }
.brand.big { padding: 0 0 14px; } .brand.big .brand-mark { width: 40px; height: 40px; } .brand.big b { font-size: 1.3rem; }
.err { color: var(--bad-ink); background: var(--bad-bg); padding: 8px 12px; border-radius: 9px; margin: 0; font-size: .9rem; }

/* ---------- responsive */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .brand-mobile { display: flex; }
  .brand-mobile .brand-mark { width: 26px; height: 26px; }
  .topbar { padding: 10px 14px 10px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  .page-title { font-size: 1.12rem; gap: 6px; }
  .page-title small { font-size: .78rem; }
  .filterbar { gap: 6px; }
  .chips { width: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; width: calc(100% + 28px); }
  .chips::-webkit-scrollbar { display: none; }
  .seg { flex: 1 1 auto; }
  .seg-i { flex: 1; justify-content: center; padding: 0 6px; }
  main { padding: 14px 12px calc(92px + env(safe-area-inset-bottom)); gap: 14px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .kpis, .kpis.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 13px 12px; }
  .kpi-v { font-size: 1.32rem; }
  .kpi-split { flex-direction: column; gap: 0; }
  .shift-cells { grid-template-columns: minmax(0, 1fr); }
  .cmp-row { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 2px; }
  .cmp-row:has(> :nth-child(3):last-child) { grid-template-columns: minmax(0, 1fr); }
  .cmp-row > .cmp-l, .cmp-row.head > :first-child { grid-column: 1 / -1; }
  .cmp-row.head > :first-child { display: none; }
  .cmp-row > a { font-size: .9rem; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.3); border-top: 1px solid var(--line-2);
  }
  .bottom-nav > a, .bottom-nav summary { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px;
    font-size: .72rem; color: var(--muted); cursor: pointer; list-style: none; }
  .bottom-nav summary::-webkit-details-marker { display: none; }
  .bottom-nav .ic { width: 23px; height: 23px; }
  .bottom-nav > a.active, .bottom-nav .more.active > summary { color: var(--ink); }
  .bottom-nav > a.active .ic { color: var(--amd); }
  .more-sheet { position: fixed; left: 10px; right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--line-2);
    border-radius: 18px; padding: 8px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; box-shadow: 0 -20px 50px -20px rgba(0,0,0,.7); }
  .more-sheet a, .more-sheet button { display: flex; align-items: center; gap: 10px; padding: 13px 12px; border-radius: 12px; font: inherit; font-size: .92rem;
    color: var(--ink-2); background: var(--surface-2); border: 0; width: 100%; cursor: pointer; text-align: left; }
  .more-sheet a.active { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
  .more-sheet form { display: contents; }
  .bell-panel { position: fixed; left: 10px; right: 10px; top: 60px; width: auto; }
  .kv > div { grid-template-columns: 1fr; gap: 0; }
  dl.nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-box { height: 220px; } .chart-box.tall { height: 360px; }
  .tbl { font-size: .86rem; }
  .search input { width: 120px; }
  .card-h .tools { width: 100%; }
  .card-h .tools .search { flex: 1; }
  .card-h .tools .search input { width: 100%; }
  .summary-pills { flex-direction: column; }
  .recon-form label { flex: 1 1 40%; } .recon-form select, .recon-form input { width: 100%; }
  .search-form select { flex: 1 1 40%; }
}
@media (max-width: 380px) {
  .kpi-v { font-size: 1.18rem; }
  .chip { padding: 0 11px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 900px) {
  .tbl td.wrap { min-width: 170px; }
}
.split.split-none { background: var(--surface-3); }

/* phones: tables become stacked cards (label from the column header, set by app.js) */
@media (max-width: 900px) {
  .topbar { position: relative; }
  .tbl.cards { font-size: .9rem; }
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards tr { display: block; padding: 10px 12px; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
  .tbl.cards tbody tr:hover td { background: none; }
  .tbl.cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 4px 0; border: 0;
    text-align: right; min-width: 0 !important; white-space: normal; }
  .tbl.cards td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; max-width: 45%; }
  .tbl.cards td:first-child { justify-content: flex-start; text-align: left; font-weight: 600; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  .tbl.cards td:first-child::before { display: none; }
  .tbl.cards td.empty { justify-content: center; }
  .tbl.cards td.empty::before { display: none; }
  .tbl.cards td:empty { display: none; }
  .tbl.cards tr.row-bad { box-shadow: inset 3px 0 0 var(--bad); }
  .tbl.cards tr.row-check { box-shadow: inset 3px 0 0 var(--check); }
  .tbl.cards tr.row-bad td:first-child, .tbl.cards tr.row-check td:first-child { box-shadow: none; }
  .tbl.cards td .num, .tbl.cards td.num { white-space: nowrap; }
  .table-wrap:has(.tbl.cards) { margin: 0; padding: 0; overflow: visible; }
  details.pick select { max-width: 100%; }
}
.pair { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 8px; border-radius: 10px; background: var(--surface-2); }
@media (max-width: 900px) {
  .tbl.cards.stack td { display: block; text-align: left; }
  .tbl.cards.stack td::before { display: none; }
  .tbl.cards.stack td:first-child { border-bottom: 0; margin-bottom: 0; }
  .tbl.cards.stack .inline-form > * { flex: 1 1 auto; }
  .tbl.cards.stack .inline-form .btn { flex: 0 0 auto; }
}
html[data-theme="light"] #themeToggle .ic:first-child, html[data-theme="dark"] #themeToggle .ic:last-child { display: none; }
.bad-ink { color: var(--bad-ink); font-weight: 600; }
