:root {
    --red: #d62828;
    --red-d: #b81f2b;
    --red-s: #fde8e8;
    --red-l: #fff5f5;
    --orange: #f77f00;
    --ink: #2f2f2f;
    --gray: #6c757d;
    --border: #e1e1e1;
    --bg: #f4f5f7;
    --white: #fff;
    --green: #28a745;
    --blue: #1976d2;
    --shadow: 0 2px 12px rgba(0, 0, 0, .09);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, .12);
    --r: 8px;
    --rl: 12px;
    --sw: 240px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: 'Sora', sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR — LANHS integrated styles (single source of truth) */
.sidebar {
    width: var(--sw);
    background: linear-gradient(180deg, #fffafb 0%, #faf7f8 100%);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    flex-shrink: 0;
    border-right: 1px solid #ece7ec;
    color: #292a40;
}

.sb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 15px 16px;
    border-bottom: 1px solid #eee8ed;
    flex-shrink: 0;
}

.sb-logo { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sb-logo-icon { width: 46px; height: 46px; display: grid; place-items: center; flex-shrink: 0; background: transparent; overflow: visible; border: 0; border-radius: 0; }
.sb-logo-icon img { width: 100%; height: 100%; object-fit: contain; filter: none; }
.sb-logo-title { display: block; color: #b20824; font-size: 13px; font-weight: 750; line-height: 1.3; letter-spacing: -.3px; }
.sb-logo-sub { display: block; margin-top: 4px; color: #7c859a; font-size: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }

.sb-nav {
    flex: 1;
    min-height: 0;
    padding: 12px 12px 16px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #dcd3dc transparent;
}
.sb-section-label { padding: 0 11px; margin: 16px 0 7px; color: #8890a3; font-size: 8px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; line-height: 1.6; }
.sb-section-label:first-child { margin-top: 5px; }
.sb-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 40px;
    padding: 10px 11px;
    margin-bottom: 3px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: #292a40;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}
.sb-item:hover { background: #f8eaf0; color: #ad1234; }
.sb-item.active { background: linear-gradient(105deg, #c20826 0%, #ad0621 100%); border-color: #b70824; color: #fff; box-shadow: 0 3px 7px #b2082415; font-weight: 600; }
.sb-item.active:hover { background: #ab0621; color: #fff; }
.sb-item-icon { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; fill: none; opacity: 1; }
.sb-item.active .sb-item-icon { opacity: 1; }

.sb-footer { padding: 12px; border-top: 1px solid #eee7ec; flex-shrink: 0; }
.sb-user { display: flex; align-items: center; gap: 9px; padding: 10px; border: 1px solid #eee5eb; border-radius: 9px; background: #ffffffa6; }
.sb-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-info strong { display: block; color: #2f2b3d; font-size: 10px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-info span { display: block; margin-top: 3px; color: #8a8395; font-size: 9px; text-transform: capitalize; }
.sb-logout { display: flex; align-items: center; justify-content: center; color: #777388; padding: 7px; border-radius: 7px; text-decoration: none; transition: background-color .16s ease, color .16s ease; }
.sb-logout .sb-item-icon { width: 17px; height: 17px; }
.sb-logout:hover { color: #b20824; background: #fbe7ed; }
.sb-item:focus-visible, .sb-logout:focus-visible, .sb-logo:focus-visible { outline: 2px solid #b20824; outline-offset: 2px; }

/* MAIN */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--white);
    padding: 13px 22px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
    flex-wrap: wrap;
}

.page-header-left h1 {
    font-size: 17px;
    font-weight: 700;
}

.page-header-left p {
    font-size: 11px;
    color: var(--gray);
    margin-top: 1px;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 7px;
    background: #f0f0f0;
    border-radius: var(--r);
    padding: 7px 12px;
    flex: 1;
    max-width: 340px;
    border: 1.5px solid transparent;
    transition: all .2s;
}

.header-search:focus-within {
    border-color: var(--red);
    background: #fff9f9;
}

.header-search input,
.header-search select {
    background: transparent;
    border: none;
    outline: none;
    font-size: 12px;
    color: var(--ink);
}

.header-search input {
    flex: 1;
}

.header-search button {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
}

.header-badge {
    background: var(--red-s);
    color: var(--red);
    border-radius: 20px;
    padding: 4px 11px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.page-content {
    padding: 22px;
    flex: 1;
}

/* ALERTS */
.alert {
    padding: 11px 16px;
    border-radius: var(--r);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 16px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--green);
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* CARD */
.card {
    background: var(--white);
    border-radius: var(--rl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--red);
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--red-s);
}

/* STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 13px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    padding: 16px;
    border-radius: var(--rl);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--red);
}

.stat-label {
    font-size: 10px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 4px;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--red);
    line-height: 1;
}

.stat-sub {
    font-size: 10px;
    color: var(--gray);
    margin-top: 3px;
}

/* BOOKS GRID */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.book-card {
    background: var(--white);
    border-radius: var(--rl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all .22s;
}

.book-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--red);
}

.book-cover {
    height: 145px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.book-cover-badge {
    position: absolute;
    top: 7px;
    right: 7px;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.book-pdf-tag {
    position: absolute;
    bottom: 7px;
    right: 7px;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.book-body {
    padding: 12px;
}

.book-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 3px;
    line-height: 1.3;
}

.book-author {
    font-size: 10px;
    color: var(--gray);
}

.book-actions {
    display: flex;
    gap: 5px;
    margin-top: 9px;
}

.btn-read {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 5px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-read:hover {
    background: var(--red-d);
}

.btn-fav {
    padding: 6px 8px;
    border: none;
    border-radius: 5px;
    background: var(--red-s);
    color: var(--red);
    font-size: 13px;
    cursor: pointer;
}

.btn-fav.saved {
    background: #d4edda;
    color: #155724;
}

/* FORMS */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
    margin-bottom: 12px;
}

.form-grid.c1 {
    grid-template-columns: 1fr;
}

.form-grid.c3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    font-size: 12px;
    transition: border .2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(214, 40, 40, .08);
}

.form-group textarea {
    resize: vertical;
    min-height: 75px;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 9px 18px;
    border-radius: var(--r);
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .18s;
}

.btn-primary {
    background: var(--red);
    color: #fff;
}

.btn-primary:hover {
    background: var(--red-d);
}

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-success:hover {
    background: #1e7e34;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #bd2130;
}

.btn-warning {
    background: #fd7e14;
    color: #fff;
}

.btn-warning:hover {
    background: #e66800;
}

.btn-secondary {
    background: #f0f0f0;
    color: var(--ink);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e4e4e4;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 10px;
}

/* TABLE */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

table th {
    background: #f8f9fa;
    font-size: 10px;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 10px 13px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

table td {
    padding: 10px 13px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    vertical-align: middle;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover td {
    background: #fef9f9;
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
}

.badge-admin {
    background: #ffe5e5;
    color: var(--red);
}

.badge-teacher {
    background: #fff3e0;
    color: #e65100;
}

.badge-student {
    background: #e8f5e9;
    color: #1b5e20;
}

.badge-approved,
.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-pending {
    background: #fff3e0;
    color: #8a5a00;
}

.badge-rejected {
    background: #ffebee;
    color: #b71c1c;
}

.badge-deactivated {
    background: #f0f0f0;
    color: #888;
}

/* TABS */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 18px;
}

.tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
}

.tab:hover {
    color: var(--red);
}

.tab.active {
    color: var(--red);
    border-bottom-color: var(--red);
}

.tab-count {
    background: var(--red-s);
    color: var(--red);
    border-radius: 20px;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
}

/* ANN/NOTES */
.ann-card {
    background: var(--white);
    border-radius: var(--rl);
    border-left: 5px solid var(--red);
    padding: 14px 17px;
    margin-bottom: 11px;
    box-shadow: var(--shadow);
}

.ann-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    color: var(--gray);
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.ann-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 5px;
}

.ann-body {
    font-size: 12px;
    color: #555;
    line-height: 1.65;
}

.note-card {
    background: var(--white);
    border-radius: var(--rl);
    border-left: 5px solid var(--orange);
    padding: 14px 17px;
    margin-bottom: 11px;
    box-shadow: var(--shadow);
}

/* NOTEPAD */
.notepad-wrap {
    background: var(--white);
    border-radius: var(--rl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.notepad-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.notepad-toolbar button {
    background: #f0f0f0;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    transition: all .18s;
}

.notepad-toolbar button:hover {
    background: var(--red-s);
    border-color: var(--red);
    color: var(--red);
}

.np-status {
    margin-left: auto;
    font-size: 10px;
    color: var(--gray);
}

.notepad-wrap textarea {
    width: 100%;
    border: none;
    outline: none;
    padding: 20px;
    font-size: 14px;
    line-height: 1.9;
    min-height: 340px;
    resize: none;
    background: transparent;
}

/* ACTIVITY */
.activity-item {
    display: flex;
    align-items: start;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
    background: var(--red);
}

.activity-text {
    flex: 1;
    font-size: 12px;
    color: var(--ink);
    line-height: 1.4;
}

.activity-time {
    font-size: 10px;
    color: var(--gray);
    white-space: nowrap;
}

/* CHART containers */
.chart-box {
    background: var(--white);
    border-radius: var(--rl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.chart-box h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 14px;
}

/* UPLOAD ZONES */
.upz {
    border: 2px dashed var(--border);
    border-radius: var(--rl);
    background: #fafafa;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    min-height: 120px;
    display: flex;
    align-items: stretch;
    transition: border-color .2s;
}

.upz:hover,
.upz:focus-within {
    border-color: var(--red);
    background: var(--red-l);
}

.upz input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.upz-idle {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    text-align: center;
    pointer-events: none;
}

.upz-idle svg {
    width: 28px;
    height: 28px;
    stroke: #bbb;
}

.upz-idle strong {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
}

.upz-idle span {
    font-size: 10px;
    color: #aaa;
}

.clr-btn {
    pointer-events: auto;
    background: #fee2e2;
    border: none;
    border-radius: 5px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 600;
    color: #dc3545;
    cursor: pointer;
}

/* Book row */
.bk-row {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.bk-row:last-child {
    border-bottom: none;
}

.bk-thumb {
    flex-shrink: 0;
}

.bk-info {
    flex: 1;
    min-width: 0;
}

.bk-acts {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.tag {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.tag-ok {
    background: #d4edda;
    color: #155724;
}

.tag-no {
    background: #f0f0f0;
    color: #aaa;
}

.tag-subj {
    background: var(--red-s);
    color: var(--red);
}

/* PROFILE AVATAR */
.pf-avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 700;
}

/* DEACTIVATED banner */
.deactivated-banner {
    background: #f0f0f0;
    border: 2px solid #ccc;
    border-radius: var(--rl);
    padding: 32px;
    text-align: center;
    color: #888;
    margin-bottom: 20px;
}

/* ONLINE dot */
.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, .3);
}

.offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    display: inline-block;
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

@media(max-width:768px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid.c3 {
        grid-template-columns: 1fr;
    }
}

/* ── Reader ──────────────────────────────────────────────────── */
#rd {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a;
    z-index: 99999;
    flex-direction: column;
}

#rd.on {
    display: flex !important;
}

#rd-bar {
    background: #d62828;
    color: #fff;
    min-height: 52px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 8px;
    flex-shrink: 0;
}

#rd-bar h3 {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.rb {
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .3);
    color: #fff;
    border-radius: 7px;
    padding: 7px 13px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: Sora, sans-serif;
    white-space: nowrap;
}

.rb:hover {
    background: rgba(255, 255, 255, .32);
}

.rb.active {
    background: rgba(255, 255, 255, .9);
    color: #d62828;
}

#rd-ttsbar {
    display: none;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, .75);
    padding: 7px 14px;
    flex-shrink: 0;
}

#rd-ttsbar.on {
    display: flex;
}

#rd-ttrack {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, .2);
    border-radius: 3px;
    overflow: hidden;
}

#rd-ttsfill {
    height: 100%;
    width: 0%;
    background: #4ade80;
    border-radius: 3px;
}

#rd-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #525659;
}

.rd-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 28px 16px;
    display: flex;
    justify-content: center;
    background: #525659;
}

#rd-page {
    max-width: 700px;
    width: 100%;
    background: #fff;
    border-radius: 6px;
    padding: 44px 48px;
    font-family: Georgia, serif;
    line-height: 1.85;
    align-self: flex-start;
}

#rd-page h2 {
    font-size: 19px;
    font-weight: 700;
    color: #d62828;
    margin: 20px 0 12px;
    border-bottom: 2px solid #fde8e8;
    padding-bottom: 6px;
}

