/* ============================================================
   Qest design system, light theme, carried over from the phase 0
   presentation so the two tools look like one.
   Rules that hold here and must not be broken:
     - square corners everywhere, radius 0, badges and pills included
     - cyan is highlight, link, active state and data viz; never white on cyan
     - cyan as text on light is #0C87B8, not #83E1FF
     - a primary action is a cyan fill with dark text
     - no gradients and no glow; headings in sentence case
   ============================================================ */
:root {
    --qest-cyan: #83e1ff;
    --qest-cyan-400: #5bc7ee;
    --qest-cyan-600: #0c87b8;
    --qest-cyan-ink: #04222e;
    --bg: #f4f4f5;
    --surface: #ffffff;
    --surface-2: #f7f7f8;
    --border: #ebebef;
    --border-strong: #d4d4d8;
    --text: #0a0a0b;
    --text-2: #52525b;
    --text-3: #a1a1aa;
    --accent: #83e1ff;
    --accent-text: #0c87b8;
    --ok: #16a34a;
    --warn: #d97706;
    --bad: #dc2626;
    --ok-bg: #eaf7ee;
    --warn-bg: #fdf3e6;
    --bad-bg: #fcecec;
    --accent-bg: #eaf9ff;
    --mute-bg: #f4f4f5;
    --dpd: #dc0032;
    --font-display: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 400 14px/1.6 var(--font-sans);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; margin: 0; }

