/* --- CẤU HÌNH BIẾN MÀU SẮC & PHÔNG CHỮ --- */
:root {
    --bg-primary: #0a0f1d;
    --bg-secondary: #131b2e;
    --bg-card: rgba(26, 37, 62, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #1e6091;
    
    --primary: #1e6091;
    --primary-hover: #1a4f78;
    --success: #2a9d8f;
    --success-hover: #228074;
    --warning: #f4a261;
    --danger: #e76f51;
    --danger-dark: #b5381b;
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #cbd5e1;
    
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
    
    --glass-bg: rgba(19, 27, 46, 0.7);
    --glass-blur: blur(12px);
}

/* --- RESET & ĐỊNH DẠNG CHUNG --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* --- BỐ CỤC CHÍNH (APP CONTAINER) --- */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* --- THANH MENU TRÁI (SIDEBAR) --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 0 20px 25px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.logo-icon {
    color: var(--warning);
    margin-right: 12px;
    display: flex;
    align-items: center;
}

.logo-text h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
}

.logo-text p {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 2px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0 10px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.menu-item .icon {
    margin-right: 12px;
    font-size: 16px;
    display: inline-block;
    width: 20px;
    text-align: center;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.menu-item.active {
    background-color: var(--primary);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.sidebar-footer {
    padding: 15px 20px 0 20px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
}

.status-offline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    margin-bottom: 5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--success);
}

.version {
    font-size: 10px;
}

/* --- KHU VỰC HIỂN THỊ NỘI DUNG CHÍNH --- */
.main-content {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    padding: 30px;
    background-image: radial-gradient(circle at 80% 20%, rgba(30, 96, 145, 0.07) 0%, transparent 50%);
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.content-header h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* --- NÚT BẤM (BUTTONS) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-main);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-success {
    background-color: var(--success);
    color: var(--text-main);
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--text-main);
}

.btn-danger:hover {
    background-color: var(--danger-dark);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* --- THANH TÌM KIẾM NHANH --- */
.search-bar-quick {
    margin-bottom: 20px;
}

.search-bar-quick input {
    width: 100%;
    padding: 14px 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 15px;
    font-family: var(--font-family);
    transition: border-color 0.2s;
}

.search-bar-quick input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(30, 96, 145, 0.15);
}

/* --- BẢNG DỮ LIỆU (DATA TABLE) --- */
.table-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.data-table th {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 14px 18px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
}

.data-table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-light);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* --- THẺ HÌNH ẢNH TRONG BẢNG --- */
.table-thumbnail {
    width: 50px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: var(--bg-secondary);
}

.table-thumbnail-placeholder {
    width: 50px;
    height: 60px;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: 1px dashed var(--border-color);
}

/* --- NHÃN TRẠNG THÁI (BADGES) --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
}

.badge-danger {
    background-color: rgba(231, 111, 81, 0.15);
    color: var(--danger);
    border: 1px solid rgba(231, 111, 81, 0.3);
}

.badge-success {
    background-color: rgba(42, 157, 143, 0.15);
    color: var(--success);
    border: 1px solid rgba(42, 157, 143, 0.3);
}

.badge-warning {
    background-color: rgba(244, 162, 97, 0.15);
    color: var(--warning);
    border: 1px solid rgba(244, 162, 97, 0.3);
}

.badge-secondary-custom {
    background-color: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* --- PHÂN HỆ VỤ ÁN: GRID & CARD --- */
.vu-an-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    backdrop-filter: var(--glass-blur);
    transition: transform 0.2s, border-color 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.vu-an-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.4;
}

.vu-an-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vu-an-meta span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vu-an-summary {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

/* --- PHÂN HỆ NHẬN DIỆN KHUÔN MẶT CỤC BỘ --- */
.face-search-container {
    max-width: 800px;
    margin: 0 auto;
}

.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    background-color: var(--bg-card);
    transition: all 0.2s ease;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--border-focus);
    background-color: rgba(30, 96, 145, 0.08);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    font-size: 40px;
}

.drop-zone p {
    font-size: 15px;
    color: var(--text-light);
}

.drop-zone p strong {
    color: var(--warning);
}

.file-info {
    font-size: 12px;
    color: var(--text-muted);
}

.preview-and-action {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.img-preview-box {
    width: 240px;
    height: 300px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-secondary);
    position: relative;
}

.img-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hiệu ứng thanh quét (Scan Bar) */
.scanning-loader {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: var(--text-light);
}

.scan-bar {
    width: 240px;
    height: 4px;
    background-color: var(--warning);
    border-radius: 2px;
    box-shadow: 0 0 12px var(--warning);
    animation: scanAnimation 2s infinite linear;
}

@keyframes scanAnimation {
    0% { transform: translateY(0); }
    50% { transform: translateY(296px); }
    100% { transform: translateY(0); }
}

/* Thẻ kết quả so khớp khuôn mặt */
.matching-results-area {
    margin-top: 40px;
}

.matching-results-area h3 {
    margin-bottom: 20px;
    font-size: 16px;
    color: var(--warning);
    letter-spacing: -0.2px;
}