#rd-page h2:first-child {
    margin-top: 0;
}

#rd-page p {
    margin-bottom: 13px;
    color: #333;
    font-size: 15px;
}

.rd-spin {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, .15);
    border-top-color: #d62828;
    border-radius: 50%;
    animation: rdspin .7s linear infinite;
}

@keyframes rdspin {
    to {
        transform: rotate(360deg);
    }
}

@media print {
    body {
        display: none !important;
    }
}

/* =========================
   MODERN PAGE HEADER
========================= */
.modern-page-header {
    min-height: 86px;
    padding: 20px 26px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid #eeeeee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(14px);
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.modern-page-header .page-header-left h1 {
    margin: 0;
    font-size: 25px;
    line-height: 1.1;
    font-weight: 900;
    color: #171717;
    letter-spacing: -0.5px;
}

.modern-page-header .page-header-left p {
    margin: 7px 0 0;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.modern-page-header .header-badge {
    min-height: 26px;
    padding: 5px 12px;
    border-radius: 999px;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-size: 12px;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modern-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-date-pill,
.header-profile-pill {
    min-height: 46px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #eeeeee;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.045);
    display: flex;
    align-items: center;
}

.header-profile-menu {
    position: relative;
    z-index: 60;
}

.header-profile-menu summary {
    list-style: none;
}

.header-profile-menu summary::-webkit-details-marker {
    display: none;
}

.header-date-pill {
    gap: 9px;
    padding: 0 16px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 600;
}

.header-action-icon {
    width: 17px;
    height: 17px;
    stroke: #4b5563;
}

.header-profile-pill {
    gap: 10px;
    padding: 5px 12px 5px 6px;
    cursor: pointer;
    user-select: none;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.header-profile-pill:hover {
    border-color: #fecaca;
    box-shadow: 0 10px 24px rgba(153, 27, 27, .08);
    transform: translateY(-1px);
}

.header-profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #991b1b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
}

.header-profile-info {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.header-profile-info strong {
    font-size: 13px;
    font-weight: 800;
    color: #222;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-profile-info span {
    margin-top: 3px;
    font-size: 10px;
    color: #8b8b8b;
    font-weight: 700;
}

.header-chevron-icon {
    width: 16px;
    height: 16px;
    stroke: #6b7280;
    transition: transform .18s ease;
}

.header-profile-menu[open] .header-chevron-icon {
    transform: rotate(180deg);
}

.header-profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    padding: 8px;
    border: 1px solid #eeeeee;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, .14);
    z-index: 80;
}

.header-profile-dropdown::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    border-left: 1px solid #eeeeee;
    border-top: 1px solid #eeeeee;
    background: #ffffff;
    transform: rotate(45deg);
}

.header-profile-dropdown a {
    position: relative;
    z-index: 1;
    min-height: 40px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    color: #374151;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: background .18s ease, color .18s ease;
}

.header-profile-dropdown a:hover {
    background: #fff1f1;
    color: #991b1b;
}

.header-profile-dropdown a.danger {
    color: #b91c1c;
}

.header-dropdown-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* SEARCH HEADER COMPATIBILITY */
.modern-page-header .header-search {
    flex: 1;
    max-width: 520px;
    min-height: 46px;
    padding: 5px 6px 5px 14px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #eeeeee;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.045);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modern-page-header .header-search span svg,
.modern-page-header .header-search .sb-item-icon {
    width: 17px;
    height: 17px;
    stroke: #9ca3af;
    flex-shrink: 0;
}

.modern-page-header .header-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: #222;
}

.modern-page-header .header-search select {
    border: none;
    outline: none;
    background: #f7f7f7;
    border-radius: 999px;
    padding: 9px 11px;
    font-family: inherit;
    font-size: 12px;
    color: #444;
}

.modern-page-header .header-search button {
    border: none;
    outline: none;
    border-radius: 999px;
    padding: 9px 15px;
    background: #dc2626;
    color: #ffffff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

/* RESPONSIVE HEADER */
@media (max-width: 1100px) {
    .modern-page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .modern-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .modern-page-header .header-search {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 650px) {
    .modern-page-header {
        padding: 18px;
    }

    .modern-page-header .page-header-left h1 {
        font-size: 22px;
    }

    .modern-header-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .header-date-pill,
    .header-profile-pill {
        width: 100%;
        justify-content: center;
    }

    .modern-page-header .header-search {
        align-items: stretch;
        flex-direction: column;
        border-radius: 18px;
        padding: 12px;
    }

    .modern-page-header .header-search input,
    .modern-page-header .header-search select,
    .modern-page-header .header-search button {
        width: 100%;
    }
}


/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — APP LAYOUT  (added for phone support)
═══════════════════════════════════════════════════════════════ */

/* ── Sidebar overlay (mobile drawer backdrop) ── */
.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, .52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.sb-overlay.on {
    display: block;
}

/* ── Close button inside sidebar (mobile only) ── */
.sb-mob-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #e8dce3;
    border-radius: 7px;
    background: #fff;
    color: #777084;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .18s;
}

.sb-mob-close svg {
    width: 18px;
    height: 18px;
}

.sb-mob-close:hover {
    color: #b20824;
    background: #fbe7ed;
}

/* ── Mobile top bar ── */
.mob-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    background: #2b1116;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    gap: 10px;
    flex-shrink: 0;
    box-shadow: 0 2px 14px rgba(0, 0, 0, .2);
}

.mob-ham {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--r);
    background: rgba(255, 255, 255, .07);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .18s;
}

.mob-ham:hover {
    background: rgba(255, 255, 255, .14);
}

.mob-ham svg {
    width: 20px;
    height: 20px;
}

.mob-logo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    min-width: 0;
    text-decoration: none;
}

