:root {
    --ink: #16222d;
    --muted: #5f6d78;
    --line: #d6dee5;
    --line-strong: #bcc8d1;
    --surface: #ffffff;
    --surface-soft: #f5f7f9;
    --surface-tint: #eef3f7;
    --primary: #17324d;
    --primary-dark: #0e2438;
    --accent: #b88722;
    --success: #176b46;
    --warning: #8b5b12;
    --danger: #962f35;
    --shadow: 0 8px 22px rgba(20, 36, 52, .07);
    --shadow-soft: 0 3px 12px rgba(20, 36, 52, .055);
    --radius: 10px;
    --radius-small: 7px;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: #edf1f4;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.container {
    width: min(1024px, calc(100% - 30px));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    color: #fff;
    background: rgba(23, 50, 77, .985);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .14);
}

.nav-wrap {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #fff;
    text-decoration: none;
    font-weight: 780;
    white-space: nowrap;
}

.brand:hover {
    color: #fff;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #16222d;
    background: var(--accent);
    font-size: .8rem;
}

.brand-name {
    font-size: 1.08rem;
}

.site-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.site-nav > a,
.link-button {
    border: 0;
    border-radius: 6px;
    padding: 8px 10px;
    color: #edf3f7;
    background: transparent;
    font-size: .92rem;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}

