:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --success: #047857;
    --error: #b91c1c;
    --warning: #92400e;
    --border: #e5e7eb;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 220px);
    color: var(--text);
    line-height: 1.5;
}

.container {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.hero-compact h1 {
    margin-bottom: 0.25rem;
}

.hero h1,
.card h2 {
    margin: 0 0 0.5rem;
}

.hero p,
.hint,
.empty {
    color: var(--muted);
}

.checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

textarea {
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.1rem;
    border-radius: 10px;
    border: none;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto;
    gap: 1rem;
    align-items: end;
}

.filters label {
    margin-bottom: 0;
}

.alert {
    padding: 1rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #ecfdf5;
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: var(--error);
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: var(--warning);
    border: 1px solid #fde68a;
}

.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}

.info-box p {
    margin: 0.25rem 0;
}

.preguntas {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.hidden {
    display: none;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    background: #f9fafb;
    color: #1f2937;
    font-size: 0.92rem;
}

/* Tablas del balance electoral (estilos propios en balance.css) */
.balance-page table.bal-pdf-table thead th,
.balance-page table.bal-prov-table thead th {
    background-color: #1e3a8a;
    color: #ffffff;
}
.balance-page table.bal-prov-table thead th {
    background-color: #cbd5e1;
    color: #0f172a;
}

.detalle {
    min-width: 260px;
    font-size: 0.95rem;
}

.error-text {
    color: var(--error);
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-label {
    display: block;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.stat-value {
    font-size: 1.6rem;
}

.matrix-table th,
.matrix-table td {
    text-align: center;
}

.matrix-table .provincia-name {
    text-align: left;
    font-weight: 600;
    min-width: 140px;
}

.matrix-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
}

.matrix-badge.ok {
    background: #dcfce7;
    color: var(--success);
}

.matrix-badge.pending {
    background: #f3f4f6;
    color: var(--muted);
}

.matrix-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.filters-compact {
    grid-template-columns: 1fr auto auto;
}

.reporte-sheet {
    max-width: 900px;
}

.reporte-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.reporte-header h2 {
    margin: 0.35rem 0 0;
}

.reporte-meta p {
    margin: 0.15rem 0;
    text-align: right;
}

.badge {
    display: inline-block;
    background: #dbeafe;
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.reporte-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.reporte-block {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}

.reporte-block.full {
    margin-top: 1rem;
}

.reporte-block h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.reporte-block dl {
    margin: 0;
}

.reporte-block dt {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 0.65rem;
}

.reporte-block dt:first-child {
    margin-top: 0;
}

.reporte-block dd {
    margin: 0.15rem 0 0;
    font-weight: 600;
}

.respuestas dd {
    font-weight: 500;
}

.pill {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-weight: 700;
}

.pill-alta { background: #fee2e2; color: #991b1b; }
.pill-media { background: #fef3c7; color: #92400e; }
.pill-baja { background: #dcfce7; color: #166534; }

.observaciones {
    margin: 0;
    white-space: pre-wrap;
}

@media print {
    body {
        background: #fff;
    }

    .no-print {
        display: none !important;
    }

    .container {
        width: 100%;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: none;
        padding: 0;
    }
}

@media (max-width: 900px) {
    .grid-2,
    .filters,
    .stats-grid,
    .reporte-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .reporte-header {
        flex-direction: column;
    }

    .reporte-meta p {
        text-align: left;
    }
}