.matching-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.match-card {
    display: flex;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px 20px;
    gap: 20px;
    backdrop-filter: var(--glass-blur);
    transition: transform 0.15s;
}

.match-card:hover {
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.15);
}

.match-avatar {
    width: 60px;
    height: 75px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.match-info {
    flex-grow: 1;
}

.match-info h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 5px;
}

.match-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.match-similarity {
    text-align: right;
}

.percentage {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
}

.percentage.high-match {
    color: #4ade80;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.match-similarity label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-top: 2px;
}

/* --- BỘ LỌC TÌM KIẾM NÂNG CAO --- */
.filter-panel {
    margin-bottom: 25px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.form-group input, .form-group select, .form-group textarea {
    padding: 10px 14px;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    font-family: var(--font-family);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

.range-group {
    display: flex;
    gap: 10px;
}

.range-group input {
    width: 50%;
}

.btn-group-right {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

.results-header {
    margin-bottom: 15px;
}

.results-header h3 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
}

/* --- MODAL (HỘP THOẠI NỔI) --- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: zoomIn 0.2s ease;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.modal-large {
    max-width: 850px;
}

.modal-full-profile {
    width: 96vw;
    max-width: 1550px;
    height: 94vh;
    max-height: 94vh;
    border-radius: 14px;
}

.modal-body-full {
    padding: 16px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
}

/* Multi-column Grid Layout for Full Profile (No-Scroll View) */
.profile-full-grid {
    display: grid;
    grid-template-columns: 220px 1.25fr 1.1fr;
    gap: 16px;
    height: 100%;
    align-items: start;
}

.profile-col-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-col-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inline-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
}

.inline-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.inline-field.full-width {
    grid-column: 1 / -1;
}

.inline-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.inline-input, .inline-select, .inline-textarea {
    width: 100%;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 12px;
    font-family: var(--font-family);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.inline-input:focus, .inline-select:focus, .inline-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.inline-input.ocr-highlighted, .inline-textarea.ocr-highlighted {
    animation: ocrPulse 1.5s ease-in-out;
    border-color: #10b981 !important;
    background: rgba(16, 185, 129, 0.15) !important;
}

@keyframes ocrPulse {
    0% { background: rgba(16, 185, 129, 0.4); }
    100% { background: rgba(0, 0, 0, 0.3); }
}

.compact-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.compact-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
}


@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s;
}

.close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.required {
    color: var(--danger);
}

/* --- LAYOUT HỒ SƠ CHI TIẾT ĐỐI TƯỢNG (IN MODAL) --- */
.profile-detail-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 30px;
}

.profile-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.profile-avatar-large {
    width: 200px;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-md);
}

.profile-main-info h3 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--warning);
}

.profile-main-info h4 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-style: italic;
}

.profile-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--warning);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin: 25px 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-section-title.first {
    margin-top: 0;
}

.info-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.info-item {
    font-size: 13px;
    line-height: 1.5;
}

.info-item label {
    font-weight: 500;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.info-item span {
    color: var(--text-light);
}

.nested-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nested-item {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 12px 15px;
    border-left: 3px solid var(--primary);
    font-size: 13px;
}

.nested-item-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-main);
}

.nested-item-body {
    color: var(--text-light);
    line-height: 1.4;
}

.nested-item.tien-an {
    border-left-color: var(--danger);
}

.nested-item.tien-su {
    border-left-color: var(--warning);
}

.nested-item-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

/* --- GALLERY HÌNH ẢNH ĐỐI TƯỢNG --- */
.profile-gallery-container {
    width: 100%;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-thumbnails-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    width: 200px; /* Bằng chiều rộng của avatar lớn để thẳng hàng */
    justify-content: flex-start;
}

