:root {
  color-scheme: light;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: #172b38;
  background: #edf2f3;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #172b38;
  --muted: #667781;
  --line: #dce4e6;
  --paper: #fff;
  --navy: #142b3a;
  --green: #07834f;
  --green-dark: #066c42;
  --amber: #e9a32b;
  --red: #c44d4d;
  --shadow: 0 24px 70px #17344712;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--navy); font-size: 15px; font-weight: 800; letter-spacing: .13em; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: white; background: var(--green); font-size: 18px; letter-spacing: 0; }
.brand-light { color: var(--green); }
.simulation-tag { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid #f0d6a6; border-radius: 999px; background: #fff8e9; color: #8b6017; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.simulation-tag span { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.app-content { min-height: calc(100vh - 148px); display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 18px 0 44px; }
.app-content > .topbar { width: 100%; }
.app-content > .panel { flex: 0 0 auto; }
.app-content > .result-controls { width: min(100%, 900px); }
.app-shell > .app-content { display: flex; }
.topbar { width: 100%; }
.site-footer { display: flex; justify-content: space-between; gap: 16px; padding: 19px 0 24px; color: #78868e; font-size: 11px; }

.panel { width: min(100%, 900px); overflow: hidden; border: 1px solid #e6ecee; border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.welcome-panel { display: grid; grid-template-columns: 1.05fr .95fr; }
.welcome-copy { padding: clamp(30px, 6vw, 68px); }
.eyebrow { margin: 0 0 14px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 16px; color: var(--navy); font-size: clamp(32px, 5vw, 51px); line-height: 1.08; letter-spacing: -.055em; }
.lead { max-width: 440px; margin-bottom: 25px; color: var(--muted); font-size: 15px; line-height: 1.75; }
.notice { display: flex; align-items: flex-start; gap: 11px; padding: 14px 15px; border: 1px solid #f1dfb9; border-radius: 12px; background: #fffaf0; color: #785e2e; font-size: 12px; line-height: 1.55; }
.notice strong { display: block; margin-bottom: 2px; color: #59451f; }
.notice-icon { display: grid; flex: 0 0 22px; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: #f7e6c3; font-weight: 800; }
.welcome-art { position: relative; display: grid; min-height: 430px; place-items: center; overflow: hidden; background: #142b3a; }
.welcome-art::before, .welcome-art::after { position: absolute; width: 310px; height: 310px; border: 1px solid #ffffff14; border-radius: 50%; content: ""; }
.welcome-art::after { width: 420px; height: 420px; }
.orbit { position: absolute; top: 18%; right: 17%; width: 10px; height: 10px; border-radius: 50%; background: #7bd4ae; box-shadow: 0 0 22px #7bd4ae; }
.ballot-card { z-index: 1; width: min(270px, 78%); padding: 25px; border: 1px solid #ffffff26; border-radius: 17px; background: #ffffff0d; color: white; transform: rotate(-4deg); backdrop-filter: blur(4px); }
.ballot-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 25px; color: #b7c8d0; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.ballot-lines { display: grid; gap: 13px; }
.ballot-line { height: 11px; border-radius: 4px; background: #ffffff1b; }
.ballot-line:nth-child(2) { width: 72%; }
.ballot-stamp { display: grid; width: 78px; height: 78px; margin: 27px auto 4px; place-items: center; border: 2px solid #69c69b; border-radius: 50%; color: #8be0b6; font-size: 11px; font-weight: 800; line-height: 1.25; text-align: center; transform: rotate(9deg); }
.actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 24px; }
.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 19px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 800; letter-spacing: .035em; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, .key:focus-visible, input:focus-visible { outline: 3px solid #36a87970; outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { color: white; background: var(--green); box-shadow: 0 7px 18px #07834f28; }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-outline { border-color: var(--line); color: var(--ink); background: white; }
.button-demo { border-color: #cfdeec; color: #315e7d; background: #f4f9fc; }
.button-danger { border-color: #efd5d5; color: #a34141; background: #fff8f8; }
.button-full { width: 100%; }
.fine-print { margin: 16px 0 0; color: #8a969c; font-size: 11px; line-height: 1.6; }

.ballot-panel { width: min(100%, 850px); padding: clamp(20px, 4vw, 38px); }
.ballot-top { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.ballot-top h1 { margin: 0; font-size: clamp(25px, 4vw, 35px); }
.voter-count { align-self: center; padding: 9px 12px; border-radius: 8px; background: #f0f5f3; color: #436255; font-family: "DM Mono", monospace; font-size: 12px; white-space: nowrap; }
.ballot-device { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(245px, .8fr); gap: 20px; padding: 20px; border-radius: 15px; background: #e9eeec; }
.vote-display { min-height: 340px; padding: 22px; border: 1px solid #d7dfdc; border-radius: 10px; background: #fff; }
.display-label { margin: 0 0 20px; color: #66746f; font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.office-label { margin: 0 0 15px; color: var(--ink); font-size: 13px; font-weight: 800; letter-spacing: .12em; }
.number-boxes { display: flex; gap: 7px; margin: 0 0 22px; }
.number-box { display: grid; width: 43px; height: 55px; place-items: center; border: 1px solid #cfd7d3; border-radius: 5px; background: white; color: var(--ink); font-family: "DM Mono", monospace; font-size: 26px; }
.candidate-info { min-height: 94px; display: flex; align-items: center; gap: 13px; padding-top: 12px; border-top: 1px solid #edf0ee; }
.avatar { display: grid; flex: 0 0 52px; width: 52px; height: 52px; place-items: center; border-radius: 50%; color: #165f42; background: #dff2e8; font-size: 17px; font-weight: 800; }
.candidate-name { margin: 0 0 4px; color: var(--ink); font-size: 15px; font-weight: 800; }
.candidate-party { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.empty-hint { color: #9aa5a0; font-size: 12px; }
.invalid-vote { color: #ae3939; }
.invalid-vote strong { display: block; font-size: 22px; letter-spacing: .04em; }
.invalid-vote span { color: #7c6565; font-size: 11px; }
.white-vote { color: #4b6270; font-size: 20px; font-weight: 800; }
.keyboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; align-content: start; padding: 4px; }
.key { min-height: 57px; border: 1px solid #cbd3d0; border-radius: 8px; color: #23333b; background: #fff; box-shadow: 0 2px 0 #cbd3d0; font-family: "DM Mono", monospace; font-size: 22px; transition: transform .1s ease; }
.key:active { transform: translateY(2px); box-shadow: none; }
.key.key-empty { visibility: hidden; }
.key-clear { color: #a34242; background: #fff8f8; font-family: "Manrope", sans-serif; font-size: 10px; font-weight: 800; }
.key-confirm { color: white; background: var(--green); box-shadow: 0 2px 0 var(--green-dark); font-family: "Manrope", sans-serif; font-size: 10px; font-weight: 800; }
.key-white { color: #325b73; background: #f6fafc; font-family: "Manrope", sans-serif; font-size: 10px; font-weight: 800; }
.ballot-help { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; color: #77857f; font-size: 10px; line-height: 1.5; }

.center-panel { width: min(100%, 570px); padding: clamp(28px, 6vw, 56px); text-align: center; }
.status-icon { display: grid; width: 65px; height: 65px; margin: 0 auto 20px; place-items: center; border-radius: 50%; color: #087547; background: #e3f5eb; font-size: 27px; }
.center-panel h1 { font-size: clamp(31px, 5vw, 43px); }
.center-panel .lead { margin-right: auto; margin-left: auto; }
.access-form { max-width: 330px; margin: 27px auto 0; text-align: left; }
.access-form label { display: block; margin-bottom: 8px; color: #50616a; font-size: 11px; font-weight: 800; }
.code-input { width: 100%; height: 54px; padding: 0 15px; border: 1px solid #d3dddf; border-radius: 9px; color: var(--ink); background: #fbfcfc; font-family: "DM Mono", monospace; font-size: 22px; letter-spacing: .32em; text-align: center; }
.error-message { min-height: 18px; margin: 9px 0 14px; color: #ae3939; font-size: 11px; font-weight: 700; }

.results-panel { width: min(100%, 900px); padding: clamp(22px, 4vw, 38px); }
.results-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.results-heading h1 { margin-bottom: 6px; font-size: clamp(28px, 4vw, 39px); }
.results-subtitle { margin: 0; color: var(--muted); font-size: 12px; }
.source-pill { padding: 8px 10px; border: 1px solid #dce7ed; border-radius: 999px; color: #42677d; background: #f5fafc; font-size: 9px; font-weight: 800; letter-spacing: .08em; white-space: nowrap; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 25px; }
.summary-card { padding: 14px; border: 1px solid #e6ebed; border-radius: 10px; background: #fbfcfc; }
.summary-card span { display: block; margin-bottom: 8px; color: #718087; font-size: 10px; }
.summary-card strong { color: var(--navy); font-family: "DM Mono", monospace; font-size: 22px; }
.summary-card small { display: block; margin-top: 3px; color: #99a3a8; font-size: 9px; }
.results-list { display: grid; gap: 13px; }
.result-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(100px, 1.4fr) auto; align-items: center; gap: 18px; }
.result-candidate { min-width: 0; }
.result-candidate strong, .result-candidate span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-candidate strong { color: var(--ink); font-size: 12px; }
.result-candidate span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.bar-track { height: 10px; overflow: hidden; border-radius: 99px; background: #e9efed; }
.bar-fill { height: 100%; min-width: 0; border-radius: inherit; background: linear-gradient(90deg, #0a8553, #6dc298); transition: width .7s ease; }
.result-number { min-width: 66px; text-align: right; }
.result-number strong { display: block; color: var(--navy); font-family: "DM Mono", monospace; font-size: 14px; }
.result-number span { display: block; margin-top: 3px; color: #78868c; font-size: 10px; }
.results-divider { height: 1px; margin: 24px 0 16px; background: var(--line); }
.results-foot { display: flex; justify-content: space-between; gap: 15px; color: #78868c; font-size: 10px; line-height: 1.6; }
.winner { color: #0b7449; font-weight: 800; }
.toast { position: fixed; z-index: 5; right: 20px; bottom: 20px; max-width: calc(100% - 40px); padding: 12px 16px; border-radius: 9px; color: white; background: var(--navy); box-shadow: 0 8px 25px #142b3a33; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-button { min-height: 36px; padding: 0 11px; font-size: 9px; }
.step-progress { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: -9px 0 19px; }
.step-progress span { height: 4px; border-radius: 10px; background: #e4eae8; }
.step-progress span.active { background: var(--green); }
.step-progress span.done { background: #8dc9a9; }
.review-title { max-width: 390px; margin: 0 0 10px; color: var(--navy); font-size: 13px; font-weight: 800; line-height: 1.5; }
.candidate-photo { flex: 0 0 70px; width: 70px; height: 80px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: #edf4f0; }
.confirmation-notice { margin-top: 13px; }
.demo-disclaimer { margin-bottom: 20px; }
.office-results { overflow: hidden; border: 1px solid #e3e9e9; border-radius: 11px; background: #fff; }
.office-results summary { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; color: var(--navy); cursor: pointer; font-size: 12px; font-weight: 800; }
.office-results summary span + span { color: var(--muted); font-size: 10px; font-weight: 500; text-align: right; }
.office-results-body { display: grid; gap: 12px; padding: 4px 16px 15px; }
.results-list { display: grid; gap: 11px; }
.admin-panel { width: min(100%, 1050px); padding: clamp(20px, 4vw, 36px); }
.admin-heading, .section-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.admin-heading { margin-bottom: 20px; }
.admin-heading h1 { margin-bottom: 6px; font-size: clamp(27px, 4vw, 38px); }
.admin-panel h2 { margin: 0 0 14px; color: var(--navy); font-size: 16px; letter-spacing: -.02em; }
.admin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 17px; }
.admin-section { min-width: 0; margin-top: 15px; padding: 19px; border: 1px solid #e6ebed; border-radius: 12px; background: #fff; }
.admin-columns .admin-section { margin-top: 0; }
.admin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.admin-form label, .inline-form label, .demo-config-form > label, .demo-target label { display: grid; gap: 6px; color: #52636b; font-size: 10px; font-weight: 800; }
.admin-form input, .admin-form select, .inline-form input, .demo-config-form input, .demo-config-form select {
  min-width: 0; height: 40px; padding: 0 10px; border: 1px solid #d6e0e1; border-radius: 7px; color: var(--ink); background: #fbfcfc; font-size: 11px; font-weight: 500;
}
.admin-form .actions { grid-column: 1 / -1; margin-top: 2px; }
.file-picker { display: flex; flex-direction: column; gap: 8px; padding: 13px; border: 1px dashed #b8c9cc; border-radius: 8px; color: #52636b; font-size: 11px; font-weight: 800; }
.file-picker input { max-width: 100%; font-size: 11px; }
.table-section { padding: 0; }
.section-title-row { align-items: center; padding: 17px 18px; }
.section-title-row h2 { margin: 0; }
.section-title-row > span { color: #7b898f; font-size: 10px; text-align: right; }
.table-scroll { overflow-x: auto; border-top: 1px solid #e7edef; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 10px 12px; color: #697980; background: #fafcfc; font-size: 9px; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid #edf1f2; color: #34464d; font-size: 10px; vertical-align: middle; }
td small { display: block; margin-top: 4px; color: #88969b; font-size: 9px; }
.status-tag { display: inline-block; padding: 5px 7px; border-radius: 999px; color: #765d25; background: #fff7e7; font-size: 8px; font-weight: 800; white-space: nowrap; }
.table-actions { display: flex; gap: 5px; }
.button.compact { min-height: 30px; padding: 0 8px; font-size: 9px; }
.demo-config-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.demo-target { display: grid; grid-template-columns: minmax(0, 1fr) 110px; align-items: end; gap: 9px; padding: 10px; border: 1px solid #edf0f1; border-radius: 8px; }
.demo-target select { width: 100%; }
.demo-config-form .actions { grid-column: 1 / -1; }
.inline-form { display: flex; align-items: end; gap: 10px; }
.inline-form label { width: min(100%, 250px); }
.admin-lead { margin: 0 0 12px; font-size: 12px; }
.audit-list { display: grid; max-height: 220px; gap: 0; overflow-y: auto; }
.audit-item { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-top: 1px solid #edf1f2; font-size: 10px; }
.audit-item strong { color: #324b54; }
.audit-item span { color: #77868c; text-align: right; }
.export-actions { margin-top: 8px; }
.finish-pulse .status-icon { animation: finish-pop .4s ease; }
.result-number { min-width: 68px; }
@keyframes finish-pop { 50% { transform: scale(1.12); } }

@media (max-width: 700px) {
  .app-shell { width: min(100% - 24px, 540px); }
  .topbar { min-height: 70px; }
  .app-content { min-height: calc(100vh - 130px); padding: 8px 0 26px; }
  .welcome-panel { grid-template-columns: 1fr; }
  .welcome-copy { padding: 30px 24px; }
  .welcome-art { min-height: 245px; }
  .ballot-card { width: 200px; padding: 17px; }
  .ballot-head { margin-bottom: 15px; }
  .ballot-lines { gap: 9px; }
  .ballot-stamp { width: 58px; height: 58px; margin-top: 16px; font-size: 9px; }
  .ballot-device { grid-template-columns: 1fr; gap: 13px; padding: 12px; }
  .vote-display { min-height: 260px; padding: 17px; }
  .keyboard { grid-template-columns: repeat(3, 1fr); }
  .key { min-height: 49px; }
  .ballot-help { flex-direction: column; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .result-row { grid-template-columns: minmax(120px, 1fr) minmax(65px, 1fr) auto; gap: 10px; }
  .result-candidate strong { font-size: 11px; }
  .site-footer { flex-direction: column; gap: 4px; padding: 15px 0 20px; font-size: 10px; }
  .nav-actions { gap: 6px; }
  .nav-actions .simulation-tag { padding: 7px 8px; font-size: 8px; }
  .nav-button { font-size: 8px; }
  .admin-columns { grid-template-columns: 1fr; }
  .admin-heading { flex-direction: column; }
  .admin-form, .demo-config-form { grid-template-columns: 1fr; }
  .demo-target { grid-template-columns: minmax(0, 1fr) 95px; }
  .demo-config-form .actions { grid-column: auto; }
  .admin-section { padding: 15px; }
  .table-section { padding: 0; }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  .section-title-row > span { text-align: left; }
  .office-results summary { flex-direction: column; }
  .office-results summary span + span { text-align: left; }
  .audit-item { flex-direction: column; gap: 4px; }
  .audit-item span { text-align: left; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form label { width: 100%; }
  .results-heading { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
