/* =========================================================
   KIHAS STAFF PORTAL — main.css
   Global styles: tokens, base, layout, shared components.
   Page-specific styles (students, add-result) live in forms.css.
   Load order: main.css → forms.css

   CONTENTS
   1. Design tokens
   2. Reset & base
   3. Layout (app shell, sidebar, topbar)
   4. Components
      4.1 Buttons
      4.2 Cards & headings
      4.3 Stats
      4.4 Forms & controls
      4.5 Filters & search
      4.6 Alerts & messages
      4.7 Data tables
      4.8 Status badge
      4.9 Empty state
      4.10 Modal
      4.11 Generic module / result cards
   5. Login page
   6. Utilities
   7. Responsive
   8. Reduced motion
   ========================================================= */


/* =========================================================
   1. DESIGN TOKENS
   (the only :root block in the project — forms.css uses these)
   ========================================================= */

:root {
    /* Brand */
    --primary: #198754;
    --primary-dark: #146c43;
    --primary-light: #eef8f2;

    /* Text */
    --dark: #10251b;
    --text: #24362c;
    --muted: #6b786f;
    --muted-light: #91a096;

    /* Surfaces & borders */
    --background: #f5f7f6;
    --surface: #ffffff;
    --surface-muted: #f8faf8;
    --border: #e3eae5;
    --border-input: #d7e1da;

    /* Feedback */
    --danger: #b42318;
    --danger-dark: #912018;
    --danger-light: #fff0f0;
    --danger-border: #f1d1ce;

    --success: #047857;
    --success-light: #ecfdf5;
    --success-border: #a7f3d0;

    --warning: #9a6700;
    --warning-light: #fff8e5;

    /* Layout */
    --sidebar-width: 250px;
    --topbar-height: 84px;

    /* Shape */
    --radius-sm: 7px;
    --radius-control: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Elevation & focus */
    --shadow-sm: 0 2px 8px rgb(16 37 27 / 4%);
    --shadow-md: 0 8px 28px rgb(16 37 27 / 8%);
    --focus-ring: 0 0 0 3px rgb(25 135 84 / 10%);

    /* Motion */
    --transition: 0.2s ease;
}


/* =========================================================
   2. RESET & BASE
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: "Inter", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid rgb(25 135 84 / 25%);
    outline-offset: 2px;
}


/* =========================================================
   3. LAYOUT
   ========================================================= */

/* ---------- App shell ---------- */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    margin-left: var(--sidebar-width);
}

.page-content {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 28px;
}

/* ---------- Sidebar ---------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;

    display: flex;
    flex-direction: column;

    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    padding: 22px 16px 16px;
    overflow-x: hidden;
    overflow-y: auto;

    background: var(--dark);
    color: #fff;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    min-height: 58px;
    padding: 0 8px 22px;
    border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.brand-link img {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-control);
    background: #fff;
    object-fit: contain;
}

.brand-link > span {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-link strong {
    color: #fff;
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.brand-link small {
    margin-top: 2px;
    color: #b8c8bd;
    font-size: 0.74rem;
}

.sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 35px;
    height: 35px;
    border: 0;
    border-radius: var(--radius-control);
    background: rgb(255 255 255 / 8%);
    color: #fff;
}

.sidebar-close:hover {
    background: rgb(255 255 255 / 15%);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 24px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 13px;

    min-height: 45px;
    padding: 11px 13px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);

    color: #c3d0c7;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.sidebar-nav .nav-link i {
    flex-shrink: 0;
    width: 20px;
    font-size: 1.05rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: rgb(255 255 255 / 7%);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    border-color: rgb(255 255 255 / 7%);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgb(255 255 255 / 10%);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    padding: 4px 5px 15px;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgb(255 255 255 / 10%);
    color: #fff;
    font-size: 1.05rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-info strong,
.user-info small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info strong {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
}

.user-info small {
    margin-top: 3px;
    color: #b8c8bd;
    font-size: 0.72rem;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;

    width: 100%;
    min-height: 42px;
    padding: 10px 13px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);

    background: transparent;
    color: #f0c4c1;
    font-size: 0.86rem;
    font-weight: 500;
    text-align: left;
    transition: background var(--transition);
}

.logout-btn:hover {
    background: rgb(255 255 255 / 7%);
    color: #fff;
}

.logout-btn i {
    font-size: 1rem;
}

/* ---------- Mobile sidebar overlay & toggle ---------- */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: none;
    background: rgb(0 0 0 / 45%);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: #fff;
    color: var(--text);
    font-size: 1.35rem;
}

