:root {
  --ink: #1F2A44; --ink-2: #4A5570; --muted: #737C92; --line: #DCE0E8; --line-2: #EEF0F4;
  --bg: #F4F6F9; --panel: #FFFFFF; --head: #E9EDF4;
  --up: #177245; --down: #B3261E; --live: #1FA35A; --amber: #C98A00;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); }
a { color: #1D4E9E; }
code { font-size: 12px; background: var(--line-2); padding: 1px 4px; border-radius: 3px; }

/* ---------- header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 24px 10px; position: sticky; top: 0; z-index: 20; }
.title-row { display: flex; align-items: center; gap: 18px; }
h1 { font: 700 25px/1.15 var(--serif); letter-spacing: .02em; margin: 0; color: var(--ink); }
h1 span { font-weight: 400; font-style: italic; letter-spacing: 0; color: var(--ink-2); }
h1 b { font-weight: 400; }
.live { margin-left: auto; display: flex; align-items: center; gap: 8px; font: 500 13px var(--sans); color: var(--ink-2); white-space: nowrap;
  padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #9AA2B4; display: inline-block; }
.live.st-live .dot { background: var(--live); box-shadow: 0 0 0 0 rgba(31,163,90,.55); animation: pulse 2s infinite; }
.live.st-live { color: #11663A; border-color: #BFE3CD; }
.live.st-poll .dot { background: var(--amber); }
.live.st-closed .dot { background: #9AA2B4; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,163,90,.55); } 70% { box-shadow: 0 0 0 7px rgba(31,163,90,0); } 100% { box-shadow: 0 0 0 0 rgba(31,163,90,0); } }
.status { display: flex; flex-wrap: wrap; gap: 6px 26px; margin-top: 8px; font: 13px/1.4 var(--serif); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.status em { font-style: normal; font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-right: 4px; letter-spacing: .02em; }
.menu { display: none; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 18px; padding: 2px 9px; cursor: pointer; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); align-items: start; }
.side { position: sticky; top: 92px; max-height: calc(100vh - 92px); overflow-y: auto; padding: 16px 16px 40px 22px; border-right: 1px solid var(--line); }
main { padding: 12px 22px 30px; min-width: 0; }
.side section { margin-bottom: 20px; }
.side h2 { font: 700 15px var(--serif); margin: 0 0 8px; color: var(--ink); }
.fld { display: block; font-size: 12.5px; color: var(--ink-2); margin: 8px 0; }
.fld input, .fld select { display: block; width: 100%; margin-top: 3px; }
.fld output { float: right; font-weight: 600; color: var(--ink); }
input[type=text], input[type=search], input[type=password], input[type=number], select, textarea {
  font: 13px var(--sans); color: var(--ink); border: 1px solid #C9CFDA; border-radius: 6px; padding: 5px 8px; background: #fff; }
input[type=range] { width: 100%; accent-color: var(--ink); }
input:focus, select:focus, textarea:focus, button:focus-visible, th:focus-visible, a:focus-visible { outline: 2px solid #5B8DEF; outline-offset: 1px; }
details { border-top: 1px solid var(--line-2); padding: 6px 0; }
summary { cursor: pointer; font-size: 13px; color: var(--ink); padding: 2px 0; }
.opts { padding: 6px 0 4px; }
.opts.cols { columns: 1; }
.chk { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; padding: 2px 0; cursor: pointer; }
.chk input { margin-top: 2px; }
.wt { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; margin: 4px 0; }
.wt input { width: 70px; }
.row { display: flex; gap: 8px; }
.cc { display: flex; justify-content: space-between; gap: 6px; padding: 6px 0; border-bottom: 1px dotted var(--line); font-size: 12.5px; }
.cc code { display: block; margin-top: 2px; word-break: break-all; }
.cc .err { display: block; color: var(--down); }
.tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.fine { font-size: 12px; color: var(--muted); margin: 6px 0; }
.lede { color: var(--ink-2); max-width: 90ch; margin: 4px 0 10px; }

button, .btn { font: 600 13px var(--sans); border-radius: 6px; padding: 6px 13px; cursor: pointer; border: 1px solid var(--ink); display: inline-block; }
button.primary, .btn.primary { background: var(--ink); color: #fff; }
button.primary:hover, .btn.primary:hover { background: #2C3B5E; }
button.ghost, .btn.ghost { background: #fff; color: var(--ink); border-color: #C9CFDA; }
button.ghost:hover, .btn.ghost:hover { border-color: var(--ink); }
button.link { border: 0; background: none; padding: 0; color: #1D4E9E; font-weight: 500; text-decoration: underline; }
button.x { border: 0; background: none; color: var(--muted); padding: 0 4px; font-weight: 400; }
button.x:hover { color: var(--down); }

/* ---------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; background: none; border-radius: 0; color: var(--ink-2); font: 500 14px var(--sans); padding: 8px 14px; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 700; }
.tabs button:hover { color: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 10px; }
.toolbar .count { font-size: 12.5px; color: var(--muted); margin-right: auto; }
.toolbar label { font-size: 13px; }

/* ---------- grid */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 215px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--head); color: var(--ink); font: 600 12px/1.25 var(--sans); text-align: left; padding: 8px 9px;
  border-bottom: 1px solid #C9D0DC; cursor: pointer; vertical-align: bottom; min-width: 64px; }
.grid th.sorted { background: #DCE3EE; }
.grid th .arrow { font-size: 9px; margin-left: 4px; color: var(--ink-2); }
.grid td { padding: 6px 9px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.grid tbody tr:hover td { background-color: #F6F8FC; }
.grid tbody tr:hover td[style*=background] { filter: brightness(.97); }
.grid .r { text-align: right; } .grid .c { text-align: center; }
.grid .sticky { position: sticky; left: 0; z-index: 1; background: var(--panel); border-right: 1px solid var(--line-2); }
.grid th.sticky { z-index: 3; background: var(--head); }
.grid td.co { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.grid td.sec { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.grid td.long { white-space: normal; min-width: 260px; max-width: 420px; font-size: 12.5px; color: var(--ink-2); }
.grid td.rr { font-weight: 600; font-size: 12px; }
.grid td.pap { font-weight: 700; }
.grid td.news .signs { font: 600 14px/1 var(--sans); letter-spacing: .12em; }
.grid td.custom { background-color: #FAFAFF; }
.grid .empty { text-align: center; color: var(--muted); padding: 30px; }
.tk { font-weight: 700; color: #1D4E9E; text-decoration: none; }
.tk:hover { text-decoration: underline; }
.pos { color: var(--up); } .neg { color: var(--down); }
.na { color: #A3AAB9; }
.src { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 6px; vertical-align: middle; background: #C3C9D5; }
.src-stream { background: var(--live); } .src-poll { background: var(--amber); }
td.flash-up { animation: fu 1.4s ease-out; } td.flash-down { animation: fd 1.4s ease-out; }
@keyframes fu { from { background: #C9EED6; } to { background: transparent; } }
@keyframes fd { from { background: #F7CFCB; } to { background: transparent; } }
.edit input[type=number] { width: 74px; } .edit input[type=text] { width: 190px; }
.edit textarea { width: 100%; min-width: 260px; resize: vertical; }
.edit select { font-weight: 600; }

/* ---------- news */
.nblock { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; margin-bottom: 10px; }
.nblock h3 { margin: 0 0 4px; font: 700 15px var(--serif); }
.nblock ul { list-style: none; padding: 0; margin: 0; }
.nblock li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.nblock li:last-child { border-bottom: 0; }
.nblock .nm { font-size: 12px; color: var(--muted); white-space: nowrap; }
.nblock a { font-size: 12.5px; white-space: nowrap; }
.sg { font-weight: 700; text-align: center; }
.sg-p { color: var(--up); } .sg-n { color: var(--down); } .sg-o { color: #9AA2B4; }

/* ---------- misc */
.setup, .method { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px 28px; max-width: 820px; }
.setup h2, .method h2 { font: 700 21px var(--serif); margin: 0 0 10px; }
.method h3 { font: 700 16px var(--serif); margin: 20px 0 4px; }
.method p { max-width: 78ch; line-height: 1.6; }
.foot { margin-top: 24px; font: italic 12.5px var(--serif); color: var(--muted); text-align: center; }
.foot p { margin: 2px 0; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: 420px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 6px 20px rgba(20,30,50,.25); }
.toast.ok { background: #14532D; } .toast.error { background: #8C1D18; }

@media (max-width: 900px) {
  .menu { display: inline-block; }
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); background: var(--panel); }
  body.side-open .side { display: block; }
  h1 { font-size: 18px; } h1 span { display: block; font-size: 14px; }
  .top { padding: 10px 14px; position: static; }
  main { padding: 10px 12px; }
  .tbl-wrap { max-height: 75vh; }
  .nblock li { grid-template-columns: 20px minmax(0, 1fr); } .nblock .nm, .nblock a { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .live.st-live .dot, td.flash-up, td.flash-down { animation: none; } }

.status .warn { color: var(--down); font-family: var(--sans); font-size: 12px; }
