:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
}

/* Navigation Bar */
.nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    border-top: 1px solid var(--border);
    z-index: 900;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.4rem;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

/* View Management */
.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 800px;
    /* More focused for mobile/single views */
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 8rem;
    /* Space for nav bar */
}

header {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    header {
        flex-direction: row;
        justify-content: space-between;
    }
}

h1 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.05em;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Dashboard Grid */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

input,
select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

button {
    cursor: pointer;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

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

.btn-secondary {
    background-color: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: bold;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.student-row-inactive {
    opacity: 0.6;
    background-color: #f1f5f9;
}

.student-row-inactive:hover {
    opacity: 0.8;
}

.eng-high {
    background: #dcfce7;
    color: #166534;
}

.eng-med {
    background: #fef3c7;
    color: #92400e;
}

.eng-low {
    background: #fee2e2;
    color: #991b1b;
}

/* Scanner */
#reader {
    width: 100%;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

#scanResults {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-align: center;
}

.scan-success {
    background: #dcfce7;
    color: #166534;
}

.scan-error {
    background: #fee2e2;
    color: #991b1b;
}

.scan-warning {
    background: #fef9c3;
    color: #854d0e;
}

/* Custom Modal Overlay */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    /* Controlled by JS .style.display='flex' */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

/* Custom Modal Content Box */
.custom-modal {
    background: white;
    padding: 2rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.custom-modal-header h3 {
    margin: 0;
}

.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* QR and extra modal helpers */
#qrContainer canvas {
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
}

/* Print */
@media print {
    body * {
        visibility: hidden;
    }

    #qrModal,
    #qrModal * {
        visibility: visible;
    }

    #qrModal {
        position: absolute;
        left: 0;
        top: 0;
    }

    .btn-secondary {
        display: none;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        padding-bottom: 8rem;
    }

    .dashboard {
        grid-template-columns: 1fr;
    }
}

/* Hub Tabs */
.tab-btn {
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent !important;
}

.tab-btn.active {
    border-bottom: 2px solid var(--primary) !important;
    color: var(--primary) !important;
}

.tab-content {
    animation: fadeIn 0.3s ease-out;
}