:root {
  --green: #008751;
  --green-dark: #006a40;
  --green-soft: #e6f4ed;
  --white: #ffffff;
  --ink: #111814;
  --muted: #5b6660;
  --line: #d7e0db;
  --bg: #f4f7f5;
  --card: #ffffff;
  --pres: #111111;
  --sen: #c8102e;
  --rep: #008751;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --err: #b91c1c;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-dark); }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px 48px; }

/* Flag header: green | white | green */
.flagbar { display: flex; height: 8px; }
.flagbar i { flex: 1; background: var(--green); }
.flagbar i:nth-child(2) { background: var(--white); }
header.top {
  background: var(--white); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  position: sticky; top: 0; z-index: 10;
}
header.top .back {
  border: 0; background: var(--green-soft); color: var(--green-dark); border-radius: 10px;
  padding: 8px 14px; font-weight: 700; cursor: pointer;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 24px; text-decoration: none; color: var(--ink); }
.logo .mark { width: 34px; height: 34px; border-radius: 9px; overflow: hidden; display: flex; border: 1px solid var(--line); }
.logo .mark i { flex: 1; background: var(--green); }
.logo .mark i:nth-child(2) { background: #fff; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 15px; color: var(--green-dark); font-weight: 900; }
.top .spacer { flex: 1; }
.top .pill { font-size: 14px; padding: 6px 10px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }

h1 { font-size: 26px; line-height: 1.2; margin: 24px 0 6px; }
h2 { font-size: 20px; margin: 0 0 4px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0 0; }

/* Home: the three election buttons */
.elections { display: grid; gap: 14px; margin-top: 8px; }
.election {
  display: flex; align-items: center; gap: 16px; width: 100%;
  border: 0; border-radius: 18px; padding: 22px 20px; cursor: pointer; text-align: left;
  color: #fff; font-size: 24px; font-weight: 800; min-height: 96px;
  box-shadow: 0 2px 0 rgba(0,0,0,.08);
}
.election small { display: block; font-size: 15px; font-weight: 500; opacity: .85; }
.election .arrow { margin-left: auto; font-size: 30px; }
.election.pres { background: var(--pres); }
.election.sen { background: var(--sen); }
.election.rep { background: var(--rep); }
.election:active { transform: translateY(1px); }
.home-links { margin-top: 28px; display: grid; gap: 10px; }
.linkbtn {
  display: block; text-align: center; padding: 16px; border-radius: var(--radius);
  background: var(--white); border: 2px solid var(--green); color: var(--green-dark);
  font-weight: 700; text-decoration: none;
}

/* Report page */
.band { color: #fff; padding: 14px 16px; font-weight: 800; font-size: 20px; }
.band.pres { background: var(--pres); } .band.sen { background: var(--sen); } .band.rep { background: var(--rep); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-top: 16px; }
.card.main { border: 2px solid var(--green); }
.step { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; font-size: 16px; margin-right: 8px; }
.card h2 { display: flex; align-items: center; }

.locstatus { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--green-soft); color: var(--green-dark); font-size: 16px; margin: 12px 0; }
.locstatus.warn { background: var(--warn-soft); color: var(--warn); }
.spin { width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

label.f { display: block; font-weight: 700; margin: 14px 0 6px; font-size: 16px; }
.picker {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 56px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; text-align: left; cursor: pointer;
}
.picker .ph { color: var(--muted); }
.picker:disabled { background: #f0f2f1; cursor: not-allowed; opacity: .7; }
.picker.set { border-color: var(--green); }
.picker .chev { color: var(--muted); flex: none; }
.codebox { display: flex; gap: 8px; }
input.txt, textarea.txt {
  width: 100%; min-height: 56px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
}
input.txt:focus, textarea.txt:focus, .picker:focus-visible { outline: none; border-color: var(--green); }
textarea.txt { min-height: 88px; resize: vertical; }
.btn {
  border: 0; border-radius: 12px; padding: 14px 18px; min-height: 56px; cursor: pointer;
  background: var(--green); color: #fff; font-weight: 800;
}
.btn.big { width: 100%; font-size: 21px; min-height: 64px; margin-top: 18px; }
.btn.ghost { background: var(--green-soft); color: var(--green-dark); }
.btn.outline { background: #fff; border: 2px solid var(--green); color: var(--green-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.or { text-align: center; color: var(--muted); margin: 16px 0 0; font-size: 15px; }
.err { color: var(--err); font-size: 16px; margin: 8px 0 0; font-weight: 600; }

.puinfo { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--green-soft); font-size: 16px; }
.puinfo b { display: block; font-size: 18px; }
.puinfo .code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--green-dark); }

/* Scores */
.scores { margin-top: 10px; display: grid; gap: 10px; }

/* Files */
.files { display: grid; gap: 12px; margin-top: 12px; }
.file { display: grid; grid-template-columns: 84px 1fr; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.file .thumb { width: 84px; height: 84px; border-radius: 8px; background: #eef1ef center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); text-align: center; overflow: hidden; }
.file .thumb video { width: 100%; height: 100%; object-fit: cover; }
.file .meta { font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.file .meta button { border: 0; background: none; color: var(--err); font-weight: 700; cursor: pointer; padding: 0; }
.file textarea { min-height: 56px; font-size: 16px; margin-top: 6px; }
.addfile { width: 100%; margin-top: 12px; }
.sheets { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.sheets .s { position: relative; width: 96px; height: 96px; border-radius: 10px; background: #eef1ef center/cover; }
.sheets .s button { position: absolute; top: -8px; right: -8px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--err); color: #fff; font-weight: 800; cursor: pointer; }

details.card summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 19px; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: "＋"; color: var(--green); font-size: 26px; }
details.card[open] summary::after { content: "－"; }

/* Full-screen picker */
.sheet { position: fixed; inset: 0; background: #fff; z-index: 50; display: flex; flex-direction: column; }
.sheet header { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet header h3 { margin: 0; font-size: 20px; flex: 1; }
.sheet .close { border: 0; background: var(--green-soft); color: var(--green-dark); border-radius: 10px; padding: 10px 14px; font-weight: 800; cursor: pointer; }
.sheet .search { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet li button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid #eef1ef; background: #fff; padding: 16px; cursor: pointer; min-height: 60px; }
.sheet li button:active, .sheet li button:hover { background: var(--green-soft); }
.sheet li .c { color: var(--muted); font-size: 14px; font-family: ui-monospace, Menlo, monospace; margin-right: 8px; }
.sheet .empty { padding: 24px 16px; color: var(--muted); }

/* Done screen */
.done { text-align: center; padding-top: 40px; }
.done .tick { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; font-size: 52px; color: #fff; background: var(--green); }
.done .tick.wait { background: var(--warn); }
.done .btn { width: 100%; margin-top: 12px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 528px; margin: 0 auto; background: var(--ink); color: #fff; padding: 14px 16px; border-radius: 12px; z-index: 60; font-size: 16px; }
.hidden { display: none !important; }

.kind { display: flex; gap: 6px; margin-top: 6px; }
.kind button { flex: 1; min-height: 44px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 15px; cursor: pointer; }
.kind button[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }

/* Score rows: logo | party + candidate | photo | votes */
.srow { display: grid; grid-template-columns: 44px minmax(0, 1fr) 104px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid #eef1ef; }
.srow.extra { grid-template-columns: 44px minmax(0, 1fr) 92px 28px; }
.logo-slot { display: flex; }
.srow input.party { font-weight: 800; text-transform: uppercase; min-height: 52px; padding: 10px; }
.plogo { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.plogo.none { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--muted); }
.pname { min-width: 0; line-height: 1.2; }
.pname b { display: block; font-size: 19px; font-weight: 800; }
.pname small { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cphoto { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: center 20%; background: #eef1ef; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.cphoto.none { display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: var(--muted); }
.srow input.votes { text-align: right; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; padding: 10px; }
.srow .x { border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; height: 56px; padding: 0; }
.sheet .pickrow { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
.sheet .pickfull { display: block; font-size: 13px; color: var(--muted); margin: 4px 0 0 54px; }

/* Location off: message + on/off switch */
.locstatus.off { flex-direction: column; align-items: stretch; gap: 12px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; color: var(--ink); font-size: 17px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .knob { position: relative; width: 56px; height: 32px; border-radius: 99px; background: #b8c2bd; flex: none; transition: background .2s; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { transform: translateX(24px); }
.switch input:focus-visible + .knob { outline: 3px solid var(--green-dark); outline-offset: 2px; }
.lochelp { font-size: 15px; color: var(--ink); background: #fff; border-radius: 10px; padding: 10px 12px; }

/* Every page ends with a way back to the start */
.homebtn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; margin: 28px auto 8px; max-width: 528px;
  border-radius: var(--radius); background: var(--green); color: #fff; font-weight: 800; font-size: 18px; text-decoration: none; }
.homebtn:active { background: var(--green-dark); }

/* "Report a problem / more photos": a clear tappable box */
details#incident { border: 3px solid var(--warn); background: var(--warn-soft); padding: 0 16px; margin-top: 20px; box-shadow: 0 2px 0 rgba(180, 83, 9, .15); }
details#incident > summary { gap: 12px; padding: 18px 16px; margin: 0 -16px; min-height: 76px; color: var(--ink); }
details#incident > summary::after { content: "＋"; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--warn); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 24px; }
details#incident[open] > summary::after { content: "－"; }
details#incident[open] > summary { border-bottom: 2px solid #f3d3a8; }
details#incident > :last-child { margin-bottom: 18px; }
details#incident[open] { background: #fff; }
.sumicon { font-size: 28px; flex: none; }
.sumtext { flex: 1; line-height: 1.3; }
.sumtext small { display: block; font-size: 14px; font-weight: 600; color: var(--warn); margin-top: 4px; }
details#incident[open] .sumtext small { display: none; }
