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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

header {
    position: relative;
    background: #1a1a2e;
    color: #fff;
    padding: 10px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header .logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #fff;
}

header .logo img {
    height: 40px;
    width: auto;
}

header .brand-name {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

nav {
    display: flex;
    gap: 18px;
}

nav a {
    color: #ccc;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 0;
}

nav a:hover, nav a.active {
    color: #fff;
    border-bottom: 2px solid #4ea8de;
}

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

.dashboard-subtitle {
    font-size: 14px;
    color: #777;
    margin-bottom: 16px;
    text-align: center;
}

.card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 18px;
    margin-bottom: 14px;
    color: #1a1a2e;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-box {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
    text-align: center;
}

.stat-box .number {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a2e;
}

.stat-box .label {
    font-size: 13px;
    color: #777;
    margin-top: 4px;
}

.search-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
}

.search-bar input[type="text"],
.search-bar select,
.search-bar input[type="date"] {
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    color: #1f2937;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-bar input[type="text"]:hover,
.search-bar select:hover,
.search-bar input[type="date"]:hover {
    border-color: #9ca3af;
}

.search-bar input[type="text"]:focus,
.search-bar select:focus,
.search-bar input[type="date"]:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.search-bar input[type="text"] {
    flex: 1;
    min-width: 140px;
}

.search-bar select {
    max-width: 120px;
}

.search-bar input[type="date"] {
    width: 115px;
}

.search-bar .date-group {
    display: flex;
    align-items: center;
    gap: 4px;
}
.search-bar .date-group .date-sep {
    font-size: 11px;
    color: #9ca3af;
}
.search-bar .date-group i {
    font-size: 11px;
    color: #9ca3af;
}

.search-bar button[type="submit"] {
    padding: 6px 10px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
    white-space: nowrap;
}

.search-bar button[type="submit"]:hover {
    background: #2a2a4e;
}

.btn-clear {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.btn-clear:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn {
    display: inline-block;
    padding: 6px 14px;
    background: #1a1a2e;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    border: none;
    cursor: pointer;
}

.btn:hover { background: #2a2a4e; }

.btn-sm {
    padding: 3px 10px;
    font-size: 12px;
}

.btn-outline {
    background: transparent;
    color: #1a1a2e;
    border: 1px solid #1a1a2e;
}

.btn-outline:hover {
    background: #1a1a2e;
    color: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f8f8;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

th a {
    color: #555;
    text-decoration: none;
}

th a:hover {
    color: #1a1a2e;
}

th .sort-arrow {
    font-size: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

tr:hover { background: #fafafa; }

tr:nth-child(even) { background: #fafbfc; }
tr:nth-child(even):hover { background: #f5f5f5; }

td a {
    color: #2563eb;
    text-decoration: none;
}

td a:hover { text-decoration: underline; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-app { background: #dcfce7; color: #166534; }
.badge-order { background: #dbeafe; color: #1e40af; }
.badge-hearing { background: #fef3c7; color: #92400e; }
.badge-transcript { background: #f3e8ff; color: #6b21a8; }

.badge-individual { background: #e0f2fe; color: #0369a1; }
.badge-trust { background: #fce7f3; color: #9d174d; }
.badge-llc { background: #fef3c7; color: #92400e; }
.badge-estate { background: #f3e8ff; color: #6b21a8; }
.badge-govt { background: #dcfce7; color: #166534; }
.badge-nonprofit { background: #ffedd5; color: #9a3412; }
.badge-life-estate { background: #ccfbf1; color: #0f766e; }
.badge-heirs { background: #fee2e2; color: #991b1b; }
.badge-unknown { background: #f3f4f6; color: #6b7280; }

.owner-row:hover {
    background: #eef6ff !important;
}

.detail-row td {
    padding: 12px 20px;
    background: #f8fafe;
    border-left: 3px solid #4ea8de;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 0;
}

.detail-table th {
    background: #e8eef5;
    font-size: 12px;
    padding: 6px 10px;
}

.detail-table td {
    padding: 5px 10px;
    border-bottom: 1px solid #eee;
    background: transparent;
}

.oc-link {
    font-size: 12px;
    text-decoration: none;
    color: #888;
    vertical-align: middle;
    margin-left: 4px;
}

.oc-link:hover {
    color: #2563eb;
}

.tps-col { width: 40px; text-align: center; }
.tps-link {
    font-size: 12px; text-decoration: none; color: #9ca3af;
    transition: color 0.15s;
}
.tps-link:hover { color: #2563eb; }
.tps-section { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e5e7eb; }
.tps-section-label { font-size: 11px; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.tps-section a { font-size: 12px; color: #6b7280; text-decoration: none; }
.tps-section a:hover { color: #2563eb; text-decoration: underline; }

.attn-line {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.addr-warning {
    color: #f59e0b;
    font-size: 12px;
    margin-left: 4px;
    cursor: help;
}

td.parcel-cell {
    font-family: monospace;
    font-size: 12px;
    white-space: nowrap;
}

td.tract-cell {
    text-align: center;
}

.export-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s;
    white-space: nowrap;
    color: #fff;
}

.btn-export-excel {
    background: #217346;
}

.btn-export-excel:hover {
    background: #1a5c38;
}

.btn-export-csv {
    background: #059669;
}

.btn-export-csv:hover {
    background: #047857;
}

.btn-excel {
    background: #217346;
}

.btn-excel:hover {
    background: #1a5c38;
}

.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-size: 13px;
}

.pagination a:hover { background: #eee; }

.pagination .current {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.pagination .dots {
    border: none;
    padding: 6px 4px;
}

.meta {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
}

.doc-list {
    list-style: none;
    padding: 0;
}

.doc-list li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-list li:last-child { border-bottom: none; }

.detail-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px 16px;
    margin-bottom: 16px;
}

.detail-grid dt {
    font-weight: 600;
    color: #555;
}

.detail-grid dd {
    color: #333;
}

.unit-header-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.unit-header-left { flex: 1; min-width: 0; }

.phone-summary {
    flex-shrink: 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    min-width: 190px;
}
.phone-summary-title {
    font-weight: 600;
    font-size: 13px;
    color: #475569;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.phone-summary-title i { color: #4ea8de; }
.phone-stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 3px 0;
}
.phone-stat-row i { width: 14px; text-align: center; font-size: 12px; }
.phone-stat-label { color: #64748b; flex: 1; }
.phone-stat-val { font-weight: 600; }
.phone-stat-match { color: #16a34a; }
.phone-stat-nomatch { color: #ef4444; }
.phone-stat-pending { color: #94a3b8; }
.phone-summary-totals {
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    margin-top: 8px;
    padding-top: 8px;
}

.actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: #999;
}

nav a i {
    margin-right: 4px;
}

.stat-box .icon {
    font-size: 20px;
    color: #4ea8de;
    margin-bottom: 6px;
}

.badge i {
    margin-right: 3px;
}

.btn i, .btn-excel i {
    margin-right: 4px;
}

.expand-icon {
    display: inline-block;
    width: 16px;
    font-size: 11px;
    color: #999;
    margin-right: 4px;
    transition: transform 0.2s;
}

.owner-row.expanded .expand-icon {
    transform: rotate(90deg);
}

.result-count {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.per-page-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

.per-page-selector select {
    padding: 3px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.alias-list { margin-bottom: 8px; font-size: 13px; line-height: 1.8; }
.alias-label { color: #555; font-weight: 600; }
.alias-list a { color: #4f46e5; text-decoration: none; }
.alias-list a:hover { text-decoration: underline; }
.aka-label { display: inline; font-size: 12px; color: #6b7280; font-style: italic; margin-left: 8px; }
.spouse-label { display: block; font-size: 12px; color: #7c3aed; margin-top: 1px; line-height: 1.3; }

.addr-conflict { color: #d97706; font-size: 11px; margin-left: 4px; cursor: help; }

/* Settings page - Login */
.settings-login {
    max-width: 400px;
    margin: 80px auto;
    text-align: center;
}
.settings-login h2 {
    margin-bottom: 16px;
    color: #1a1a2e;
}
.settings-login input[type="password"] {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    margin-bottom: 12px;
}
.settings-login .error-msg {
    color: #dc2626;
    font-size: 13px;
    margin-bottom: 10px;
}

/* Settings page - Responsive row grid */
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
}
.settings-row .settings-card {
    margin-bottom: 0;
    min-width: 0;
}
.settings-row .settings-card-body {
    overflow-x: auto;
    flex: 1;
}
.settings-row.settings-row-full {
    grid-template-columns: 1fr;
}
@media (max-width: 1024px) {
    .settings-row {
        gap: 12px;
    }
}
@media (max-width: 768px) {
    .settings-row {
        grid-template-columns: 1fr;
    }
}

/* Settings page - Collapsible cards */
.settings-card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 180px;
}
.settings-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    transition: background 0.15s;
    flex-shrink: 0;
}
.settings-card-header:hover {
    background: #f8f8f8;
}
.settings-card-header h2 {
    font-size: 16px;
    color: #1a1a2e;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-card-header h2 i {
    color: #4ea8de;
    width: 20px;
    text-align: center;
}
.settings-card-header .toggle-icon {
    color: #999;
    transition: transform 0.2s;
    font-size: 12px;
}
.settings-card.collapsed {
    min-height: 0;
}
.settings-card.collapsed .settings-card-body {
    display: none;
}
.settings-card.collapsed .toggle-icon {
    transform: rotate(-90deg);
}
.settings-card-body {
    padding: 20px;
    border-top: 1px solid #eee;
}

/* Toggle switches */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.toggle-switch input[type="checkbox"] {
    width: 40px;
    height: 22px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch input[type="checkbox"]:checked {
    background: #4ea8de;
}
.toggle-switch input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: left 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-switch input[type="checkbox"]:checked::before {
    left: 20px;
}
.toggle-switch label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
}
.toggle-switch .toggle-desc {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* Settings form controls */
.settings-form-group {
    margin-bottom: 16px;
}
.settings-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}
.settings-form-group input,
.settings-form-group select,
.settings-form-group textarea {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    max-width: 400px;
}
.settings-form-group textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}
.settings-form-group input[type="number"] {
    max-width: 150px;
}
.settings-form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.settings-form-row .settings-form-group {
    flex: 0 0 auto;
}
.settings-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

/* Password field with toggle */
.password-wrapper {
    position: relative;
    max-width: 400px;
}
.password-wrapper input {
    padding-right: 40px;
    width: 100%;
}
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
    font-size: 14px;
    padding: 4px;
}
.password-toggle:hover {
    color: #555;
}

/* Run Now buttons */
.btn-run {
    background: #16a34a;
    color: #fff;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-run:hover { background: #15803d; }
.btn-run:disabled {
    background: #d97706;
    cursor: wait;
}
.btn-run .spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.btn-run:disabled .spinner {
    display: inline-block;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Process output console */
.process-output {
    background: #1a1a2e;
    color: #a3e635;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 12px;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 12px;
    display: none;
    line-height: 1.6;
}
.process-output.visible {
    display: block;
}

/* Progress bar */
.progress-bar-container {
    background: #e5e7eb;
    border-radius: 10px;
    height: 22px;
    overflow: hidden;
    margin: 8px 0;
    max-width: 500px;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ea8de, #2563eb);
    border-radius: 10px;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    font-weight: 600;
    min-width: 40px;
}

/* Data quality metrics grid */
.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.quality-metric {
    background: #f8f8f8;
    border-radius: 6px;
    padding: 14px;
    text-align: center;
}
.quality-metric .number {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
}
.quality-metric .qlabel {
    font-size: 12px;
    color: #777;
    margin-top: 2px;
}
.quality-metric.warn .number { color: #d97706; }
.quality-metric.good .number { color: #16a34a; }

/* Log tables */
.log-table { font-size: 12px; }
.log-table th { font-size: 11px; padding: 6px 8px; }
.log-table td { padding: 6px 8px; }
.log-status-success { color: #16a34a; font-weight: 600; }
.log-status-error, .log-status-failed { color: #dc2626; font-weight: 600; }
.log-status-running { color: #d97706; font-weight: 600; }

/* Crontab display */
.crontab-display {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 10px 14px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #374151;
    margin: 10px 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Type checkboxes grid */
.type-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.type-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}
.type-checkboxes input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1a1a2e;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.visible {
    opacity: 1;
    transform: translateY(0);
}
.toast.toast-error {
    background: #dc2626;
}

/* Section save buttons */
.section-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* Debug mode indicators (for owner pages) */
.debug-source-btn {
    color: #999;
    font-size: 11px;
    cursor: pointer;
    margin-left: 6px;
}
.debug-source-btn:hover { color: #4ea8de; }
.debug-source-panel {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 10px 14px;
    font-size: 12px;
    margin-top: 8px;
}
.debug-source-panel dt {
    font-weight: 600;
    color: #555;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.debug-source-panel dd {
    color: #333;
    margin-bottom: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}
.debug-invalid-row td {
    opacity: 0.5;
    text-decoration: line-through;
}
.debug-low-confidence {
    background: #fef3c7 !important;
}
.debug-split-original td {
    background: #f0f9ff;
    font-style: italic;
}
.debug-badge-invalid {
    background: #fee2e2;
    color: #991b1b;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}
.debug-badge-split {
    background: #dbeafe;
    color: #1e40af;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}
.debug-badge-low {
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}

/* SMTP config grid */
.smtp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 500px;
}

/* Log file list */
.log-file-list {
    list-style: none;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}
.log-file-list li {
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}
.log-file-list li:last-child { border-bottom: none; }
.log-file-list a {
    color: #2563eb;
    text-decoration: none;
}
.log-file-list a:hover { text-decoration: underline; }

/* Database maintenance section */
.db-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.db-stat-card {
    background: #f8f8f8;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
}
.db-stat-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
}
.db-stat-card .stat-label {
    font-size: 11px;
    color: #777;
    margin-top: 2px;
}
.db-table-stats {
    font-size: 12px;
    width: 100%;
    margin-bottom: 16px;
}
.db-table-stats th {
    font-size: 11px;
    padding: 6px 10px;
    text-align: left;
    background: #f3f4f6;
    border-bottom: 2px solid #e5e7eb;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.db-table-stats td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    font-family: 'Courier New', monospace;
}
.db-table-stats tr:hover td {
    background: #f8f9fa;
}
.db-table-stats .text-right {
    text-align: right;
}
.maintenance-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}
.maintenance-action-card {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 16px;
}
.maintenance-action-card h4 {
    font-size: 14px;
    color: #1a1a2e;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.maintenance-action-card .action-desc {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
}
.maintenance-action-card .action-stat {
    font-size: 12px;
    color: #555;
    margin-bottom: 8px;
}
.maintenance-action-card .action-stat strong {
    color: #1a1a2e;
}

/* Danger zone (purge) */
.danger-zone {
    border: 2px solid #dc2626;
    border-radius: 6px;
    padding: 16px;
    margin-top: 20px;
    background: #fef2f2;
}
.danger-zone h3 {
    font-size: 15px;
    color: #991b1b;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.danger-zone .danger-desc {
    font-size: 13px;
    color: #7f1d1d;
    margin-bottom: 12px;
}
.danger-zone .danger-count {
    font-size: 14px;
    font-weight: 700;
    color: #dc2626;
    margin-bottom: 12px;
}
.danger-zone .confirm-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.danger-zone .confirm-row input[type="text"] {
    padding: 8px 12px;
    border: 2px solid #fca5a5;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    width: 160px;
    background: #fff;
}
.danger-zone .confirm-row input[type="text"]:focus {
    outline: none;
    border-color: #dc2626;
}
.btn-danger {
    background: #dc2626;
    color: #fff;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled {
    background: #999;
    cursor: not-allowed;
}
.btn-danger .spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.btn-danger:disabled .spinner {
    display: inline-block;
}

/* Phone column */
.phone-col {
    width: 70px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
}
th.phone-col {
    cursor: default;
}
.phone-yes { color: #059669; font-size: 13px; }
.phone-no { color: #dc2626; font-size: 13px; }
.phone-na { color: #d1d5db; font-size: 13px; }
.phone-household { color: #7c3aed; font-size: 13px; cursor: help; }

/* Contact card in detail rows */
.contact-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.contact-card-header {
    background: #f0f7ff;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.contact-card-header i {
    font-size: 14px;
}
.contact-card-body {
    padding: 12px 14px;
}
.contact-columns {
    display: flex;
    gap: 32px;
}
.contact-col {
    flex: 1;
    min-width: 0;
}
.contact-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.contact-entry + .contact-entry {
    border-top: 1px solid #f3f4f6;
}
.phone-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}
.phone-badge-mobile {
    background: #d1fae5;
    color: #065f46;
}
.phone-badge-landline {
    background: #dbeafe;
    color: #1e40af;
}
.contact-phone-link {
    color: #1a1a2e;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.contact-phone-link:hover {
    color: #2563eb;
    text-decoration: underline;
}
.contact-email-icon {
    color: #9ca3af;
    font-size: 13px;
    flex-shrink: 0;
}
.contact-email-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 13px;
}
.contact-email-link:hover {
    text-decoration: underline;
}
.contact-empty {
    font-size: 13px;
    color: #9ca3af;
    padding: 8px 0;
}
.contact-empty i {
    margin-right: 4px;
}
.contact-meta {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
    font-size: 11px;
    color: #9ca3af;
}

/* Household contact card */
.household-card {
    background: #fff;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.household-card-header {
    background: #f5f3ff;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #6d28d9;
    border-bottom: 1px solid #e9d5ff;
    display: flex;
    align-items: center;
    gap: 6px;
}
.household-card-header i { font-size: 14px; }
.household-card-body { padding: 12px 14px; }
.household-member { margin-bottom: 8px; }
.household-member:last-child { margin-bottom: 0; }
.household-member-name {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.household-rel-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: #ede9fe;
    color: #6d28d9;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

@media (max-width: 640px) {
    .contact-columns {
        flex-direction: column;
        gap: 12px;
    }
}

/* Phone Lookup Section */
.phone-progress-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.phone-stat {
    text-align: center;
    padding: 10px 8px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}
.phone-stat-value {
    display: block;
    font-size: 1.4em;
    font-weight: 700;
    color: #1f2937;
}
.phone-stat-label {
    display: block;
    font-size: 0.75em;
    color: #6b7280;
    margin-top: 2px;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
    }
    header .brand-name {
        position: static;
        transform: none;
        order: 1;
    }
    nav { flex-wrap: wrap; gap: 10px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .unit-header-row { flex-direction: column; }
    .phone-summary { min-width: 0; }
    .search-bar { padding: 10px; gap: 6px; }
    .search-bar input[type="text"] { min-width: auto; width: 100%; }
    .search-bar select, .search-bar input[type="date"] { width: 100%; max-width: none; }
    .search-bar .date-group { width: 100%; }
    .result-count { flex-direction: column; gap: 8px; align-items: flex-start; }
    table { font-size: 12px; }
    th, td { padding: 6px 8px; }
    .maintenance-actions { grid-template-columns: 1fr; }
}