.mob-logo-wrap img {
    width: 30px;
    height: 30px;
}

.mob-logo-wrap span {
    font-size: 13px;
    font-weight: 700;
    color: var(--red);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mob-profile-btn {
    display: flex;
    flex-shrink: 0;
    text-decoration: none;
}

.mob-profile-av {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

/* ── Mobile bottom nav bar ── */
.mob-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    height: 62px;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 18px rgba(0, 0, 0, .07);
    padding: 0 6px;
    align-items: stretch;
    justify-content: space-around;
    /* safe area padding for notch phones */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--gray);
    font-size: 9.5px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    padding: 5px 2px;
    transition: color .18s;
    position: relative;
    min-width: 0;
}

.mbn-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.mbn-item.active,
.mbn-item:hover {
    color: var(--red);
}

.mbn-item.active svg {
    stroke-width: 2.5;
}

.mbn-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mbn-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 16px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid #fff;
}

/* ── Active nav indicator dot ── */
.mbn-item.active::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--red);
}

/* ═══════════════════════════════════════════════════════════════
   BREAKPOINT: ≤768px (phones and small tablets)
═══════════════════════════════════════════════════════════════ */
@media(max-width:768px) {

    /* Show mobile UI elements */
    .mob-topbar {
        display: flex;
    }

    .mob-bottom-nav {
        display: flex;
    }

    .sb-mob-close {
        display: flex;
    }

    /* Sidebar becomes a fixed drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 200;
        width: min(80vw, var(--sw));
        transform: translateX(-110%);
        transition: transform .32s cubic-bezier(.22, .61, .36, 1);
        height: 100vh;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 36px rgba(0, 0, 0, .3);
    }

    /* Sidebar header accommodates close button */
    .sb-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* App main area */
    .app-main {
        min-width: 0;
    }

    /* Page content padding reduction */
    .page-content {
        padding: 14px 12px;
        padding-bottom: 76px;
    }

    /* Modern page header — tighter on mobile */
    .modern-page-header {
        padding: 12px 14px;
        min-height: unset;
        gap: 10px;
    }

    .modern-page-header .page-header-left h1 {
        font-size: 18px;
    }

    .modern-page-header .page-header-left p {
        font-size: 11px;
        margin-top: 3px;
    }

    .modern-header-actions {
        gap: 8px;
    }

    .header-date-pill,
    .header-profile-pill {
        min-height: 38px;
    }

    .header-date-pill {
        padding: 0 12px;
        font-size: 12px;
    }

    .header-profile-info strong {
        font-size: 12px;
        max-width: 90px;
    }

    /* Stats grid — 2 columns on phone */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 14px;
    }

    .stat-number {
        font-size: 20px;
    }

    /* Books grid — 2 cols min on phone */
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    /* Table horizontal scrolling */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 540px;
    }

    table th,
    table td {
        padding: 8px 10px;
        font-size: 11px;
    }

    /* Tab bar horizontal scroll */
    .tab-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .tab-bar::-webkit-scrollbar {
        display: none;
    }

    .tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 12px;
    }

    /* Cards */
    .card {
        padding: 14px;
    }

    .card-title {
        font-size: 13px;
    }

    /* Forms */
    .form-grid.c3,
    .form-grid {
        grid-template-columns: 1fr;
    }

    /* Announcement / note cards */
    .ann-card,
    .note-card {
        padding: 12px 14px;
    }

    .ann-title {
        font-size: 13px;
    }

    .ann-body {
        font-size: 11px;
    }

    /* Book row */
    .bk-acts {
        flex-wrap: wrap;
    }

    .bk-row {
        gap: 10px;
    }

    /* Notepad */
    .notepad-wrap textarea {
        min-height: 220px;
        font-size: 13px;
    }

    .notepad-toolbar {
        gap: 4px;
    }

    .notepad-toolbar button {
        padding: 4px 8px;
        font-size: 10px;
    }

    /* Chart box */
    .chart-box {
        padding: 13px;
    }

    .chart-box h4 {
        font-size: 12px;
    }

    /* Toast above bottom nav */
    #app-toast {
        bottom: 76px !important;
    }

    /* Reader — mobile-optimized ── */
    #rd-bar {
        flex-wrap: wrap;
        row-gap: 6px;
        padding: 8px 10px;
    }

    #rd-bar h3 {
        font-size: 12px;
        order: -1;
        width: 100%;
        white-space: normal;
        line-height: 1.3;
    }

    .rb {
        padding: 5px 9px;
        font-size: 11px;
    }

    #rd-page {
        padding: 20px 16px;
        max-width: 100%;
    }

    #rd-page p {
        font-size: 14px;
    }

    /* SweetAlert above bottom nav */
    .swal2-container {
        z-index: 99998 !important;
    }

    .swal2-popup {
        font-size: 13px !important;
    }

    /* Profile dropdown stays visible on mobile */
    .header-profile-dropdown {
        right: -10px;
        width: 200px;
    }

    /* Alert margin */
    .alert {
        margin-bottom: 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   BREAKPOINT: ≤480px (small phones)
═══════════════════════════════════════════════════════════════ */
@media(max-width:480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .books-grid {
        grid-template-columns: 1fr 1fr;
    }

    .modern-page-header .page-header-left h1 {
        font-size: 16px;
    }

    .page-content {
        padding: 10px;
        padding-bottom: 76px;
    }

    .stat-number {
        font-size: 18px;
    }

    .card {
        padding: 12px;
    }

    .page-header {
        flex-wrap: wrap;
        padding: 10px 14px;
    }

    /* Hide date pill on very small screens */
    .header-date-pill {
        display: none;
    }
}

/* ── Page header hamburger (desktop: hidden, mobile: shown) ── */
.mph-ham {
    display: none;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: #f7f7f7;
    color: var(--ink);
    cursor: pointer;
    transition: background .18s;
}

.mph-ham svg {
    width: 18px;
    height: 18px;
}

.mph-ham:hover {
    background: var(--red-s);
    border-color: var(--red);
    color: var(--red);
}

@media(max-width:768px) {
    .mph-ham {
        display: flex;
    }

    /* hide the sticky page header bar on mobile since we have mob-topbar */
    .modern-page-header {
        position: static;
        top: unset;
    }

    /* bottom nav as button (not anchor) resets */
    .mob-bottom-nav button.mbn-item {
        border: none;
        background: transparent;
        font-family: inherit;
        font-size: 9.5px;
        font-weight: 600;
        cursor: pointer;
        color: var(--gray);
    }

    .mob-bottom-nav button.mbn-item:hover {
        color: var(--red);
    }
}

/* LANHS eLibrary — final shared desktop header (no desktop hamburger or duplicate profile) */
.modern-page-header {
    min-height: 80px;
    padding: 16px 25px;
    background: #fff;
    border-bottom: 1px solid #e9e7e8;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 9px rgba(40, 16, 20, .025);
    backdrop-filter: none
}

.modern-page-header .page-header-left {
    flex: 0 1 auto;
    min-width: 0
}

.modern-page-header .page-header-left h1 {
    font-size: 23px;
    letter-spacing: -.6px;
    font-weight: 800;
    color: #242124
}

.modern-page-header .page-header-left p {
    font-size: 12px;
    color: #818087;
    margin-top: 5px
}

.modern-page-header .modern-header-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    width: auto;
    min-width: 0;
    flex: 1
}