.profile-thumb-wrapper {
    position: relative;
    width: 60px;
    height: 75px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.profile-thumb-wrapper.active {
    border-color: var(--warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.profile-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-thumb-wrapper .thumb-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 8px;
    text-align: center;
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.profile-thumb-wrapper .btn-delete-thumb {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--danger);
    color: #fff;
    border: none;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.profile-thumb-wrapper:hover .btn-delete-thumb {
    opacity: 1;
}

.profile-thumb-wrapper .btn-delete-thumb:hover {
    background-color: #ef4444;
    transform: scale(1.1);
}

.btn-add-thumb {
    width: 60px;
    height: 75px;
    border-radius: 6px;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-thumb:hover {
    border-color: var(--warning);
    color: var(--warning);
    background-color: rgba(245, 158, 11, 0.05);
}

/* ============================================================
   TỔNG QUAN DASHBOARD
   ============================================================ */

/* --- Stat Cards (4 thẻ số liệu tổng hợp) --- */
.tq-stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 30px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px 24px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    opacity: 0.06;
    border-radius: 14px;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.stat-card-total {
    background: linear-gradient(135deg, rgba(30, 96, 145, 0.35), rgba(10, 15, 29, 0.7));
    border-color: rgba(30, 96, 145, 0.4);
}

.stat-card-danger {
    background: linear-gradient(135deg, rgba(231, 111, 81, 0.35), rgba(10, 15, 29, 0.7));
    border-color: rgba(231, 111, 81, 0.4);
}

.stat-card-warning {
    background: linear-gradient(135deg, rgba(244, 162, 97, 0.35), rgba(10, 15, 29, 0.7));
    border-color: rgba(244, 162, 97, 0.4);
}

.stat-card-normal {
    background: linear-gradient(135deg, rgba(42, 157, 143, 0.35), rgba(10, 15, 29, 0.7));
    border-color: rgba(42, 157, 143, 0.4);
}

.stat-icon {
    font-size: 32px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(255,255,255,0.2));
}

.stat-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* --- Section headers cho dashboard --- */
.tq-section {
    margin-bottom: 30px;
}

.tq-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.tq-section-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-light);
    letter-spacing: -0.2px;
}

/* --- Legend cảnh báo --- */
.tq-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.legend-do   { background-color: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.6); }
.legend-cam  { background-color: #f97316; box-shadow: 0 0 8px rgba(249,115,22,0.6); }
.legend-vang { background-color: #eab308; box-shadow: 0 0 8px rgba(234,179,8,0.6); }

/* --- Bảng thống kê địa bàn (progress bars) --- */
.tq-dia-ban-container {
    padding: 20px 24px;
}

.dia-ban-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dia-ban-row:last-child {
    border-bottom: none;
}

.dia-ban-name {
    width: 220px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dia-ban-bar-wrap {
    flex-grow: 1;
    height: 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 5px;
    overflow: hidden;
}

.dia-ban-bar-fill {
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, #1e6091, #2a9d8f);
    transition: width 0.6s ease;
    box-shadow: 0 0 8px rgba(42, 157, 143, 0.4);
}

.dia-ban-count {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    min-width: 28px;
    text-align: right;
}

.dia-ban-pct {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 38px;
    text-align: right;
}

/* --- Badge cảnh báo nguy hiểm --- */
.badge-canh-bao {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.badge-canh-bao-do {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

.badge-canh-bao-cam {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.35);
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.15);
}

.badge-canh-bao-vang {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.35);
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.15);
}

/* Highlight toàn bộ dòng theo mức cảnh báo */
.row-alert-do   td { background: rgba(239, 68, 68, 0.05) !important; }
.row-alert-cam  td { background: rgba(249, 115, 22, 0.05) !important; }
.row-alert-vang td { background: rgba(234, 179, 8, 0.04) !important; }

/* Tội danh pill list */
.toi-danh-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.toi-danh-pill {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.07);
    color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
}

/* Responsive: thu gọn stat cards xuống 2 cột trên màn nhỏ */
@media (max-width: 1100px) {
    .tq-stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- PHÂN HỆ PHÂN TÍCH CHUYÊN SÂU --- */
.phan-tich-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    margin-top: 20px;
}

.graph-card {
    height: 100%;
}

.graph-canvas-container {
    background-color: #0b0f19;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

#link-analysis-canvas {
    display: block;
    cursor: grab;
}

#link-analysis-canvas:active {
    cursor: grabbing;
}

.graph-controls {
    position: absolute;
    bottom: 15px;
    left: 15px;
    z-index: 5;
    background: rgba(15, 23, 42, 0.85);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
}

.graph-legend {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    font-size: 12px;
}

