:root {
  --bg: #f4f6f9; --panel: #ffffff; --panel2: #f0f3f7; --text: #171c24; --muted: #5d6775; --line: #e1e6ed;
  --accent: #1f5fbf; --accent-text: #ffffff; --accent-soft: #e4eefb;
  --good: #14804a; --good-soft: #e0f3e8; --bad: #c62f33; --bad-soft: #fbe6e6; --warn: #96640f; --warn-soft: #fbf0d9;
  --bar: #2f6fd0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --panel: #1a2029; --panel2: #232b36; --text: #e8ecf1; --muted: #9aa5b3; --line: #2d3642;
    --accent: #5b9bf0; --accent-text: #0d1117; --accent-soft: #1e2f47;
    --good: #4fc98a; --good-soft: #17352a; --bad: #ef7478; --bad-soft: #3d2124; --warn: #e3b35c; --warn-soft: #3a2f1a;
    --bar: #5b9bf0;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 16px; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; }
.side a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--panel2); }
.side a.on { background: var(--accent-soft); color: var(--accent); }
.side .grow { flex: 1; }
.content { padding: 24px; max-width: 1240px; width: 100%; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .grow { flex: 1; min-width: 200px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600;
  padding: 7px 13px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.field small { font-weight: 400; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.sessions th:last-child, .sessions td:last-child { position: sticky; right: 0; background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--panel); }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--panel2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--panel2); color: var(--muted); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
.code-input { text-align: center; font-size: 24px; letter-spacing: 6px; font-weight: 700; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: 1px; }
.qcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.qcard .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qcard .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.qcard img { max-height: 160px; max-width: 100%; border-radius: 8px; }
.optline { display: flex; gap: 8px; padding: 5px 8px; border-radius: 6px; align-items: flex-start; }
.optline.ok { background: var(--good-soft); }
.optline img { max-height: 70px; }
.editor { display: flex; flex-direction: column; gap: 12px; }
.optedit { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.thumb { max-height: 56px; max-width: 90px; border-radius: 6px; }
.mathbar { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 400; }
.mathbar .btn { min-height: 38px; min-width: 44px; justify-content: center; font-size: 14px; }
.optprev { grid-column: 1 / -1; min-height: 0; }
.optprev[hidden] { display: none; }
.preview { min-height: 34px; padding: 8px 10px; border-radius: 8px; background: var(--panel2); overflow-x: auto; white-space: pre-wrap; }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 14, 20, .5); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; z-index: 40; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px; width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: 10px; font-weight: 500; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); color: #fff; }
/* Single-series column chart: one hue, thin marks, 2px gap, direct labels only. */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding-top: 22px; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1; height: 100%; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.chart .col i { display: block; width: min(34px, 80%); background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.chart .col:hover i { filter: brightness(1.15); }
.chart .col span { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; margin-bottom: 3px; }
.chart-x { display: flex; gap: 2px; margin-top: 5px; }
.chart-x span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--panel2); min-width: 70px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--bar); border-radius: 3px; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .brand { display: none; }
  .side .grow { display: none; }
  .content { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .optedit { grid-template-columns: auto 1fr; }
}
