@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================
   DESIGN TOKENS
   ============================ */
:root {
    --primary:        #0f172a;
    --primary-light:  #1e293b;
    --secondary:      #334155;
    --accent:         #3b82f6;
    --accent-hover:   #2563eb;
    --accent-light:   #eff6ff;
    --background:     #f1f5f9;
    --surface:        #ffffff;
    --text-main:      #0f172a;
    --text-muted:     #64748b;
    --success:        #10b981;
    --success-light:  #ecfdf5;
    --danger:         #ef4444;
    --danger-light:   #fef2f2;
    --warning:        #f59e0b;
    --warning-light:  #fffbeb;
    --border:         #e2e8f0;
    --shadow-sm:      0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
    --shadow:         0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
    --shadow-lg:      0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.06);
    --radius-sm:      0.5rem;
    --radius:         0.75rem;
    --radius-lg:      1.25rem;
    --transition:     all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width:  260px;
}

/* ============================
   RESET & BASE
   ============================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================
   LOADING OVERLAY
   ============================ */
#loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

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

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

.spinner-sm {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ============================
   APP LAYOUT
   ============================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1.75rem 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 0.75rem;
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.45);
}

.sidebar-brand-icon i { width: 20px; height: 20px; color: white; }

.sidebar-brand-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.025em;
}

.sidebar-brand-text span {
    color: var(--accent);
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    padding: 1.25rem 1.5rem 0.5rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    transition: var(--transition);
    position: relative;
}

