[hidden] { display: none !important; }
:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f1f4; --fg: #15171c; --muted: #6b7280; --line: #e3e5ea;
  --acc: #2f6fed; --acc-fg: #fff; --ok: #1f9d55; --warn: #c27c0e; --bad: #d43d3d; --chip: #eef1f7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --fg: #e8eaee; --muted: #9aa1ad; --line: #2a2f39;
    --acc: #5b8cff; --chip: #232833;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --fg: #e8eaee; --muted: #9aa1ad; --line: #2a2f39;
  --acc: #5b8cff; --chip: #232833;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
a { color: var(--acc); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { min-height: 140px; font-family: ui-monospace, monospace; font-size: 12px; }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 12px; }
label input, label select { margin-top: 4px; color: var(--fg); font-size: 14px; }
button { padding: 8px 14px; border: 0; border-radius: 8px; background: var(--acc); color: var(--acc-fg); cursor: pointer; }
button.ghost { background: var(--chip); color: var(--fg); }
button.danger { background: var(--bad); }
button.small { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card button { width: 100%; margin-top: 8px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; }
#tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
#tabs button { background: transparent; color: var(--muted); padding: 6px 10px; white-space: nowrap; }
#tabs button.on { background: var(--chip); color: var(--fg); }
.who { white-space: nowrap; color: var(--muted); font-size: 12px; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.bot-card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.big { font-size: 22px; font-weight: 700; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: none; }
.row input, .row select { width: auto; flex: 1; min-width: 140px; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--chip); font-size: 12px; white-space: nowrap; }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--bad); }
.chip.acc { color: var(--acc); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.scroll { overflow-x: auto; }
.reasons { margin: 0; padding-left: 16px; color: var(--muted); font-size: 12px; }
.codes { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; color: var(--muted); }

.bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding-top: 8px; }
.bars div { flex: 1; background: var(--acc); border-radius: 2px 2px 0 0; min-height: 1px; position: relative; }
.bars div:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 20; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; }
  #tabs { order: 3; flex-basis: 100%; }
  main { padding: 12px; }
  .tbl .hide-m { display: none; }
}

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.bad-t { color: var(--bad); }
.warn-t { color: var(--warn); }
.meter { height: 4px; border-radius: 2px; background: var(--chip); margin-top: 4px; min-width: 70px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--acc); }
input.mini { width: 64px; padding: 4px 6px; }
label.inl { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 0 6px; font-size: 12px; }
label.inl input { width: auto; margin: 0; }
.nowrap { white-space: nowrap; }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.modal-box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: 100%; max-width: 640px; }
.modal-box textarea { min-height: 220px; }
.codelist { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.codelist .tbl td { padding: 5px 8px; }