.menu-toggle:hover {
    border-color: #c4dfce;
    background: var(--primary-light);
}

body.sidebar-open {
    overflow: hidden;
}

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 500;

    display: flex;
    align-items: center;
    gap: 18px;

    min-height: var(--topbar-height);
    padding: 17px 28px;
    border-bottom: 1px solid var(--border);
    background: rgb(255 255 255 / 96%);
    backdrop-filter: blur(12px);
}

.topbar-title {
    flex: 1;
    min-width: 0;
}

.topbar-title h1 {
    margin: 0;
    color: var(--dark);
    font-size: 1.35rem;
    font-weight: 750;
    letter-spacing: -0.035em;
}

.topbar-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.topbar > .btn {
    flex-shrink: 0;
}


/* =========================================================
   4. COMPONENTS
   ========================================================= */

/* ---------- 4.1 Buttons ---------- */

.btn,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    min-height: 40px;
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);

    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;

    transition:
            background var(--transition),
            border-color var(--transition),
            color var(--transition),
            box-shadow var(--transition);
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    color: #fff;
}

.btn-secondary {
    border-color: var(--border-input);
    background: #fff;
    color: var(--text);
}

.btn-secondary:hover {
    border-color: #cbd8cf;
    background: #f4f7f5;
}

.btn-danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    border-color: var(--danger-dark);
    background: var(--danger-dark);
}

.btn-outline {
    border-color: var(--border);
    background: transparent;
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.btn-block {
    width: 100%;
}


/* ---------- 4.2 Cards & headings ---------- */

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 0;
    color: var(--dark);
    font-size: 1rem;
    font-weight: 700;
}

.section-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 0.83rem;
}

.content-card {
    min-width: 0;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.content-card + .content-card {
    margin-top: 24px;
}


/* ---------- 4.3 Stats ---------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;

    min-width: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.25rem;
}

.stat-card p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.8rem;
}

.stat-card h2 {
    margin: 0;
    color: var(--dark);
    font-size: 1.5rem;
    font-weight: 750;
    letter-spacing: -0.04em;
}


/* ---------- 4.4 Forms & controls ----------
   One definition for every text control. Spacing between
   groups is set by the container (grid gap, or the page's
   own rules in forms.css).                                  */

.form-section {
    margin-bottom: 25px;
}

.form-section-title {
    margin: 0 0 16px;
    color: var(--dark);
    font-size: 1rem;
    font-weight: 700;
}

.form-grid,
.edit-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.form-group label,
.filter-group label {
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
}

.form-control,
.form-group input,
.form-group select,
.form-group textarea,
.filter-group select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-control);
    outline: none;
    background: var(--surface);
    color: var(--text);
    font-size: 0.87rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-control::placeholder,
.form-group input::placeholder,
.search-box input::placeholder,
.search-input input::placeholder {
    color: var(--muted-light);
}

.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.filter-group select:focus,
.search-box input:focus,
.filters select:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-help {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.76rem;
}


/* ---------- 4.5 Filters & search ---------- */

.filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 180px;
}

.search-box > i {
    position: absolute;
    top: 50%;
    left: 13px;
    color: var(--muted-light);
    font-size: 0.95rem;
    pointer-events: none;
    transform: translateY(-50%);
}

.search-box input {
    width: 100%;
    min-height: 43px;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-control);
    outline: none;
    background: #fff;
    color: var(--text);
    font-size: 0.85rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.filters select {
    width: auto;
    min-width: 155px;
    min-height: 43px;
    padding: 10px 34px 10px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-control);
    outline: none;
    background-color: #fff;
    color: var(--text);
    font-size: 0.84rem;
}


/* ---------- 4.6 Alerts & messages ----------
   .form-error / .form-success are hidden until `.visible`
   is added. .student-message is toggled by its script.      */

.page-message,
.form-error,
.form-success,
.student-message {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.85rem;
    line-height: 1.5;
}

.page-message {
    margin: 14px 0;
    border-color: #d6ebdc;
    background: var(--primary-light);
    color: #174c32;
}

.form-error,
.form-success {
    display: none;
    margin-top: 14px;
}

.form-error.visible,
.form-success.visible {
    display: block;
}

