:root {
  --accent: #39C5BB;
  --accent-deep: #1b8f87;
  --accent-soft: #e6f8f6;
  --accent-mid: #b9ece7;
  --coral: #ff7a59;
  --coral-soft: #ffe4dc;
  --amber: #f5b335;
  --ink: #1d2b2a;
  --muted: #6d7f7d;
  --line: #e4ecea;
  --bg: #fff;
  --radius: 18px;
  font-family: "Nunito", "Baloo 2", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.6; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.top { max-width: 1180px; margin: 0 auto; padding: 36px 20px 8px; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent-deep); font-weight: 800; }
h1 { margin: 2px 0 4px; font-size: clamp(28px, 5vw, 40px); line-height: 1.15; font-weight: 800; }
.sub { margin: 0; color: var(--muted); }

.layout { max-width: 1180px; margin: 0 auto; padding: 16px 20px 40px; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr) 390px; align-items: start; } .side { position: sticky; top: 16px; } }

.mapcard { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: #fcfefe; overflow: hidden; }
#map { display: block; width: 100%; height: auto; aspect-ratio: 900 / 761; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
#map:active { cursor: grabbing; }
.tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 2; }
.tools button { min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-weight: 700; }
.tools button:hover { border-color: var(--accent); }
.legend { list-style: none; margin: 0; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.k { width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid transparent; display: inline-block; }
.k-origin { background: var(--accent); }
.k-dest { background: var(--accent-deep); }
.k-path { background: var(--accent-mid); }
.k-cand { background: #fff; border-color: var(--accent); }
.k-wp { background: #fff; border-color: var(--amber); }

/* map */
.prov { fill: #eef3f2; stroke: #fff; stroke-width: 1.1; stroke-linejoin: round; cursor: pointer; transition: fill .15s; vector-effect: non-scaling-stroke; }
.prov:hover { fill: #dfeae8; }
.prov.p-out { fill: var(--accent-mid); }
.prov.p-ret { fill: var(--coral-soft); }
.prov.p-out.p-ret { fill: #ffd9b8; }
.prov.origin, .prov.p-out.origin, .prov.p-ret.origin, .prov.p-out.p-ret.origin { fill: var(--accent); }
.prov.dest, .prov.p-out.dest, .prov.p-ret.dest, .prov.p-out.p-ret.dest { fill: var(--accent-deep); }
.prov.blk { fill: #e3e8e7; opacity: .7; }
.prov.cand { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.prov.cand:hover { fill: #cdf3ef; }
.prov.wp { stroke: var(--amber); stroke-width: 2.4; }
.prov.sel { stroke: var(--ink); stroke-width: 2.4; }
.lbl { font-weight: 700; fill: #3b4f4d; text-anchor: middle; dominant-baseline: central; pointer-events: none; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; stroke-linejoin: round; }
.lbl.on { fill: #fff; stroke: rgba(0,0,0,.18); }
.lbl .n { fill: var(--accent-deep); font-weight: 800; }
.sea { stroke: #b6c6c4; stroke-dasharray: 3 4; stroke-width: 1.2; fill: none; pointer-events: none; vector-effect: non-scaling-stroke; }
.route { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; vector-effect: non-scaling-stroke; }
.route.out { stroke: var(--accent-deep); stroke-width: 3; stroke-dasharray: 7 6; }
.route.ret { stroke: var(--coral); stroke-width: 3; stroke-dasharray: 7 6; }
.route.done { stroke-width: 4; stroke-dasharray: 1; stroke-dashoffset: 0; }
.route.draw { animation: draw 2.6s cubic-bezier(.5, 0, .2, 1) both; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.node { fill: #fff; stroke-width: 2.4; pointer-events: none; vector-effect: non-scaling-stroke; }
.node.out { stroke: var(--accent-deep); }
.node.ret { stroke: var(--coral); }
.badge circle { fill: var(--amber); stroke: #fff; stroke-width: 1.5; }
.badge text { fill: #5b3d00; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
@media (prefers-reduced-motion: reduce) { .route.draw { animation: none; } .prov { transition: none; } }

/* side */
.side { display: grid; gap: 14px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: #fff; }
.card h2 { margin: 0 0 6px; font-size: 18px; }
.card p { margin: 6px 0; }
.label { display: block; margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.muted { color: var(--muted); font-size: 13.5px; }
.ok { color: var(--accent-deep); font-weight: 700; }
.warn { color: #b26a00; }
.count { font-size: 26px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }

.tabs { display: flex; gap: 8px; }
.tabs button { flex: 1; padding: 9px 12px; border: 1px solid var(--line); background: #fff; border-radius: 12px; font-weight: 700; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs button.ret.on { background: var(--coral); border-color: var(--coral); }

.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 8px 0 12px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 13.5px; font-weight: 700; border: 1px solid transparent; }
.chip.cur { background: var(--accent); color: #fff; }
.chip.btn { cursor: pointer; border-color: var(--accent-mid); }
.chip.btn:hover { border-color: var(--accent); }
.chip.wp { background: #fff3d6; }
.chip button { border: 0; background: none; padding: 0 0 0 4px; font-weight: 800; color: #8a6200; }
.arrow { color: var(--muted); font-size: 12px; }

.vote-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin: 0 0 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: left; overflow: hidden; }
.vote-row:hover:not(:disabled) { border-color: var(--accent); }
.vote-row .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); z-index: 0; transition: width .3s; }
.vote-row > span { position: relative; z-index: 1; }
.vote-row .nm { font-weight: 800; }
.vote-row.mine { border-color: var(--accent); }
.vote-row .ct { font-variant-numeric: tabular-nums; color: var(--muted); }

.btn { padding: 9px 16px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 12px; font-weight: 800; }
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); background: #fff; }
.btn.danger { background: #fff; color: #c2410c; border-color: #f3cdbd; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fld { display: grid; gap: 4px; margin: 8px 0; font-size: 14px; }
.fld > span { font-size: 13px; color: var(--muted); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 38px; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chk { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }

.log { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.log li { display: grid; grid-template-columns: 72px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.log li:first-child { border-top: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 2px; }
.tag { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 800; background: var(--accent-soft); color: var(--accent-deep); }
.tag.admin { background: #fff3d6; color: #8a6200; }
.tag.voter { background: #eef3f2; color: #4a5f5d; }
.loghead { display: flex; justify-content: space-between; align-items: center; }

.foot { max-width: 1180px; margin: 0 auto; padding: 0 20px 36px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; }
.link:hover { color: var(--accent-deep); }

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(92vw, 340px); }
dialog::backdrop { background: rgba(20, 40, 38, .35); }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; max-width: 90vw; padding: 10px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; pointer-events: none; transition: .25s; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #b3341a; }

/* tiny provinces: visible pin + leader line */
.pin { fill: #8fa6a3; stroke: #fff; stroke-width: 1.5; cursor: pointer; vector-effect: non-scaling-stroke; }
.pin.p-out { fill: var(--accent-deep); }
.pin.p-ret { fill: var(--coral); }
.pin.cand { fill: #fff; stroke: var(--accent); stroke-width: 2.5; }
.pin.origin { fill: var(--accent); }
.pin.dest { fill: var(--accent-deep); }
.pin.wp { stroke: var(--amber); stroke-width: 2.5; }
.pin.sel { stroke: var(--ink); stroke-width: 2.5; }
.lead { stroke: #8fa6a3; stroke-width: 1; pointer-events: none; vector-effect: non-scaling-stroke; }