.site-nav > a:hover,
.link-button:hover {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

.inline {
    display: inline;
    margin: 0;
}

.nav-toggle {
    display: none;
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 6px;
    padding: 6px 10px;
    color: #fff;
    background: transparent;
}

.page-shell {
    min-height: calc(100vh - 112px);
    padding-block: 18px 26px;
}

.site-footer {
    color: var(--muted);
    background: #e3e8ec;
    border-top: 1px solid var(--line);
    font-size: .88rem;
}

.footer-content {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

h1,
h2,
h3 {
    margin: 0 0 7px;
    color: var(--ink);
    line-height: 1.22;
}

h1 {
    font-size: clamp(1.55rem, 2.2vw, 2rem);
}

h2 {
    font-size: 1.28rem;
}

h3 {
    font-size: 1.08rem;
}

p {
    margin: 0 0 9px;
}

ul,
ol {
    margin: 6px 0 9px;
    padding-left: 21px;
}

li + li {
    margin-top: 4px;
}

code {
    font-family: Consolas, "Courier New", monospace;
    font-size: .88rem;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 12px 0;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 13px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    background: linear-gradient(135deg, #ffffff 0%, #f7f9fb 100%);
    box-shadow: var(--shadow-soft);
}

.page-heading__content {
    max-width: 960px;
}

.page-heading__content p {
    margin: 0;
    color: var(--muted);
}

.page-heading__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 830;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.muted,
.help,
.helptext {
    color: var(--muted);
    font-size: .88rem;
}

.card,
.form-card,
.action-panel,
.result-panel,
.appointment-panel,
.informational-card,
.security-card,
.auth-card,
.receipt-box,
.integrity-box,
.success-panel,
.verification-result,
.privacy-notice,
.result-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.card,
.action-panel,
.result-panel,
.appointment-panel,
.informational-card,
.security-card,
.receipt-box,
.integrity-box,
.success-panel,
.verification-result,
.privacy-notice,
.result-card {
    padding: 14px;
}

.form-card {
    padding: 14px;
}

.auth-card,
.form-card-narrow {
    width: min(580px, 100%);
    margin-inline: auto;
    padding: 18px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 11px;
}

.dashboard-organisation-grid {
    grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
}

.dashboard-appointment-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.dashboard-section {
    margin-top: 13px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.dashboard-section > .table-wrap,
.dashboard-section > form > .table-wrap {
    box-shadow: none;
}

.dashboard-card {
    min-height: 140px;
    display: flex;
    flex-direction: column;
}

.dashboard-card .actions {
    margin-top: auto;
}

.card-topline {
    display: flex;
    justify-content: space-between;
    gap: 9px;
    margin-bottom: 6px;
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(280px, .75fr);
    gap: 13px;
    align-items: start;
}

.stack {
    display: grid;
    gap: 10px;
}

.actions,
.table-actions,
.form-actions,
.registry-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.button {
    appearance: none;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--primary);
    border-radius: 7px;
    padding: 7px 13px;
    color: #fff;
    background: var(--primary);
    font-size: .9rem;
    font-weight: 720;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    color: #fff;
    background: var(--primary-dark);
}

.button.secondary {
    color: var(--primary);
    background: var(--surface);
    border-color: #a8b6c1;
}

.button.secondary:hover {
    color: var(--primary-dark);
    background: var(--surface-soft);
}

.button.danger {
    background: var(--danger);
    border-color: var(--danger);
}

.button.small {
    min-height: 31px;
    padding: 5px 10px;
    font-size: .83rem;
}

.button.large {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 1rem;
}

.button-block {
    width: 100%;
}

.button[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.text-link,
.operation-link {
    font-size: .92rem;
    font-weight: 680;
}

form {
    margin: 0;
}

.form-grid,
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 9px 12px;
}

.form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-group,
.field-group,
.compact-field,
.form-card form > p,
.auth-card form > p {
    min-width: 0;
    margin: 0 0 9px;
}

.form-group label,
.field-group label,
.compact-field label,
.form-card form > p > label,
.auth-card form > p > label {
    display: block;
    margin-bottom: 4px;
    font-size: .88rem;
    font-weight: 760;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    min-height: 37px;
    border: 1px solid #b7c3cc;
    border-radius: 6px;
    padding: 6px 9px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

textarea {
    min-height: 76px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 50, 77, .12);
}

input[disabled],
select[disabled],
textarea[disabled] {
    color: #66717a;
    background: #eef1f3;
}

.checkbox-field {
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-field label {
    margin: 0;
}

.required-marker {
    color: var(--danger);
}

.field-errors,
.errorlist {
    margin: 4px 0 0;
    color: var(--danger);
    font-size: .86rem;
}

.field-errors p,
.errorlist li {
    margin: 0;
}

.form-footer-link {
    margin-top: 9px;
    text-align: center;
    font-size: .9rem;
}

.notice {
    margin-bottom: 11px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius-small);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.notice p:last-child {
    margin-bottom: 0;
}

.notice-info {
    border-left-color: #3d78a6;
    background: #f4f8fb;
}

.notice-warning {
    border-left-color: var(--warning);
    background: #fff9ed;
}

.notice-error {
    border-left-color: var(--danger);
    background: #fff4f4;
}

.notice-success {
    border-left-color: var(--success);
    background: #f0f8f4;
}

.messages {
    display: grid;
    gap: 7px;
    margin-bottom: 11px;
}

.message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    border: 1px solid #bfd1dd;
    border-radius: 7px;
    padding: 9px 11px;
    background: #edf4f8;
}

.message.success {
    background: #edf8f2;
    border-color: #acd3bd;
}

.message.error {
    background: #fff1f1;
    border-color: #dfb2b5;
}

.message.warning {
    background: #fff8e9;
    border-color: #e2ca94;
}

.message-close {
    border: 0;
    background: transparent;
    font-size: 1.35rem;
    cursor: pointer;
}

.badge {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    border-radius: 99px;
    padding: 3px 8px;
    color: #3e4a55;
    background: #e8edf1;
    font-size: .78rem;
    font-weight: 820;
    white-space: nowrap;
}

.status-ready,
.status-open {
    color: var(--success);
    background: #dff3e8;
}

.status-cancelled {
    color: var(--danger);
    background: #f7dfe1;
}

.status-read-only {
    color: var(--warning);
    background: #fff0cc;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th,
td {
    padding: 9px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #e5eaee;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #34434f;
    background: #edf1f4;
    font-size: .81rem;
    font-weight: 800;
    letter-spacing: .025em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f8fafb;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.row-error {
    background: #fff3f3;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 9px;
}

.metric {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.metric span {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 650;
}

.metric strong {
    display: block;
    margin-top: 2px;
    font-size: 1.28rem;
}

.definition-list,
.compact-definition-list {
    margin: 0;
    display: grid;
    gap: 6px;
}

.definition-list > div,
.compact-definition-list > div {
    display: grid;
    grid-template-columns: minmax(115px, .7fr) minmax(0, 1.3fr);
    gap: 9px;
    border-bottom: 1px solid #edf0f2;
    padding-bottom: 5px;
}

dt {
    color: var(--muted);
    font-size: .86rem;
}

dd {
    margin: 0;
    font-weight: 680;
}

.pagination {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 11px;
    font-size: .9rem;
}

.pagination__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.pagination__current {
    padding: 5px 8px;
}

.empty-state,
.home-empty-state {
    padding: 25px 15px;
    color: var(--muted);
    text-align: center;
}

.action-details {
    margin-top: 6px;
}

.action-details > summary {
    width: fit-content;
    list-style: none;
}

.action-details > summary::-webkit-details-marker {
    display: none;
}

.action-details__content {
    margin-top: 7px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-soft);
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 20, 30, .62);
}

.modal__dialog {
    position: relative;
    width: min(620px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .3);
}

.modal__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 11px;
    border-bottom: 1px solid var(--line);
    padding: 14px;
}

.modal__body {
    padding: 14px;
}

.modal__close {
    border: 0;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
}

.home-viewport,
.home-hero,
.election-hero,
.election-workspace {
    display: grid;
    gap: 13px;
}

.home-hero {
    grid-template-columns: minmax(0, 1.5fr) minmax(310px, .8fr);
}

.home-hero-main,
.home-security-card,
.election-hero {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.home-election-grid,
.result-grid,
.verification-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 11px;
}

.verification-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ballot-form {
    display: grid;
    gap: 12px;
}

.ballot-header {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.ballot-question {
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.ballot-question legend {
    padding: 0 6px;
    font-size: 1.06rem;
    font-weight: 760;
}

.final-warning {
    padding: 11px 12px;
    border: 1px solid #e6cf9a;
    border-radius: 8px;
    background: #fff9ed;
}

.receipt-box {
    text-align: center;
}

.success-mark {
    color: var(--success);
    font-size: 2.2rem;
}

.schedule {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.schedule > div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.schedule span {
    display: block;
    color: var(--muted);
    font-size: .84rem;
}

.plain-list {
    padding: 0;
    list-style: none;
}

.prose {
    max-width: 900px;
}

.error-page {
    min-height: 50vh;
    display: grid;
    place-items: center;
    text-align: center;
}

.error-code {
    font-size: 4.2rem;
    font-weight: 900;
    opacity: .18;
}

.step-label {
    display: inline-flex;
    margin-bottom: 6px;
    border-radius: 999px;
    padding: 3px 8px;
    color: var(--primary);
    background: var(--surface-tint);
    font-size: .8rem;
    font-weight: 800;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 980px) {
    .two-column,
    .home-hero {
        grid-template-columns: 1fr;
    }

    .form-grid.three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    html {
        font-size: 15px;
    }

    .container {
        width: min(100% - 18px, 1520px);
    }

    .nav-toggle {
        display: inline-flex;
    }

    .site-nav {
        position: absolute;
        top: 58px;
        left: 9px;
        right: 9px;
        display: none;
        flex-direction: column;
        align-items: stretch;
        border-radius: 0 0 9px 9px;
        padding: 7px;
        background: var(--primary);
        box-shadow: var(--shadow);
    }

    .site-nav.is-open {
        display: flex;
    }

    .site-nav > a,
    .link-button {
        width: 100%;
        text-align: left;
    }

    .page-heading,
    .section-heading,
    .footer-content,
    .pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading__actions,
    .actions {
        justify-content: flex-start;
    }

    .form-grid,
    .filter-grid,
    .form-grid.three,
    .verification-grid-two {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 8px;
    }

    .button {
        min-height: 38px;
    }
}

@media print {
    .site-header,
    .site-footer,
    .nav-toggle,
    .actions,
    .table-actions,
    .messages {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .page-shell {
        width: 100%;
        padding: 0;
    }

    .card,
    .form-card,
    .table-wrap,
    .dashboard-section,
    .page-heading {
        box-shadow: none;
    }
}

.context-help {
    display: flex;
    justify-content: flex-end;
    margin: -3px 0 8px;
}
.context-help a {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--surface);
    font-size: .88rem;
    font-weight: 700;
    text-decoration: none;
}