.gh {
    display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.gh .brand { font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.gh .right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.gh .meta { font: 200 11px/1 var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-2); }

.appnav {
    display: flex; align-items: stretch; background: var(--surface);
    border-bottom: 1px solid var(--border); position: sticky; top: 56px; z-index: 29; padding-left: 20px;
}
.appnav .appname {
    display: flex; align-items: center; font-family: var(--font-display); font-size: 17px;
    font-weight: 800; letter-spacing: -0.02em; padding-right: 28px; white-space: nowrap;
}
.appnav .tabs { display: flex; align-items: stretch; overflow-x: auto; }
.appnav .tab {
    display: flex; align-items: center; padding: 0 18px; height: 48px; color: var(--text-2);
    font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: none;
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.appnav .tab:hover { color: var(--text); }
.appnav .tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

.wrap { max-width: 1580px; margin: 0 auto; padding: 20px 20px 72px; }

.card { background: var(--surface); border: 1px solid var(--border); margin-bottom: 16px; }
.card > h2 {
    display: flex; align-items: center; gap: 10px; padding: 14px 18px;
    border-bottom: 1px solid var(--border); font-size: 17px;
}
.card > h2 .n {
    font-family: var(--font-mono); font-weight: 200; color: var(--text-2); font-size: 11px;
    letter-spacing: 0.16em; text-transform: uppercase; margin-left: auto;
}
.card .body { padding: 18px; }
.card .body.tight { padding: 0; }
.sub { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.hint { background: var(--surface-2); border-left: 2px solid var(--accent); padding: 11px 14px; font-size: 13px; margin: 0 0 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    background: var(--surface-2); text-align: left; color: var(--text-2); padding: 9px 12px;
    border-bottom: 1px solid var(--border-strong); white-space: nowrap;
    font: 200 11px/1.3 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tw { overflow-x: auto; }
td.note { color: var(--text-2); font-size: 12px; max-width: 420px; white-space: normal; }

.b {
    display: inline-block; padding: 2px 8px; font: 500 11px/16px var(--font-sans);
    white-space: nowrap; border: 1px solid transparent;
}
.b.g { background: var(--ok-bg); color: #116534; border-color: #c6e9d3; }
.b.r { background: var(--bad-bg); color: #991b1b; border-color: #f3c9c9; }
.b.a { background: var(--warn-bg); color: #92400e; border-color: #f3ddbe; }
.b.n { background: var(--mute-bg); color: var(--text-2); border-color: var(--border-strong); }
.b.bl { background: var(--accent-bg); color: var(--qest-cyan-600); border-color: #bde7f7; }
.b.dpd { background: var(--accent); color: var(--qest-cyan-ink); border-color: var(--accent); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); padding: 18px; }
.kpi .t {
    font: 200 11px/1.3 var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--accent-text); margin-bottom: 10px;
}
.kpi .v {
    font-family: var(--font-display); font-weight: 800; font-size: 34px; line-height: 1.05;
    letter-spacing: -0.025em;
}
.kpi .v small { font-family: var(--font-sans); font-size: 14px; color: var(--text-2); font-weight: 400; letter-spacing: 0; }
.kpi .d { font-size: 12.5px; color: var(--text-2); margin-top: 8px; line-height: 1.5; }
.kpi.acc { border-top: 2px solid var(--accent); }
.kpi.ok { border-top: 2px solid var(--ok); }
.kpi.warn { border-top: 2px solid var(--warn); }
.kpi.bad { border-top: 2px solid var(--bad); }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: var(--lw, 190px) 1fr 110px; align-items: center; gap: 12px; font-size: 13px; }
.bar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { background: var(--mute-bg); height: 18px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--qest-cyan-400); transition: width 0.4s; }
.bar .fill.dpd { background: var(--dpd); }
.bar .fill.mut { background: var(--border-strong); }
.bar .fill.g { background: var(--ok); }
.bar .fill.r { background: var(--bad); }
.bar .val { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.bar .val b { color: var(--text); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

.ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, input[type='search'], .btn {
    height: 32px; border: 1px solid var(--border-strong); background: var(--surface);
    padding: 0 10px; font: 400 13px var(--font-sans); color: var(--text); outline: none; border-radius: 0;
}
select:focus, input[type='search']:focus { border-color: var(--qest-cyan-600); box-shadow: 0 0 0 2px var(--accent-bg); }
.btn { cursor: pointer; }
.btn:hover { border-color: var(--qest-cyan-600); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--qest-cyan-ink); font-weight: 600; }
.btn.danger { background: var(--bad-bg); border-color: #f3c9c9; color: #991b1b; font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }
.list { background: var(--surface); border: 1px solid var(--border); max-height: 72vh; overflow: auto; }
.list .row {
    display: flex; gap: 8px; align-items: baseline; padding: 9px 14px;
    border-bottom: 1px solid var(--border); cursor: pointer;
}
.list .row:hover { background: var(--surface-2); }
.list .row.on { background: var(--accent-bg); box-shadow: inset 2px 0 0 var(--accent); }
.list .row .dom { font-weight: 600; }
.list .row .m { margin-left: auto; color: var(--text-2); font-size: 12px; white-space: nowrap; }
.dot { width: 7px; height: 7px; flex: none; background: var(--text-3); }
.dot.accepted { background: var(--ok); }
.dot.rejected { background: var(--bad); }
.dot.judge_right { background: var(--ok); }
.dot.judge_wrong { background: var(--bad); }
.dot.both_wrong { background: var(--warn); }
/* The judge's correction beside the stored read: what it struck, added, changed. */
tr.del td { background: var(--bad-bg); text-decoration: line-through; color: #991b1b; }
tr.add td { background: var(--ok-bg); }
td.chg { background: var(--warn-bg); }
td.chg .was { display: block; color: var(--text-2); font-size: 11px; text-decoration: line-through; }
img.shot { max-width: 100%; border: 1px solid var(--border); display: block; margin-top: 8px; }
.empty { color: var(--text-2); padding: 28px 18px; }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* Grafy (SVG a pruhy), barvy z proměnných motivu. */
.donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut svg { width: 150px; height: 150px; flex: none; }
.donut .dc { font: 600 17px var(--font-display, var(--font-sans)); fill: var(--text); }
.donut .ds { font: 10px var(--font-sans); fill: var(--text-3); }
.legend { display: grid; gap: 6px; font-size: 13px; min-width: 180px; flex: 1; }
.legend .lg { display: flex; align-items: center; gap: 8px; }
.legend .lg b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.cols { display: flex; align-items: flex-end; gap: 2px; padding-bottom: 18px; position: relative; }
.cols .col { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.cols .cbar { background: var(--qest-cyan); border-radius: 2px 2px 0 0; min-height: 1px; }
.cols .cbar.dpd { background: var(--dpd); }
.cols .cbar.g { background: var(--ok); }
.cols .cbar.mut { background: var(--border-strong); }
.cols .clab { position: absolute; bottom: -17px; left: 0; font-size: 10px; color: var(--text-3); white-space: nowrap; }
.gauge { margin: 8px 0 2px; }
.gauge .gtrack { position: relative; height: 10px; background: var(--mute-bg); border-radius: 5px; }
.gauge .gtrack.mut { opacity: 0.5; }
.gauge .gfill { height: 100%; border-radius: 5px; background: var(--qest-cyan); }
.gauge .gfill.g { background: var(--ok); }
.gauge .gfill.r { background: var(--warn); }
.gauge .gmark { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--text); }
.gauge .gnote { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.stack { display: flex; height: 26px; border-radius: 4px; overflow: hidden; font-size: 11px; color: #fff; }
.stack > div { display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.ak { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.ak .akc { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface); }
.ak .akc h3 { margin: 0 0 2px; font-size: 13px; }
.ak .akc .sub { margin: 0; }
.pts { display: inline-block; font-size: 10px; color: var(--text-3); margin-left: 4px; }
.dots { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); display: inline-block; }
.dots i.on { background: var(--qest-cyan-600); }

/* Loading. The bar along the top runs while any request is out: an
   aggregate on a cold database takes tens of seconds, and a page that does
   not move for that long reads as broken. Square like everything else, no
   gradient. */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 30%;
  background: var(--accent-text);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
}
body.busy::before {
  opacity: 1;
  animation: busy-bar 1.1s ease-in-out infinite;
}
@keyframes busy-bar {
  from { transform: translateX(-100%); }
  to { transform: translateX(340%); }
}

.loading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 28px 18px;
  color: var(--text-2);
}
.loading .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-text);
  animation: spin 0.8s linear infinite;
  flex: none;
}
.loading .slow {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--text-3);
  opacity: 0;
  animation: appear 0.3s ease-out 4s forwards;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { to { opacity: 1; } }

/* A detail about to be replaced, dimmed only after a moment so that quick
   J/K stepping does not flicker. */
.pending { opacity: 0.45; pointer-events: none; transition: opacity 0.15s 0.2s; }

@media (prefers-reduced-motion: reduce) {
  body.busy::before { animation: none; width: 100%; }
  .loading .spinner { animation: none; }
}
