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

:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --secondary: #0f766e;
    --accent: #f59e0b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0284c7;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 250px;
    --sidebar-collapsed: 60px;
    --topbar-height: 60px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --bg-light: #f8fafc;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: width 0.3s;
    overflow-x: hidden;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 28px;
    color: var(--accent);
}

.logo h2 {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

.logo small {
    font-size: 11px;
    opacity: 0.7;
    white-space: nowrap;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 80px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.sidebar-menu li {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.sidebar-menu li:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-menu li.active {
    background: rgba(255,255,255,0.15);
    border-left-color: var(--accent);
}

.sidebar-menu li i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: margin-left 0.3s;
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
    display: none;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

.academic-year {
    background: var(--primary-light);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 14px;
}

.user-info i { font-size: 24px; }

/* ===== Page Container ===== */
.page-container {
    padding: 24px;
}

/* ===== Dashboard Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--success); }
.stat-icon.amber { background: var(--accent); }
.stat-icon.red { background: var(--danger); }
.stat-icon.teal { background: var(--secondary); }
.stat-icon.info { background: var(--info); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.stat-info p {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== Card / Panel ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

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

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: #f8fafc;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-unpaid { background: #fee2e2; color: #991b1b; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-refunded { background: #e0e7ff; color: #3730a3; }
.badge-held { background: #fef3c7; color: #92400e; }
.badge-full { background: #fee2e2; color: #991b1b; }
.badge-available { background: #d1fae5; color: #065f46; }
.badge-present { background: #d1fae5; color: #065f46; }
.badge-absent { background: #fee2e2; color: #991b1b; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; border: 1px solid var(--border);
    background: white; cursor: pointer; color: var(--text-light);
}
.btn-icon:hover { background: #f1f5f9; }

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.form-group label .required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

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

.form-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

.radio-group, .checkbox-group {
    display: flex;
    gap: 16px;
    align-items: center;
    padding-top: 4px;
}

.radio-group label, .checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Application Type Toggle ===== */
.app-type-toggle {
    display: flex;
    border: 2px solid var(--primary);
    border-radius: 10px;
    overflow: hidden;
    background: white;
}
.app-type-toggle button {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.app-type-toggle button:not(:last-child) { border-right: 2px solid var(--primary); }
.app-type-toggle button.active { background: var(--primary); color: white; }
.app-type-toggle button:not(.active):hover { background: #eff6ff; }
.app-form-actions { position: sticky; bottom: 0; background: white; z-index: 2; margin: 0 -20px -20px; padding: 16px 20px; border-top: 1px solid var(--border); box-shadow: 0 -4px 12px rgba(0,0,0,0.05); }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar input,
.filters-bar select {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.filters-bar input { width: 220px; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.hidden { display: none; }

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-content.modal-lg { max-width: 900px; }

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

.modal-header h2 { font-size: 18px; }

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
}

/* ===== Detail Grid ===== */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.detail-item {
    padding: 8px 0;
}

.detail-item label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-item p {
    font-size: 14px;
    font-weight: 500;
    margin-top: 2px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Hostel Cards ===== */
.hostel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.hostel-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    border: 1px solid var(--border);
}
.hostel-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.hostel-card-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.hostel-card-header .btn {
    color: white;
    border-color: rgba(255,255,255,0.5);
    flex-shrink: 0;
}
.hostel-card-header .btn:hover {
    background: rgba(255,255,255,0.2);
}

.hostel-card-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.hostel-card-header small {
    opacity: 0.85;
    font-size: 12px;
}

.hostel-card-body {
    padding: 16px 20px;
}

.hostel-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.hostel-stat-row:last-child { border-bottom: none; }
.hostel-stat-row span:first-child { color: var(--text-light); }
.hostel-stat-row span:last-child { font-weight: 600; }

.hostel-card-actions {
    display: flex;
    gap: 6px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-light);
}
.hostel-card-actions .btn { flex: 1; font-size: 12px; }

/* Occupancy ring */
.occ-ring {
    width: 64px; height: 64px; position: relative;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.occ-ring svg { transform: rotate(-90deg); position: absolute; top: 0; left: 0; }
.occ-ring .occ-pct { font-size: 14px; font-weight: 800; z-index: 1; }

.plan-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
    background: var(--bg-light); border: 1px solid var(--border); margin: 2px;
}
.plan-chip.default { background: #dbeafe; border-color: #93c5fd; color: var(--primary); }
.plan-chip .plan-amt { color: var(--text-light); font-weight: 500; }

/* ===== Attendance ===== */
.attendance-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.geo-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.geo-status.within { background: #d1fae5; color: #065f46; }
.geo-status.outside { background: #fee2e2; color: #991b1b; }
.geo-status.unknown { background: #f1f5f9; color: var(--text-light); }

.attendance-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 16px;
}

.cal-day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    padding: 8px 0;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: default;
}

.cal-day.empty { background: transparent; }
.cal-day.present { background: #d1fae5; color: #065f46; }
.cal-day.absent { background: #fee2e2; color: #991b1b; }
.cal-day.today { border: 2px solid var(--primary); }
.cal-day.future { color: #cbd5e1; }

.attendance-summary {
    display: flex;
    gap: 24px;
    margin-top: 16px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
}

.att-summary-item {
    text-align: center;
}

.att-summary-item .count {
    font-size: 28px;
    font-weight: 700;
}

.att-summary-item .label {
    font-size: 12px;
    color: var(--text-light);
}

.att-summary-item .count.green { color: var(--success); }
.att-summary-item .count.red { color: var(--danger); }
.att-summary-item .count.blue { color: var(--primary); }

/* ===== Fee Summary Boxes ===== */
.fee-summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.fee-box {
    text-align: center;
    padding: 16px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.fee-box .amount {
    font-size: 24px;
    font-weight: 700;
}

.fee-box .label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    /* Sidebar: hidden off-screen, slides in as overlay */
    .sidebar {
        position: fixed;
        left: -260px;
        width: 250px;
        transition: left 0.3s ease;
        z-index: 200;
    }
    .sidebar.open {
        left: 0;
    }
    .sidebar span, .sidebar small, .sidebar h2 {
        display: inline; /* Show text when overlay is open */
    }
    .sidebar-header { padding: 20px 16px; }
    .sidebar-menu li { justify-content: flex-start; padding: 12px 20px; min-height: 48px; }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 199;
        display: none;
    }
    .sidebar-overlay.active {
        display: block;
    }

    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid, .fee-summary-row { grid-template-columns: repeat(2, 1fr); }
    .card-header { padding: 12px 16px; flex-direction: column; align-items: stretch; gap: 12px; }
    .card-body { padding: 16px; }
    .form-section h3 { font-size: 14px; }
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; padding: 10px 12px; }
    .app-type-toggle button { padding: 10px 8px; font-size: 13px; }
    .app-type-toggle button span { display: none; }
    .app-type-toggle button::after { font-size: 12px; }
    .app-type-toggle button[data-type="new"]::after { content: "New Student"; }
    .app-type-toggle button[data-type="existing"]::after { content: "Renewal"; }
    .form-actions, .app-form-actions { flex-wrap: wrap; }
    .app-form-actions .btn { flex: 1; min-width: 0; justify-content: center; }
    .filters-bar { flex-direction: column; gap: 8px; }
    .filters-bar input, .filters-bar select { font-size: 14px; min-width: 0; flex: 1; width: 100% !important; }
    .modal-content { width: 95%; max-width: none; margin: 10px; max-height: 90vh; }

    /* Tab nav scrollable on mobile */
    .tab-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
    .tab-btn { white-space: nowrap; }

    /* Mobile-friendly scrollable tables */
    .table-wrapper, .table-responsive {
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    .table-wrapper::after, .table-responsive::after {
        content: '';
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 20px;
        background: linear-gradient(to left, var(--bg-card), transparent);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
    }
    .table-wrapper.scrollable::after, .table-responsive.scrollable::after {
        opacity: 1;
    }

    /* Sticky first column for tables */
    .data-table th:first-child, .data-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--bg-card);
    }
    .data-table { font-size: 13px; }
    .data-table td, .data-table th { padding: 8px 10px; }

    /* Touch-friendly targets */
    .btn, .btn-icon, .tab-btn {
        min-height: 44px;
        min-width: 44px;
    }
    .btn-sm {
        min-height: 36px;
        padding: 8px 12px;
    }

    /* Action buttons in tables: icon only */
    .data-table .btn-sm span, .data-table .btn span { display: none; }
}

@media (max-width: 480px) {
    .stats-grid, .fee-summary-row { grid-template-columns: 1fr; }
    .page-container { padding: 12px; }
    .topbar h1 { font-size: 15px; }
    .card { border-radius: 10px; }
    .form-section { margin-bottom: 18px; }
    .app-form-actions { margin: 0 -16px -16px; padding: 12px 16px; }
}

/* ===== Login Screen ===== */
.login-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.login-screen.hidden { display: none; }

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}

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

.login-header p {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

.login-card .form-group {
    margin-bottom: 16px;
}

.login-card .form-group input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Sidebar Divider ===== */
.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.15);
    margin: 8px 16px;
    padding: 0 !important;
    cursor: default !important;
    border: none !important;
}

.sidebar-divider:hover {
    background: rgba(255,255,255,0.15) !important;
}

/* ===== Sidebar Collapsible Groups ===== */
.sidebar-group-header {
    position: relative;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    padding: 10px 20px !important;
    margin-top: 4px;
    border-left: 3px solid transparent !important;
    user-select: none;
}
.sidebar-group-header:hover {
    opacity: 1;
}
.sidebar-group-header .group-chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    transition: transform 0.25s ease;
    opacity: 0.6;
}
.sidebar-group-header.expanded .group-chevron {
    transform: translateY(-50%) rotate(90deg);
}

.sidebar-menu li.sidebar-group-item {
    padding-left: 36px;
    font-size: 13.5px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
    border-left-color: transparent;
}
.sidebar-menu li.sidebar-group-item.visible {
    max-height: 48px;
    opacity: 1;
    padding-top: 10px;
    padding-bottom: 10px;
}
.sidebar-menu li.sidebar-group-item i {
    font-size: 14px;
    width: 18px;
}

/* Highlight group header when a child page is active */
.sidebar-group-header.has-active-child {
    background: rgba(255,255,255,0.06);
    opacity: 1;
}
.sidebar-group-header.has-active-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
}

/* ===== Sidebar Search ===== */
.sidebar-search {
    position: relative;
    padding: 10px 16px 6px;
}
.sidebar-search input {
    width: 100%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    padding: 9px 30px 9px 32px;
    outline: none;
    transition: background 0.2s, border-color 0.2s;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,0.45); }
.sidebar-search input:focus {
    background: rgba(255,255,255,0.12);
    border-color: var(--accent);
}
.sidebar-search > i.fa-search {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    pointer-events: none;
}
.sidebar-search-clear {
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    display: none;
    padding: 4px;
}
.sidebar-search-clear:hover { color: #fff; }
.sidebar-search.has-text .sidebar-search-clear { display: block; }

/* ===== Quick Access (pinned) ===== */
.quick-access-header {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    padding: 8px 20px 6px !important;
    cursor: default !important;
    border-left: 3px solid transparent !important;
}
.quick-access-header:hover { background: transparent !important; }
.quick-access-header i { color: var(--accent); }
.sidebar-menu li.quick-access-item {
    padding-left: 36px;
    font-size: 13.5px;
}

/* Pin (star) toggle on menu items */
.sidebar-menu li[data-page] { position: relative; }
.pin-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.55);
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    padding: 4px;
    z-index: 2;
}
.sidebar-menu li[data-page]:hover .pin-btn { opacity: 0.7; }
.pin-btn:hover { opacity: 1 !important; color: var(--accent); }
.pin-btn.pinned { opacity: 1; color: var(--accent); }
@media (hover: none) {
    .pin-btn { opacity: 0.5; }
}

/* ===== Sidebar Search Filtering ===== */
.sidebar-menu.searching .sidebar-group-header,
.sidebar-menu.searching .quick-access-header,
.sidebar-menu.searching .quick-access-item,
.sidebar-menu.searching .quick-access-divider {
    display: none !important;
}
.sidebar-menu.searching li[data-page]:not(.search-match) {
    display: none !important;
}
.sidebar-menu.searching li.sidebar-group-item.search-match {
    max-height: 48px;
    opacity: 1;
    padding-top: 10px;
    padding-bottom: 10px;
}
.sidebar-search-empty {
    padding: 16px 20px;
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    font-style: italic;
    display: none;
}
.sidebar-menu.searching ~ .sidebar-search-empty.show,
.sidebar-search-empty.show { display: block; }

/* ===== Logout Button ===== */
.btn-logout {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
    padding: 5px 10px;
    font-size: 13px;
}

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

/* ===== User/Settings Badges ===== */
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-super_admin { background: #ede9fe; color: #5b21b6; }
.badge-admin { background: #dbeafe; color: #1e40af; }
.badge-hostel_warden { background: #fef3c7; color: #92400e; }
.badge-accountant { background: #e0e7ff; color: #3730a3; }
.badge-student { background: #d1fae5; color: #065f46; }

/* ===== Settings Form ===== */
.settings-category {
    margin-bottom: 24px;
}

.settings-category h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-light);
    text-transform: capitalize;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.settings-row label {
    font-size: 14px;
    font-weight: 500;
    min-width: 200px;
}

.settings-row input,
.settings-row select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    flex: 1;
    max-width: 300px;
}

/* ===== Attendance Tab Styles ===== */
.att-tabs button:hover { color: var(--primary) !important; }
.badge-leave { background: #fef3c7; color: #92400e; }
.badge-present { background: #d1fae5; color: #065f46; }
.badge-absent { background: #fee2e2; color: #991b1b; }

/* ===== Sortable Table Headers ===== */
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; position: relative; }
th[data-sort]:hover { color: var(--primary); }
th[data-sort]::after { content: '⇅'; margin-left: 4px; font-size: 10px; opacity: 0.35; }
th[data-sort].sort-asc::after { content: '↑'; opacity: 0.9; color: var(--primary); }
th[data-sort].sort-desc::after { content: '↓'; opacity: 0.9; color: var(--primary); }

/* ===== View Toggle ===== */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.view-toggle button { padding: 6px 10px; border: none; background: white; cursor: pointer; color: var(--text-light); font-size: 13px; transition: all 0.2s; }
.view-toggle button:not(:last-child) { border-right: 1px solid var(--border); }
.view-toggle button.active { background: var(--primary); color: white; }
.view-toggle button:hover:not(.active) { background: var(--bg-light); }

/* ===== Hostel List View ===== */
#eh-map-container { z-index: 1; }
#eh-map-container .leaflet-control-attribution { font-size: 10px; }
.hostel-list-table td { vertical-align: middle; }
.hostel-list-table .occ-bar { height: 6px; background: #e2e8f0; border-radius: 3px; min-width: 60px; }
.hostel-list-table .occ-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* ===== Instant CSS Tooltips ===== */
[data-tip] {
    position: relative;
}
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30,41,59,0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
    line-height: 1.4;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
[data-tip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(30,41,59,0.92);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
}
[data-tip]:hover::after,
[data-tip]:hover::before {
    opacity: 1;
}
/* Tooltip below variant */
[data-tip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 6px);
}
[data-tip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: rgba(30,41,59,0.92);
}
/* Sidebar menu tooltips — always show to the right */
.sidebar-menu li[data-tip]::after {
    bottom: auto;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
}
.sidebar-menu li[data-tip]::before {
    bottom: auto;
    left: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-left-color: transparent;
    border-right-color: rgba(30,41,59,0.92);
}
/* Hide sidebar tooltips when sidebar is expanded (text is visible) */
@media (min-width: 769px) {
    .sidebar-menu li[data-tip]::after,
    .sidebar-menu li[data-tip]::before { display: none; }
}
/* Action icon buttons — tooltip above */
.btn-icon[data-tip]::after { font-size: 10px; padding: 3px 8px; }

/* ===== Empty States ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}
.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}
.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}
.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}
.empty-state .btn {
    margin-top: 8px;
}

/* ===== Skeleton Loading ===== */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, rgba(255,255,255,0.15) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.long { width: 90%; }

.skeleton-row {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.skeleton-row > div { flex: 1; }

.skeleton-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-btn {
    width: 80px;
    height: 32px;
    border-radius: 4px;
}

/* ===== Inline Form Validation ===== */
.input-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.field-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-error::before {
    content: '\f071';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
}

/* ===== Filter Chips ===== */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    align-items: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--primary-light);
    color: white;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.filter-chip i {
    cursor: pointer;
    opacity: 0.7;
    font-size: 10px;
}

.filter-chip i:hover {
    opacity: 1;
}

.filter-chip-clear {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.filter-chip-clear:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ===== Dark Mode ===== */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #0f172a;
        --bg-card: #1e293b;
        --text: #e2e8f0;
        --text-light: #94a3b8;
        --border: #334155;
        --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
        --shadow-lg: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    }

    body { background: var(--bg); color: var(--text); }

    .login-card { background: var(--bg-card); }

    .card, .stat-card { background: var(--bg-card); border-color: var(--border); }

    thead th { background: #0f172a; color: var(--text-light); }
    tbody td { border-color: var(--border); }
    tbody tr:hover { background: rgba(255,255,255,0.03); }

    input, select, textarea,
    .form-group input, .form-group select, .form-group textarea,
    .filters-bar input, .filters-bar select,
    .modal-content input, .modal-content select, .modal-content textarea {
        background: #0f172a;
        border-color: var(--border);
        color: var(--text);
    }
    input::placeholder, textarea::placeholder { color: #64748b; }
    input:focus, select:focus, textarea:focus {
        border-color: var(--primary-light);
    }

    .sidebar { background: #0f172a; border-color: var(--border); }
    .topbar { background: var(--bg-card); border-color: var(--border); }

    .btn-outline { border-color: var(--border); color: var(--text-light); }
    .btn-outline:hover { background: rgba(255,255,255,0.05); }

    .btn-icon { background: var(--bg-card); border-color: var(--border); color: var(--text-light); }
    .btn-icon:hover { background: rgba(255,255,255,0.05); }

    .modal-content { background: var(--bg-card); }
    .modal-overlay { background: rgba(0,0,0,0.7); }

    .badge { opacity: 0.9; }

    .filters-bar { background: var(--bg-card); border-color: var(--border); }

    .empty-state { color: var(--text-light); }

    .toast { background: var(--bg-card); color: var(--text); border-color: var(--border); }

    .hostel-card { background: var(--bg-card); border-color: var(--border); }
    .hostel-card-actions { background: #0f172a; }

    .fee-box { background: #0f172a; border-color: var(--border); }

    .attendance-summary { background: #0f172a; }

    .view-toggle button { background: var(--bg-card); color: var(--text-light); border-color: var(--border); }
    .view-toggle button.active { background: var(--primary); color: white; }

    .app-type-toggle { background: var(--bg-card); }
    .app-type-toggle button { background: var(--bg-card); color: var(--text-light); }
    .app-type-toggle button.active { background: var(--primary); color: white; }
    .app-form-actions { background: var(--bg-card); }

    .settings-row input, .settings-row select { background: #0f172a; color: var(--text); }

    ::placeholder { color: var(--text-light); opacity: 0.6; }
}

/* ===== Report Tab Groups ===== */
.report-tab-group { margin-bottom: 4px; }
.report-tab-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 4px;
    padding-left: 2px;
}

/* ===== Print ===== */
@media print {
    .sidebar, .topbar, .btn, .filters-bar { display: none !important; }
    .main-content { margin-left: 0; }
}