.legend-node {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.node-dt {
    background: #3b82f6;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
}

.node-va {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

/* Accordion băng ổ nhóm */
.scroll-panel {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 5px;
}

.gang-accordion-item {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.02);
}

.gang-accordion-header {
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    user-select: none;
}

.gang-accordion-header:hover {
    background: rgba(255,255,255,0.06);
}

.gang-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gang-name {
    font-weight: 600;
    color: var(--text-light);
    font-size: 14px;
}

.gang-count-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.gang-arrow {
    font-size: 12px;
    transition: transform 0.2s;
    color: var(--text-muted);
}

.gang-accordion-item.active .gang-arrow {
    transform: rotate(90deg);
}

.gang-accordion-body {
    display: none;
    padding: 10px 16px 15px;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.gang-accordion-item.active .gang-accordion-body {
    display: block;
}

.gang-member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.gang-member-row:last-child {
    border-bottom: none;
}

.gang-member-avatar {
    width: 32px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.1);
}

.gang-member-placeholder {
    width: 32px;
    height: 40px;
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.gang-member-info {
    flex-grow: 1;
}

.gang-member-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
}

.gang-member-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.gang-member-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gang-member-badge {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.gang-member-badge-an {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.gang-member-badge-su {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
}

/* SVG Chart */
.trend-svg-container {
    width: 100%;
    height: 100%;
    padding: 10px 0;
}

.trend-bar {
    fill: #2a9d8f;
    transition: fill 0.3s;
}

.trend-bar:hover {
    fill: #48cae4;
}

.trend-grid-line {
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 1;
}

.trend-axis {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 1;
}

.trend-text {
    fill: var(--text-muted);
    font-size: 10px;
    font-family: var(--font-main);
}

.trend-value-text {
    fill: var(--text-light);
    font-size: 9px;
    font-weight: bold;
    text-anchor: middle;
}

/* -------------------------------------------------------------------------- */
/* Vietnamese revolutionary visual theme                                      */
/* -------------------------------------------------------------------------- */
:root {
    --bg-primary: #26070c;
    --bg-secondary: rgba(71, 7, 15, 0.94);
    --bg-card: rgba(74, 12, 22, 0.86);
    --primary: #b5121b;
    --primary-hover: #d21d2a;
    --success: #4b9e5a;
    --warning: #f2c14e;
    --danger: #d62828;
    --danger-dark: #8f0e16;
    --border-color: rgba(255, 215, 0, 0.2);
    --border-focus: #ffd700;
    --text-main: #fff8e1;
    --text-muted: #e4c79c;
    --text-light: #ffedbf;
    --glass-bg: rgba(55, 6, 14, 0.86);
    --shadow: 0 12px 32px rgba(24, 0, 5, 0.38);
}

html,
body {
    background: #26070c;
}

body {
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(48, 4, 11, 0.94) 0%, rgba(48, 4, 11, 0.78) 36%, rgba(48, 4, 11, 0.55) 100%),
        url("/background/hinh-nen-powerpoint-trong-dong-hoa-sen-32.jpg") center / cover no-repeat;
}

.app-container {
    position: relative;
    z-index: 1;
}

.sidebar {
    background: linear-gradient(180deg, rgba(104, 8, 18, 0.97), rgba(48, 4, 11, 0.96));
    border-right-color: rgba(255, 215, 0, 0.24);
    box-shadow: 8px 0 28px rgba(24, 0, 5, 0.3);
}

.sidebar-header {
    border-bottom-color: rgba(255, 215, 0, 0.2);
}

.logo-icon {
    color: #ffd700;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.35));
}

.menu-item {
    color: #f8dfb0;
}

.menu-item:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #fff3c4;
}

.menu-item.active {
    background: linear-gradient(90deg, rgba(181, 18, 27, 0.96), rgba(126, 9, 20, 0.84));
    color: #fff1b8;
    border-left-color: #ffd700;
    box-shadow: inset 0 0 18px rgba(255, 215, 0, 0.08);
}

.main-content {
    background: linear-gradient(135deg, rgba(40, 5, 12, 0.78), rgba(72, 8, 17, 0.52));
}

.content-header h2 {
    color: #fff3c4;
    position: relative;
    padding-bottom: 7px;
    text-shadow: 0 2px 14px rgba(24, 0, 5, 0.55);
}

.content-header h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 68px;
    height: 2px;
    background: linear-gradient(90deg, #ffd700, rgba(255, 215, 0, 0));
}

.card,
.stat-card,
.modal-content,
.tq-section,
.profile-col-card {
    background: linear-gradient(145deg, rgba(102, 14, 25, 0.84), rgba(52, 6, 14, 0.9));
    border-color: var(--border-color);
    box-shadow: var(--shadow);
}

.card:hover,
.stat-card:hover {
    border-color: rgba(255, 215, 0, 0.42);
    box-shadow: 0 16px 36px rgba(24, 0, 5, 0.5);
}

.btn-primary {
    background: linear-gradient(135deg, #c51622, #8f0e16);
    border-color: rgba(255, 215, 0, 0.3);
    color: #fff4c7;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #e02430, #b5121b);
    border-color: rgba(255, 215, 0, 0.58);
}

input,
select,
textarea {
    background-color: rgba(38, 5, 12, 0.72);
    border-color: rgba(255, 215, 0, 0.2);
    color: #fff8e1;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #ffd700;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.14);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.34);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.55);
}

@media (max-width: 900px) {
    body::before {
        background-position: center top;
    }
}

/* -------------------------------------------------------------------------- */
/* Precision operations UI: trust-first, dense, readable                       */
/* -------------------------------------------------------------------------- */
:root {
    --bg-primary: #1c0a0d;
    --bg-secondary: rgba(45, 14, 20, 0.97);
    --bg-card: rgba(55, 20, 27, 0.88);
    --surface-raised: rgba(69, 25, 32, 0.92);
    --surface-inset: rgba(27, 8, 12, 0.64);
    --primary: #c52c38;
    --primary-hover: #e24a53;
    --accent-gold: #e7bf63;
    --success: #58ad73;
    --success-hover: #6ac789;
    --warning: #e8b85e;
    --danger: #ef6262;
    --danger-dark: #a71f2d;
    --border-color: rgba(231, 191, 99, 0.19);
    --border-strong: rgba(231, 191, 99, 0.38);
    --border-focus: #f0cb73;
    --text-main: #fff8ed;
    --text-muted: #d8bfae;
    --text-light: #f7e5cd;
    --shadow: 0 16px 40px rgba(11, 2, 5, 0.34);
    --shadow-soft: 0 8px 22px rgba(11, 2, 5, 0.23);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-family: "Segoe UI", "Noto Sans", system-ui, -apple-system, sans-serif;
}

html {
    color-scheme: dark;
    background: var(--bg-primary);
}

body {
    background: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.45;
}

body::before {
    background:
        linear-gradient(90deg, rgba(28, 10, 13, 0.96) 0%, rgba(28, 10, 13, 0.88) 45%, rgba(28, 10, 13, 0.66) 100%),
        url("/background/hinh-nen-powerpoint-trong-dong-hoa-sen-32.jpg") center / cover no-repeat;
    filter: saturate(0.78);
}

.app-container {
    min-height: 100dvh;
    height: 100dvh;
}

.sidebar {
    width: 272px;
    padding: 18px 12px 14px;
    background: linear-gradient(180deg, rgba(73, 20, 28, 0.98), rgba(35, 9, 14, 0.98));
    border-right: 1px solid var(--border-strong);
    box-shadow: 12px 0 34px rgba(10, 1, 4, 0.24);
}

.sidebar-header {
    gap: 12px;
    padding: 2px 10px 18px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    flex: 0 0 auto;
    margin-right: 0;
    width: 42px;
    height: 42px;
    justify-content: center;
    border: 1px solid rgba(231, 191, 99, 0.42);
    border-radius: 12px;
    background: rgba(14, 4, 7, 0.32) !important;
}

.logo-icon img {
    width: 34px !important;
    height: 34px !important;
}

.logo-text h1 {
    color: var(--text-main);
    font-size: 13px;
    letter-spacing: 0.08em;
    line-height: 1.25;
}

.logo-text p {
    color: var(--accent-gold);
    font-size: 10px;
    letter-spacing: 0.16em;
}

.sidebar-menu {
    gap: 4px;
    padding: 0 2px;
}

.menu-item {
    position: relative;
    min-height: 44px;
    padding: 11px 13px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 0.01em;
}

.menu-item .icon {
    width: 22px;
    margin-right: 10px;
    color: var(--accent-gold);
    opacity: 0.86;
}

.menu-item:hover {
    background: rgba(231, 191, 99, 0.08);
    border-color: rgba(231, 191, 99, 0.18);
    color: var(--text-main);
}

.menu-item.active {
    background: linear-gradient(90deg, rgba(197, 44, 56, 0.95), rgba(128, 25, 37, 0.88));
    border-color: rgba(231, 191, 99, 0.34);
    border-left: 3px solid var(--accent-gold);
    color: #fff7df;
    box-shadow: 0 7px 18px rgba(13, 1, 5, 0.22);
}

.sidebar-footer {
    padding: 14px 10px 0;
    border-top-color: var(--border-color);
    color: var(--text-muted);
}

.status-dot {
    box-shadow: 0 0 0 3px rgba(88, 173, 115, 0.12), 0 0 10px rgba(88, 173, 115, 0.72);
}

.main-content {
    min-width: 0;
    padding: clamp(20px, 3vw, 38px);
    background:
        linear-gradient(135deg, rgba(37, 10, 16, 0.78), rgba(67, 19, 28, 0.48)),
        radial-gradient(circle at 92% 6%, rgba(231, 191, 99, 0.08), transparent 35%);
}

.tab-panel {
    width: min(100%, 1680px);
    margin: 0 auto;
}

.content-header {
    min-height: 48px;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(231, 191, 99, 0.16);
}

.content-header h2 {
    max-width: 820px;
    color: var(--text-main);
    font-size: clamp(20px, 2vw, 29px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-shadow: none;
}

.content-header h2::after {
    width: 54px;
    height: 3px;
    bottom: -16px;
    background: var(--accent-gold);
}

.btn {
    min-height: 40px;
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
}

.btn:focus-visible,
.menu-item:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.btn:active {
    transform: translateY(1px) scale(0.985);
}

.btn-primary {
    background: linear-gradient(135deg, #cf3440, #9f1f2b);
    border-color: rgba(255, 235, 187, 0.2);
    color: #fff8eb;
    box-shadow: 0 6px 14px rgba(119, 15, 26, 0.28);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #e24a53, #b42835);
    border-color: rgba(231, 191, 99, 0.48);
}

.btn-secondary {
    background: rgba(28, 8, 13, 0.42);
    border-color: var(--border-color);
    color: var(--text-light);
}

.btn-secondary:hover {
    background: rgba(231, 191, 99, 0.1);
    border-color: var(--border-strong);
    color: var(--text-main);
}

.card,
.stat-card,
.modal-content,
.tq-section,
.profile-col-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(71, 25, 33, 0.92), rgba(41, 12, 19, 0.94));
    box-shadow: var(--shadow-soft);
}

.card-header,
.tq-section-header {
    border-bottom-color: rgba(231, 191, 99, 0.14);
}

.card:hover,
.stat-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

input,
select,
textarea {
    min-height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(24, 7, 11, 0.68);
    color: var(--text-main);
}

textarea {
    min-height: 96px;
}

input::placeholder,
textarea::placeholder {
    color: rgba(216, 191, 174, 0.66);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(231, 191, 99, 0.12);
}

.table-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(24, 7, 11, 0.42);
    box-shadow: var(--shadow-soft);
}

.data-table {
    min-width: 840px;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 14px;
    background: rgba(75, 21, 30, 0.98);
    border-bottom: 1px solid var(--border-strong);
    color: var(--accent-gold);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.data-table td {
    padding: 12px 14px;
    border-bottom-color: rgba(231, 191, 99, 0.1);
    color: var(--text-light);
    font-size: 12px;
}

.data-table tbody tr:nth-child(even) td {
    background: rgba(255, 248, 237, 0.018);
}

.data-table tbody tr:hover td {
    background: rgba(231, 191, 99, 0.075);
}

.search-bar-quick,
.filter-panel,
.graph-filter-bar {
    border-color: var(--border-color) !important;
    background: rgba(49, 14, 21, 0.64) !important;
    border-radius: var(--radius-md) !important;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    position: absolute;
    right: 18px;
    bottom: -20px;
    width: 90px;
    height: 90px;
    border: 1px solid rgba(231, 191, 99, 0.18);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.stat-card-total,
.stat-card-danger,
.stat-card-warning,
.stat-card-normal {
    background: linear-gradient(145deg, rgba(102, 28, 39, 0.9), rgba(48, 13, 20, 0.94));
}

.stat-card .stat-value {
    color: var(--text-main);
}

.graph-card,
.graph-canvas-container {
    border-color: var(--border-color);
    border-radius: var(--radius-md);
}

.graph-canvas-container {
    background: rgba(20, 6, 10, 0.86);
}

#link-analysis-canvas {
    width: 100%;
    height: auto;
    min-height: 420px;
}

.graph-controls {
    border-color: var(--border-color);
    background: rgba(35, 9, 14, 0.92);
}

.gang-accordion-item,
.insight-gang-item {
    border-color: rgba(231, 191, 99, 0.16);
    border-radius: var(--radius-sm);
    background: rgba(29, 8, 13, 0.46);
}

.gang-accordion-header:hover {
    background: rgba(231, 191, 99, 0.08);
}

.insight-card {
    min-height: 218px;
    background: linear-gradient(145deg, rgba(72, 24, 34, 0.92), rgba(38, 10, 16, 0.95));
}

.insight-bar-track,
.insight-density-track {
    background: rgba(255, 248, 237, 0.11);
}

.insight-bar-fill {
    background: linear-gradient(90deg, #b82b37, #e7bf63);
}

.insight-density-fill {
    background: linear-gradient(90deg, #4f9f68, #e7bf63, #c52c38);
}

.modal {
    background: rgba(9, 2, 5, 0.76);
    backdrop-filter: blur(8px);
}

.modal-content {
    max-width: min(760px, calc(100vw - 32px));
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(22, 5, 9, 0.42);
}

::-webkit-scrollbar-thumb {
    border: 2px solid rgba(22, 5, 9, 0.42);
    border-radius: 999px;
    background: rgba(231, 191, 99, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 1024px) {
    .app-container {
        display: block;
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
        width: 100%;
        min-height: 72px;
        flex-direction: row;
        align-items: center;
        gap: 14px;
        padding: 10px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--border-strong);
    }

    .sidebar-header {
        flex: 0 0 auto;
        padding: 0 14px 0 0;
        margin: 0;
        border-bottom: 0;
        border-right: 1px solid var(--border-color);
    }

    .sidebar-menu {
        flex-direction: row;
        min-width: 0;
        overflow-x: auto;
        padding: 0;
    }

    .menu-item {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 9px 11px;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        min-height: calc(100dvh - 72px);
        padding: 24px 20px 32px;
        overflow: visible;
    }

    .phan-tich-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .sidebar-header {
        border-right: 0;
        padding-right: 0;
    }

    .logo-text {
        display: none;
    }

    .menu-item .icon {
        margin-right: 0;
    }

    .menu-item {
        font-size: 11px;
    }

    .menu-item .icon {
        margin-right: 5px;
        font-size: 15px;
    }

    .main-content {
        padding: 18px 12px 28px;
    }

    .content-header {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .content-header .btn {
        width: 100%;
    }

    .tq-stat-cards,
    .graph-insights-grid {
        grid-template-columns: 1fr;
    }

    .phan-tich-layout {
        display: block;
    }

    .phan-tich-sidebar {
        margin-top: 16px;
    }

    #link-analysis-canvas {
        min-height: 300px;
    }

    .graph-controls {
        position: static;
        margin: 10px;
        overflow-x: auto;
    }
}
#graph-insights-grid-placeholder { display: none; }

.graph-insights-grid {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

#tab-phan-tich .graph-insights-grid {
    display: grid;
}

.insight-card {
    min-height: 218px;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.94), rgba(30, 41, 59, 0.78));
}

.insight-card-wide {
    grid-column: 1 / -1;
}

.insight-caption {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}

.insight-empty {
    padding: 22px 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.insight-bars {
    display: grid;
    gap: 10px;
}

.insight-bar-row {
    display: grid;
    grid-template-columns: minmax(105px, 0.9fr) minmax(100px, 2fr) 42px;
    align-items: center;
    gap: 9px;
    font-size: 12px;
}

.insight-bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-light);
}

.insight-bar-track {
    height: 9px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.15);
    overflow: hidden;
}

