:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --accent: #f97316;
    --success: #15803d;
    --danger: #b91c1c;
    --border: #dbe3f0;
    --input-border: #94a3b8;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #eff6ff 0%, var(--bg) 40%, #fff 100%);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(1120px, 92vw); margin: 0 auto; }
.page-content { padding: 2rem 0 3rem; }

.site-header {
    background: rgba(255,255,255,0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}
.brand strong { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); }
.logo { height: 42px; width: auto; }
.main-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.main-nav a { font-weight: 600; }

.hero {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.hero-card, .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}
.hero h1 { margin: 0 0 0.5rem; font-size: 2.2rem; }
.hero p { color: var(--muted); line-height: 1.6; }
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.stat {
    background: #eff6ff;
    border-radius: 14px;
    padding: 1rem;
}
.stat strong { display: block; font-size: 1.4rem; color: var(--primary); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.table-wrap { overflow-x: auto; }
.upload-format-help { margin: 0.75rem 0; }
.upload-format-help pre {
    margin: 0.5rem 0 0;
    padding: 0.65rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    overflow-x: auto;
}
.checkbox-inline { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0.5rem 0; }
.form-actions { margin-top: 0.75rem; }
.login-reset-panel {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.login-reset-panel h2 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}
.login-status {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.login-status-ready {
    background: #dcfce7;
    color: #166534;
}
.login-status-pending {
    background: #fef3c7;
    color: #92400e;
}
.inline-reset-form {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.datatable .inline-reset-form .btn-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.78rem;
}
.inline-reset-form input[type="password"] {
    min-width: 10rem;
    padding: 0.35rem 0.45rem;
    border: 1.5px solid var(--input-border);
    border-radius: 6px;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f8fafc; font-size: 0.92rem; }

.form-group { margin-bottom: 1rem; }
.field-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.35;
}
label { display: block; margin-bottom: 0.35rem; font-weight: 600; }
input, select, textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    font: inherit;
    background: #fff;
}
input[type="checkbox"], input[type="radio"] {
    width: auto;
    padding: 0;
    border: none;
}
textarea { min-height: 110px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn + .btn { margin-left: 0.5rem; }

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}
.alert-success { background: #dcfce7; color: var(--success); }
.alert-error { background: #fee2e2; color: var(--danger); }
.alert-info { background: #dbeafe; color: var(--primary-dark); }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}
.auth-card { width: min(520px, 100%); text-align: center; }
.auth-card h1 { margin-top: 0; }

.totp-setup { text-align: left; }
.totp-steps {
    margin: 0 0 1rem 1.1rem;
    padding: 0;
    color: var(--muted);
    line-height: 1.55;
}
.totp-steps li + li { margin-top: 0.45rem; }
.totp-qr-wrap {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
}
.totp-qr {
    display: block;
    border-radius: 8px;
}
.totp-manual {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}
.totp-secret {
    display: inline-block;
    padding: 0.45rem 0.65rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    word-break: break-all;
}
.totp-hint { margin: 0.35rem 0 0; font-size: 0.85rem; }
.totp-verify-form { margin-top: 0.5rem; }
.totp-note {
    margin: 1rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tab {
    flex: 1;
    padding: 0.65rem;
    border-radius: 10px;
    background: #e2e8f0;
    font-weight: 700;
}
.tab.active { background: var(--primary); color: #fff; }

.contestants-list-page {
    margin-bottom: 1.5rem;
}

.contestants-list-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-bottom: 1.35rem;
}

.contestants-list-page h1 {
    margin: 0 0 0.35rem;
}

.contestants-list-subtitle {
    margin: 0;
    max-width: 42rem;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.contestants-search-wrap {
    min-width: min(100%, 22rem);
    flex: 1 1 18rem;
}

.contestants-search-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.contestants-search-input {
    width: 100%;
    padding: 0.72rem 0.95rem;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #fff;
    font: inherit;
    color: #0f172a;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

.contestants-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.contestants-search-count {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: var(--muted);
}

.contestants-no-results {
    margin: 1rem 0 0;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    text-align: center;
}

.contestant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.15rem;
}

.contestant-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
    color: #fff;
    min-height: 300px;
    position: relative;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.contestant-card:hover,
.contestant-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
}

.contestant-card:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 3px;
}

.contestant-card:nth-child(6n + 1) { background: linear-gradient(145deg, #1d4ed8 0%, #7c3aed 100%); }
.contestant-card:nth-child(6n + 2) { background: linear-gradient(145deg, #0f766e 0%, #0891b2 100%); }
.contestant-card:nth-child(6n + 3) { background: linear-gradient(145deg, #b45309 0%, #ea580c 100%); }
.contestant-card:nth-child(6n + 4) { background: linear-gradient(145deg, #be123c 0%, #db2777 100%); }
.contestant-card:nth-child(6n + 5) { background: linear-gradient(145deg, #4338ca 0%, #2563eb 100%); }
.contestant-card:nth-child(6n + 6) { background: linear-gradient(145deg, #047857 0%, #16a34a 100%); }

.contestant-card-vote-no {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0.95rem 0.95rem 0;
    padding: 0.65rem 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid rgba(255, 255, 255, 0.98);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
}

.contestant-card-vote-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #1e40af;
}

.contestant-card-vote-number {
    font-size: clamp(1.85rem, 4vw, 2.35rem);
    font-weight: 900;
    line-height: 1.05;
    color: #1d4ed8;
    letter-spacing: 0.03em;
}

.contestant-card-media {
    display: flex;
    justify-content: center;
    margin: 0.85rem 0 0.35rem;
}

.contestant-card-photo {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.22);
}

.contestant-card-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.22);
    font-size: 1.8rem;
    font-weight: 800;
}

.contestant-card-body {
    flex: 1;
    padding: 0.35rem 1rem 0.75rem;
    text-align: center;
}

.contestant-card h3 {
    margin: 0 0 0.35rem;
    font-size: 1.08rem;
    line-height: 1.25;
    text-wrap: balance;
}

.contestant-card-company {
    margin: 0 0 0.25rem;
    font-weight: 700;
    opacity: 0.96;
}

.contestant-card-meta {
    margin: 0;
    font-size: 0.88rem;
    opacity: 0.9;
}

.contestant-card-cta {
    display: block;
    margin: 0 1rem 1rem;
    padding: 0.55rem 0.75rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.28);
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.contestant-card[hidden] {
    display: none;
}

.profile-hero {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
    align-items: start;
}
.profile-photo {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 18px;
    border: 4px solid #fff;
    box-shadow: var(--shadow);
    background: #cbd5e1;
}
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: #dbeafe;
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 700;
}
.disclaimer {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.admin-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}
.admin-shell { width: min(1480px, 98vw); margin: 0 auto; }
.admin-page-content { padding: 1.25rem 0 2.5rem; }
.admin-main { min-width: 0; }
.admin-nav {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
    height: fit-content;
    position: sticky;
    top: 5.25rem;
}
.admin-nav a {
    display: block;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    color: var(--text);
    font-weight: 600;
}
.admin-nav a.active, .admin-nav a:hover {
    background: #eff6ff;
    text-decoration: none;
}

.admin-nav-group {
    margin-top: 0.45rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
}
.admin-nav > a + .admin-nav-group {
    margin-top: 0.55rem;
}
.admin-nav-group + .admin-nav-group {
    margin-top: 0.45rem;
}
.admin-nav-group + a {
    margin-top: 0.45rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border);
}

.admin-nav-group-label {
    padding: 0.45rem 0.75rem 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.admin-nav-group.is-active .admin-nav-group-label {
    color: var(--primary-dark);
}

.admin-nav-sub a {
    padding: 0.5rem 0.75rem 0.5rem 1.15rem;
    font-size: 0.92rem;
}

.report-disclaimer {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.92rem;
    line-height: 1.45;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 0 2rem;
    color: var(--muted);
    text-align: center;
}

.testing-panel {
    margin-top: 1rem;
    border-color: #fecaca;
    background: #fff7f7;
}
.testing-panel h2 { color: var(--danger); }

.ballot-view-page h1 { margin-top: 0; }
.ballot-view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.ballot-view-header p { margin: 0.25rem 0 0; color: var(--muted); }
.ballot-view-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.ballot-paper-search {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.ballot-paper-search label { font-size: 0.86rem; font-weight: 600; }
.ballot-paper-search input[type="number"] {
    width: 6.5rem;
    padding: 0.45rem 0.55rem;
    border: 1.5px solid var(--input-border);
    border-radius: 8px;
}
.ballot-round-filter {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.ballot-round-filter label { font-size: 0.86rem; font-weight: 600; }
.ballot-round-filter select {
    padding: 0.45rem 0.55rem;
    border: 1.5px solid var(--input-border);
    border-radius: 8px;
}
.ballot-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.ballot-pager-bottom {
    margin-top: 0.75rem;
    margin-bottom: 0;
}
.ballot-pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.5rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.ballot-pager-btn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.ballot-pager-info {
    font-size: 0.84rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.ballot-view-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.ballot-view-item-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.85rem;
    align-items: center;
    padding: 0.55rem 0.7rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 0.86rem;
}
.ballot-view-item-head strong { color: var(--primary-dark); }
.ballot-view-meta { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.ballot-view-badge {
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.ballot-view-badge.ok { background: #dcfce7; color: #166534; }
.ballot-view-badge.bad { background: #fee2e2; color: #991b1b; }
.ballot-view-valid { border-color: #86efac; }
.ballot-view-invalid {
    border: 2px solid #f87171;
    background: linear-gradient(180deg, #fff5f5 0%, #fff 18%);
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.15);
}
.ballot-invalid-banner {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.55rem 0.7rem;
    background: #fee2e2;
    border-bottom: 1px solid #fca5a5;
    color: #991b1b;
    font-size: 0.82rem;
}
.ballot-invalid-banner strong {
    font-size: 0.88rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.ballot-view-invalid .ballot-view-item-head {
    background: #fef2f2;
    border-bottom-color: #fecaca;
}
.ballot-votes-invalid {
    background: repeating-linear-gradient(
        -45deg,
        #fff7f7,
        #fff7f7 8px,
        #fff 8px,
        #fff 16px
    );
}
.ballot-votes-invalid th,
.ballot-votes-invalid td {
    color: #7f1d1d;
}
.ballot-record-only {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.ballot-view-votes {
    width: 100%;
    font-size: 0.84rem;
}
.ballot-view-votes th,
.ballot-view-votes td {
    padding: 0.35rem 0.7rem;
}
.ballot-view-empty {
    margin: 0;
    padding: 0.55rem 0.7rem;
    color: var(--muted);
    font-size: 0.84rem;
}
.ballot-invalid-reason {
    margin: 0.35rem 0 0;
    font-size: 0.84rem;
}
.ballot-updated-meta {
    margin: 0 0.7rem 0.55rem;
    color: var(--muted);
    font-size: 0.78rem;
}
.ballot-edit-link { margin-left: 0.5rem; }
.ballot-edit-panel {
    border: 2px solid #60a5fa;
    background: repeating-linear-gradient(
        -45deg,
        #eff6ff,
        #eff6ff 8px,
        #f8fbff 8px,
        #f8fbff 16px
    );
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.18);
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.ballot-edit-panel .counting-table-wrap {
    max-height: min(60vh, 520px);
    background: repeating-linear-gradient(
        -45deg,
        #dbeafe,
        #dbeafe 8px,
        #eff6ff 8px,
        #eff6ff 16px
    );
    border-color: #93c5fd;
}
.ballot-edit-panel .counting-table {
    background: transparent;
}
.ballot-edit-panel .counting-table tbody tr:not(.vote-overflow-marker) {
    background-color: rgba(255, 255, 255, 0.72);
}
.ballot-edit-panel.ballot-edit-valid-state {
    border-color: #4ade80;
    background: repeating-linear-gradient(
        -45deg,
        #ecfdf5,
        #ecfdf5 8px,
        #f0fdf4 8px,
        #f0fdf4 16px
    );
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.18);
}
.ballot-edit-panel.ballot-edit-valid-state .counting-table-wrap {
    background: repeating-linear-gradient(
        -45deg,
        #bbf7d0,
        #bbf7d0 8px,
        #dcfce7 8px,
        #dcfce7 16px
    );
    border-color: #86efac;
}
.ballot-edit-panel.ballot-edit-invalid-state {
    border-color: #fb7185;
    background: repeating-linear-gradient(
        -45deg,
        #fff1f2,
        #fff1f2 8px,
        #ffe4e6 8px,
        #ffe4e6 16px
    );
    box-shadow: 0 0 0 1px rgba(244, 63, 94, 0.18);
}
.ballot-edit-panel.ballot-edit-invalid-state .counting-table-wrap {
    background: repeating-linear-gradient(
        -45deg,
        #fecdd3,
        #fecdd3 8px,
        #ffe4e6 8px,
        #ffe4e6 16px
    );
    border-color: #fda4af;
}
.ballot-edit-statusbar {
    margin-bottom: 0.55rem;
    background: rgba(255, 255, 255, 0.85);
}
.ballot-edit-panel h2 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
}
.user-status-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.user-status-pill.is-active {
    background: #dcfce7;
    color: #166534;
}
.user-status-pill.is-inactive {
    background: #fee2e2;
    color: #991b1b;
}
.ballot-edit-history {
    margin-top: 1rem;
}
.ballot-edit-history h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}
.ballot-edit-history-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.55rem;
    background: #f8fafc;
}
.ballot-edit-history-item header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
}
.ballot-edit-summary,
.log-details-pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.78rem;
    line-height: 1.35;
}
.ballot-edit-diff-line {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
}
.diff-added { color: #166534; font-weight: 600; }
.diff-removed { color: #991b1b; font-weight: 600; }
.log-details-cell {
    max-width: 28rem;
}
.ballot-edit-invalid textarea {
    width: 100%;
    margin-top: 0.35rem;
}
.ballot-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0.75rem 0 1rem;
}
.stat-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 4.5rem;
    padding: 0.65rem 0.75rem;
    border-radius: 12px;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    text-align: center;
}
.stat-badge-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.85;
}
.stat-badge-value {
    font-size: 1.65rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-badge-valid {
    background: linear-gradient(180deg, #ecfdf5 0%, #dcfce7 100%);
    border-color: #86efac;
    color: #166534;
}
.stat-badge-invalid {
    background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
    border-color: #fda4af;
    color: #9f1239;
}
.stat-badge-total {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #93c5fd;
    color: #1e3a8a;
}
.status-pill {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.status-pill-valid {
    background: #dcfce7;
    color: #166534;
}
.status-pill-invalid {
    background: #fee2e2;
    color: #991b1b;
}
@media (max-width: 640px) {
    .ballot-summary-stats {
        grid-template-columns: 1fr;
    }
}
.row-invalid-ballot td {
    background: #fff7f7;
}
.schedule-conclude-card {
    margin-top: 1rem;
    border: 2px solid #fecaca;
    background: linear-gradient(180deg, #fff5f5 0%, #fff 55%);
}
.schedule-conclude-card h2 {
    margin-top: 0;
    color: #991b1b;
}
.conclude-counting-form {
    max-width: 28rem;
}
.conclude-counting-form .btn-danger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 860px) {
    .hero, .grid-2, .grid-3, .profile-hero, .admin-layout { grid-template-columns: 1fr; }
}

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.page-toolbar h1 { margin: 0; }
.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.text-muted { color: var(--muted); font-size: 0.9rem; }
.card-inner {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}
.progress-bar {
    width: 100%;
    height: 0.65rem;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin: 0.5rem 0;
}
.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2563eb, #1d4ed8);
    transition: width 0.25s ease;
}
.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.82rem;
}
.report-meta {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: -0.25rem;
}
.report-order-toggle {
    display: flex;
    gap: 0.45rem;
    margin: 0.35rem 0 0.65rem;
}
.report-order-toggle .lb-order-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    font-size: 0.76rem;
    font-weight: 700;
    text-decoration: none;
}
.report-order-toggle .lb-order-btn.is-active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.report-table th,
.report-table td {
    white-space: nowrap;
    font-size: 0.86rem;
}
.datatable + .dt-container,
.dataTables_wrapper {
    margin-top: 0.5rem;
    overflow-x: auto;
}
.dataTables_wrapper .dataTables_filter input {
    min-width: 12rem;
}
.admin-body .card { overflow: hidden; }

@media print {
    .site-header,
    .site-footer,
    .admin-nav,
    .no-print,
    .toolbar-actions {
        display: none !important;
    }
    .admin-layout {
        display: block;
    }
    .page-content {
        padding: 0;
    }
    .report-table {
        font-size: 10pt;
    }
    .report-table th,
    .report-table td {
        border: 1px solid #333;
        padding: 4px 6px;
    }
}

.email-compose .select2-container--default .select2-selection--multiple {
    min-height: 44px;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    padding: 0.2rem 0.35rem;
}

.email-compose .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--primary);
}

.email-compose .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: #e2e8f0;
    border: none;
    border-radius: 6px;
    padding: 0.15rem 0.45rem;
}

.email-compose .select2-container--default .select2-search--inline .select2-search__field {
    margin-top: 0.35rem;
    font: inherit;
}

.email-compose .tox-tinymce {
    border-radius: 10px;
    border-color: var(--input-border) !important;
}

.email-compose .tox .tox-edit-area__iframe {
    background: #fff;
}

.email-compose .field-hint code {
    font-size: 0.85em;
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

.progress-bar.compact {
    height: 8px;
    margin-bottom: 0.25rem;
}

.queue-monitor-table .queue-actions {
    white-space: nowrap;
}

.queue-monitor-table .queue-actions .btn {
    margin-bottom: 0.25rem;
}

.campaign-progress-text {
    font-size: 0.8rem;
    color: var(--muted);
}

.contestant-dashboard .contestant-panel {
    margin-bottom: 1rem;
}

.contestant-dashboard-grid {
    margin-bottom: 1rem;
}

.share-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.share-link-input {
    flex: 1 1 280px;
    min-width: 0;
}

.profile-facts {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem 1rem;
    margin: 0;
}

.profile-facts dt {
    margin: 0;
    font-weight: 700;
    color: var(--muted);
}

.profile-facts dd {
    margin: 0;
}

.vote-total-line {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.profile-preview {
    max-width: 180px;
    border-radius: 12px;
    margin-top: 0.5rem;
}

.logo-preview {
    max-height: 72px;
    width: auto;
}

.contestant-public-page {
    position: relative;
    overflow: hidden;
    padding: 1.5rem;
}

.contestant-public-page .contestant-lang-switch {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.contestant-public-page .contestant-lang-icon {
    font-size: 0.9rem;
    line-height: 1;
    opacity: 0.75;
}

.contestant-public-page .contestant-lang-switch select {
    width: auto;
    min-width: 3.2rem;
    padding: 0.2rem 0.35rem;
    border: none;
    background: transparent;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
}

.contestant-public-page .contestant-public-grid {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: stretch;
}

.contestant-public-page .contestant-panel {
    border-radius: 20px;
    padding: 1.25rem;
    min-height: 100%;
}

.contestant-public-page .contestant-panel-profile {
    background: linear-gradient(165deg, #eff6ff 0%, #dbeafe 52%, #e0f2fe 100%);
    border: 1px solid #93c5fd;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.contestant-public-page .contestant-panel-company {
    background: linear-gradient(165deg, #fff7ed 0%, #ffedd5 55%, #fef3c7 100%);
    border: 1px solid #fdba74;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.contestant-public-page .contestant-photo-wrap {
    margin-bottom: 1rem;
}

.contestant-public-page .profile-photo {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    display: block;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 18px;
    border: 4px solid #fff;
    box-shadow: 0 10px 24px rgba(29, 78, 216, 0.18);
}

.contestant-public-page .profile-photo-placeholder {
    background: linear-gradient(135deg, #bfdbfe, #93c5fd);
}

.contestant-public-page .contestant-vote-id {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 3px solid #1d4ed8;
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: 0 4px 14px rgba(29, 78, 216, 0.22);
}

.contestant-public-page .contestant-vote-id-label {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #1e40af;
}

.contestant-public-page .contestant-vote-id-number {
    font-size: clamp(2.1rem, 5vw, 3rem);
    font-weight: 900;
    line-height: 1.05;
    color: #1d4ed8;
    letter-spacing: 0.04em;
}

.contestant-public-page .contestant-name {
    margin: 0 0 1rem;
    font-size: clamp(1.35rem, 2.4vw, 1.85rem);
    line-height: 1.2;
    color: #1e3a8a;
}

.contestant-public-page .contestant-details {
    display: grid;
    gap: 0.65rem;
}

.contestant-public-page .detail-chip {
    display: grid;
    gap: 0.15rem;
    padding: 0.65rem 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.contestant-public-page .detail-chip-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.contestant-public-page .detail-chip-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.4;
    word-break: break-word;
}

.contestant-public-page .detail-chip-role .detail-chip-label { color: #1d4ed8; }
.contestant-public-page .detail-chip-company .detail-chip-label { color: #7c3aed; }
.contestant-public-page .detail-chip-location .detail-chip-label { color: #0f766e; }
.contestant-public-page .detail-chip-phone .detail-chip-label { color: #c2410c; }
.contestant-public-page .detail-chip-phone .detail-chip-value {
    color: #c2410c;
    text-decoration: none;
}

.contestant-public-page .contestant-logo-wrap {
    min-height: 110px;
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed #fdba74;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contestant-public-page .company-logo {
    max-width: 100%;
    max-height: 96px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.contestant-public-page .company-logo-placeholder {
    color: #9a3412;
    font-size: 0.92rem;
    font-weight: 700;
    text-align: center;
    opacity: 0.75;
}

.contestant-public-page .contestant-writeup-title {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
    color: #9a3412;
}

.contestant-public-page .contestant-writeup-wrap {
    padding: 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.95);
}

.contestant-public-page .contestant-writeup-empty {
    margin: 0;
    color: #9a3412;
    opacity: 0.8;
    font-style: italic;
}

.contestant-public-page .developer-credit {
    margin-top: 1.25rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.contestant-writeup {
    line-height: 1.65;
    color: #334155;
}

.contestant-writeup [style*="font-family"],
.contestant-writeup [style*="font-size"],
.contestant-writeup [style*="color"] {
    line-height: inherit;
}

.contestant-writeup p {
    margin: 0 0 0.75rem;
}

.contestant-writeup ul,
.contestant-writeup ol {
    margin: 0 0 0.75rem 1.25rem;
}

.developer-credit {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.55;
    text-align: center;
}

.developer-credit-line {
    display: block;
}

.developer-credit-line + .developer-credit-line {
    margin-top: 0.2rem;
}

.developer-credit-copy {
    font-size: 0.76rem;
    opacity: 0.92;
}

.developer-credit a,
.developer-credit-link {
    color: var(--primary-dark);
    white-space: nowrap;
}

#description-word-count.is-over-limit {
    color: var(--danger);
    font-weight: 700;
}

.counting-footer {
    padding: 0.75rem 0 1.25rem;
    text-align: center;
}

@media (max-width: 900px) {
    .contestant-public-page .contestant-public-grid {
        grid-template-columns: 1fr;
    }

    .contestant-public-page .contestant-lang-switch {
        position: static;
        margin-bottom: 0.75rem;
        width: fit-content;
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    .profile-facts {
        grid-template-columns: 1fr;
    }
}

