/* Giao Ly Diem Danh - Main Stylesheet */
:root {
    --primary: #1e5aa8;
    --primary-dark: #164680;
    --primary-light: #e8f0fa;
    --accent: #f5d76e;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --text: #2c3e50;
    --text-muted: #6c757d;
    --bg: #f4f7fb;
    --white: #ffffff;
    --border: #dee2e6;
    --sidebar-width: 260px;
    --shadow: 0 2px 8px rgba(0,0,0,.08);
    --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 50%, #fff 100%);
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
}

.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-logo { width: 80px; height: 80px; margin-bottom: 1rem; }
.login-header h1 { font-size: 1.25rem; color: var(--primary); margin-bottom: .25rem; }
.login-subtitle { color: var(--text-muted); font-size: .9rem; }
.login-version { margin-top: .35rem; }

.login-form .form-group { margin-bottom: 1rem; }
.login-form label { display: block; margin-bottom: .35rem; font-weight: 500; font-size: .9rem; }
.login-form input {
    width: 100%;
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,90,168,.15); }

/* Layout */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--primary);
    color: var(--white);
    z-index: 100;
    overflow-y: auto;
    transition: transform .3s;
}

.sidebar-header { padding: 1.25rem; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar-header .logo { width: 48px; height: 48px; margin-bottom: .75rem; }
.sidebar-user strong { display: block; font-size: .95rem; }
.role-badge {
    display: inline-block;
    background: rgba(255,255,255,.2);
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .75rem;
    margin-top: .25rem;
}

.sidebar-nav { padding: .75rem 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .7rem 1.25rem;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .9rem;
    transition: background .2s;
}
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,.15);
    color: var(--white);
    text-decoration: none;
}
.icon { display: block; width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.nav-icon { display: flex; align-items: center; justify-content: center; width: 1.5rem; flex-shrink: 0; }
.nav-label { flex: 1; }
.notification-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #ff4d5e; border: 2px solid var(--primary); flex-shrink: 0; }

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    padding: .25rem;
    border-radius: 6px;
}
.menu-toggle .icon { width: 1.5rem; height: 1.5rem; }

.page-title { font-size: 1.15rem; flex: 1; color: var(--primary); }
.logo-sm { width: 36px; height: 36px; }

.content-area { padding: 1.5rem; }

/* Cards & Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }

.stat-label { font-size: .85rem; color: var(--text-muted); margin-bottom: .35rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.card-title { font-size: 1.05rem; font-weight: 600; color: var(--primary); }

/* Announcements */
.announcement-list { display: grid; gap: 1rem; }
.announcement-item { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 1rem 1.15rem; background: linear-gradient(180deg, #fff 0%, #f8fbff 100%); }
.announcement-title { color: var(--primary-dark); font-size: 1rem; margin-bottom: .35rem; }
.announcement-meta { color: var(--text-muted); font-size: 1rem; margin-bottom: .75rem; }
.announcement-content { font-size: 1rem; white-space: pre-line; overflow-wrap: anywhere; }
.import-note { max-width: 100%; overflow-wrap: anywhere; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .35rem; font-weight: 500; font-size: .9rem; }
.form-control {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    text-align: center;
}
input[type="date"].form-control,
input[type="datetime-local"].form-control {
    display: block;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; min-width: 0; max-width: 100%; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 1rem; }
.form-row > .form-group { min-width: 0; }
.form-inline { display: flex; min-width: 0; max-width: 100%; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.form-inline > .btn { margin-bottom: 1rem; }
.form-inline > .form-group { min-width: 0; }
.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
    align-items: end;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    margin-bottom: .75rem;
}
.filter-form > .form-group { width: 100%; min-width: 0; margin-bottom: 0; }
.filter-form > .form-control { grid-column: 1 / -1; }
.filter-form > .btn { grid-column: 1 / -1; justify-self: start; width: auto; max-width: 100%; margin: 0; }
.date-filter-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-start; gap: .75rem; }
.filter-form > .date-filter-actions { grid-column: 1 / -1; width: 100%; }
.date-filter-actions > .btn { flex: 0 1 auto; width: auto; max-width: 100%; margin-bottom: 0; }

select.form-control { cursor: pointer; text-align-last: center; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .1s;
    min-height: 2.25rem;
    min-width: 5.5rem;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--text); }
