:root {
  color-scheme: light;
  --navy: #12233f;
  --navy-2: #1d3557;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --paper: #f4f6f9;
  --white: #ffffff;
  --ink: #182033;
  --muted: #667085;
  --line: #dfe4eb;
  --green: #0d7a55;
  --red: #b42318;
  --shadow: 0 18px 45px rgba(18, 35, 63, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-size: 16px; }
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.lock-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #31558a 0, transparent 38%), var(--navy); }
.lock-card { width: min(100%, 430px); padding: 32px; border-radius: 24px; background: var(--white); box-shadow: 0 30px 80px rgba(0,0,0,.24); }
.mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 24px; border-radius: 16px; color: white; background: var(--blue); font-size: 30px; font-weight: 800; transform: rotate(-4deg); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 7vw, 2.5rem); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: clamp(1.65rem, 6vw, 2.25rem); letter-spacing: -.035em; }
h3 { margin-bottom: 10px; font-size: 1.05rem; }
.eyebrow { margin-bottom: 5px; color: var(--blue); font-size: .77rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.eyebrow.light { color: #afc7f4; }
.muted, .privacy-note, .legal-note { color: var(--muted); line-height: 1.55; }
.privacy-note, .legal-note { margin: 18px 0 0; font-size: .84rem; }
label { display: block; margin: 18px 0 8px; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--ink); padding: 13px 14px; outline: none; }
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(37,99,235,.28); outline-offset: 2px; border-color: var(--blue); }

button { min-height: 48px; border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer; font-weight: 750; }
button:disabled { opacity: .42; cursor: not-allowed; }
.primary { color: white; background: var(--blue); }
.secondary { color: var(--navy); background: var(--blue-soft); }
.ghost { color: var(--navy); background: white; border: 1px solid var(--line); }
.danger { color: white; background: var(--red); }
.full { width: 100%; margin-top: 18px; }
.error { min-height: 1.3em; margin: 10px 0 0; color: var(--red); }
.success { min-height: 1.3em; margin: 10px 0 0; color: var(--green); }

.app { min-height: 100vh; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px max(18px, calc((100vw - 980px) / 2)); background: rgba(244,246,249,.94); border-bottom: 1px solid rgba(223,228,235,.8); backdrop-filter: blur(14px); }
.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.status-pill, .total-chip { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 11px; border-radius: 999px; color: var(--green); background: #e7f7f1; font-size: .82rem; font-weight: 800; white-space: nowrap; }
.status-pill.offline { color: #8a4b09; background: #fff1df; }
.icon-button { width: 42px; min-height: 42px; padding: 0; background: white; border: 1px solid var(--line); font-size: 1.3rem; }
main { width: min(100%, 980px); margin: 0 auto; padding: 22px 18px 40px; }
.view { display: none; }
.view.active { display: block; }
.summary-card { display: flex; align-items: end; justify-content: space-between; gap: 20px; min-height: 150px; padding: 26px; border-radius: 22px; box-shadow: var(--shadow); }
.summary-card.navy { color: white; background: linear-gradient(135deg, var(--navy), #234f83); }
.summary-card h2 { font-size: clamp(2rem, 11vw, 4.5rem); }
.summary-meta { max-width: 180px; margin: 0; color: #c8d8f3; font-size: .86rem; line-height: 1.4; text-align: right; }
.counter-button { width: 100%; min-height: 190px; margin-top: 18px; display: grid; place-content: center; gap: 4px; color: white; background: var(--blue); border-radius: 22px; box-shadow: 0 16px 35px rgba(37,99,235,.22); font-size: 1.12rem; }
.counter-button:active, .ballot-button:active { transform: scale(.985); }
.plus { font-size: 4rem; line-height: 1; font-weight: 850; }
.action-row { display: flex; gap: 10px; margin-top: 12px; }
.action-row > * { flex: 1; }
.panel { margin-top: 18px; padding: 20px; border-radius: 18px; background: white; border: 1px solid var(--line); box-shadow: 0 8px 26px rgba(18,35,63,.05); }
.panel-heading, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.small-muted { color: var(--muted); font-size: .83rem; }
.activity-list { margin: 12px 0 0; padding: 0; list-style: none; }
.activity-list li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.activity-list time { color: var(--muted); white-space: nowrap; }
.section-heading { margin-bottom: 16px; }
.contest-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: thin; }
.contest-tab { flex: 0 0 auto; max-width: 230px; min-height: 44px; padding: 10px 14px; color: var(--muted); background: white; border: 1px solid var(--line); }
.contest-tab.active { color: white; background: var(--navy); border-color: var(--navy); }
.ballot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ballot-button { position: relative; min-height: 118px; padding: 20px 54px 20px 18px; color: var(--navy); background: white; border: 1px solid var(--line); text-align: left; box-shadow: 0 7px 20px rgba(18,35,63,.04); }
.ballot-button:hover { border-color: #9db7e4; }
.ballot-count { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 999px; color: white; background: var(--blue); font-size: 1rem; }
.ballot-name { overflow-wrap: anywhere; line-height: 1.25; }
.sticky-actions { position: sticky; bottom: 82px; z-index: 5; padding: 10px; margin: 14px -4px 0; background: rgba(244,246,249,.92); backdrop-filter: blur(12px); border-radius: 14px; }
.settings-form, .export-panel, .danger-zone { max-width: 720px; }
.contest-editor { margin-top: 22px; padding-top: 4px; border-top: 1px solid var(--line); }
.contest-editor p { margin-bottom: 8px; color: var(--muted); font-size: .84rem; }
.export-panel { margin-top: 28px; }
.danger-zone { margin-top: 22px; padding: 18px; border: 1px solid #f1c7c3; border-radius: 16px; background: #fff8f7; }
.danger-zone summary { cursor: pointer; color: var(--red); font-weight: 800; }
.danger-zone p { color: var(--muted); }
.bottom-nav { position: fixed; z-index: 20; bottom: 0; left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 720px); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -8px 32px rgba(18,35,63,.08); backdrop-filter: blur(16px); }
.nav-item { min-height: 54px; display: grid; place-items: center; gap: 2px; padding: 5px; color: var(--muted); background: transparent; font-size: .78rem; }
.nav-item span { font-size: 1.3rem; line-height: 1; }
.nav-item.active { color: var(--blue); background: var(--blue-soft); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 95px; transform: translate(-50%, 18px); max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 999px; color: white; background: var(--navy); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .lock-card { padding: 25px 20px; }
  .summary-card { align-items: start; flex-direction: column; min-height: 165px; }
  .summary-meta { text-align: left; }
  .ballot-grid { grid-template-columns: 1fr; }
  .ballot-button { min-height: 92px; }
  .action-row { flex-direction: column; }
  .sticky-actions { bottom: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
