:root {
    --bg: #f7f8fa;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1f2933;
    --accent: #ff8c00;
    --success: #2eb872;
    --danger: #e63946;
    --sidebar: #0f172a;
    --sidebar-text: #e2e8f0;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f6f9;
    color: var(--text);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-bar {
    display: flex;
    flex-direction: column;
}

.filter-toggle {
    align-self: flex-start;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.filter-bar .collapse {
    width: 100%;
}

.filter-form label {
    font-size: 0.9rem;
    color: #475569;
}

.filter-form select,
.filter-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
}

.filter-form .form-group {
    margin-bottom: 0.5rem;
}

.filter-form .form-control-sm {
    min-height: 2.125rem;
    border-radius: 6px;
}

.filter-form .btn-sm {
    padding: 0.45rem 0.9rem;
}

.attendance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.student-tile {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    text-align: left;
    width: 100%;
    cursor: pointer;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.student-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

.student-tile.in {
    border-color: var(--accent);
    background: #fff6ed;
}

.student-tile.out {
    border-color: var(--success);
    background: #ecfdf5;
}

.student-tile.timeout {
    border-color: var(--danger);
    background: #ffe4e6;
    animation: flash 1s linear infinite;
}

.student-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.student-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #475569;
    overflow: hidden;
    flex-shrink: 0;
}

.student-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.student-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.student-name {
    font-size: 1.05rem;
    font-weight: 600;
}

.student-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.35rem 0 0.25rem;
}

.student-pill {
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    /* background: #eef2ff; */
    color: #3730a3;
    /* padding: 0.1rem 0.65rem; */
    border-radius: 999px;
}

.student-pill--subtle {
    /* background: #f1f5f9; */
    color: #475569;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.student-status {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    background: #e2e8f0;
    color: #0f172a;
    align-self: flex-start;
}

.student-tile.in .student-status {
    background: #fed7aa;
    color: #9a3412;
}

.student-tile.out .student-status {
    background: #bbf7d0;
    color: #065f46;
}

.empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 2rem 0;
}

.info-box .info-box-number {
    font-size: 1.4rem;
}

.report-table table {
    margin-bottom: 0;
}

.table-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-grid label {
    font-size: 0.85rem;
    color: #475569;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem;
    width: 100%;
    font-size: 1rem;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.form-errors {
    border: 1px solid var(--danger);
    background: #fff0f3;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.form-errors ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--danger);
}

.table-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    font-weight: 600;
}

.table-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.table-avatar--fallback {
    color: #475569;
}

.current-photo-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.current-photo-img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}

.remove-photo-toggle {
    font-size: 0.85rem;
    margin-bottom: 0;
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    color: #475569;
}

@keyframes flash {
    0% {
        box-shadow: 0 0 0 rgba(230, 57, 70, 0.2);
    }
    50% {
        box-shadow: 0 0 16px rgba(230, 57, 70, 0.7);
    }
    100% {
        box-shadow: 0 0 0 rgba(230, 57, 70, 0.2);
    }
}

@media (max-width: 1024px) {
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        z-index: 1000;
        max-width: 80%;
        box-shadow: 4px 0 25px rgba(15, 23, 42, 0.4);
    }

    .menu-toggle {
        display: inline-flex;
    }

    body.nav-open {
        overflow: hidden;
    }

    body.nav-open .app-sidebar {
        transform: translateX(0);
    }

    body.nav-open .app-main::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 900;
    }

    .sidebar-close {
        display: inline-flex;
    }
}

@media (max-width: 640px) {
    .app-content,
    .filter-form,
    .form-card {
        padding: 1rem;
    }

    .app-header {
        flex-wrap: wrap;
    }

    .attendance-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .report-table table,
    .dashboard-cards {
        display: block;
        overflow-x: auto;
    }

    .table-actions {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .filter-form .form-group {
        margin-bottom: 0.35rem;
    }

    .student-avatar {
        width: 44px;
        height: 44px;
    }
}
