:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #0f1a33;
  --muted: #56627a;
  --line: #dde3ec;
  --brand: #061a51;      /* logon tummansininen */
  --accent: #0058e6;     /* logon sininen */
  --accent-soft: #e5efff;
  --teal: #00c2d6;       /* logon turkoosi */
  --good: #1d7a46;
  --good-soft: #e3f4ea;
  --warn-soft: #fff6dc;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1226; --surface: #121b33; --text: #e8edf7; --muted: #9aa8c2; --line: #263352;
    --brand: #ffffff; --accent: #5c9dff; --accent-soft: #16264a; --teal: #3fdcec; --good: #5cc78b; --good-soft: #17301f;
    --warn-soft: #3a3118; --danger: #ff8a80; --danger-soft: #3b1f1d;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .25rem; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 64px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.empty { text-align: center; padding: 40px 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.crumbs { margin: 0 0 8px; font-size: .9rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.inline { display: inline; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
label .muted { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input[readonly], textarea[readonly] { background: var(--bg); color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; margin: 0; }
legend { font-weight: 600; padding: 0 4px; }
.code-input { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; letter-spacing: 2px; text-transform: uppercase; text-align: center; }

.btn { display: inline-block; font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.big { padding: 12px 22px; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.danger-text { color: var(--danger) !important; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.flash-success { background: var(--good-soft); }
.flash-error { background: var(--danger-soft); }
.notice { background: var(--warn-soft); padding: 10px 14px; border-radius: 6px; }
.notice ul { margin: 4px 0 0; }

.badge { display: inline-block; font-size: .8rem; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-weight: 500; }
.badge-open { background: var(--good-soft); border-color: transparent; color: var(--good); }
.badge-draft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge-closed { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
@media (max-width: 700px) { .table { display: block; overflow-x: auto; } }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { white-space: nowrap; }
.actions form + form { margin-left: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; color: var(--muted); font-size: .9rem; }
.tile-n { font-size: 1.5rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.tile-n.small-n { font-size: 1rem; }

.question .options { margin: 6px 0 0; padding-left: 20px; }
.ballot-q { padding: 14px 16px; }
.choice { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.choice:hover { background: var(--bg); }
.choice input { transform: scale(1.2); }
.blank-choice { color: var(--muted); }
.review { border-bottom: 1px solid var(--line); padding: 8px 0; }
.review ul { margin: 4px 0; }
.check-big { font-size: 3rem; color: var(--good); }

.bars { width: 100%; border-collapse: collapse; }
.bars th { text-align: left; font-weight: 500; padding: 6px 12px 6px 0; width: 35%; }
.bars td { padding: 6px 0 6px 12px; }
.bar-cell { width: 45%; }
.bar { width: 100%; height: 14px; display: block; }
.bar rect { fill: var(--line); }
.bars tr.win .bar rect { fill: var(--accent); }
.bars tr.win th { font-weight: 700; }
.bars tr.blank th { color: var(--muted); font-weight: 400; }
@media (max-width: 600px) { .bars th { width: auto; } .bar-cell { width: 30%; } }

.danger-zone { margin-top: 40px; padding: 16px; border: 1px solid var(--danger-soft); border-radius: var(--radius); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }

/* Kokousnäkymät */
.election-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; padding: 14px 18px; }
.election-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 260px; }
.election-main .badge { align-self: flex-start; }
.election-title { font-weight: 600; font-size: 1.05rem; text-decoration: none; color: var(--text); }
a.election-title:hover { text-decoration: underline; }
.election-row .badge + .badge { margin-left: 4px; }
.needs-vote { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.muted-row { opacity: .85; }
.notice.row.space { justify-content: space-between; margin: 12px 0; }
.waiting p { margin: 4px 0; }
.adhoc { border-style: dashed; margin-top: 28px; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.table tr.removed td { color: var(--muted); }

/* Logo ja brändi */
.brand { display: flex; align-items: center; }
.logo, .logo img { display: block; height: auto; }
.brand .logo img { height: 30px; width: auto; }
.hero-logo { display: flex; justify-content: center; margin: 24px 0 8px; }
.hero-logo .logo img { height: 56px; width: auto; }
.topbar { border-bottom: 0; box-shadow: 0 1px 0 var(--line); position: relative; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; background: linear-gradient(90deg, var(--accent), var(--teal)); }
h1 { color: var(--brand); }
@media (prefers-color-scheme: dark) { h1 { color: var(--text); } }
body:has(.hero-logo) .brand { visibility: hidden; }
@media (prefers-color-scheme: dark) { .btn.danger { background: #c42b1f; border-color: #c42b1f; } }
