:root {
    --bg: #f7f3ea;
    --ink: #221b16;
    --muted: #6f665e;
    --line: #ded4c4;
    --panel: #fffaf1;
    --green: #246b48;
    --green-dark: #174832;
    --red: #b53b35;
    --gold: #c08a2c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 16px clamp(16px, 4vw, 48px);
    background: #fffdf8;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-size: 18px;
}
.brand img {
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
}
.brand span { display: grid; gap: 2px; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); font-size: 13px; font-weight: 700; }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.container { width: min(1180px, calc(100% - 28px)); margin: 24px auto 60px; }

.login-card {
    min-height: calc(100vh - 150px);
    display: grid;
    grid-template-columns: 1.1fr 420px;
    gap: 32px;
    align-items: center;
}

.login-card h1, .toolbar h1, .panel h1, .candidate-preview h1 {
    margin: 0;
    line-height: 1.06;
}

.login-card h1 { font-size: clamp(38px, 6vw, 76px); max-width: 780px; }
.login-card p { color: var(--muted); font-size: 18px; max-width: 600px; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 800; margin: 0 0 8px; }

.panel, .login-card form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}
.danger-zone {
    margin-top: 18px;
    border-color: #efc1bd;
    background: #fff6f4;
}
.danger-zone h2 {
    margin: 0;
}
.danger-zone p {
    color: #7d514d;
}

.narrow { max-width: 760px; margin: 0 auto; }
.compact { max-width: 420px; }