.insight-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ef4444, #f59e0b 48%, #3b82f6);
    transition: width 350ms ease;
}

.insight-bar-value {
    text-align: right;
    color: var(--text-light);
    font-weight: 700;
}

.insight-gang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.insight-gang-item {
    padding: 11px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.5);
}

.insight-gang-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 700;
}

.insight-gang-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 7px;
    color: var(--text-muted);
    font-size: 11px;
}

.insight-density-track {
    height: 7px;
    margin-top: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.15);
    overflow: hidden;
}

.insight-density-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
}

@media (max-width: 900px) {
    .graph-insights-grid { grid-template-columns: 1fr; }
    .insight-card-wide { grid-column: auto; }
}

/* Final readability pass: larger type and controls for daily operations. */
:root {
    --font-family: Tahoma, "Segoe UI", "Noto Sans", Arial, sans-serif;
    --font-size-base: 15px;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
}

.sidebar {
    width: 286px;
}

.logo-icon {
    width: 46px;
    height: 46px;
}

.logo-icon img {
    width: 38px !important;
    height: 38px !important;
}

.logo-text h1 {
    font-size: 14px;
}

.menu-item {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 14px;
}

.menu-item .icon {
    font-size: 18px;
}

.main-content {
    padding: clamp(24px, 3.4vw, 44px);
}

