:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    --badge-bg: #e0e7ff;
    --badge-text: #3730a3;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, "Noto Sans Gujarati", sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    padding: 30px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 24px;
}

.header-title-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-title h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.header-title p {
    font-size: 14px;
    color: #bfdbfe;
}

.header-badge {
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
}

/* Stats Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    padding: 18px 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-info .stat-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-info .stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* Search Box Container */
.search-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.search-bar-wrap {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.search-input-group {
    position: relative;
    flex: 1;
}

.search-input-group svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    outline: none;
    transition: all 0.2s;
    background: #ffffff;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-search {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-search:hover {
    background: var(--primary-hover);
}

.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 13px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-select, .filter-input {
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.btn-reset {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
}

.btn-reset:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.search-tips {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Results Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.results-count {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.table-responsive {
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.voters-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.voters-table th {
    background: #f8fafc;
    padding: 14px 16px;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.voters-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.voters-table tr:hover {
    background: #f1f5f9;
}

/* Badges & Labels */
.badge-page {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #dbeafe;
    color: #1e40af;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.badge-page:hover {
    background: #2563eb;
    color: #ffffff;
}

.badge-ward {
    background: #fef3c7;
    color: #92400e;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.badge-person-no {
    display: inline-block;
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-size: 13px;
}

.person-name-cell {
    font-weight: 600;
    font-size: 15px;
    color: #0f172a;
}

.guardian-type-tag {
    font-size: 11px;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 4px;
}

.badge-deleted {
    background: var(--danger-light);
    color: var(--danger);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #fca5a5;
}

.badge-active {
    background: var(--success-light);
    color: var(--success);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.voter-id-tag {
    font-family: monospace;
    font-weight: 600;
    color: #334155;
    background: #f8fafc;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

/* Pagination */
.pagination-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-buttons {
    display: flex;
    gap: 6px;
}

.btn-page {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-page.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty & Loading States */
.state-box {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.state-box svg {
    margin-bottom: 12px;
    color: #94a3b8;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    flex: 1;
    overflow: hidden;
}

.modal-iframe {
    width: 100%;
    height: 70vh;
    border: none;
}

@media (max-width: 768px) {
    .container {
        padding: 14px 10px;
    }
    .header-title h1 {
        font-size: 20px;
    }
    .search-bar-wrap {
        flex-direction: column;
    }
    .btn-search {
        padding: 12px;
        justify-content: center;
    }
}

.btn-voter-print, .btn-family {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 9px;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-align: left;
}
.btn-family { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.btn-voter-print:hover, .btn-family:hover { filter: brightness(.96); }
.family-modal { max-width: 720px; }
.family-body { overflow-y: auto; padding: 20px 24px; }
.family-note { color: #64748b; font-size: 13px; margin-bottom: 14px; }
.family-count { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.family-list { display: grid; gap: 8px; max-height: 55vh; overflow-y: auto; }
.family-option { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px;
    border: 1px solid #e2e8f0; border-radius: 9px; cursor: pointer; }
.family-option:has(input:checked) { background: #eff6ff; border-color: #bfdbfe; }
.family-option input { margin-top: 5px; flex: none; }
.family-person { display: grid; gap: 2px; min-width: 0; }
.family-person span, .family-person small { color: #475569; font-size: 12px; }
.family-person em { color: #2563eb; font-size: 11px; font-style: normal; }
.family-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.family-error { color: #dc2626; }
#printSheet { display: none; }
@media print {
    body > :not(#printSheet) { display: none !important; }
    #printSheet { display: block !important; color: #111827; font: 12px Arial, sans-serif; }
    #printSheet h1 { font-size: 20px; margin-bottom: 6px; }
    #printSheet p { margin-bottom: 12px; }
    #printSheet table { width: 100%; border-collapse: collapse; }
    #printSheet th, #printSheet td { border: 1px solid #94a3b8; padding: 6px; text-align: left; }
    #printSheet th { background: #e2e8f0; }
    #printSheet .print-note { margin-top: 12px; color: #475569; font-size: 10px; }
    #printSheet.thermal { width: 100%; max-width: 58mm; margin: 0; padding: 0 3mm; box-sizing: border-box; color: #000;
        font: 700 13pt/1.45 'Noto Sans Gujarati', Arial, sans-serif; }
    #printSheet.thermal .slip { padding: 3mm 0; border-top: 1.5px dashed #000; break-inside: avoid; overflow-wrap: anywhere; }
    #printSheet.thermal .slip:last-child { border-bottom: 1.5px dashed #000; }
    #printSheet.thermal b { font-weight: 700; }
    #printSheet.thermal .slip-serial { font-size: 16pt; }
}
