:root {
    color-scheme: light;
    --ink: #1d2927;
    --muted: #62706c;
    --paper: #f3f5ef;
    --white: #fff;
    --green: #176e61;
    --green-dark: #0e4b43;
    --lime: #d3e6a8;
    --coral: #e8795f;
    --line: #dce3db;
    --danger: #a8392b;
    --serif: Georgia, 'Times New Roman', serif;
    --sans: 'Trebuchet MS', 'Segoe UI', sans-serif;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.auth-page { display: grid; min-height: 100svh; place-items: center; padding: 28px 18px; background: radial-gradient(ellipse at 9% 92%, rgba(232,121,95,.17), transparent 28rem), linear-gradient(132deg, #e8eee1 0%, #f5f4ed 55%, #e7f0e9 100%); }
.auth-shell { width: min(100%, 430px); padding: 34px clamp(22px, 7vw, 42px) 30px; background: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.8); border-radius: 12px; box-shadow: 0 24px 70px rgba(27,54,46,.12); animation: rise-in .45s ease both; }
.brand-mark { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px 14px 14px 4px; background: var(--green); color: white; font: 20px var(--serif); }
.eyebrow { margin: 25px 0 7px; color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font: 42px/1.02 var(--serif); }
h1 span { color: var(--green); }
.auth-copy { max-width: 310px; margin: 15px 0 23px; color: var(--muted); line-height: 1.55; }
.form-stack { display: grid; gap: 10px; }
.field-label { margin-top: 5px; font-size: 13px; font-weight: 700; }
input[type=email], input[type=password], input[type=text], input[type=tel], input[type=date], input[type=time], input[type=number], select, textarea { width: 100%; min-height: 48px; padding: 12px 13px; color: var(--ink); background: #fff; border: 1px solid #cbd6cc; border-radius: 7px; outline: none; }
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,110,97,.14); }
.check-row { display: flex; align-items: flex-start; gap: 10px; line-height: 1.4; }
.check-row input { width: 20px; height: 20px; flex: 0 0 auto; margin: 0; accent-color: var(--green); }
.remember-row { margin: 8px 0 7px; color: #43524d; font-size: 13px; }
.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 12px; padding: 11px 17px; border: 0; border-radius: 7px; font-weight: 700; cursor: pointer; text-decoration: none; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); }
.button-wide { width: 100%; margin-top: 5px; }
.button-secondary { background: var(--white); color: var(--ink); border: 1px solid #bfcbc2; }
.auth-shell .install-app-button { margin-bottom: 14px; }
.auth-footnote { margin: 22px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.notice { padding: 12px 14px; border-radius: 7px; font-size: 13px; line-height: 1.45; }
.notice-error { margin: 0 0 16px; background: #fff0ed; color: var(--danger); border: 1px solid #f1cbc3; }
.notice-success { background: #ebf4dc; color: #315a25; border: 1px solid #d3e2be; }
.app-header { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 16px; padding: 10px clamp(16px, 4vw, 48px); background: var(--green-dark); color: white; }
.app-brand { display: flex; align-items: center; gap: 10px; color: white; font-weight: 700; text-decoration: none; }
.app-brand .brand-mark { width: 36px; height: 36px; border-radius: 10px 10px 10px 3px; background: var(--lime); color: var(--green-dark); font-size: 16px; }
.app-nav { display: flex; align-items: center; gap: 8px; }
.app-nav a, .app-nav button { min-height: 38px; padding: 9px 11px; color: white; background: transparent; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; font-size: 12px; text-decoration: none; cursor: pointer; }
.app-nav form { margin: 0; }
.app-nav .install-app-button { background: var(--lime); border-color: var(--lime); color: var(--green-dark); font-weight: 700; }
.app-nav .install-app-button:hover { background: white; border-color: white; }
.app-nav .install-app-button:focus-visible, .install-dialog-close:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.install-dialog { width: min(460px, calc(100vw - 32px)); max-width: none; padding: 22px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--white); box-shadow: 0 20px 60px rgba(14,32,28,.25); }
.install-dialog::backdrop { background: rgba(14,32,28,.58); }
.install-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.install-dialog h2 { margin: 0; font: 24px/1.15 var(--serif); }
.install-dialog p, .install-dialog li { color: var(--muted); font-size: 14px; line-height: 1.5; }
.install-dialog p { margin: 14px 0; }
.install-dialog ol { display: grid; gap: 10px; margin: 0; padding-left: 22px; }
.install-dialog li strong { color: var(--ink); }
.install-dialog-close { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: white; font-size: 22px; line-height: 1; cursor: pointer; }
.header-user { padding: 0 7px; color: #e6efe6; font-size: 12px; }
.app-nav a:hover, .app-nav button:hover { background: rgba(255,255,255,.12); }
.app-main { width: min(100%, 1100px); margin: 0 auto; padding: 26px clamp(14px, 3vw, 32px) 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { font-size: 34px; }
.page-heading p { margin: 8px 0 0; color: var(--muted); }
.panel { padding: 20px; background: var(--white); border: 1px solid var(--line); border-radius: 9px; }
.panel-title { margin: 0 0 12px; font: 24px var(--serif); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.status-pill::before { width: 8px; height: 8px; border-radius: 50%; background: currentColor; content: ''; }
.status-online { background: #e7f3e5; color: #286347; }
.status-offline { background: #fff0e8; color: #9c4a2d; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-field { display: grid; gap: 6px; }
.form-field label, .question-title { font-size: 14px; font-weight: 700; line-height: 1.4; }
.form-field small, .field-hint { color: var(--muted); font-size: 12px; }
.section-label { margin: 26px 0 12px; padding-bottom: 9px; color: var(--green); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.choice { display: flex; min-height: 46px; align-items: center; gap: 10px; padding: 10px 11px; background: #fbfcf9; border: 1px solid var(--line); border-radius: 7px; line-height: 1.35; cursor: pointer; }
.choice:has(input:checked) { background: #edf5e6; border-color: #8db4a0; }
.choice input { width: 19px; height: 19px; flex: 0 0 auto; margin: 0; accent-color: var(--green); }
.question-block { margin: 22px 0 26px; }
.question-number { display: inline-grid; width: 27px; height: 27px; place-items: center; margin-right: 7px; border-radius: 50%; background: var(--lime); color: var(--green-dark); font-size: 12px; font-weight: 700; vertical-align: middle; }
.candidate-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .95fr) minmax(0, 1fr); gap: 12px; align-items: center; margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #f8faf6; }
.candidate-name { min-width: 0; font-size: 13px; font-weight: 600; }
.candidate-row select { min-width: 0; }
.candidate-row select:disabled { background-color: #edf1ec; color: var(--muted); opacity: 1; }
.actions-row { display: flex; justify-content: space-between; gap: 10px; padding-top: 22px; border-top: 1px solid var(--line); }
.subtle-button { min-height: 44px; padding: 9px 13px; border: 1px solid #bfcbc2; border-radius: 7px; background: white; color: var(--ink); font-weight: 700; cursor: pointer; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { min-height: 112px; padding: 17px; background: var(--green-dark); border-radius: 8px; color: white; }
.metric:nth-child(2) { background: #d9e8bb; color: var(--ink); }
.metric:nth-child(3) { background: #e77c63; color: #fff; }
.metric:nth-child(4) { background: #e8eee6; color: var(--ink); }
.metric strong { display: block; font: 31px var(--serif); }
.metric span { display: block; margin-top: 4px; font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.hidden { display: none !important; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 20; max-width: min(390px, calc(100vw - 36px)); padding: 13px 16px; border-radius: 8px; background: var(--ink); color: white; box-shadow: 0 12px 35px rgba(14,32,28,.25); }
.progress-track { height: 5px; overflow: hidden; margin: 18px 0 22px; border-radius: 8px; background: #dfe7df; }
.progress-track span { display: block; height: 100%; background: var(--coral); transition: width .2s ease; }
.offline-banner { margin-bottom: 16px; padding: 11px 13px; border-radius: 7px; background: #fff0e8; color: #874322; font-size: 13px; }
.sync-controls { display: flex; align-items: center; gap: 9px; }
.capture-meta { min-height: 20px; margin: -10px 0 8px; color: var(--muted); font-size: 12px; }
.pending-panel { margin-top: 20px; }
.pending-panel p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.pending-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13px; }
.pending-row button { min-height: 36px; padding: 7px 10px; border: 1px solid #d6c6bf; border-radius: 6px; background: white; color: var(--danger); font-weight: 700; }
.header-user { white-space: nowrap; }
.app-footer { padding: 0 18px 26px; color: var(--muted); text-align: center; font-size: 11px; }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.distribution-row { display: flex; justify-content: space-between; gap: 15px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.distribution-row strong { color: var(--green); }
.distribution-heading { margin: 16px 0 5px; font-size: 13px; }
.filter-panel, .records-panel, .create-user-panel { margin-bottom: 16px; }
.filter-actions, .form-actions { display: flex; align-items: end; gap: 8px; }
.panel-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.user-filters { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr) auto; align-items: end; gap: 12px; }
.filter-actions { display: flex; align-items: center; gap: 12px; }
.text-link { color: var(--green-dark); font-size: 13px; font-weight: 700; }
.users-table td { vertical-align: middle; }
.users-table td:first-child { min-width: 230px; }
.role-pill { display: inline-flex; min-height: 30px; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.role-admin { background: #e7f3e5; color: #286347; }
.role-enumerator { background: #f4eddd; color: #76552a; }
.edit-user-link { display: inline-flex; min-height: 36px; align-items: center; text-decoration: none; }
.empty-users { padding: 24px 10px; color: var(--muted); text-align: center; }
.users-pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; color: var(--muted); font-size: 12px; }
.users-pagination > div { display: flex; align-items: center; gap: 12px; }
.users-pagination a, .pagination-disabled { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--green-dark); font-weight: 700; text-decoration: none; }
.pagination-disabled { color: #89938e; }
.pagination-current { white-space: nowrap; }
.user-form { max-width: 760px; }
.user-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.user-form-actions { display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.user-form-actions .text-link { padding: 10px 0; }
.field-error { color: var(--danger) !important; }
.user-form-note { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.survey-stepper-wrap { margin: 14px 0 8px; }
.step-caption { margin: 0 0 12px; color: var(--green-dark); font-size: 13px; font-weight: 700; }
.survey-stepper { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.survey-stepper::before { position: absolute; top: 17px; right: 12.5%; left: 12.5%; height: 2px; background: var(--line); content: ''; }
.survey-stepper li { position: relative; display: grid; justify-items: center; gap: 7px; color: var(--muted); font-size: 11px; text-align: center; }
.survey-stepper li > span:first-child { display: grid; width: 36px; aspect-ratio: 1; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--muted); font-size: 11px; font-weight: 700; }
.survey-stepper li[aria-current="step"] { color: var(--green-dark); font-weight: 700; }
.survey-stepper li[aria-current="step"] > span:first-child { border-color: var(--green); background: var(--green); color: white; }
.survey-stepper li.is-complete > span:first-child { border-color: #a7c794; background: var(--lime); color: var(--green-dark); }
.survey-step:not([hidden]) { animation: step-arrive .22s ease both; }
.survey-step > .panel { margin-bottom: 0; }
.step-actions { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 16px; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(220,227,219,.9); background: rgba(243,245,239,.96); backdrop-filter: blur(12px); }
.step-actions-next { grid-template-columns: 1fr auto; }
.step-actions > :first-child { justify-self: start; }
.step-actions > :last-child { justify-self: end; }
.step-actions .field-hint { margin: 0; text-align: center; }
.step-actions .btn { min-height: 46px; }
.step-actions-final { grid-template-columns: auto 1fr auto; }
.step-actions-final .subtle-button[type="reset"] { justify-self: center; }
.step-actions-final .btn-primary { min-width: 190px; }
.step-caption, .survey-stepper li, .step-actions .btn { letter-spacing: 0; }

@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes step-arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 720px) {
    .app-header { align-items: flex-start; flex-direction: column; gap: 7px; }
    .app-nav { width: 100%; overflow-x: auto; padding-bottom: 2px; }
    .app-nav a, .app-nav button { flex: 0 0 auto; }
    .app-main { padding-top: 20px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .choice-grid, .report-grid { grid-template-columns: 1fr; }
    .candidate-row { grid-template-columns: minmax(0, 1fr); gap: 9px; margin: 10px 0; padding: 12px; }
    .candidate-name { font-size: 14px; }
    .user-filters, .user-form-grid { grid-template-columns: 1fr; }
    .filter-actions { align-items: center; }
    .users-pagination { align-items: flex-start; flex-direction: column; }
    .users-pagination > div { width: 100%; justify-content: space-between; gap: 6px; }
    .pagination-current { text-align: center; }
    .sync-controls { width: 100%; justify-content: space-between; }
    .panel { padding: 16px; }
    .actions-row .button, .actions-row .subtle-button { flex: 1; }
    .step-actions { margin-right: -14px; margin-left: -14px; padding-right: 14px; padding-left: 14px; }
    .step-actions .field-hint { display: none; }
    .step-actions-final { grid-template-columns: auto 1fr; }
    .step-actions-final .subtle-button[type="reset"] { justify-self: end; }
    .step-actions-final .btn-primary { grid-column: 1 / -1; width: 100%; }
    .survey-stepper li { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}