.form { display: grid; gap: 14px; }
.form.inline { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: end; }
.form label, .filters label { display: grid; gap: 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.form input, .form select, .filters select, .filters input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    font: inherit;
}

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex !important; align-items: center; gap: 8px; }
.check input { width: auto; min-height: auto; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf8;
    color: var(--ink);
    padding: 10px 16px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.primary {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.primary:hover { background: var(--green-dark); }
button:disabled,
.primary:disabled {
    opacity: .55;
    cursor: not-allowed;
    background: #7f8f84;
    border-color: #7f8f84;
}
.small { min-height: 36px; padding: 8px 12px; }
.danger { color: var(--red); }
.danger-button {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}
.danger-button:hover {
    background: #8f2824;
    border-color: #8f2824;
}
.toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.kpis div {
    background: #fffdf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}
.kpis strong { display: block; font-size: 34px; }
.kpis span { color: var(--muted); }

.filters { display: flex; gap: 12px; align-items: end; margin: 12px 0 18px; flex-wrap: wrap; }
.filters label { min-width: 260px; }

.grid.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.person-card {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 12px;
    align-items: center;
    background: #fffdf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.person-card img, .avatar {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    background: #eadfce;
}

.person-card strong { display: block; margin-bottom: 5px; }
.person-card span { display: block; color: var(--muted); font-size: 13px; }
.person-card.done { opacity: .72; }
.mini-actions { display: flex; gap: 12px; margin-top: 8px; }
.badge { color: var(--green) !important; font-weight: 800; }
.badge.pending {
    color: var(--muted) !important;
    background: #eee5d7;
    border-radius: 999px;
    padding: 5px 9px;
    display: inline-block;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fffdf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.table th, .table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { background: #ede4d4; font-size: 13px; color: #493f34; }
.table tr:last-child td { border-bottom: 0; }
.ranking tbody tr:first-child { background: #fff4d6; }
.table-scroll {
    width: 100%;
    overflow-x: auto;
}
.scores-table {
    min-width: 920px;
}
.scores-table td,
.scores-table th {
    white-space: nowrap;
}

.score-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.candidate-preview {
    background: #fffdf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    position: sticky;
    top: 88px;
}
.candidate-preview img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 8px; background: #eadfce; }
.candidate-preview p { color: var(--muted); margin: 8px 0 0; }
.candidate-facts {
    display: grid;
    gap: 3px 8px;
    grid-template-columns: auto 1fr;
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 13px;
}
.candidate-facts dt {
    color: var(--muted);
    font-weight: 900;
}
.candidate-facts dd {
    margin: 0;
    color: var(--ink);
}
.score-form h2 { margin: 0; }
.hint, .empty { color: var(--muted); }
.score-row {
    grid-template-columns: 1fr 160px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}
.score-row small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.live-total {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 18px;
    align-items: center;
    padding: 18px 20px;
    border: 2px solid #9bc4aa;
    border-radius: 8px;
    background: #e8f2ec;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7);
}
.live-total span {
    color: var(--green-dark);
    font-weight: 900;
    font-size: 18px;
}
.live-total strong {
    color: var(--green-dark);
    font-size: clamp(38px, 6vw, 58px);
    line-height: 1;
}
.live-total small {
    grid-column: 1 / -1;
    color: var(--muted);
    font-weight: 800;
}
.criterion-row { display: grid; grid-template-columns: 1fr 130px; gap: 10px; }
.category-create { grid-template-columns: 1fr 180px auto; }
.category-edit {
    display: grid;
    grid-template-columns: 1fr 170px 120px auto;
    gap: 12px;
    align-items: center;
}
.category-edit input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 9px 12px;
    font: inherit;
}
.category-edit > span {
    color: var(--muted);
    font-weight: 800;
}

.scoreboard-hero {
    min-height: 132px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: clamp(16px, 3vw, 26px);
    margin-bottom: 12px;
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(36, 107, 72, .94), rgba(192, 138, 44, .88)),
        #246b48;
    color: #fff;
}
.scoreboard-hero h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 56px);
    line-height: 1;
}
.scoreboard-hero p { margin: 6px 0 0; font-size: 17px; color: #fff6df; }
.scoreboard-hero .eyebrow { color: #ffe7a6; }
.scoreboard-title {
    display: flex;
    align-items: center;
    gap: 16px;
}
.hero-logo {
    width: clamp(52px, 7vw, 78px);
    height: clamp(52px, 7vw, 78px);
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 3px;
    margin-bottom: 0;
    flex: 0 0 auto;
}
.public-filter { margin: 0; }
.public-filter label { color: #fff6df; }
.public-filter select { min-width: 230px; min-height: 40px; }

.public-ranking {
    display: grid;
    gap: 8px;
}
.rank-card {
    display: grid;
    grid-template-columns: 70px 56px 1fr minmax(100px, auto);
    gap: 12px;
    align-items: center;
    background: #fffdf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 12px;
}
.rank-card.place-1 {
    border-color: #dfb34b;
    background: #fff5d7;
}
.rank-card.awaiting {
    opacity: .72;
    background: #f8f1e5;
}
.rank-card.awaiting .rank-place,
.rank-card.awaiting .rank-score {
    color: var(--muted);
}
.rank-place {
    font-size: 28px;
    font-weight: 900;
    color: var(--green);
}
.rank-card img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: #eadfce;
}
.rank-info strong { display: block; font-size: clamp(16px, 2.4vw, 23px); }
.rank-info span { color: var(--muted); }
.rank-score {
    font-size: clamp(22px, 4vw, 36px);
    font-weight: 900;
    color: var(--green-dark);
    text-align: right;
}
.auto-refresh, .public-empty { text-align: center; }

.site-footer {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto 24px;
    padding: 18px 0 0;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    color: var(--muted);
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}
.footer-brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
}
.site-footer strong { color: var(--ink); }

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    background: #e8f2ec;
    border: 1px solid #b9d4c3;
    color: #174832;
    font-weight: 700;
}
.flash.bad { background: #fbe8e5; border-color: #efc1bd; color: #8c2721; }

.print-title { display: none; }

@media (max-width: 820px) {
    .login-card, .score-layout { grid-template-columns: 1fr; }
    .form.inline { grid-template-columns: 1fr; }
    .category-create, .category-edit { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: 1fr; }
    .toolbar { align-items: flex-start; flex-direction: column; }
    .two { grid-template-columns: 1fr; }
    .candidate-preview { position: static; }
    .score-row { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .scoreboard-hero { flex-direction: column; align-items: stretch; }
    .scoreboard-title { align-items: center; }
    .rank-card { grid-template-columns: 62px 56px 1fr; }
    .rank-card img { width: 56px; height: 56px; }
    .rank-score { grid-column: 1 / -1; text-align: left; }
    .site-footer { align-items: flex-start; flex-direction: column; }
}

@media print {
    .topbar, .print-hide, .flash, .site-footer { display: none !important; }
    body { background: #fff; }
    .container { width: 100%; margin: 0; }
    .print-title { display: block; margin-bottom: 20px; }
    .table { border-color: #999; }
    .table th, .table td { border-color: #bbb; }
}
