.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:hover {
    border-color: #1f2937;
    color: #1f2937;
    background: #f9fafb;
}

.btn-primary {
    background: #1f2937;
    color: #fff;
    border-color: #1f2937;
}

.btn-primary:hover {
    background: #374151;
    color: #fff;
}

.btn-danger {
    border-color: #fca5a5;
    color: #dc2626;
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.btn-link {
    border: none;
    background: none;
    padding: 0.3rem 0.6rem;
    color: #374151;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-link:hover {
    color: #1f2937;
    text-decoration: underline;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    font-size: 0.875rem;
}

.data-table thead {
    background: #fafafa;
}

.data-table th {
    text-align: left;
    padding: 0.85rem 1.1rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.data-table td {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid #f3f4f6;
    color: #111827;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #fafafa;
}

.data-table a {
    color: #1f2937;
    font-weight: 600;
    text-decoration: none;
}

.data-table a:hover {
    text-decoration: underline;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-submitted { background: #e0e7ff; color: #3730a3; }
.status-under_review { background: #fef3c7; color: #92400e; }
.status-accepted { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-enrollment_completed { background: #dbeafe; color: #1e40af; }
/* ── Forms ── */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 560px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    font-size: 0.875rem;
    color: #111827;
    background: white;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 1rem;
    font-size: 0.875rem;
    color: #111827;
    background: white;
    outline: none;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #1f2937;
}

.form fieldset {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form fieldset legend {
    font-size: 0.8rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 0.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
}

@media (max-width: 600px) {
    .form { max-width: 100%; }
}
/* ── Detail pages ── */
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.detail-meta div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.detail-meta .meta-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}

.detail-meta .meta-value {
    font-size: 0.9rem;
    color: #111827;
    font-weight: 500;
}

.section-heading {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    margin: 2.5rem 0 1rem;
}

.section-heading:first-of-type {
    margin-top: 0;
}

.inline-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    max-width: none;
}

.info-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-list li {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-size: 0.875rem;
    color: #374151;
}

.muted-note {
    color: #6b7280;
    font-size: 0.875rem;
    font-style: italic;
}
/* ── Timetable grid ── */
.timetable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.75rem 0 2.5rem;
}

.timetable-day-column {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 120px;
}

.timetable-day-column h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.timetable-entry-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.entry-time {
    font-size: 0.72rem;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: 0.02em;
}

.entry-subject {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.entry-teacher {
    font-size: 0.8rem;
    color: #6b7280;
}

.entry-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.4rem;
}

.entry-actions .btn-link {
    padding: 0;
    font-size: 0.75rem;
}

.muted {
    color: #9ca3af;
    font-size: 0.8rem;
    font-style: italic;
}

/* --- Invoice status badges (Finance module) --- */
.status-unpaid { background: #fee2e2; color: #991b1b; }
.status-partial { background: #fef3c7; color: #92400e; }
.status-paid { background: #dcfce7; color: #166534; }
.status-overdue { background: #fecaca; color: #7f1d1d; }
.status-void { background: #f3f4f6; color: #6b7280; }

.status-pending { background: #fef3c7; color: #92400e; }
.status-approved { background: #dcfce7; color: #166534; }
.status-present { background: #dcfce7; color: #166534; }
.status-absent { background: #fee2e2; color: #991b1b; }
.status-late { background: #fef3c7; color: #92400e; }
.status-excused { background: #dbeafe; color: #1e40af; }



/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 0;
    margin-top: 1rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.85rem;
    color: #6b7280;
}

.pagination-btns {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.85rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 0.82rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.page-btn:hover:not(.disabled):not(.active) {
    border-color: #1f2937;
    color: #1f2937;
}

.page-btn.active {
    background: #1f2937;
    color: #fff;
    border-color: #1f2937;
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 600px) {
    .pagination {
        flex-direction: column;
        align-items: flex-start;
    }
}
/* ── Alerts ── */
.alert { padding: 0.85rem 1.1rem; border-radius: 8px; font-size: 0.875rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }

/* ── Info label/value pairs ── */
.info-label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #9ca3af; margin-bottom: 0.2rem; }
.info-value { display: block; font-size: 0.9rem; color: #111827; font-weight: 500; }

/* ── Field errors ── */
.field-error { color: #dc2626; font-size: 0.78rem; margin: -0.75rem 0 0.75rem; }

/* ── Checkbox labels ── */
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: #374151; cursor: pointer; margin-bottom: 0.5rem; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ── Secondary button ── */
.btn-secondary { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }
.btn-secondary:hover { background: #e5e7eb; }

/* ── Generic tag badge (target/category — distinct from status-badge pills) ── */
.badge { display: inline-block; padding: 0.25rem 0.65rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; background: #f3f4f6; color: #374151; }

/* ── Bare form fields not wrapped in .form-group ──
   Fixes the bug flagged earlier: Student/profile.html and settings.html
   use plain <label>/<input> without .form-group, so the original
   .form-group-scoped rules never matched them. */
.form label { display: block; font-size: 0.75rem; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.375rem; }
.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="date"],
.form select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    font-size: 0.875rem;
    color: #111827;
    background: white;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    margin-bottom: 1rem;
}
.form input:focus, .form select:focus { border-color: #1f2937; }

/* ── Month navigation (used by attendance + calendar) ── */
.month-nav { display: flex; align-items: center; justify-content: space-between; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 0.85rem 1.25rem; margin-bottom: 1.5rem; font-size: 0.9rem; font-weight: 600; color: #111827; }
.month-nav a { color: #374151; text-decoration: none; font-size: 0.85rem; }
.month-nav a:hover { color: #1f2937; text-decoration: underline; }

/* ── Stat blocks (used by attendance summary + grade summary) ── */
.stat { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; background: #fafafa; border: 1px solid #e5e7eb; border-radius: 10px; padding: 1rem 1.25rem; min-width: 100px; }
.stat strong { font-size: 1.4rem; color: #111827; }
.stat span { font-size: 0.75rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; }


/* ── Mobile responsiveness ── */
@media (max-width: 640px) {
    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table {
        border: none;
        background: transparent;
    }

    .data-table tbody tr {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        margin-bottom: 0.85rem;
        padding: 0.25rem 0;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: 0.6rem 1rem;
        border-bottom: 1px solid #f3f4f6;
        text-align: right;
    }

    .data-table td:last-child {
        border-bottom: none;
    }

    .data-table td::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #9ca3af;
        text-align: left;
        flex-shrink: 0;
    }
    .data-table td.data-table-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.5rem 1rem;
    }
    
    .data-table td.data-table-actions::before {
        content: none;
    }

    /* Cells with no meaningful label (e.g. action buttons) skip the label row */
    .data-table td[data-label=""]::before,
    .data-table td:not([data-label])::before {
        content: none;
    }

    /* Admin page header: stack title and action button instead of forcing them side by side */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    /* Forms: full width, no fixed max-width fighting the screen */
    .form {
        max-width: 100%;
        gap: 1.1rem;
    }

    .form fieldset {
        padding: 1rem 1.1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    /* Detail meta / stat blocks: stack instead of overflowing */
    .detail-meta {
        flex-direction: column;
        gap: 0.75rem;
    }

    .month-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .timetable-grid {
        grid-template-columns: 1fr;
    }
    .page-header h1 {
        font-size: 1.25rem;
    }
    .page-header > div {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    .data-table.attendance-radio-table,
    .data-table.attendance-radio-table tbody,
    .data-table.attendance-radio-table tr {
        display: table;
        width: auto;
    }

    .data-table.attendance-radio-table thead {
        display: table-header-group;
    }

    .data-table.attendance-radio-table tbody {
        display: table-row-group;
    }

    .data-table.attendance-radio-table tr {
        display: table-row;
    }

    .data-table.attendance-radio-table th,
    .data-table.attendance-radio-table td {
        display: table-cell;
        width: auto;
    }

}

@media (max-width: 400px) {
    .entry-actions {
        flex-direction: column;
        gap: 0.4rem;
    }
}

.attendance-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
}

.data-table.attendance-radio-table {
    width: max-content;
    min-width: 100%;
    border: none;
    border-radius: 0;
}

.data-table.attendance-radio-table th,
.data-table.attendance-radio-table td {
    white-space: nowrap;
    text-align: center;
    min-width: 90px;
}

.data-table.attendance-radio-table th:first-child,
.data-table.attendance-radio-table td:first-child {
    text-align: left;
    min-width: 160px;
}

.data-table.attendance-radio-table td::before {
    content: none;
}

/* Sticky first column so the student name stays visible while scrolling statuses */
.sticky-col {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
}

.data-table.attendance-radio-table thead .sticky-col {
    background: #fafafa;
    z-index: 2;
}