/* ===================================================
   CCCD eKYC System - Main Stylesheet
   Design: Clean, modern card-based UI matching mockup
   Colors: White/gray bg, dark text, coral accent (#E8576C)
   =================================================== */

/* --- CSS Variables --- */
:root {
    --bg-primary: #F0F2F5;
    --bg-card: #FFFFFF;
    --bg-section: #F8F9FA;
    --text-primary: #1A1A2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --border-color: #E5E7EB;
    --border-dashed: #CBD5E1;
    --accent-primary: #E8576C;
    --accent-primary-hover: #D64458;
    --accent-primary-light: rgba(232, 87, 108, 0.08);
    --accent-success: #10B981;
    --accent-info: #3B82F6;
    --accent-warning: #F59E0B;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* --- App Container --- */
.app-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

/* --- Main Card --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Card Header --- */
.card-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    background: var(--bg-card);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.btn-close {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--text-primary);
    background: var(--bg-section);
}

/* --- Info Section --- */
.info-section {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.info-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}

.action-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-action {
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-action:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-primary-light);
    transform: translateY(-1px);
}

.btn-action:active {
    transform: translateY(0);
}

/* --- Extract Section (Portrait + QR) --- */
.extract-section {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.extract-card {
    background: var(--bg-section);
    border-radius: var(--radius-md);
    padding: 12px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.extract-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Portrait */
.portrait-frame {
    width: 100%;
    aspect-ratio: 3/4;
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-card);
    transition: var(--transition);
}

.portrait-frame.has-image {
    border: 2px solid var(--accent-success);
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* QR Content */
.qr-content {
    min-height: 80px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.qr-data {
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-primary);
    width: 100%;
}

.qr-data .qr-field {
    display: flex;
    gap: 4px;
    padding: 2px 0;
}

.qr-data .qr-field-label {
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 60px;
}

.qr-data .qr-field-value {
    color: var(--text-primary);
    word-break: break-all;
}

/* --- CCCD Sections (Front & Back) --- */
.cccd-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.section-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* --- Dropzone --- */
.image-dropzone {
    width: 100%;
    min-height: 160px;
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    background: var(--bg-section);
}

.image-dropzone:hover {
    border-color: var(--accent-info);
    background: rgba(59, 130, 246, 0.03);
}

.image-dropzone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-light);
    transform: scale(1.01);
}

.image-dropzone.has-image {
    border: 2px solid var(--accent-success);
    cursor: default;
}

.dropzone-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.dropzone-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* --- Image Preview --- */
.image-preview {
    position: relative;
    width: 100%;
}

.image-preview img {
    width: 100%;
    display: block;
    border-radius: 10px;
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.btn-remove:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
}

/* Preview actions container (edit + remove buttons) */
.preview-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 6;
}

.preview-actions .btn-remove {
    position: static;
    top: auto;
    right: auto;
}

.btn-edit {
    width: 28px;
    height: 28px;
    background: rgba(59, 130, 246, 0.85);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.btn-edit:hover {
    background: #2563EB;
    transform: scale(1.1);
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.image-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: var(--accent-success);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    letter-spacing: 0.3px;
}

/* --- Processing Overlay --- */
.processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 5;
    backdrop-filter: blur(4px);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Spinner */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --- Card Footer --- */
.card-footer {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-section);
}

.footer-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    flex: 1;
}

.footer-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* --- Buttons --- */
.btn {
    padding: 10px 22px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
    white-space: nowrap;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-section);
    border-color: var(--text-muted);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(232, 87, 108, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-primary-hover);
    box-shadow: 0 4px 16px rgba(232, 87, 108, 0.4);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* --- Camera Modal --- */
.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    color: white;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.btn-close-camera {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
}

.camera-body {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.camera-body video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-guide {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.guide-frame {
    width: 85%;
    max-width: 360px;
    aspect-ratio: 1.585;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
}

.guide-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--accent-primary);
    border-style: solid;
    border-width: 0;
}

.guide-corner.tl { top: -2px; left: -2px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 12px; }
.guide-corner.tr { top: -2px; right: -2px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 12px; }
.guide-corner.bl { bottom: -2px; left: -2px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 12px; }
.guide-corner.br { bottom: -2px; right: -2px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 12px; }

