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

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #252836;
    --bg-input: #2d3040;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;
    --border-color: #3c4043;
    --accent-green: #34a853;
    --accent-green-hover: #2d9249;
    --accent-red: #ea4335;
    --accent-red-hover: #d33426;
    --accent-blue: #8ab4f8;
    --accent-yellow: #fdd663;
    --focus-ring: rgba(138, 180, 248, 0.4);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --transition: 0.15s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 28px; font-weight: 700; color: var(--accent-blue); }
.login-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--text-secondary); }
.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color var(--transition);
}
.login-form input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--focus-ring); }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-error { background: rgba(234, 67, 53, 0.15); border: 1px solid var(--accent-red); color: var(--accent-red); }

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.logo { font-size: 20px; font-weight: 700; color: var(--accent-blue); }

.tabs { display: flex; gap: 4px; }
.tab {
    background: none;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
}
.tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.tab.active { background: var(--bg-tertiary); color: var(--accent-blue); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-info { font-size: 14px; color: var(--text-secondary); }
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--bg-tertiary);
    color: var(--accent-blue);
    margin-left: 6px;
}
.btn-logout {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: all var(--transition);
}
.btn-logout:hover { border-color: var(--accent-red); color: var(--accent-red); }

/* Content */
.content { height: calc(100vh - 56px); overflow: hidden; }

.tab-panel { display: none; height: 100%; overflow-y: auto; padding: 20px; }
.tab-panel.active { display: block; }

/* Verify layout */
.verify-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.record-counter { font-size: 16px; font-weight: 600; }
.record-counter span { color: var(--accent-blue); }
.record-filename { font-size: 14px; color: var(--text-secondary); }

.search-form {
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-form input[type="text"] {
    width: 260px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition);
}
.search-form input[type="text"]:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--focus-ring); }

.btn-search {
    padding: 6px 14px;
    background: var(--accent-blue);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
}
.btn-search:hover { opacity: 0.85; }

.btn-search-clear {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-search-clear:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.btn-search-clear.hidden { display: none; }

.search-mode .record-counter,
.search-mode .record-filename { display: none; }

.verify-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    height: calc(100vh - 200px);
}

/* Image panel */
.image-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: #111;
    position: relative;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.1s ease;
}

.image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 18px;
}

.image-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.image-controls button {
    padding: 4px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}
.image-controls button:hover { border-color: var(--accent-blue); }
.image-controls #zoom-level { font-size: 13px; color: var(--text-secondary); min-width: 40px; text-align: center; }

/* Data panel */
.data-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    overflow-y: auto;
}

.field-group { margin-bottom: 12px; }
.field-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.data-field {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition);
}
.data-field:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--focus-ring); }
.data-field.modified { border-color: var(--accent-yellow); background: rgba(253, 214, 99, 0.05); }

select.data-field { appearance: none; cursor: pointer; }
textarea.data-field { resize: vertical; font-family: inherit; }

/* FR address lookup */
.field-with-action {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
}
.field-with-action .data-field { flex: 1; }

.btn-fr-lookup {
    padding: 8px 12px;
    background: var(--accent-blue);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity var(--transition);
}
.btn-fr-lookup:hover { opacity: 0.85; }
.btn-fr-lookup.hidden { display: none; }

.fr-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow);
    margin-top: 4px;
}
.fr-results-dropdown.hidden { display: none; }

.fr-result-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition);
}
.fr-result-item:last-child { border-bottom: none; }
.fr-result-item:hover, .fr-result-item.selected { background: var(--bg-tertiary); }

.fr-result-label { font-size: 13px; flex: 1; line-height: 1.4; }
.fr-result-score {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--accent-red);
    flex-shrink: 0;
}
.fr-result-score.high { background: var(--accent-green); }
.fr-result-score.medium { background: var(--accent-yellow); }

/* Verify actions */
.verify-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.action-hint { font-size: 12px; color: var(--text-muted); }
.action-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    color: var(--text-secondary);
}

.action-buttons { display: flex; gap: 12px; }

