:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #667085; --line: #e3e6eb;
  --accent: #2f6fed; --accent-2: #1f55c4; --ok: #16794c; --warn: #b54708; --bad: #c0362c;
  --ok-bg: #e7f6ee; --warn-bg: #fff4e5; --bad-bg: #fdecea; --chip: #eef2f7;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.hidden { display: none !important; }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: #c5cad3; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-2); }
button.danger { color: var(--bad); border-color: #f1c4bf; }
button.danger.solid { background: var(--bad); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { padding: 3px 8px; font-size: 12px; }
input, select, textarea {
  font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c9dafc; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field input, .field select, .field textarea { width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.alert { padding: 10px 12px; border-radius: 6px; margin: 10px 0; }
.alert.err { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; white-space: nowrap; }
.st-invited { background: #e8effd; color: #1f55c4; }
.st-in_progress { background: #fff4e5; color: #b54708; }
.st-finished, .st-reviewed { background: var(--ok-bg); color: var(--ok); }
.st-suspended { background: #f2f4f7; color: #475467; }
.st-expired { background: var(--bad-bg); color: var(--bad); }
.st-archived { background: #f2f4f7; color: #98a2b3; }
.pass { color: var(--ok); font-weight: 600; }
.fail { color: var(--bad); font-weight: 600; }

table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; cursor: default; }
th.sortable { cursor: pointer; user-select: none; }
tr:hover td { background: #fafcff; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }

/* ---------------- candidate pages ---------------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.center-card { width: 100%; max-width: 560px; }
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.lang a { margin-left: 8px; font-size: 13px; }
.lang a.on { font-weight: 700; color: var(--text); }
.disclaimer li { margin: 8px 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; font-size: 14px; color: var(--text); }
.check input { margin-top: 3px; width: 18px; height: 18px; }

body.term { background: #0f1115; color: #e6e6e6; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 6px 14px; background: #161a22; border-bottom: 1px solid #262c38; font-size: 13px; }
.topbar .timer { font-family: var(--mono); font-size: 16px; font-weight: 700; color: #fff; }
.topbar .timer.warn { color: #fdb022; }
.topbar .timer.crit { color: #f97066; }
.topbar button { background: #222836; color: #e6e6e6; border-color: #343b4a; }
.topbar button:hover { border-color: #5a6375; }
.topbar button.finish { background: #b42318; border-color: #b42318; color: #fff; }
.conn { display: inline-flex; align-items: center; gap: 6px; color: #a7b0c0; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #667085; }
.conn.on::before { background: #32d583; }
.conn.wait::before { background: #fdb022; }
.conn.off::before { background: #f97066; }
.hint { color: #7d8597; font-size: 12px; }
#term { flex: 1; padding: 6px 4px 4px 8px; min-height: 0; }
.banner { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); background: #fdb022; color: #1d2330; padding: 10px 18px; border-radius: 8px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.4); z-index: 10; }
.banner.crit { background: #f97066; color: #fff; }
.overlay { position: fixed; inset: 0; background: rgba(10,12,16,.88); display: flex; align-items: center; justify-content: center; z-index: 20; font-size: 18px; text-align: center; padding: 24px; }

/* ---------------- admin ---------------- */
.admin-nav { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: #111827; color: #e5e7eb; }
.admin-nav a { color: #cbd5e1; }
.admin-nav a.on { color: #fff; font-weight: 600; }
.admin-nav .brand { color: #fff; margin-right: 12px; }
.admin-main { padding: 20px; max-width: 1500px; margin: 0 auto; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-card { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid2, .grid-card { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.task-list .task { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; background: #fff; }
.task .tid { font-family: var(--mono); font-weight: 700; margin-right: 6px; }
.task .text { white-space: pre-wrap; font-size: 13px; margin: 6px 0; }
.task.sent { border-color: #b7cdf8; background: #f7faff; }
.block-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 14px 0 6px; }
.cmd { border-bottom: 1px solid var(--line); padding: 6px 4px; }
.cmd .line { display: flex; gap: 8px; align-items: baseline; cursor: pointer; }
.cmd .line .t { color: var(--muted); font-size: 12px; min-width: 64px; font-family: var(--mono); }
.cmd .line .c { font-family: var(--mono); font-size: 13px; flex: 1; white-space: pre-wrap; word-break: break-all; }
.cmd .line .x { font-size: 12px; font-family: var(--mono); }
.cmd .line .x.bad { color: var(--bad); }
.cmd .out { background: #0f1115; color: #e6e6e6; padding: 8px 10px; border-radius: 6px; margin: 6px 0 4px 72px; max-height: 360px; overflow: auto; }
.cmd .cwd { color: var(--muted); }
.ev { padding: 4px 4px 4px 76px; font-size: 12px; color: var(--muted); border-bottom: 1px dashed var(--line); }
.ev.hl { color: var(--warn); background: var(--warn-bg); }
.group-head { background: #f2f4f7; padding: 6px 10px; font-weight: 600; margin-top: 10px; border-radius: 6px; }
.watch-box { background: #0f1115; border-radius: 8px; padding: 6px; height: 420px; }
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 10px; padding: 20px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.inv { background: #f6f8fb; border: 1px solid var(--line); padding: 10px; border-radius: 6px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; }
.big-pass { font-family: var(--mono); font-size: 22px; letter-spacing: 2px; font-weight: 700; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 60; }
.cmp td, .cmp th { white-space: nowrap; }
.cmp-cols { display: grid; gap: 10px; }
.cmp-cols .col { border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 8px; min-width: 0; }
.cmp-cols .col .c { font-family: var(--mono); font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); word-break: break-all; }
.score-input { width: 70px; }
.qr svg { width: 200px; height: 200px; }
/* card layout fixes */
.watch-box { overflow: auto; }
.kv div { overflow-wrap: anywhere; min-width: 0; }
.task .row { flex-wrap: nowrap; }
.task .row b { flex: 1; min-width: 0; }
.task .row button { white-space: nowrap; flex-shrink: 0; }
.task .row .right { display: none; }
/* language switches */
.lang-switch a, .tlang a { color: #9ca3af; margin-left: 6px; font-size: 13px; }
.lang-switch a.on, .tlang a.on { color: #fff; font-weight: 700; }
.lang-toggle button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

/* task cards: title on its own line, actions below the text */
.task .task-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.task .task-head b { flex: 1 1 auto; min-width: 0; }
.task .task-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.grid-card { grid-template-columns: 420px minmax(0, 1fr); }
@media (max-width: 1100px) { .grid-card { grid-template-columns: 1fr; } }
.topbar .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* self-paced tasks panel on the terminal page */
.topbar button.primary-ghost { background: #2f6fed; border-color: #2f6fed; color: #fff; }
.tasks-panel { position: fixed; top: 46px; right: 0; bottom: 0; width: min(520px, 45vw); background: #151922; border-left: 1px solid #2b3240;
  color: #e6e6e6; padding: 14px 16px; overflow: auto; z-index: 15; box-shadow: -10px 0 30px rgba(0,0,0,.35); }
.tasks-panel button { background: #222836; color: #e6e6e6; border-color: #343b4a; }
.tasks-panel .tp-task { border-top: 1px solid #2b3240; padding: 10px 0; }
.tasks-panel .tp-task h4 { margin: 0 0 6px; font-size: 14px; }
.tasks-panel .tp-task h4 span { font-family: var(--mono); color: #8fb3ff; margin-right: 6px; }
.tasks-panel pre { white-space: pre-wrap; font-size: 12.5px; color: #cfd6e4; margin: 0; }

/* ---------- monitoring */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); padding: 5px 10px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.mon-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.mon-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.mon-tile .k { font-size: 12px; color: var(--muted); }
.mon-tile .v { font-size: 24px; font-weight: 600; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.mon-tile .s { font-size: 12px; color: var(--muted); }
.mon-tile .bar { height: 4px; border-radius: 2px; background: var(--chip); margin-top: 8px; overflow: hidden; }
.mon-tile .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.mon-tile .bar i.warn { background: var(--warn); } .mon-tile .bar i.bad { background: var(--bad); }
.mon-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .mon-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .admin-nav { flex-wrap: wrap; gap: 8px 14px; padding: 10px 16px; } .admin-main { padding-left: 16px; padding-right: 16px; } }
.mon-h { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; flex-wrap: wrap; }
.mon-chart { position: relative; height: 200px; }
.mon-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mon-chart .grid line { stroke: var(--line); stroke-width: 1; }
.mon-chart .ax text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mon-chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mon-chart .ln2 { fill: none; stroke: #9db7f5; stroke-width: 1; stroke-dasharray: 3 3; }
.mon-chart .ar { fill: var(--accent); opacity: .10; }
.mon-chart .bars path { fill: var(--accent); }
.mon-chart .bars path.hl { fill: var(--accent-2); }
.mon-chart .xh { stroke: #98a2b3; stroke-width: 1; }
.mon-chart .dot { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.mon-chart .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.mon-tip { position: absolute; pointer-events: none; background: #1d2330; color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 2; }
.mon-tip b { font-variant-numeric: tabular-nums; }