.guide-text {
    color: white;
    font-size: 0.85rem;
    margin-top: 16px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.camera-footer {
    padding: 24px;
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.btn-capture {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.capture-ring {
    width: 64px;
    height: 64px;
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.capture-dot {
    width: 52px;
    height: 52px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-capture:hover .capture-ring {
    transform: scale(1.05);
}

.btn-capture:active .capture-dot {
    transform: scale(0.85);
    background: var(--accent-primary);
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: toastIn 0.3s ease forwards;
    max-width: 90%;
}

.toast.error {
    background: var(--accent-primary);
}

.toast.success {
    background: var(--accent-success);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    padding: 20px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    text-align: center;
    max-width: 340px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-icon {
    margin-bottom: 16px;
}

.modal-icon.success {
    color: var(--accent-success);
}

.modal-content h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal-content .btn {
    width: 100%;
}

/* --- Responsive --- */
@media (max-width: 540px) {
    body {
        padding: 0 0 40px 0;
        align-items: flex-start;
    }

    .app-container {
        max-width: 100%;
    }

    .card {
        border-radius: 0;
        min-height: auto;
        overflow: visible;
        box-shadow: none;
    }

    .extract-section {
        grid-template-columns: 120px 1fr;
    }
}

@media (max-width: 480px) {
    .extract-section {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .portrait-card {
        max-width: 140px;
        margin: 0 auto;
    }
}

/* --- Utility Animations --- */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.processing .dropzone-placeholder {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ===================================================
   CCCD eKYC System - Premium UI & Dark Mode Updates
   =================================================== */

/* --- Navigation & Tabs --- */
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow: visible;
    padding: 6px 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tab {
    padding: 10px 18px !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 30px !important;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    font-size: 0.88rem !important;
    transition: var(--transition) !important;
    white-space: nowrap !important;
    box-shadow: var(--shadow-sm) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    height: auto !important;
}

.nav-tab:hover {
    color: var(--text-primary) !important;
    border-color: var(--text-muted) !important;
    transform: translateY(-1.5px) !important;
}

.nav-tab.active {
    background: var(--accent-primary) !important;
    color: #FFFFFF !important;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 4px 12px var(--accent-primary-light) !important;
}

.nav-tab.active:hover {
    color: #FFFFFF !important;
    transform: none !important;
}

@media (min-width: 640px) {
    .nav-tabs {
        justify-content: center;
    }
}

@media (max-width: 700px) {
    .nav-tabs {
        gap: 8px;
        margin-bottom: 18px;
        padding: 8px 0;
    }

    .nav-tab {
        padding: 9px 14px !important;
        font-size: 0.82rem !important;
    }

    .nav-user-chip {
        padding: 5px 10px;
    }

    .nav-user-chip .user-name {
        max-width: 130px;
    }

    .info-section {
        flex-direction: column;
        align-items: stretch;
    }

    .action-buttons {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .card-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .footer-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
        width: 100%;
    }

    .json-code-block {
        max-width: 100%;
        overflow-x: auto;
    }
}

/* --- Dynamic User Chip & Theme Control --- */
.nav-user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    margin-left: 0;
    transition: var(--transition);
    min-width: 0;
    max-width: 100%;
}

.nav-user-chip .user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #F43F5E 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.nav-user-chip .user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-chip .btn-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
}

.nav-user-chip .btn-logout:hover {
    color: var(--accent-primary);
    background: var(--bg-section);
}

.theme-toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    padding: 0;
    margin-left: 0;
    flex: 0 0 auto;
}

.theme-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    transform: scale(1.05);
}

/* --- Dark Mode Configuration --- */
body[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-card: #1E293B;
    --bg-section: #0F172A;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border-color: #334155;
    --border-dashed: #475569;
    --accent-primary-light: rgba(232, 87, 108, 0.18);
}

body[data-theme="dark"] .card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

body[data-theme="dark"] .card-header,
body[data-theme="dark"] .info-section,
body[data-theme="dark"] .extract-section,
body[data-theme="dark"] .cccd-section {
    border-bottom-color: var(--border-color);
}

body[data-theme="dark"] .card-footer {
    background: var(--bg-section);
    border-top: 1px solid var(--border-color);
}

body[data-theme="dark"] .extract-card,
body[data-theme="dark"] .image-dropzone {
    background: var(--bg-section);
    border-color: var(--border-color);
}

body[data-theme="dark"] .portrait-frame {
    background: var(--bg-card);
    border-color: var(--border-dashed);
}

body[data-theme="dark"] .btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body[data-theme="dark"] .btn-secondary:hover {
    background: var(--bg-section);
    border-color: var(--text-muted);
}

body[data-theme="dark"] .processing-overlay {
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-primary);
}

body[data-theme="dark"] .modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

body[data-theme="dark"] .doc-item {
    background: var(--bg-card);
    border-color: var(--border-color);
}

body[data-theme="dark"] .doc-item:hover {
    border-color: var(--accent-primary);
}

body[data-theme="dark"] .detail-tag {
    background: var(--bg-section);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

body[data-theme="dark"] .detail-tag strong {
    color: var(--text-primary);
}

body[data-theme="dark"] .btn-delete {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

body[data-theme="dark"] .btn-delete:hover {
    background: #ef4444;
}

body[data-theme="dark"] .field-group {
    background: var(--bg-section);
    border-color: var(--border-color);
}

body[data-theme="dark"] .field-group:hover {
    background: var(--bg-card);
}

body[data-theme="dark"] .field-value {
    color: var(--text-primary);
}

/* Agribank page dark overrides */
body.agribank-page[data-theme="dark"] {
    --bg-primary: #0F1A15;
    --bg-card: #182C22;
    --bg-section: #0B130E;
    --border-color: rgba(16, 185, 129, 0.15);
    --border-dashed: rgba(16, 185, 129, 0.25);
    --accent-success: #10B981;
}

/* Bìa Đỏ page dark overrides */
body.biado-page[data-theme="dark"] {
    --bg-primary: #1E0F0F;
    --bg-card: #2E1818;
    --bg-section: #150B0B;
    --border-color: rgba(217, 56, 58, 0.15);
    --border-dashed: rgba(217, 56, 58, 0.25);
}

/* Phương Tiện page dark overrides */
body.phuongtien-page[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-card: #1E293B;
    --bg-section: #0B132B;
    --border-color: rgba(2, 132, 199, 0.15);
    --border-dashed: rgba(2, 132, 199, 0.25);
}

/* --- Premium Lightbox Style --- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.show {
    opacity: 1;
}

.lightbox-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    cursor: default;
}

.lightbox-overlay.show .lightbox-img {
    transform: scale(1);
}

.btn-close-lightbox {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-close-lightbox:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* --- Shared Results Grid & Dropzones layout --- */
.dropzones-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 15px;
}

@media (min-width: 640px) {
    .dropzones-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.dropzone-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dropzone-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: left;
}

/* --- CCCD Results Grid Layout --- */
.cccd-results-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 15px;
}

@media (min-width: 640px) {
    .cccd-results-container {
        grid-template-columns: 150px 1fr;
    }
}

/* --- Field Grid & Field Group --- */
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .field-grid {
        grid-template-columns: 1fr;
    }
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.field-group::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transition: var(--transition);
}

.field-group:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--text-muted);
    background: var(--bg-card);
}

