:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #1c2430;
  --ink-2: #4a5666;
  --muted: #6b7686;
  --line: #d9dfe7;
  --blue: #1f4e79;
  --blue-2: #2c6aa0;
  --blue-soft: #e7eff8;
  --bar: #3a78b5;
  --warn-bg: #fff7e6;
  --warn-line: #e8c77a;
  --crit: #b42318;
  --crit-bg: #fdecea;
  --good: #1e7a4a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 1px 1px rgba(16, 32, 56, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171e; --surface: #1a212b; --surface-2: #1f2733; --ink: #e6ebf1; --ink-2: #b7c1cd; --muted: #8e99a8;
    --line: #2d3746; --blue: #8cb8e6; --blue-2: #6fa3d8; --blue-soft: #1f3046; --bar: #5b98d6;
    --warn-bg: #2e2716; --warn-line: #7a6326; --crit: #ff8a7a; --crit-bg: #3a1d1a; --good: #6fd19b;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; color: var(--ink); }
h2 { font-size: 1.05rem; margin: 0 0 .4rem; color: var(--blue); }
a { color: var(--blue-2); }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.25rem;
  background: var(--blue); color: #fff; }
@media (prefers-color-scheme: dark) { .top { background: #16263a; } }
.brand { display: flex; align-items: center; gap: .7rem; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #8fb8e0, #e9f1f9); }
.brand-title { font-weight: 650; font-size: 1.05rem; letter-spacing: .01em; }
.brand-sub { font-size: .8rem; opacity: .8; }
.who { display: flex; align-items: center; gap: .75rem; font-size: .85rem; }
.who .link { color: #dce9f6; }

.tabs { display: flex; gap: .25rem; padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; position: sticky; top: 0; z-index: 5; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: .8rem .9rem .65rem; font: inherit;
  color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--blue-2); }
.tab[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue-2); font-weight: 600; }

main { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow); margin-bottom: 1rem; }
.narrow { max-width: 420px; margin: 3rem auto; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.opt { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 7px; padding: .5rem .6rem; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 1px; }
textarea { resize: vertical; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; margin-top: 1rem; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
form:not(.grid) { display: flex; flex-direction: column; gap: .8rem; margin-top: 1rem; }
.actions { display: flex; gap: .6rem; align-items: center; }
.btn { display: inline-block; background: var(--blue-2); color: #fff; border: 0; border-radius: 7px; padding: .55rem 1rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--blue); }
@media (prefers-color-scheme: dark) { .btn { color: #0f1620; } }
.btn.secondary { background: var(--blue-soft); color: var(--blue); }
.link { background: none; border: 0; color: var(--blue-2); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.msg { min-height: 1.2em; margin: .6rem 0 0; }
.msg.err { color: var(--crit); }
.msg.ok { color: var(--good); }

.notice { border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; margin-top: .6rem; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.notice.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.notice.urgent { background: var(--crit-bg); border: 1px solid var(--crit); color: var(--ink); }
.ico { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--crit);
  color: #fff; font-weight: 700; font-size: .75rem; }

.confirm { background: var(--blue-soft); border: 1px solid var(--blue-2); border-radius: 8px; padding: .8rem 1rem; margin-top: 1rem; }
.confirm .ref { font-size: 1.4rem; font-weight: 700; color: var(--blue); letter-spacing: .02em; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.filters select { width: auto; min-width: 140px; font-size: .9rem; padding: .35rem .5rem; }

.list { display: flex; flex-direction: column; gap: .6rem; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem;
  cursor: pointer; box-shadow: var(--shadow); text-align: left; font: inherit; color: inherit; width: 100%; }
.item:hover { border-color: var(--blue-2); }
.item-top { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.item-ref { font-weight: 700; color: var(--blue); font-size: .95rem; }
.item-text { margin: .35rem 0 0; }
.item-replies { margin-top: .4rem; font-size: .85rem; color: var(--blue-2); }
.empty { padding: 2rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem;
  font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.badge.status-New { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge.status-Fixed { color: var(--good); }
.badge.urgent { background: var(--crit-bg); color: var(--crit); border-color: var(--crit); }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(760px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(12, 22, 36, .45); }
.d-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); }
.d-body { padding: 1rem 1.25rem 1.25rem; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: .35rem 1rem; font-size: .92rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: .4rem; } }
.reply { border-left: 3px solid var(--blue-2); background: var(--surface-2); padding: .5rem .75rem; border-radius: 0 6px 6px 0; margin: .4rem 0; }
.reply-meta { font-size: .78rem; color: var(--muted); }
.reply-body { white-space: pre-wrap; }
.adminbox { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; display: grid; gap: .8rem; }
.rw-note { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: .6rem .75rem; }
.history { font-size: .8rem; color: var(--muted); margin-top: 1rem; }
.history li { margin: .15rem 0; }

.prose h2 { margin-top: 1.1rem; }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 1.2rem; margin: .3rem 0; }
.prose p { margin: .4rem 0; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.tile-n { font-size: 1.8rem; font-weight: 700; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.tile.alert { border-color: var(--crit); }
.tile.alert .tile-l { color: var(--crit); font-weight: 600; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .charts { grid-template-columns: 1fr; } }
.chart-title { font-weight: 600; color: var(--ink); margin: 0 0 .6rem; font-size: .95rem; }
.bars { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: .4rem .6rem; align-items: center; font-size: .85rem; }
.bars .lbl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { height: 12px; }
.bars .fill { height: 12px; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .val { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.bars .row-hit { display: contents; }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--line); padding-top: 6px; }
.cols .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; cursor: default; }
.cols .c .f { background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.cols .c:hover .f { background: var(--blue); }
.cols .c .tip { display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--surface); font-size: .75rem; padding: .2rem .45rem; border-radius: 5px; white-space: nowrap; z-index: 2; }
.cols .c:hover .tip, .cols .c:focus .tip { display: block; }
.col-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: .3rem; }
details.tbl { margin-top: .6rem; font-size: .82rem; }
details.tbl table { border-collapse: collapse; margin-top: .4rem; }
details.tbl td, details.tbl th { border-bottom: 1px solid var(--line); padding: .15rem .6rem .15rem 0; text-align: left; }
.urgent-list li { margin: .3rem 0; }
