:root {
  --bg: #15171a; --panel: #1e2125; --line: #2e3238; --text: #e6e6e6; --muted: #8b929b;
  --accent: #cd412b; --ok: #4caf50; --bad: #e05252;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: normal; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
h1, h2 { margin: 0 0 12px; } h2 { font-size: 17px; margin-top: 24px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 32px; text-align: center; max-width: 360px; width: 100%; }

header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
nav { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; white-space: nowrap; }
nav button.active { color: var(--text); background: var(--line); }
.user { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); display: inline-block; }
.dot.on { background: var(--ok); }

main { padding: 16px; max-width: 1100px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; }

.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.row.between { justify-content: space-between; } .row.between h2 { margin: 0; }
input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 9px 11px; border-radius: 6px; font: inherit; }
.btn { background: var(--line); color: var(--text); border: 0; padding: 9px 14px; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.2); }
.btn.primary { background: var(--accent); }
.btn.danger { background: #7a2626; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: var(--panel); }
td.actions { text-align: right; display: flex; gap: 6px; justify-content: flex-end; }

.log { background: #0f1113; border: 1px solid var(--line); border-radius: 8px; padding: 10px; height: 55vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.log .line { padding: 1px 0; }
.log .time { color: var(--muted); margin-right: 8px; }
.log .warn { color: #e0b252; } .log .err { color: var(--bad); }
.log .who { color: #7fb3e0; font-weight: 600; margin-right: 6px; }
.log .team { color: #7fd17f; }

.candidates { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cand { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.cand.chosen { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.cand img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #0f1113; display: block; }
.cand .body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.cand .title { font-weight: 700; }
.cand .votes { font-size: 20px; font-weight: 700; }
.cand .small { font-size: 12px; color: var(--muted); }
.warn-box { background: #3a2f12; border: 1px solid #6b5520; color: #f0d79a; padding: 10px 12px; border-radius: 8px; margin-top: 12px; }
label.check { display: flex; gap: 6px; align-items: center; white-space: nowrap; color: var(--muted); }
label.check input { flex: none; }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px); }
.toast.error { border-color: var(--bad); }

@media (max-width: 640px) {
  header { padding: 8px 12px; } main { padding: 12px; }
  .user #me { display: none; }
}