.field-group:hover::before {
    background: var(--accent-primary);
}

.field-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-word;
}

.field-value.highlight {
    color: var(--accent-primary);
    font-weight: 700;
}

/* Dark theme customizations for field-group */
body[data-theme="dark"] .field-group {
    background: rgba(15, 23, 42, 0.35);
}
body[data-theme="dark"] .field-group:hover {
    background: rgba(30, 41, 59, 0.8);
}

/* ===================================================
   User & Role Management System
   =================================================== */

.user-role-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: 4px;
}

.admin-mgmt-header {
    margin-bottom: 20px;
}

.admin-mgmt-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.admin-mgmt-table th,
.admin-mgmt-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.admin-mgmt-table tbody tr {
    transition: var(--transition);
}

.admin-mgmt-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.02);
}

body[data-theme="dark"] .admin-mgmt-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Status Badge Styles */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

/* Role Badge Styles */
.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: white;
}

.role-badge.admin {
    background: #a855f7; /* purple */
}

.role-badge.user {
    background: #3b82f6; /* blue */
}

.role-badge.custom {
    background: #10b981; /* green */
}

.permission-grid label {
    transition: var(--transition);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.permission-grid label:hover {
    background: rgba(0, 0, 0, 0.05);
}

body[data-theme="dark"] .permission-grid label:hover {
    background: rgba(255, 255, 255, 0.05);
}

body[data-theme="dark"] .permission-grid {
    background: rgba(255, 255, 255, 0.02) !important;
}

/* Action button icons styling */
.action-btn-group {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.btn-icon:hover {
    background: var(--bg-section);
    color: var(--text-primary);
    transform: scale(1.05);
}

.btn-icon.delete:hover {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
    color: white;
}

.btn-icon.edit:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}
