:root { --bg: #f2f4f7; --card: #fff; --ink: #191919; --muted: #666; --line: #dde2e7; --navy: #010547; --accent: #123f87; --red: #c81e1e; --ok: #12663a; --warn: #9a5b00; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--navy); color: #fff; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; line-height: 1.15; }
.brand img { width: 32px; height: 32px; flex: none; }
.brand .bn { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.brand #brand { display: block; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; font-size: 13px; }
.stats span b { font-size: 15px; }
.me { font-size: 12px; opacity: .9; }
.sound { border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff; border-radius: 8px; padding: 5px 8px; cursor: pointer; }
.sound.on { background: #1b7f4b; border-color: #1b7f4b; }
.tabs { display: flex; gap: 2px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 0; z-index: 900; }
.tabs button { border: 0; background: transparent; padding: 12px 14px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; font-size: 14px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs b { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
.tabs b:empty { display: none; }
main { padding: 14px 16px 60px; max-width: 1400px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
label { display: block; font-weight: 600; margin: 8px 0; font-size: 13px; }
label.check { display: flex; gap: 8px; align-items: center; }
input, select, textarea { font: inherit; padding: 8px 9px; border: 1px solid #c5ccd3; border-radius: 8px; background: #fff; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; }
label.check input { width: auto; display: inline; margin: 0; }
button { font: inherit; font-weight: 700; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.ghost { background: #fff; color: var(--accent); }
button.danger { background: var(--red); border-color: var(--red); }
button.okb { background: var(--ok); border-color: var(--ok); }
button:disabled { opacity: .5; cursor: default; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row label { margin: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.pill { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; background: #eef1f4; }
.pill.red { background: #fde8e8; color: var(--red); }
.pill.green { background: #e6f4ec; color: var(--ok); }
.pill.amber { background: #fff3dc; color: var(--warn); }
.pill.party { background: #1f2a44; color: #fff; }

/* alerts */
.alert { border: 2px solid var(--line); border-radius: 12px; background: #fff; padding: 14px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.alert.open { border-color: var(--red); animation: pulse 1.2s infinite; background: #fff6f6; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(200,30,30,.18); } }
.alert h4 { margin: 0 0 4px; font-size: 17px; }
.alert .acts { display: flex; flex-direction: column; gap: 6px; min-width: 170px; }
.alert .acts a { text-align: center; }
a.btn { display: inline-block; text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--accent); color: var(--accent); background: #fff; }
a.btn.call { background: var(--ok); border-color: var(--ok); color: #fff; font-size: 16px; }
.empty { padding: 30px; text-align: center; color: var(--muted); background: #fff; border-radius: 12px; border: 1px dashed var(--line); }

/* result review */
.sub { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1fr); gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
@media (max-width: 800px) { .sub { grid-template-columns: 1fr; } }
.sub .photo img { width: 100%; max-height: 480px; object-fit: contain; background: #111; border-radius: 8px; cursor: zoom-in; }
.sub .photo .nophoto { padding: 40px; text-align: center; background: #fafafa; border: 1px dashed #ccc; border-radius: 8px; color: var(--muted); }
.sub h4 { margin: 0; font-size: 16px; }
.sub .flags { margin: 8px 0; padding: 0; list-style: none; }
.sub .flags li { color: var(--red); font-weight: 600; }
.sub .flags li.okf { color: var(--ok); }
.vt td input { width: 90px; text-align: right; font-size: 16px; padding: 6px; font-variant-numeric: tabular-nums; }
.vt td input.changed { border-color: var(--warn); background: #fff8e6; }
.chip { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.sub .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

#map { height: calc(100vh - 190px); min-height: 420px; border-radius: 12px; border: 1px solid var(--line); }

.codebox { background: #fffbea; border: 1px solid #f2d27a; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.codebox code { font-size: 18px; font-weight: 800; letter-spacing: .08em; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.mcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 12px; }
.mcard img, .mcard video { width: 100%; height: 200px; object-fit: contain; background: #111; border-radius: 8px; cursor: zoom-in; }
.mcard.hidden-item { opacity: .55; }
dialog#zoom { padding: 0; border: 0; max-width: 96vw; max-height: 96vh; background: #000; }
dialog#zoom img { max-width: 96vw; max-height: 90vh; display: block; }
dialog#zoom button { position: absolute; top: 8px; right: 8px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #191919; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 2000; font-weight: 600; }
.cand-row { display: grid; grid-template-columns: 1.4fr 1.2fr .7fr 60px 60px 70px 70px; gap: 6px; align-items: center; margin-bottom: 6px; }
.cand-row input[type=color] { padding: 0; height: 34px; width: 100%; }
.place-row { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.place-row input { flex: 1; }
.card textarea { width: 100%; }
.cand-row input, .cand-row select { width: 100%; min-width: 0; }
.cand-row label.check { justify-content: center; margin: 0; }
.cand-row label.check input { width: auto; }

/* party staff logins: admin-only controls are not shown (the server refuses them anyway) */
.party-user .super-only { display: none !important; }
.notlisted { max-width: 560px; margin: 60px auto; background: #fff; border: 1px solid #e3e7e5; border-radius: 14px; padding: 24px; }

.sub .photo video { width: 100%; max-height: 320px; background: #000; border-radius: 8px; margin-top: 8px; display: block; }

.vt b.over { color: var(--red); }
.vt b.over::after { content: ' ⚠'; }

/* ---------- phones: compact header, tables become cards, setup rows stack ---------- */
@media (max-width: 639px) {
  .top { flex-direction: column; align-items: stretch; gap: 8px; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12px; }
  .stats span b { font-size: 14px; }
  .me { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  input, select, textarea { font-size: 16px; }
  .tbl { border: 0; overflow: visible; }
  table.cardify, table.cardify tbody { display: block; background: transparent; }
  table.cardify thead { display: none; }
  table.cardify tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; }
  table.cardify td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 4px 0; text-align: right; min-height: 28px; overflow-wrap: anywhere; }
  table.cardify td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; max-width: 45%; }
  table.cardify td:first-child { font-weight: 700; font-size: 15px; justify-content: flex-start; text-align: left; }
  table.cardify td:first-child::before, table.cardify td[data-label=""]::before { display: none; }
  table.cardify td:empty { display: none; }
  .place-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .place-row input { grid-column: 1 / -1; }
}
.ph-only { display: none; }
@media (max-width: 639px) {
  /* candidate editor: name / party + short / colour, order, on ballot, save */
  .cand-row { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
  .cand-row.muted { display: none; }
  .cand-row [data-k="name"] { grid-column: 1 / -1; }
  .cand-row [data-k="party"] { grid-column: span 3; }
  .cand-row label.check { gap: 4px; font-size: 12px; }
  .ph-only { display: inline; }
}

/* flag stripe under the header, as on the public site */
.flag { height: 8px; background: linear-gradient(to bottom, #e00411 0 2px, #fff 2px 3px, #0025c1 3px 5px, #fff 5px 6px, #028419 6px 8px); }

/* IEC staff: the IEC check tab only. Party staff: they can read it, not edit it. */
.iec-user .tabs button:not([data-tab="iec"]), .iec-user .super-only:not(.edit-iec), .iec-user #sound { display: none !important; }
.party-user .edit-iec { display: none !important; }

/* second key: password page (login.js) */
.pwgate { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: var(--navy); overflow: auto; }
.pwcard { width: min(100%, 400px); background: #fff; border-radius: 16px; padding: 32px 24px 24px; display: grid; gap: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.pwcard picture img { display: block; width: 200px; height: auto; margin: 0 auto; }
.pwsub { margin: -4px 0 0; text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pwcard h2 { margin: 8px 0 0; font-size: 20px; color: var(--navy); }
.pwcard p { margin: 0; }
.pwcard label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.pwcard input { min-height: 44px; font-size: 16px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; }
.pwcard input[readonly] { background: #f2f4f7; color: var(--muted); }
.pwcard button { min-height: 48px; font-size: 16px; }
.pwerr { color: var(--red); font-weight: 700; }
.linkb { background: none; border: 0; color: #fff; text-decoration: underline; font: inherit; font-size: 12px; padding: 4px; cursor: pointer; min-height: 0; }

/* read-only desks (radio/TV, fact-checkers, observers): the IEC check, nothing to edit */
.monitor-user .edit-iec, .monitor-user [data-iec-del], .monitor-user [data-confirm] { display: none !important; }

.ours-hint { display: block; font-size: 12px; font-weight: 600; color: var(--muted); min-height: 16px; }
.ours-hint.same, #iecSum .same { color: var(--ok); }
.ours-hint.diff, #iecSum .diff { color: var(--red); }