.content-header h2 {
    font-size: clamp(22px, 2.15vw, 31px);
}

.btn {
    min-height: 44px;
    padding: 10px 17px;
    font-size: 14px;
}

.btn-sm {
    min-height: 36px;
    padding: 8px 13px;
    font-size: 13px;
}

input,
select,
textarea {
    min-height: 44px;
    font-family: var(--font-family);
    font-size: 14px;
}

textarea {
    min-height: 108px;
}

label,
.form-group label,
.form-label {
    font-size: 13px;
}

.data-table {
    min-width: 920px;
}

.data-table th {
    padding: 14px 15px;
    font-size: 11px;
}

.data-table td {
    padding: 14px 15px;
    font-size: 14px;
}

.card-body,
.card-body p,
.scroll-panel {
    font-size: 14px;
}

.stat-card .stat-value,
.stat-value {
    font-size: 38px;
}

.stat-card .stat-label,
.stat-label {
    font-size: 13px;
}

.tq-section-header h3,
.card-header h3 {
    font-size: 17px;
}

.graph-filter-bar label,
.graph-controls,
.graph-legend {
    font-size: 13px;
}

.insight-caption,
.insight-gang-meta {
    font-size: 12px;
}

.insight-empty,
.insight-bar-row,
.insight-gang-title {
    font-size: 13px;
}