.btn-secondary { background: #6c757d; color: var(--white); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-sm { min-width: 4.5rem; min-height: 2rem; padding: .35rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; }

.btn-group { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.btn-group form { display: inline-flex !important; margin: 0; }
.student-list-downloads { margin: -.35rem 0 1rem; padding: .85rem; border: 1px solid var(--border); border-radius: var(--radius); background: #f8fbff; }
.student-list-downloads[hidden] { display: none; }
.student-list-downloads p { margin-bottom: .65rem; }
.student-list-download-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.student-edit-permission { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; line-height: 1; cursor: help; }
.student-edit-permission .icon { width: 1rem; height: 1rem; }
.student-edit-permission.is-granted { color: #eab308; }
.student-edit-permission.is-denied { color: #cbd5e1; }
.assigned-classes { width: 14rem; max-width: 14rem; }
.assigned-classes span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Study tracking */
.study-tabs {
    display: flex;
    gap: .35rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}
.study-tab {
    display: inline-flex;
    align-items: center;
    padding: .75rem 1.1rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.study-tab:hover { color: var(--primary); text-decoration: none; }
.study-tab.active { color: var(--primary); border-color: var(--primary); }
.study-class-card { padding: 1rem; }
.study-class-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
}
.study-class-picker label { font-weight: 600; }
.study-class-picker .form-control { width: auto; min-width: min(18rem, 100%); }
.study-range-form .form-group { min-width: 8rem; }
.study-list-header { align-items: flex-start; gap: 1rem; }
.study-list-header .text-muted { margin-top: .25rem; }
.study-report-downloads {
    margin: -.35rem 0 1rem;
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fbff;
}
.study-report-downloads[hidden] { display: none; }
.study-report-downloads p { margin-bottom: .65rem; }
.study-report-download-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.study-not-configured { padding: .75rem; margin-bottom: 1rem; background: #fff8e1; border-radius: 6px; }
.study-table td { vertical-align: middle; }
.study-search-form { margin-top: .75rem; }
.study-coming-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 55vh;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
}
.forms-card { padding: 1rem 1.25rem 1.25rem; }
.forms-tabs {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 2px solid var(--border);
    margin: -.25rem 0 1.25rem;
}
.forms-tab {
    flex: 0 0 auto;
    padding: .75rem .9rem;
    border: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.forms-tab:hover, .forms-tab.active { color: var(--primary); }
.forms-tab.active { border-bottom-color: var(--primary); }
.forms-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.forms-panel[hidden] { display: none; }
.forms-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.forms-panel-heading .text-muted { margin-top: .3rem; }
.assignment-computer .card-title, .assignment-computer .assignment-note label { color: #2864a5; }
.assignment-computer .forms-panel-heading > .btn { background: #2864a5; }
.assignment-computer .assignment-table thead { background: #e8f1fb; }
.assignment-mountain-prayer .card-title, .assignment-mountain-prayer .assignment-note label { color: #7047a3; }
.assignment-mountain-prayer .forms-panel-heading > .btn { background: #7047a3; }
.assignment-mountain-prayer .assignment-table thead { background: #f0eafb; }
.assignment-management .card-title, .assignment-management .assignment-note label { color: #21805a; }
.assignment-management .forms-panel-heading > .btn { background: #21805a; }
.assignment-management .assignment-table thead { background: #e8f5ee; }
.assignment-sunday-liturgy .card-title, .assignment-sunday-liturgy .assignment-note label { color: #bd641f; }
.assignment-sunday-liturgy .forms-panel-heading > .btn { background: #bd641f; }
.assignment-sunday-liturgy .assignment-table thead { background: #fff1e5; }
.form-info-preview {
    display: grid;
    gap: .55rem;
    padding: 1.25rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: #fbfcfe;
}
.form-info-preview strong { color: var(--primary); font-size: 1.05rem; }
.form-info-preview small { color: var(--text-muted); }
.assignment-table { width: 100%; }
.assignment-table th, .assignment-table td { vertical-align: middle; }
.assignment-table tbody th { min-width: 13rem; white-space: normal; }
.assignment-table input { text-align: left; }
.assignment-note { margin: 1rem 0 .5rem; }
.assignment-note textarea { text-align: left; resize: vertical; }
.assignment-status { min-height: 1.25rem; }
.assignment-status.is-error { color: var(--danger); }
.assignment-status.is-saved { color: var(--success); }
.study-record-modal .form-group { margin: 1rem 0; }
.study-completion-list { display: grid; gap: .5rem; }
.study-completion-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .65rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f8fbff;
}
.study-completion-row > span { min-width: 0; }
.study-score-table { width: 100%; min-width: 68rem; table-layout: fixed; }
.study-score-table .study-score-col-number { width: 4%; }
.study-score-table .study-score-col-name { width: 28%; }
.study-score-table .study-score-col-grade { width: 9%; }
.study-score-table .study-score-col-average { width: 18%; }
.study-score-table .study-score-col-action { width: 14%; }
.study-score-table th,
.study-score-table td {
    text-align: center;
    vertical-align: middle;
}
.study-score-table td.student-name {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}
.study-score-inputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .25rem 1rem;
}
.study-score-inputs .form-group { margin: .5rem 0; }
.study-score-input:disabled { background: #eef1f4; color: var(--text-muted); cursor: not-allowed; }
.study-scores-modal { max-width: 760px; }

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: .25rem;
    width: 100%;
    margin-top: 1rem;
}
.pagination .btn-sm {
    flex: 1 1 0;
    min-width: 0;
    max-width: 3rem;
    padding: .35rem .2rem;
}
.pagination-current {
    color: var(--text-muted, #6b7280);
    font-size: .9rem;
}
table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    table-layout: auto;
}
thead { background: var(--primary-light); }
th, td {
    padding: .65rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}
th {
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}
.table-toolbar {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .65rem;
}
.table-search-label { font-size: .85rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.table-search { flex: 1 1 18rem; max-width: 22rem; text-align: left; }
.table-toolbar > .btn { flex: 0 0 auto; }
.table-no-results[hidden], tbody tr[hidden] { display: none; }
.student-name { min-width: 10rem; }
.parent-name { min-width: 12rem; }
tr:hover { background: #fafbfc; }

.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: var(--primary-light); color: var(--primary); }

.top-list {
    display: grid;
    gap: .85rem;
}
.top-list-scroll {
    max-height: 51rem;
    overflow-y: auto;
    padding: 0 .35rem .25rem 0;
}
.top-list-item {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 2px 8px rgba(14, 30, 53, .06);
}
.top-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    font-size: .85rem;
    font-weight: 700;
    flex-shrink: 0;
}
.top-info {
    flex: 1;
    min-width: 0;
}
.top-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    overflow-wrap: anywhere;
}
.top-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .2rem;
    color: var(--text-muted);
    font-size: .8rem;
}
.top-meta span {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.top-absent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .4rem .7rem;
    border-radius: 999px;
    background: #fff3cd;
    color: #856404;
    font-size: .8rem;
    font-weight: 700;
    border: 1px solid #f8d77d;
    white-space: nowrap;
}
.absent-student-item {
    display: grid;
    grid-template-columns: 2.4rem minmax(0, 1fr);
    grid-template-areas: "rank info" "rank actions";
    align-items: center;
    column-gap: .85rem;
    row-gap: .45rem;
}
.absent-student-item .top-rank { grid-area: rank; }
.absent-student-item .top-info { grid-area: info; width: 100%; }
.absent-student-item .top-name {
    max-width: 100%;
    overflow-x: auto;
    overflow-wrap: normal;
    white-space: nowrap;
}
.absent-student-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
}

/* Flash messages */
.flash-container { margin-bottom: 1rem; }
.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: .5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.flash-info { background: var(--primary-light); color: var(--primary); border: 1px solid #b8d4f0; }
.flash-icon { display: inline-flex; flex: 0 0 auto; }
.flash-icon .icon { width: 1.15rem; height: 1.15rem; }
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1200;
    width: min(420px, calc(100vw - 2rem));
    margin: 0;
    pointer-events: none;
}
.toast-container .flash {
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
    pointer-events: auto;
}

/* Filter bar */
.filter-bar {
    background: var(--white);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

/* Scanner */
.scanner-page { max-width: 600px; margin: 0 auto; }
.special-manual-attendance { margin-top: 2rem; }
.scanner-container {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
    max-height: 400px;
}
#qr-reader {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
#qr-reader video {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}
.scanner-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.scanner-frame {
    width: 70%;
    height: 70%;
    border: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.4);
}
.scanner-guide {
    text-align: center;
    margin: 1rem 0;
    color: var(--text-muted);
}

.scan-result {
    text-align: center;
    padding: 2rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}
.scan-result.success { background: #d4edda; border: 2px solid var(--success); }
.scan-result.warning { background: #fff3cd; border: 2px solid var(--warning); }
.scan-result.error { background: #f8d7da; border: 2px solid var(--danger); }
.scan-result-icon { display: flex; justify-content: center; margin-bottom: .75rem; }
.scan-result-icon .icon { width: 3rem; height: 3rem; }
.scan-result h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.scan-result p { margin: .25rem 0; }

.scanner-status {
    text-align: center;
    padding: .5rem;
    font-weight: 600;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.scanner-status.ready { background: var(--primary-light); color: var(--primary); }
.scanner-status.scanning { background: #fff3cd; color: #856404; }

/* QR display */
.qr-print-area { display: flex; flex-direction: column; align-items: flex-start; }
.qr-card {
    width: 85.6mm;
    height: 53.98mm;
    padding: 4mm;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 36mm auto;
    gap: 1mm;
    align-content: center;
    justify-items: center;
    background: var(--white);
    border: 1px solid var(--border);
    overflow: hidden;
}
.qr-canvas-wrap {
    width: 36mm;
    height: 36mm;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
}
.qr-canvas-wrap #qrcode,
.qr-canvas-wrap canvas,
.qr-canvas-wrap img { display: block; width: 36mm !important; height: 36mm !important; }
.qr-info {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: center;
    font-size: .7rem;
    line-height: 1.2;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    display: flex;
}
.modal-backdrop.hidden { display: none; }
.modal {
    background: var(--white);
    border: 1px solid #c9d7e8;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    max-width: 620px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 32px rgba(15, 36, 64, .24);
    color: var(--text);
}
.modal-dialog {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}
.modal-content form { display: block; }
.modal-title { font-size: 1.1rem; margin-bottom: 1rem; color: var(--primary); }
.modal-student-name { font-weight: 600; color: var(--primary); }
.student-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem 1rem;
    padding-top: .25rem;
}
.student-details p {
    padding: .75rem;
    border: 1px solid #d8e2ee;
    border-radius: 6px;
    background: #f7faff;
    color: var(--text);
}
.student-details p:last-child { border-bottom: none; }
.student-details strong { display: block; margin-bottom: .2rem; color: var(--primary-dark); font-size: .82rem; }
.student-details span { display: block; color: #172b42; font-weight: 600; overflow-wrap: anywhere; }
.justify-end { justify-content: flex-end; }

@media (max-width: 600px) {
    .modal { padding: 1rem; }
    .student-details { grid-template-columns: 1fr; }
    .study-tabs { overflow-x: auto; }
    .study-tab { padding: .65rem .75rem; white-space: nowrap; }
    .study-list-header { flex-direction: column; }
    .study-class-picker { align-items: stretch; flex-direction: column; }
    .study-class-picker .form-control { width: 100%; }
    .study-completion-row { align-items: flex-start; }
    .study-score-inputs { grid-template-columns: 1fr; }
}

/* Print */
@media print {
    @page { size: 85.6mm 53.98mm; margin: 0; }
    html, body {
        width: 85.6mm;
        height: 53.98mm;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden;
        background: var(--white);
    }
    body * { visibility: hidden !important; }
    #qrPrintArea, #qrPrintArea * { visibility: visible !important; }
    #qrPrintArea {
        position: fixed;
        left: 0;
        top: 0;
        width: 85.6mm;
        height: 53.98mm;
        border: none;
        box-shadow: none;
        page-break-after: avoid;
        break-after: avoid-page;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content-area { padding: 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .table-toolbar { align-items: center; flex-direction: row; gap: .5rem; }
    .table-search-label { font-size: .8rem; }
    .table-search { flex: 1 1 0; width: 0; max-width: none; padding: .45rem .6rem; font-size: .9rem; }
    .table-toolbar > .btn { min-width: 0; padding: .4rem .6rem; }
    .date-filter-form > .form-group { flex-basis: 100%; }
    .date-filter-actions { flex: 1 1 100%; }
    .forms-panel-heading { align-items: flex-start; flex-direction: column; }
    .forms-panel-heading > .btn { width: 100%; }
    .forms-card { padding: .85rem; }
    .forms-tab { padding: .65rem .75rem; font-size: .85rem; }
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.text-muted { color: var(--text-muted); font-size: .85rem; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