.student-message {
    display: none;
    margin-bottom: 16px;
    background: var(--surface-muted);
    color: var(--muted);
}

.page-message.error,
.student-message.error,
.form-error {
    border-color: var(--danger-border);
    background: var(--danger-light);
    color: var(--danger);
}

.form-success {
    border-color: var(--success-border);
    background: var(--success-light);
    color: var(--success);
}


/* ---------- 4.7 Data tables ---------- */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    text-align: left;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) { width: 22%; }
.data-table th:nth-child(2),
.data-table td:nth-child(2) { width: 28%; }
.data-table th:nth-child(3),
.data-table td:nth-child(3) { width: 50%; }

.data-table td { overflow-wrap: anywhere; }

.data-table th,
.data-table td {
    padding: 15px 16px;
    border-bottom: 1px solid #e9eeeb;
    vertical-align: middle;
}

.data-table th {
    background: var(--surface-muted);
    color: #617067;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    color: var(--text);
    font-size: 0.85rem;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: #fbfdfb;
}

.table-loading {
    padding: 32px !important;
    color: var(--muted) !important;
    text-align: center;
}

/* Mobile list used alongside .table-responsive */
.students-mobile-list {
    display: none;
}


/* ---------- 4.8 Status badge ---------- */

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 5px 9px;
    border-radius: 20px;
    background: #eaf7ef;
    color: #187044;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}


/* ---------- 4.9 Empty state ---------- */

.empty-state {
    padding: 42px 20px;
    text-align: center;
}

.empty-state > i {
    color: var(--muted-light);
    font-size: 2rem;
}

.empty-state h3 {
    margin: 12px 0 6px;
    color: var(--dark);
    font-size: 1rem;
}

.empty-state p {
    max-width: 360px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 0.84rem;
}


/* ---------- 4.10 Modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;

    display: none;
    align-items: center;
    justify-content: center;

    padding: 20px;
    overflow-y: auto;
    background: rgb(10 25 16 / 55%);
    backdrop-filter: blur(3px);
}

.modal-backdrop.show {
    display: flex;
}

.edit-modal {
    width: min(100%, 650px);
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    padding: 25px;
    overflow-y: auto;

    border: 1px solid rgb(255 255 255 / 50%);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: 0 20px 60px rgb(0 0 0 / 20%);
    animation: modal-enter 0.18s ease-out;
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.edit-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 23px;
}

.edit-modal-header h2 {
    margin: 0 0 5px;
    color: var(--dark);
    font-size: 1.2rem;
    font-weight: 750;
}

.edit-modal-header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.83rem;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: #fff;
    color: #45554a;
    transition: background var(--transition);
}

.modal-close:hover {
    background: #f2f6f3;
}

.edit-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;

    margin-top: 25px;
    padding-top: 18px;
    border-top: 1px solid #edf1ee;
}

/* Single result details modal */
.result-modal {
    width: min(100%, 680px);
}

.result-modal .form-error:not([hidden]) {
    display: block;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.result-edit-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.result-summary .form-group p {
    margin: 0;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.result-student-heading h2 {
    margin: 0;
    color: var(--dark);
    font-size: 1.2rem;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.result-subjects-group {
    margin-top: 20px;
}

.result-subjects {
    display: grid;
    gap: 8px;
    max-height: none;
    overflow: visible;
}

.result-subject-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(130px, 180px);
    gap: 12px;
    padding: 0 12px 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.result-subject-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(130px, 180px);
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--surface-muted);
    color: var(--text);
    font-size: 0.85rem;
}

.result-subject-item span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.result-subject-item label {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
}

.result-subject-item .form-control {
    min-height: 38px;
}


/* ---------- 4.11 Generic module / result cards ---------- */

.module-card,
.result-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.module-card h3,
.result-card h3 {
    margin-bottom: 8px;
    color: var(--dark);
    font-size: 0.96rem;
    font-weight: 700;
}

.module-card p,
.result-card p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.83rem;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}


/* =========================================================
   5. LOGIN PAGE
   ========================================================= */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;

    background:
            radial-gradient(circle at top right, rgb(25 135 84 / 10%), transparent 35%),
            var(--background);
}

.login-card {
    width: min(100%, 420px);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-md);
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
    text-align: center;
}

.login-brand img {
    width: 68px;
    height: 68px;
    margin-bottom: 14px;
    object-fit: contain;
}

