:root {
    --bg-body: #f4f6f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e3c72;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-sidebar: rgba(255, 255, 255, 0.8);
    --border-color: #e0e0e0;
    --accent-color: #1e3c72;
    --accent-hover: #2a5298;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --color-blue: #e3f2fd;
    --text-blue: #1976d2;
    --color-green: #e8f5e9;
    --text-green: #388e3c;
    --color-yellow: #fff8e1;
    --text-yellow: #ffa000;
    --color-red: #ffebee;
    --text-red: #d32f2f;
}

body.dark-mode {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-sidebar: #000000;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-sidebar: #b0b0b0;
    --border-color: #333333;
    --accent-color: #3f51b5;
    --accent-hover: #5c6bc0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --color-blue: rgba(25, 118, 210, 0.2);
    --text-blue: #64b5f6;
    --color-green: rgba(56, 142, 60, 0.2);
    --text-green: #81c784;
    --color-yellow: rgba(255, 160, 0, 0.2);
    --text-yellow: #ffd54f;
    --color-red: rgba(211, 47, 47, 0.2);
    --text-red: #e57373;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.btn-theme-toggle:hover {
    background: var(--bg-body);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
}

.login-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 20px;
}

body.dark-mode .login-container {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-header h2 {
    color: var(--accent-color);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.input-wrapper {
    position: relative;
}

.input-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.input-wrapper input, .form-group input, .form-group select {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-primary);
}

.form-group input:not([type="file"]), .form-group select {
    padding-left: 12px;
}

.input-wrapper input {
    padding-left: 40px;
}

.input-wrapper input:focus, .form-group input:focus, .form-group select:focus {
    border-color: var(--accent-color);
    outline: none;
}

.dashboard-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: white;
    padding: 20px;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
    text-align: center;
}

.sidebar-header .brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 20px;
    margin-bottom: 5px;
}

.sidebar-logo-img {
    max-width: 40px;
    max-height: 40px;
    border-radius: 5px;
    object-fit: contain;
    background: #fff;
    padding: 2px;
}

.nav-links {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.nav-links li {
    margin-bottom: 5px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-sidebar);
    border-radius: 8px;
    font-size: 15px;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-links a.logout {
    color: #ff8a80;
}

.nav-links a.logout:hover {
    background: rgba(255, 82, 82, 0.1);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    background: var(--bg-body);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.welcome-text h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.welcome-text p {
    color: var(--text-secondary);
    font-size: 14px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.action-card {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    padding: 25px;
    border-radius: 12px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 15px rgba(30, 60, 114, 0.2);
    min-height: 140px;
    text-align: center;
}

.action-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(30, 60, 114, 0.4);
}

.action-card i {
    font-size: 32px;
    margin-bottom: 10px;
}

.action-card span {
    font-weight: 600;
    font-size: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-info h3 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.icon-blue { background: var(--color-blue); color: var(--text-blue); }
.icon-green { background: var(--color-green); color: var(--text-green); }
.icon-yellow { background: var(--color-yellow); color: var(--text-yellow); }
.icon-red { background: var(--color-red); color: var(--text-red); }

.content-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-size: 18px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 30px;
}

.table-container {
    overflow-x: auto;
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

th {
    background-color: rgba(30, 60, 114, 0.05);
    color: var(--accent-color);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
}

tr:hover {
    background-color: rgba(0,0,0,0.02);
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.badge-class {
    background: rgba(0,0,0,0.05);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-primary);
}

.settings-container {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 800px;
}

.form-section {
    margin-bottom: 25px;
}

.drop-zone {
    width: 100%;
    height: 200px;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    background-color: var(--bg-body);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover {
    border-color: var(--accent-color);
    background-color: rgba(30, 60, 114, 0.05);
}

.drop-zone__input {
    display: none;
}

.drop-zone__prompt {
    color: var(--text-secondary);
}

.drop-zone__prompt i {
    font-size: 40px;
    margin-bottom: 10px;
    display: block;
    color: var(--accent-color);
}

.drop-zone__thumb {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
    background-color: #cccccc;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    position: absolute;
    top: 0;
    left: 0;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}

.mobile-header {
    display: none;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 900;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .sidebar {
        left: -270px;
        transition: left 0.3s ease-in-out;
    }
    .sidebar.active {
        left: 0;
    }
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    .main-content {
        margin-left: 0;
        padding: 80px 20px 20px 20px;
    }
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: var(--bg-card);
        padding: 0 20px;
        z-index: 800;
        box-shadow: var(--shadow);
    }
    .mobile-header h3 {
        color: var(--accent-color);
        font-weight: bold;
    }
    .top-bar {
        display: none;
    }
    .stats-grid, .action-grid {
        grid-template-columns: 1fr;
    }
}

.scan-wrapper {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--shadow);
}

#reader {
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: #000;
}

.camera-select {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.btn-control-group {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.btn-scan {
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    transition: transform 0.2s;
}

.btn-scan:active {
    transform: scale(0.95);
}

.btn-start { background: var(--accent-color); }
.btn-stop { background: #e74c3c; }

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 15px;
    flex-direction: column;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.result-card {
    background: var(--bg-card);
    width: 90%;
    max-width: 380px;
    padding: 35px 30px;
    border-radius: 20px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    animation: popUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popUp { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.close-result {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.close-result:hover { color: var(--text-primary); }

.student-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent-color);
    margin: 0 auto 15px;
    display: block;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.status-badge {
    display: inline-block;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.bg-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.bg-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

.result-title { font-size: 22px; font-weight: bold; color: var(--text-primary); margin-bottom: 5px; }
.result-desc { font-size: 16px; color: var(--text-secondary); margin-bottom: 5px; }
.result-time { font-size: 13px; color: var(--text-secondary); opacity: 0.8; }