:root {
    --red: #c8102e;
    --red-dark: #8f0d21;
    --red-deep: #4a0712;
    --gold: #e8c547;
    --ink: #1c1214;
    --muted: #6b5458;
    --paper: #fff8f7;
    --card: #ffffff;
    --line: rgba(200, 16, 46, 0.14);
    --shadow: 0 14px 40px rgba(74, 7, 18, 0.12);
    --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    min-height: 100vh;
    font-family: "Segoe UI", "PT Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 480px at 10% -10%, rgba(200, 16, 46, 0.08), transparent 55%),
        radial-gradient(900px 420px at 100% 0%, rgba(232, 197, 71, 0.12), transparent 50%),
        var(--paper);
}

a { color: inherit; }

.hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 28px),
        linear-gradient(180deg, var(--red) 0%, var(--red-dark) 62%, var(--red-deep) 100%);
    background-size: 28px 28px, auto;
    box-shadow: 0 8px 28px rgba(74, 7, 18, 0.28);
}

.hero::before {
    content: "";
    position: absolute;
    inset: auto -80px -140px auto;
    width: 360px;
    height: 360px;
    background: url("/kprf.gif") center / cover no-repeat;
    opacity: 0.12;
    pointer-events: none;
}

.hero-inner {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 24px 32px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.logo-link {
    flex: 0 0 auto;
    display: block;
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    outline: 2px solid rgba(255, 255, 255, 0.35);
    outline-offset: 3px;
}

.logo-link img {
    display: block;
    width: 132px;
    height: 132px;
    border-radius: 14px;
}

.eyebrow {
    margin: 0 0 8px;
    font-size: 13px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
    font-weight: 700;
}

h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 5vw, 48px);
    line-height: 1.05;
    font-weight: 800;
}

.lead {
    margin: 0 0 16px;
    max-width: 42rem;
    font-size: 18px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.9);
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
    font-weight: 600;
}

.pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
}

main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.section-head { margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: clamp(22px, 3vw, 30px); }
.section-head p { margin: 6px 0 0; color: var(--muted); }

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.card-label {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.card-view .card-label { color: var(--red-dark); background: rgba(200, 16, 46, 0.08); }
.card-input .card-label { color: #fff; background: var(--red); }

.card h3 { margin: 0 0 8px; font-size: 24px; }
.card p { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }

.home-section { margin-bottom: 28px; }
.home-card { padding: 16px; }
.home-card .btn { min-height: 64px; }

.btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    font: inherit;
}

.btn small { display: block; font-size: 12px; font-weight: 600; opacity: 0.75; margin-top: 2px; }

.btn-arrow {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.btn-arrow svg {
    display: block;
    width: 28px;
    height: 28px;
}

.btn-outline { background: #fff; border-color: rgba(200, 16, 46, 0.18); }
.btn-outline .btn-arrow { background: rgba(200, 16, 46, 0.08); color: var(--red); }
.btn-outline:hover { border-color: var(--red); }

.btn-solid {
    color: #fff;
    background: linear-gradient(180deg, #e21a3a 0%, var(--red) 100%);
    box-shadow: 0 8px 18px rgba(200, 16, 46, 0.22);
}

.btn-solid .btn-arrow { background: rgba(255, 255, 255, 0.16); }
.btn-wide { width: 100%; justify-content: center; }

.btn-danger {
    color: #fff;
    justify-content: center;
    background: linear-gradient(180deg, #b01028 0%, #7a0b1c 100%);
    box-shadow: 0 8px 18px rgba(122, 11, 28, 0.22);
}

.admin-precinct {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.admin-precinct p { margin: 0 0 8px; }

.admin-confirm {
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(200, 16, 46, 0.08);
    border: 1px solid rgba(200, 16, 46, 0.2);
}

.admin-confirm p {
    margin: 0;
    color: var(--red-dark);
    font-weight: 700;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.form-actions .btn {
    width: auto;
}

.form-card { max-width: 520px; margin: 0 auto; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 700; margin-bottom: 6px; }
.captcha-image {
    display: block;
    width: min(100%, 400px);
    height: auto;
    border: 1px solid rgba(200, 16, 46, 0.16);
    border-radius: 10px;
}

.form-row select,
.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(200, 16, 46, 0.2);
    border-radius: 12px;
    font: inherit;
    background: #fff;
}

.form-row textarea {
    min-height: 140px;
    resize: vertical;
}

.toolbar .links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    background: rgba(200, 16, 46, 0.08);
    color: var(--red-dark);
    font-weight: 600;
}

.alert-ok { background: #e8f5e9; color: #1b5e20; }

.protocol-table,
.results-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 32px;
}

.protocol-table th,
.protocol-table td,
.results-table th,
.results-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0e4e4;
    vertical-align: top;
}

.protocol-table th,
.results-table th { background: #fff0f0; text-align: left; }

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.sort-btn:hover,
.sort-btn.is-active { color: var(--red-dark); }
.sort-arrow { min-width: 0.8em; color: var(--red); }

.protocol-table input[type="text"],
.protocol-table input[type="number"] {
    width: 100px;
    padding: 8px;
    border: 1px solid #d7b4b8;
    border-radius: 8px;
    font: inherit;
}

.protocol-table tr.is-bad td { box-shadow: inset 3px 0 0 var(--red); background: #fff5f5; }

.muted { color: var(--muted); }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.stat {
    background: #fff;
    border: 3px solid var(--red);
    border-radius: 16px;
    padding: 12px 16px;
    min-width: 160px;
    text-align: center;
    font-weight: 700;
}

.links a { color: var(--red-dark); font-weight: 700; }
.links .protocol-more {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.chart-wrap {
    position: relative;
    height: 480px;
    margin-top: 40px;
}

.chart-refresh {
    display: flex;
    justify-content: center;
    margin: 20px 0 0;
}

footer {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px 36px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 14px;
}

footer a { color: var(--red-dark); font-weight: 700; text-decoration: none; }

@media (max-width: 760px) {
    .hero-inner { flex-direction: column; align-items: flex-start; padding: 22px 18px; }
    .logo-link img { width: 96px; height: 96px; }
    .grid { grid-template-columns: 1fr; }
    main { padding: 22px 16px 36px; }
}
