:root {
    --primary-color: #1A67B2; /* Xanh dương chuẩn HVN */
    --primary-hover: #155594;
    --bg-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --nav-height: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background-color: var(--bg-color); color: var(--text-main); line-height: 1.5; padding-bottom: var(--nav-height); }

/* --- LOGIN SCREEN --- */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.login-box {
    background: var(--surface-color); padding: 2.5rem 2rem; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md); text-align: center; max-width: 400px; width: 90%;
}
.login-box .logo-wrapper {
    width: 64px; height: 64px; background: var(--primary-color); color: white; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center; margin: 0 auto 1.5rem;
}
.login-box .logo-wrapper svg { width: 32px; height: 32px; }
.login-box h2 { margin-bottom: 0.5rem; font-size: 1.5rem; }
.login-box p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-box input {
    width: 100%; padding: 0.875rem; border: 1px solid var(--border-color); border-radius: var(--radius-md);
    margin-bottom: 1rem; font-size: 1.2rem; text-align: center; letter-spacing: 0.2rem;
}
.error-msg { color: #dc2626; margin-top: 1rem; font-size: 0.9rem; min-height: 20px; }

/* --- APP LAYOUT --- */
.app-header {
    background: var(--surface-color); padding: 1rem; box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 100;
}
.header-content {
    max-width: 1000px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center;
}
.header-content h1 { font-size: 1.25rem; color: var(--primary-color); }
.user-info { display: flex; align-items: center; gap: 1rem; font-weight: 500; }
.btn-text { background: none; border: none; color: #dc2626; cursor: pointer; font-weight: 600; font-family: inherit; }

.app-main { max-width: 1000px; margin: 2rem auto; padding: 0 1rem; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- COMMON COMPONENTS --- */
.panel { background: var(--surface-color); border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 1.1rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.input-group { margin-bottom: 1.2rem; }
.input-group label { display: block; font-weight: 600; margin-bottom: 0.4rem; font-size: 0.9rem; }
.input-group input[type="url"], .input-group input[type="text"] {
    width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-family: inherit; font-size: 0.95rem; background-color: var(--surface-color); color: var(--text-main);
}
.input-group input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(26, 103, 178, 0.15); }

/* --- CUSTOM SELECT --- */
.custom-select { position: relative; font-family: inherit; }
.custom-select .select-selected {
    background-color: var(--surface-color); color: var(--text-main); padding: 0.75rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-md); cursor: pointer;
    font-size: 0.95rem; display: flex; justify-content: space-between; align-items: center; user-select: none;
}
.custom-select .select-selected:after {
    content: ""; width: 0; height: 0; border: 5px solid transparent; border-color: var(--text-muted) transparent transparent transparent; margin-top: 5px;
}
.custom-select .select-selected.select-arrow-active:after { border-color: transparent transparent var(--text-muted) transparent; margin-top: -5px; }
.custom-select .select-selected:focus-visible { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(26, 103, 178, 0.15); }
.custom-select .select-items {
    position: absolute; background-color: var(--surface-color); top: 100%; left: 0; right: 0; z-index: 99;
    border: 1px solid var(--border-color); border-radius: var(--radius-md); margin-top: 4px; box-shadow: var(--shadow-md);
    overflow: hidden;
}
.custom-select .select-items div {
    color: var(--text-main); padding: 0.75rem; cursor: pointer; font-size: 0.95rem; border-bottom: 1px solid var(--border-color);
}
.custom-select .select-items div:last-child { border-bottom: none; }
.custom-select .select-items div:hover, .same-as-selected { background-color: rgba(26, 103, 178, 0.1); }
.select-hide { display: none; }
.input-group small { color: var(--text-muted); font-size: 0.8rem; display: block; margin-top: 0.2rem; }
.input-group input[type="file"] { width: 100%; padding: 0.5rem; background: var(--bg-color); border-radius: var(--radius-md); }

.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; width: 100%; padding: 0.75rem 1rem;
    border-radius: var(--radius-md); font-weight: 600; border: none; cursor: pointer; transition: 0.2s; font-family: inherit;
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-color); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.grid-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.qr-preview-container { background: var(--bg-color); min-height: 250px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); margin-bottom: 1rem; padding: 1rem; }
#qrCanvas { max-width: 100%; height: auto; display: none; border-radius: 8px; box-shadow: var(--shadow-md); }

/* --- CARD LIST (LIKE APP) --- */
.card-list { display: flex; flex-direction: column; gap: 1rem; }
.card { background: var(--surface-color); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1rem; }
.card-title { font-weight: 600; color: var(--primary-color); margin-bottom: 0.25rem; font-size: 1rem; }
.card-detail { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; word-break: break-all; }

/* --- LOG TABLE (PC & MOBILE) --- */
.table-responsive { overflow-x: auto; margin-bottom: 1rem; }
.log-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.log-table th, .log-table td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; }
.log-table th { background: var(--bg-color); font-weight: 600; }

.pagination { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.page-btn { padding: 0.5rem 0.75rem; border: 1px solid var(--border-color); background: white; cursor: pointer; border-radius: 0.25rem; }
.page-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* --- BOTTOM NAV --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%; height: var(--nav-height);
    background: var(--surface-color); display: flex; border-top: 1px solid var(--border-color); z-index: 100;
}
.nav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem;
    background: none; border: none; color: var(--text-muted); cursor: pointer; transition: 0.2s;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn span { font-size: 0.7rem; font-weight: 500; white-space: nowrap; }
.nav-btn.active { color: var(--primary-color); }

/* MEDIA QUERIES */
@media (max-width: 768px) {
    .grid-layout { grid-template-columns: 1fr; }
    /* Giấu header trên mobile cho giống app hơn hoặc giữ nguyên tuỳ ý */
}

@media (min-width: 769px) {
    /* PC: Đưa Bottom Nav lên thành dạng Header/Sidebar nếu cần, nhưng hiện tại ta có thể giữ nguyên nó ở dưới đáy hoặc thiết kế lại. */
    /* Để đơn giản, biến Bottom Nav thành Top Nav tích hợp vào header. */
    body { padding-bottom: 0; }
    .bottom-nav { position: static; height: auto; border-top: none; width: auto; background: none; }
    .nav-btn { flex-direction: row; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: var(--radius-md); }
    .nav-btn span { font-size: 0.9rem; }
    .nav-btn.active { background: rgba(37, 99, 235, 0.1); }
    .header-content { justify-content: flex-start; gap: 2rem; }
    .user-info { margin-left: auto; }
}