.login-brand h1 {
    margin: 0;
    color: var(--dark);
    font-size: 1.25rem;
    font-weight: 800;
}

.login-brand p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form .btn {
    width: 100%;
    min-height: 45px;
    margin-top: 5px;
}


/* =========================================================
   6. UTILITIES
   ========================================================= */

.text-muted   { color: var(--muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-danger  { color: var(--danger) !important; }

.fw-semibold { font-weight: 600 !important; }
.fw-bold     { font-weight: 700 !important; }

.w-100 { width: 100% !important; }

.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }

.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }


/* =========================================================
   7. RESPONSIVE
   Breakpoints: 1200 (tablet) · 900 (mobile nav)
                760 (table → cards) · 480 (small phones)
   ========================================================= */

@media (max-width: 1200px) {
    :root {
        --sidebar-width: 230px;
    }

    .page-content {
        padding: 24px;
    }

    .topbar {
        padding-inline: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-card {
        padding: 20px;
    }
}

@media (max-width: 900px) {
    :root {
        --topbar-height: 74px;
    }

    .sidebar {
        width: min(290px, 85vw);
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close,
    .menu-toggle {
        display: inline-flex;
    }

    .main-wrapper {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        gap: 13px;
        padding: 14px 20px;
    }

    .topbar-title h1 {
        font-size: 1.2rem;
    }

    .topbar-title p {
        font-size: 0.78rem;
    }

    .page-content {
        padding: 20px;
    }
}

@media (max-width: 760px) {
    .table-responsive {
        display: none;
    }

    .students-mobile-list {
        display: grid;
        width: 100%;
        gap: 12px;
    }

    .filters {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .search-box,
    .filters select {
        width: 100%;
        min-width: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
    }

    .content-card {
        padding: 16px;
        border-radius: 12px;
    }

    .section-heading {
        margin-bottom: 16px;
    }

    .edit-modal {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .topbar {
        gap: 10px;
        padding: 12px 14px;
    }

    .topbar-title h1 {
        font-size: 1.05rem;
    }

    .topbar-title p,
    .topbar > .btn span {
        display: none;
    }

    .topbar > .btn {
        min-height: 39px;
        padding: 9px 11px;
    }

    .page-content,
    .content-card {
        padding: 14px;
    }

    .form-grid,
    .edit-form-grid {
        grid-template-columns: 1fr;
    }

    .edit-modal {
        padding: 17px;
        border-radius: 12px;
    }

    .result-summary,
    .result-edit-fields {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .result-subject-columns,
    .result-subject-item {
        grid-template-columns: minmax(0, 1fr) minmax(112px, 145px);
        gap: 8px;
    }

    .edit-modal-header h2 {
        font-size: 1.08rem;
    }

    .edit-modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .edit-modal-actions .btn,
    .edit-modal-actions .btn-secondary {
        width: 100%;
    }

    .login-card {
        padding: 24px 19px;
    }
}


/* =========================================================
   8. REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Student table action column */
.data-table.students-table {
    table-layout: fixed;
}

.data-table.students-table th:nth-child(1),
.data-table.students-table td:nth-child(1) { width: 23%; }
.data-table.students-table th:nth-child(2),
.data-table.students-table td:nth-child(2) { width: 23%; }
.data-table.students-table th:nth-child(3),
.data-table.students-table td:nth-child(3) { width: 21%; }
.data-table.students-table th:nth-child(4),
.data-table.students-table td:nth-child(4) { width: 14%; }
.data-table.students-table th:last-child,
.data-table.students-table td:last-child {
    width: 19%;
    text-align: center;
    white-space: nowrap;
}

.student-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.student-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 78px;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 0.78rem;
    line-height: 1.15;
    white-space: nowrap;
}

.student-actions .btn i {
    font-size: 0.9rem;
}

.student-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.student-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.student-card-header p {
    margin: 0;
    color: var(--dark);
    font-size: 0.96rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.student-card-header span,
.student-card-label {
    color: var(--muted);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.student-card-row {
    margin-top: 7px;
}

.student-card .student-actions {
    justify-content: flex-start;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .data-table.students-table th,
    .data-table.students-table td {
        padding-inline: 10px;
    }
}

@media (max-width: 760px) {
    .student-actions {
        justify-content: flex-start;
    }

    .student-actions .btn {
        flex: 1 1 110px;
    }
}