#link-analysis-canvas {
    min-height: 460px;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 20px 14px 30px;
    }

    .menu-item {
        min-height: 42px;
        padding: 9px 11px;
        font-size: 12px;
    }

    .menu-item .icon {
        font-size: 16px;
    }

    .data-table {
        min-width: 820px;
    }

    .data-table td {
        font-size: 13px;
    }

    #link-analysis-canvas {
        min-height: 320px;
    }
}

/* Authentication, notification and account surfaces. */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(27, 7, 12, 0.94), rgba(66, 16, 25, 0.88)),
        url("/background/hinh-nen-powerpoint-trong-dong-hoa-sen-32.jpg") center / cover no-repeat;
    transition: opacity 180ms ease, visibility 180ms ease;
}

.auth-locked .app-container {
    pointer-events: none;
    user-select: none;
}

.auth-gate.is-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.auth-panel {
    width: min(100%, 450px);
    padding: 36px;
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(82, 25, 36, 0.97), rgba(36, 9, 15, 0.98));
    box-shadow: 0 28px 70px rgba(11, 1, 5, 0.52), inset 0 1px 0 rgba(255, 248, 237, 0.08);
}

.auth-brand-mark {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 22px;
    border: 1px solid rgba(231, 191, 99, 0.44);
    border-radius: 16px;
    background: rgba(25, 5, 10, 0.4);
}

.auth-brand-mark img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.auth-eyebrow,
.panel-kicker {
    color: var(--accent-gold);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-align: center;
}

.auth-panel h1 {
    margin: 8px 0 8px;
    color: var(--text-main);
    font-size: clamp(26px, 4vw, 34px);
    line-height: 1.15;
}

