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

:root {
    --primary: #0f766e;
    --primary-light: #14b8a6;
    --primary-dark: #065f46;
    --secondary: #0284c7;
    --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);
}

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

/* ===== Login Screen ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    text-align: center;
    padding: 40px 32px 24px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
}

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

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-header p {
    font-size: 14px;
    opacity: 0.8;
}

.login-card form {
    padding: 32px;
}

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

.login-card .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
}

.login-card .form-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

.login-card .form-group input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 42px !important;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 16px;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-error::before {
    content: '\f06a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
}

.login-footer {
    text-align: center;
    padding: 0 32px 28px;
    font-size: 12px;
    color: var(--text-light);
}

/* ===== App Shell ===== */
.app-shell {
    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: 12px 0;
}

.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: 16px;
}

.hostel-badge {
    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;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--secondary); }
.stat-icon.green { background: var(--success); }
.stat-icon.amber { background: var(--accent); }
.stat-icon.red { background: var(--danger); }
.stat-icon.teal { background: var(--primary); }
.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, .badge-partial { background: #fef3c7; color: #92400e; }
.badge-approved, .badge-paid, .badge-present, .badge-resolved { background: #d1fae5; color: #065f46; }
.badge-rejected, .badge-unpaid, .badge-absent { background: #fee2e2; color: #991b1b; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-open { background: #e0f2fe; color: #0369a1; }
.badge-closed { background: #f1f5f9; color: #475569; }
.badge-in_progress { background: #ede9fe; color: #6d28d9; }

/* ===== 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;
    font-family: inherit;
}

.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-lg { padding: 12px 24px; font-size: 16px; }
.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);
    font-family: inherit;
}
.btn-icon:hover { background: #f1f5f9; }

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== 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(20, 184, 166, 0.15);
}

.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);
}

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

/* ===== 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;
}

/* ===== 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-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; }
}

/* ===== 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: 20px 16px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

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

.fee-box .amount.green { color: var(--success); }
.fee-box .amount.red { color: var(--danger); }
.fee-box .amount.blue { color: var(--primary); }

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

/* ===== Welcome Banner ===== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-radius: var(--radius);
    padding: 28px 32px;
    color: white;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}

.welcome-banner h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.welcome-banner p {
    opacity: 0.85;
    font-size: 14px;
}

/* ===== Today Status Card ===== */
.today-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.today-status.marked {
    background: #d1fae5;
    border: 1px solid #a7f3d0;
}

.today-status.not-marked {
    background: #fef3c7;
    border: 1px solid #fde68a;
}

.today-status i {
    font-size: 28px;
}

.today-status .status-text h4 {
    font-size: 15px;
    font-weight: 600;
}

.today-status .status-text p {
    font-size: 13px;
    color: var(--text-light);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 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;
}

/* ===== Hidden ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }
    .sidebar span, .sidebar small, .sidebar h2 {
        display: none;
    }
    .sidebar-header { padding: 20px 12px; justify-content: center; }
    .logo { justify-content: center; }
    .sidebar-menu li { justify-content: center; padding: 14px 0; min-height: 48px; }
    .main-content { margin-left: var(--sidebar-collapsed); }
    .sidebar-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .hide-mobile { display: none; }
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar h1 { font-size: 16px; }
    .hostel-badge { display: none; }
    .attendance-summary { flex-wrap: wrap; gap: 16px; }

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

    .btn-sm {
        min-height: 36px;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-container { padding: 16px; }
    .welcome-banner { padding: 20px; }
    .welcome-banner h2 { font-size: 18px; }
    .fee-summary-row { grid-template-columns: 1fr; }
}

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

/* ===== Sidebar Mobile Overlay ===== */
.sidebar.mobile-open {
    width: var(--sidebar-width);
    z-index: 150;
}

.sidebar.mobile-open span,
.sidebar.mobile-open small,
.sidebar.mobile-open h2 {
    display: inline;
}

.sidebar.mobile-open .sidebar-menu li {
    justify-content: flex-start;
    padding: 12px 20px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 140;
}

.sidebar-backdrop.active {
    display: block;
}

/* ===== Loading Spinner ===== */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.loading-spinner i {
    font-size: 24px;
}

.loading-spinner p {
    margin-top: 8px;
}

/* ===== Complaint Status Timeline ===== */
.complaint-timeline {
    padding: 16px 0;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-left: 2px solid var(--border);
    margin-left: 8px;
    padding-left: 20px;
    position: relative;
}

.timeline-item::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    position: absolute;
    left: -7px;
    top: 16px;
}

.timeline-item .time {
    font-size: 12px;
    color: var(--text-light);
}

/* ===== 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;
}
/* Sidebar menu tooltips — 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 */
@media (min-width: 769px) {
    .sidebar-menu li[data-tip]::after,
    .sidebar-menu li[data-tip]::before { display: none; }
}

/* ===== 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);
}

/* ===== Mobile Bottom Navigation ===== */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding: 0 8px;
    }

    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        text-decoration: none;
        color: var(--text-light);
        font-size: 10px;
        font-weight: 500;
        padding: 6px 8px;
        border-radius: 8px;
        transition: color 0.2s;
        min-width: 56px;
    }

    .mobile-bottom-nav a.active {
        color: var(--primary);
    }

    .mobile-bottom-nav a i {
        font-size: 20px;
    }

    .page-container {
        padding-bottom: 70px;
    }
}

/* ===== Dark Mode ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --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); }
    .login-card form { 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 {
        background: #0f172a;
        border-color: var(--border);
        color: var(--text);
    }
    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); }

    .welcome-banner { background: linear-gradient(135deg, #0f172a, #1e293b); }

    .today-status.marked { background: #064e3b; border-color: #065f46; }
    .today-status.not-marked { background: #78350f; border-color: #92400e; }

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

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

    .complaint-timeline .timeline-item { border-left-color: var(--border); }

    .sidebar-backdrop { background: rgba(0,0,0,0.6); }

    .loading-spinner { color: var(--text-light); }

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

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 2px;
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 2px;
}
.lang-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}
.lang-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.lang-btn.active { background: rgba(255,255,255,0.25); color: #fff; }
@media (max-width: 768px) {
    .lang-switcher { gap: 1px; }
    .lang-btn { padding: 3px 6px; font-size: 11px; }
}

/* ===== Pull-to-Refresh ===== */
.pull-indicator {
    position: fixed;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    transition: top 0.2s ease;
    color: var(--primary);
    font-size: 18px;
}
.pull-indicator.pulling {
    top: 10px;
}
.pull-indicator.refreshing {
    top: 10px;
}
.pull-indicator.refreshing i {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Sidebar: scroll, search, groups, quick access ===== */
.sidebar-menu {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 140px);
    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; }

/* 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; }

/* 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; }

/* Quick Access */
.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 */
.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; } }

/* 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; }
.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);
}

/* 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-search-empty.show { display: block; }