.modern-page-header .header-global-search {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(315px, 100%);
    height: 40px;
    padding: 0 14px;
    background: #f6f5f6;
    border: 1px solid #efebed;
    border-radius: 10px;
    color: #a21c30;
    flex-shrink: 1;
    min-width: 120px
}

.modern-page-header .header-global-search:focus-within {
    border-color: #c88490;
    background: #fff
}

.modern-page-header .header-global-search input {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    min-width: 0;
    color: #343037;
    font: inherit;
    font-size: 12px
}

.modern-page-header .header-global-search input::placeholder {
    color: #969097
}

.modern-page-header .header-notifications {
    width: 39px;
    height: 40px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border-radius: 9px;
    color: #373037;
    text-decoration: none;
    font-size: 18px;
    border: 1px solid transparent
}

.modern-page-header .header-notifications:hover {
    background: #f8eff1;
    color: #a21c30
}

.modern-page-header .header-date-pill {
    height: 40px;
    min-height: 40px;
    padding: 0 13px;
    border-radius: 10px;
    border: 1px solid #ebe6e8;
    box-shadow: none;
    background: #fff;
    color: #50464e;
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
    gap: 9px
}

.modern-page-header .header-date-pill i {
    font-size: 15px;
    color: #a21c30
}

.modern-page-header .header-page-search {
    max-width: 380px;
    min-width: 200px;
    box-shadow: none;
    border-radius: 10px;
    min-height: 40px
}

@media(max-width:1100px) {
    .modern-page-header {
        flex-direction: row;
        align-items: center
    }

    .modern-page-header .modern-header-actions {
        width: auto;
        justify-content: flex-end
    }

    .modern-page-header .header-page-search {
        max-width: 280px
    }
}

@media(max-width:900px) {
    .modern-page-header .header-global-search {
        width: 180px
    }

    .modern-page-header .header-date-pill {
        padding: 0 10px
    }
}

@media(max-width:768px) {
    .modern-page-header {
        display: none !important
    }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar, .sb-item, .sb-logout, .sb-mob-close { transition: none; }
}