.view-mode-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-secondary);
}
.view-mode-banner.hidden { display: none; }
.view-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--accent-blue);
    color: #000;
}
.view-mode-banner strong { color: var(--accent-blue); }
.view-hint { flex: 1; }

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn .shortcut { font-weight: 400; opacity: 0.7; font-size: 12px; }
.btn-accept { background: var(--accent-green); color: #fff; }
.btn-accept:hover { background: var(--accent-green-hover); }
.btn-reject { background: var(--accent-red); color: #fff; }
.btn-reject:hover { background: var(--accent-red-hover); }
.btn-primary { background: var(--accent-blue); color: #000; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg-tertiary); border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-secondary:hover { border-color: var(--accent-blue); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: var(--accent-red-hover); }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: var(--shadow);
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(20px); pointer-events: none; }
.toast-success { background: var(--accent-green); color: #fff; }
.toast-error { background: var(--accent-red); color: #fff; }
.toast-info { background: var(--accent-blue); color: #000; }

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.loading-overlay.hidden { display: none; }

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.stat-value { font-size: 36px; font-weight: 700; color: var(--accent-blue); }
.stat-label { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

.stats-user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.stat-user-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
}
.stat-user-card h4 { font-size: 16px; margin-bottom: 12px; color: var(--accent-blue); }
.stat-user-card .stat-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.stat-user-card .stat-row span:first-child { color: var(--text-secondary); }

/* Audit table */
.audit-controls { display: flex; gap: 12px; margin-bottom: 16px; }
.audit-controls input, .audit-controls select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}
.audit-controls input { flex: 1; }

.audit-table-container { overflow-x: auto; }
.audit-table { width: 100%; border-collapse: collapse; }
.audit-table th, .audit-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.audit-table th { background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.audit-table tr:hover { background: var(--bg-tertiary); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; font-size: 14px; color: var(--text-secondary); }

/* Users table */
.user-controls { margin-bottom: 16px; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}
.users-table th { background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
}
.modal-content h3 { margin-bottom: 16px; }
.modal-content .form-group { margin-bottom: 16px; }
.modal-content label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--text-secondary); }
.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}
.modal-content input:focus, .modal-content select:focus { outline: none; border-color: var(--accent-blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes flashGreen { 0% { box-shadow: 0 0 0 3px rgba(52, 168, 83, 0); } 50% { box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.5); } 100% { box-shadow: 0 0 0 3px rgba(52, 168, 83, 0); } }
@keyframes flashRed { 0% { box-shadow: 0 0 0 3px rgba(234, 67, 53, 0); } 50% { box-shadow: 0 0 0 3px rgba(234, 67, 53, 0.5); } 100% { box-shadow: 0 0 0 3px rgba(234, 67, 53, 0); } }

.flash-accept { animation: flashGreen 0.5s ease; }
.flash-reject { animation: flashRed 0.5s ease; }

@keyframes fieldPulse {
    0% { background-color: var(--bg-input); box-shadow: none; }
    30% { background-color: rgba(52, 168, 83, 0.25); box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.4); }
    100% { background-color: rgba(253, 214, 99, 0.05); box-shadow: none; }
}
.field-flash { animation: fieldPulse 0.8s ease; }

/* Confidence indicators */
.confidence-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    font-size: 0;
    position: relative;
    cursor: help;
    background: var(--text-muted);
    opacity: 0.3;
    line-height: 10px;
    text-align: center;
}
.confidence-dot::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
}
.confidence-dot.high { background: var(--accent-green); opacity: 1; }
.confidence-dot.medium { background: var(--accent-yellow); opacity: 1; }
.confidence-dot.low { background: var(--accent-red); opacity: 1; }
.confidence-dot.none { background: var(--text-muted); opacity: 0.3; }

.confidence-dot::after {
    content: attr(title);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 50;
}
.confidence-dot:hover::after { opacity: 1; }

.overall-confidence {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.overall-confidence .confidence-bar {
    width: 80px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}
.overall-confidence .confidence-fill {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
}
.overall-confidence .confidence-text {
    font-weight: 600;
    min-width: 35px;
}

/* Validation indicators */
.validation-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-left: 4px; vertical-align: middle;
    position: relative; cursor: help; border: 1px solid var(--border-color);
}
.validation-dot.valid { background: var(--accent-green); border-color: var(--accent-green); }
.validation-dot.invalid { background: var(--accent-red); border-color: var(--accent-red); animation: pulseRed 2s infinite; }
.validation-dot.warn { background: var(--accent-yellow); border-color: var(--accent-yellow); }
.validation-dot.auto-corrected { background: var(--accent-blue); border-color: var(--accent-blue); }
.validation-dot.empty { background: transparent; border-color: transparent; }
.validation-dot::after {
    content: attr(title); position: absolute; bottom: 120%; left: 50%;
    transform: translateX(-50%); padding: 4px 8px;
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 4px; font-size: 11px; color: var(--text-secondary);
    white-space: nowrap; opacity: 0; pointer-events: none;
    transition: opacity 0.15s; z-index: 50;
}
.validation-dot:hover::after { opacity: 1; }
@keyframes pulseRed {
    0%, 100% { box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(234, 67, 53, 0); }
}
.auth-badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.auth-badge-ldap { background: #e8f0fe; color: #1a73e8; }
.auth-badge-local { background: #e6f4ea; color: #137333; }
.login-hint { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: 12px; margin-bottom: 0; }
.data-field.invalid { border-color: #ea4335; background: #fce8e6; }