.nav-item i { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: white;
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: white;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0.75rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    background: rgba(59,130,246,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-avatar i { width: 18px; height: 18px; }

.sidebar-user-info small {
    display: block;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-user-info strong {
    display: block;
    font-size: 0.875rem;
    color: white;
    font-weight: 600;
    line-height: 1.3;
}

/* Mobile close button */
.mobile-close {
    display: none;
    background: rgba(255,255,255,0.08);
    border: none;
    color: white;
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    position: absolute;
    top: 1.25rem;
    right: 1rem;
}

/* ============================
   MAIN WRAPPER
   ============================ */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ============================
   TOPBAR (Mobile)
   ============================ */
.mobile-topbar {
    display: none;
    background: var(--surface);
    padding: 0.875rem 1.25rem;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.mobile-topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.mobile-topbar-brand i { color: var(--accent); width: 22px; height: 22px; }
.mobile-topbar-brand span { color: var(--accent); }

.mobile-menu-btn {
    border: none;
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.mobile-menu-btn:hover { background: var(--border); }

/* ============================
   MAIN CONTENT
   ============================ */
.main-content {
    flex: 1;
    padding: 2rem 2.25rem;
    width: 100%;
}

/* Page Header inside content */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.page-title-group { flex: 1; min-width: 200px; }
.page-title { font-size: 1.625rem; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; line-height: 1.2; }
.page-subtitle { font-size: 0.95rem; color: var(--text-muted); margin-top: 0.25rem; }
.page-actions { display: flex; gap: 0.75rem; align-items: center; }

/* ============================
   TYPOGRAPHY
   ============================ */
h1 { font-size: 1.75rem; font-weight: 700; color: var(--primary); letter-spacing: -0.025em; margin-bottom: 0.5rem; }
h2 { font-size: 1.375rem; font-weight: 700; color: var(--primary); margin-bottom: 0.5rem; }
h3 { font-size: 1.125rem; font-weight: 600; color: var(--primary); margin-bottom: 0.5rem; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.875rem; }
.text-xs     { font-size: 0.75rem; }

/* ============================
   BUTTONS
   ============================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn i { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary   { background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59,130,246,0.35); }

.btn-success   { background: var(--success); color: white; box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger    { background: var(--danger); color: white; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-ghost     { background: transparent; color: var(--secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--background); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-icon { padding: 0.5rem; border-radius: var(--radius-sm); }

/* Guard-specific big action buttons */
.btn-access-allow {
    background: var(--success);
    color: white;
    padding: 1.25rem 2rem;
    font-size: 1.1rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 20px rgba(16,185,129,0.35);
    flex: 1;
}
.btn-access-allow:hover { background: #059669; transform: translateY(-2px); }

.btn-access-deny {
    background: var(--danger);
    color: white;
    padding: 1.25rem 2rem;
    font-size: 1.1rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 20px rgba(239,68,68,0.35);
    flex: 1;
}
.btn-access-deny:hover { background: #dc2626; transform: translateY(-2px); }

/* ============================
   FORMS
   ============================ */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    background: var(--surface);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-control::placeholder { color: #cbd5e1; }

select.form-control { cursor: pointer; }

/* ============================
   CARDS
   ============================ */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

/* Stat Cards */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon i { width: 24px; height: 24px; }

.stat-icon.blue   { background: var(--accent-light); color: var(--accent); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.red    { background: var(--danger-light); color: var(--danger); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }

.stat-info p  { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-info h3 { font-size: 2rem; font-weight: 800; color: var(--primary); margin: 0; letter-spacing: -0.04em; line-height: 1; }

/* ============================
   TABLES
   ============================ */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

table { width: 100%; border-collapse: collapse; background: var(--surface); }

thead th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #fafbfc; }

/* ============================
   BADGES
   ============================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-green  { background: var(--success-light); color: #065f46; }
.badge-red    { background: var(--danger-light); color: #991b1b; }
.badge-amber  { background: var(--warning-light); color: #92400e; }
.badge-gray   { background: #f1f5f9; color: var(--secondary); }

/* ============================
   ALERTS
   ============================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
}

.alert i { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--accent-light);  color: #1e40af; border: 1px solid #bfdbfe; }

/* ============================
   STATUS INDICATORS (Guard UI)
   ============================ */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.green  { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.status-dot.red    { background: var(--danger);  box-shadow: 0 0 0 3px rgba(239,68,68,0.2); }
.status-dot.amber  { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }

/* ============================
   FOOTER
   ============================ */
footer {
    padding: 1.25rem 2.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================
   OVERLAY
   ============================ */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    z-index: 1050;
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
}

.overlay.active { display: flex; }

/* ============================
   AUTH PAGE — SPLIT PANEL
   ============================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(rgba(10,15,30,0.45), rgba(10,15,30,0.45)),
                url('../img/login_bg.png') center/cover fixed;
}

/* Solid white right panel */
.auth-panel {
    width: 420px;
    flex-shrink: 0;
    min-height: 100vh;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 2.5rem;
    margin-left: auto;
    box-shadow: -24px 0 80px rgba(0,0,0,0.35);
}

.auth-container {
    width: 100%;
    animation: fadeUp 0.6s cubic-bezier(0.4,0,0.2,1);
}

/* No background card needed inside solid panel */
.auth-card { background: transparent; }

.auth-header { text-align: center; margin-bottom: 2.5rem; }

.logo-circle {
    width: 68px;
    height: 68px;
    background: var(--accent);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 12px 28px rgba(59,130,246,0.5);
    transition: var(--transition);
}

.auth-card:hover .logo-circle { transform: scale(1.05) rotate(-3deg); }
.logo-circle i { width: 34px; height: 34px; color: white; }

.auth-header h2 {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
    margin-bottom: 0.375rem;
}

.auth-header h2 span { color: var(--accent); }
.auth-header p { color: var(--text-muted); font-size: 0.95rem; }

.auth-error {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    margin-bottom: 1.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.auth-error i { width: 16px; height: 16px; flex-shrink: 0; }

.auth-form .form-group { margin-bottom: 1.5rem; }

.auth-form label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.input-with-icon { position: relative; }

.input-with-icon > i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #94a3b8;
    pointer-events: none;
    transition: var(--transition);
}

.input-with-icon .form-control {
    padding-left: 3rem;
    height: 3.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.input-with-icon .form-control:focus ~ i,
.input-with-icon .form-control:focus + i { color: var(--accent); }

.btn-block {
    width: 100%;
    justify-content: center;
    height: 3.25rem;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================
   ANIMATIONS
   ============================ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* ============================
   RESPONSIVE
   ============================ */
/* ============================
   RESPONSIVE UTILITIES
   ============================ */
.grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* ============================
   SCANNER EFFECTS
   ============================ */
.scanner-wrapper {
    position: relative;
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
}

.scan-region-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-line {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 0 15px 2px var(--accent);
    z-index: 20;
    animation: scanMove 2s ease-in-out infinite;
    opacity: 0.8;
}

@keyframes scanMove {
    0%   { top: calc(50% - 125px); }
    50%  { top: calc(50% + 125px); }
    100% { top: calc(50% - 125px); }
}

/* Premium QR Search Component */
.qr-search-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 0.5rem;
    width: 100%;
}

.qr-input-group {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.qr-search-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--accent);
    width: 20px;
    height: 20px;
    z-index: 10;
}

.qr-input {
    height: 4rem;
    font-size: 1.15rem;
    border-radius: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    padding-left: 3.5rem;
    padding-right: 1.5rem;
    width: 100%;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.qr-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
    outline: none;
}

.qr-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.qr-action-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.qr-btn-scan {
    height: 4rem;
    width: 4rem;
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.qr-btn-scan:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.qr-btn-validate {
    flex: 1;
    height: 4rem;
    padding: 0 2rem;
    border-radius: 1.25rem;
    font-weight: 800;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
    color: white;
    border: none;
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.qr-btn-validate:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px -5px rgba(37, 99, 235, 0.5);
    filter: brightness(1.1);
}

@media (max-width: 640px) {
    .qr-search-container { gap: 1.25rem; }
    .qr-input { height: 3.75rem; font-size: 1.1rem; }
    .qr-btn-scan { height: 3.75rem; width: 3.75rem; }
    .qr-btn-validate { height: 3.75rem; }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); }
    .mobile-close { 
        display: flex !important; 
        z-index: 1200; 
        background: var(--accent); 
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
        right: 1rem;
        top: 1.25rem;
    }
    
    .main-wrapper { margin-left: 0; width: 100%; overflow-x: hidden; }
    .mobile-topbar { display: flex; }
    
    /* Hide topbar branding/button when menu is open to avoid "repetition" */
    .sidebar.active ~ .main-wrapper .mobile-topbar {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .overlay.active {
        backdrop-filter: blur(8px);
        background: rgba(15, 23, 42, 0.85);
    }

    .main-content { padding: 0.75rem 0.5rem; }
}

@media (max-width: 480px) {
    :root { --sidebar-width: 280px; }
    .sidebar { width: 88%; }
    .mobile-close { right: 1rem; top: 1.25rem; }
    .page-header { flex-direction: column; align-items: stretch; gap: 1rem; }
    .page-actions { flex-direction: column; }
    .page-actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 768px) {
    .grid-responsive { grid-template-columns: 1fr; }
    .auth-panel { width: 100%; margin-left: 0; padding: 2rem 1.5rem; }
    
    /* Tables on mobile: Force scroll and hide extra borders */
    .table-wrapper { 
        overflow-x: auto; 
        margin-right: -1.25rem; 
        margin-left: -1.25rem; 
        border-radius: 0; 
        border-left: none; 
        border-right: none;
        -webkit-overflow-scrolling: touch;
    }
    table { min-width: 700px; }
}

@media (max-width: 640px) {
    .page-header { flex-direction: column; align-items: stretch; gap: 1rem; }
    .page-header h1 { font-size: 1.4rem; text-align: center; }
    .page-header .btn { width: 100%; justify-content: center; }
    .search-box { width: 100% !important; }
    .search-box input { width: 100% !important; }
    .stat-card { padding: 1rem; flex-direction: row; align-items: center; gap: 1rem; }
    .stat-info h3 { font-size: 1.5rem; }
    .btn-access-allow, .btn-access-deny { font-size: 1rem; }
    
    /* Tables on mobile */
    .table-wrapper { 
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        border-radius: 0;
        border-left: none;
        border-right: none;
        display: block;
        -webkit-overflow-scrolling: touch;
    }
    .table-wrapper::-webkit-scrollbar {
        height: 5px;
    }
    .table-wrapper::-webkit-scrollbar-thumb {
        background: var(--accent);
        border-radius: 10px;
    }
    .table-wrapper::-webkit-scrollbar-track {
        background: #f1f5f9;
    }
    table { 
        min-width: 650px; /* Force overflow on mobile */
        width: 100%; 
        table-layout: auto; 
        border-collapse: collapse;
    }
    thead th { 
        white-space: nowrap; 
        background: #f8fafc;
    }
    tbody td { 
        padding: 0.75rem 0.5rem; 
        font-size: 0.85rem; 
        white-space: nowrap; /* Prevent squashing */
    }
    /* Allow wrapping ONLY for specific content if needed, but not by default */
    tbody td div { font-size: 0.85rem !important; }
    .badge { padding: 0.25rem 0.6rem; font-size: 0.7rem; white-space: nowrap; }

    /* Auth tweaks */
    .logo-circle { width: 56px; height: 56px; }
    .auth-header h2 { font-size: 1.75rem; }
}