.auth-subtitle,
.auth-note {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-form {
    display: grid;
    gap: 9px;
    margin-top: 26px;
}

.auth-form label {
    margin-top: 4px;
    color: var(--text-light);
    font-size: 13px;
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    background: rgba(19, 5, 9, 0.66);
}

.auth-submit {
    width: 100%;
    margin-top: 8px;
}

.auth-error {
    min-height: 20px;
    margin: 2px 0 0;
    color: #ff9a94;
    font-size: 13px;
}

.auth-note {
    margin: 22px 0 0;
    font-size: 11px;
}

.session-panel {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.session-user {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.session-avatar {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(231, 191, 99, 0.44);
    border-radius: 50%;
    background: linear-gradient(135deg, #c52c38, #7c1b29);
    color: #fff8ed;
    font-size: 14px;
    font-weight: 700;
}

.session-user-copy {
    display: grid;
    min-width: 0;
}

.session-user-copy strong,
.session-user-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-user-copy strong {
    color: var(--text-main);
    font-size: 12px;
}

.session-user-copy small {
    margin-top: 2px;
    color: var(--accent-gold);
    font-size: 10px;
}

.session-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.session-action {
    min-height: 30px;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background: rgba(22, 5, 9, 0.42);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
}

.session-action:hover {
    border-color: var(--border-strong);
    background: rgba(231, 191, 99, 0.1);
    color: var(--text-main);
}

.session-action[hidden] {
    display: none;
}

.session-action:first-child {
    color: var(--accent-gold);
}

#notification-count {
    display: inline-grid;
    min-width: 16px;
    min-height: 16px;
    place-items: center;
    margin-left: 4px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-main);
    font-size: 10px;
}

.notification-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 80;
    display: grid;
    width: min(420px, calc(100vw - 28px));
    max-height: min(680px, calc(100dvh - 40px));
    padding: 20px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(77, 24, 34, 0.98), rgba(32, 8, 14, 0.99));
    box-shadow: 0 24px 60px rgba(8, 1, 4, 0.52);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.notification-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.notification-panel-header,
.notification-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.notification-panel-header {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.notification-panel h2 {
    margin-top: 4px;
    font-size: 22px;
}

.notification-list {
    display: grid;
    gap: 9px;
    max-height: 510px;
    overflow-y: auto;
    padding: 14px 2px;
}

.notification-item {
    padding: 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(22, 5, 9, 0.42);
}

.notification-item.is-unread {
    border-color: rgba(231, 191, 99, 0.38);
    background: rgba(231, 191, 99, 0.07);
}

.notification-item strong {
    color: var(--text-main);
    font-size: 14px;
}

.notification-item time {
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
}

.notification-item p {
    margin: 7px 0 0;
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.45;
}

.notification-mark-read,
.notification-read-all {
    margin-top: 9px;
    color: var(--accent-gold);
    font-size: 11px;
}

.notification-mark-read {
    border: 0;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

.notification-empty {
    padding: 24px 8px;
    color: var(--text-muted);
    text-align: center;
    font-size: 13px;
}

.user-management-modal {
    max-width: 720px;
}

.user-create-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-create-form .btn {
    width: 100%;
}

.user-list {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.user-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(27, 7, 12, 0.4);
}

.user-row > div {
    display: grid;
    min-width: 0;
}

.user-row strong {
    color: var(--text-main);
    font-size: 13px;
}

.user-row small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

.user-status {
    color: var(--text-muted);
    font-size: 11px;
}

.user-status.is-active {
    color: var(--success);
}

@media (max-width: 640px) {
    .auth-panel {
        padding: 26px 22px;
    }

    .notification-panel {
        top: 10px;
        right: 10px;
        max-height: calc(100dvh - 20px);
    }

    .user-create-form {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   MOBILE RESPONSIVE EXTENSION & BUG FIXES
   ============================================================ */

/* Khắc phục lỗi tràn bảng dữ liệu (Data Table Overflow) */
.table-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Đảm bảo bảng co giãn tốt và có thể cuộn ngang */
.data-table {
    width: 100%;
}

/* Modal lý lịch toàn màn hình (Full Profile Dashboard) trên mobile */
@media (max-width: 900px) {
    .modal-full-profile {
        width: 98vw !important;
        height: 96vh !important;
        max-height: 96vh !important;
    }
    
    .profile-full-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow-y: visible !important;
        gap: 16px !important;
    }

    .profile-sidebar {
        width: 100% !important;
    }

    .profile-avatar-large {
        width: 150px !important;
        height: 188px !important;
    }

    .profile-thumbnails-list {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* Responsive cho các Form Grid */
@media (max-width: 768px) {
    .form-grid-3, 
    .form-grid-2, 
    .inline-form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* Responsive cho các ô nhập liệu dạng khoảng (range group) */
    .range-group {
        flex-direction: column;
        gap: 6px;
    }
    
    .range-group input {
        width: 100% !important;
    }

    /* Đổi các nút bấm sang chiều rộng đầy đủ trên màn hình nhỏ */
    .btn-group-right {
        flex-direction: column-reverse;
        width: 100%;
    }
    
    .btn-group-right .btn {
        width: 100% !important;
    }
}

/* Tối ưu hóa Tổng quan Dashboard trên mobile */
@media (max-width: 480px) {
    .tq-stat-cards {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 16px 18px !important;
    }

    .stat-value {
        font-size: 30px !important;
    }

    /* Xử lý dòng địa bàn của Tổng quan */
    .dia-ban-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .dia-ban-name {
        width: 100% !important;
        white-space: normal;
    }

    .dia-ban-bar-wrap {
        width: 100%;
    }

    .dia-ban-count, .dia-ban-pct {
        align-self: flex-end;
    }
}

/* Tối ưu hóa hiển thị kết quả so khớp khuôn mặt trên di động */
@media (max-width: 520px) {
    .match-card {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 18px !important;
        gap: 12px !important;
    }

    .match-info {
        width: 100% !important;
    }

    .match-similarity {
        width: 100% !important;
        text-align: center !important;
        border-top: 1px solid var(--border-color);
        padding-top: 10px;
    }
}

/* Cải thiện Touch Target trên di động theo tiêu chuẩn Google/Apple */
@media (max-width: 768px) {
    input, 
    select, 
    textarea,
    .btn, 
    .btn-sm,
    .menu-item {
        min-height: 44px !important;
        font-size: 14px !important;
    }
    
    .close-btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
