@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #166534;
    --secondary: #16a34a;
    --accent: #eab308;
    --success: #15803d;
    --danger: #ef4444;
    --warning: #eab308;
    --light: #f0fdf4;
    --dark: #14532d;
    --gray: #64748b;
    --border: #bbf7d0;
    --sidebar-w: 260px;
    --radius: 10px;
    --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(22,163,74,.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(22,163,74,.45); }
* { scrollbar-width: thin; scrollbar-color: rgba(22,163,74,.25) transparent; }

body {
    font-family: var(--font);
    background: #f0fdf4;
    color: #1e293b;
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
    overflow-x: hidden;
}

img,
svg,
canvas {
    max-width: 100%;
}

/* AUTH PAGES */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #14532d 0%, #166534 50%, #16a34a 100%);
    padding: 1.25rem 1rem;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem 1.25rem;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.auth-logo {
    text-align: center;
    margin-bottom: 1rem;
}

.auth-brand-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    margin-bottom: .4rem;
}
.auth-brand-logos img {
    height: 44px;
    width: auto;
    object-fit: contain;
}
.auth-center-logo {
    height: 56px !important;
    max-width: 110px;
}
.auth-brand-name {
    font-size: .72rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.4;
    margin-bottom: .4rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.auth-brand-name span {
    font-weight: 500;
    color: var(--gray);
    text-transform: none;
    font-size: .68rem;
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.04em;
    font-family: var(--font);
}

.auth-logo span { color: var(--secondary); }
.auth-logo p { color: var(--gray); font-size: 0.72rem; margin-top: 2px; }

/* ── DESKTOP: split layout so everything fits without scroll ── */
@media (min-width: 820px) {
    .auth-wrapper {
        padding: 1.5rem 2rem;
    }
    .auth-card {
        max-width: 860px;
        padding: 0;
        display: grid;
        grid-template-columns: 1fr 1fr;
        overflow: hidden;
        border-radius: 20px;
        box-shadow: 0 24px 80px rgba(0,0,0,.35);
        position: relative;
    }
    /* full-height gradient divider between the two panels */
    .auth-card::after {
        content: '';
        position: absolute;
        top: 0; bottom: 0;
        left: 50%;
        width: 3px;
        transform: translateX(-50%);
        background: linear-gradient(180deg,
            transparent 0%,
            #166534 8%,
            #16a34a 30%,
            #eab308 55%,
            #16a34a 78%,
            #166534 92%,
            transparent 100%);
        z-index: 5;
        pointer-events: none;
    }
    /* left panel — tech gradient, no oval, no ::after divider (moved to card) */
    .auth-logo {
        margin: 0;
        padding: 2.75rem 2rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        border-radius: 0;
        position: relative;
        overflow: hidden;
        background:
            radial-gradient(ellipse 80% 60% at 50% 0%,   rgba(22,163,74,.13) 0%, transparent 70%),
            radial-gradient(ellipse 60% 50% at 10% 80%,  rgba(22,101,52,.10) 0%, transparent 65%),
            radial-gradient(ellipse 50% 40% at 90% 90%,  rgba(234,179,8,.08) 0%, transparent 60%),
            #fff;
    }
    /* grid lines on left panel */
    .auth-logo::before {
        content: '';
        position: absolute; inset: 0;
        background-image:
            linear-gradient(rgba(22,163,74,.07) 1px, transparent 1px),
            linear-gradient(90deg, rgba(22,163,74,.07) 1px, transparent 1px);
        background-size: 32px 32px;
        pointer-events: none;
    }
    .auth-logo::after { display: none; }
    /* logos — no oval, just clean row */
    .auth-logo .auth-brand-logos {
        background: none;
        border: none;
        box-shadow: none;
        padding: 0;
        margin-bottom: 1rem;
        gap: 1rem;
        position: relative;
        z-index: 1;
    }
    .auth-logo .auth-brand-logos img {
        height: 54px;
        filter: drop-shadow(0 2px 8px rgba(0,0,0,.12));
    }
    .auth-logo .auth-center-logo {
        height: 70px !important;
    }
    .auth-logo .auth-brand-name {
        color: #166534;
        font-size: .75rem;
        margin-bottom: .5rem;
        position: relative; z-index: 1;
    }
    .auth-logo .auth-brand-name span { color: #64748b; }
    .auth-logo h1 {
        font-size: 2rem;
        color: #166534;
        position: relative; z-index: 1;
    }
    .auth-logo h1 span { color: #16a34a; }
    .auth-logo p {
        color: #64748b;
        font-size: .75rem;
        max-width: 200px;
        line-height: 1.5;
        position: relative; z-index: 1;
    }
    /* right panel — clean white form */
    .auth-form-panel {
        padding: 1.5rem 2rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow-y: auto;
        max-height: 90vh;
        background: #fff;
        position: relative;
    }
    .form-group { margin-bottom: .5rem; }
    .captcha-widget { margin-bottom: .5rem; }
    .auth-form-panel .form-label { font-size: .75rem; margin-bottom: .25rem; }
    .auth-form-panel .form-control { padding: .45rem .75rem; font-size: .82rem; }
    .auth-form-panel .btn { padding: .6rem; font-size: .85rem; }
    .auth-form-panel .btn-google { padding: .55rem .875rem; font-size: .82rem; margin-bottom: .5rem; }
    .auth-form-panel .auth-divider { margin: .4rem 0; }
    .auth-form-panel p { font-size: .78rem; margin-top: .875rem; }
    .captcha-image { height: 62px; }
    .captcha-hint { font-size: .68rem; }
    .captcha-status { font-size: .7rem; }
}

/* very short viewports — allow scroll */
@media (max-height: 650px) {
    .auth-wrapper {
        justify-content: flex-start;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-brand-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: .6rem;
}
.auth-brand-logos img {
    height: 64px;
    width: auto;
    object-fit: contain;
}
.auth-center-logo {
    height: 80px !important;
    max-width: 150px;
}
.auth-brand-name {
    font-size: .8rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.4;
    margin-bottom: .75rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.auth-brand-name span {
    font-weight: 500;
    color: var(--gray);
    text-transform: none;
    font-size: .75rem;
}

.auth-logo h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.04em;
    font-family: var(--font);
}

.auth-logo span { color: var(--secondary); }
.auth-logo p { color: var(--gray); font-size: 0.8rem; margin-top: 4px; }

/* PASSWORD TOGGLE */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 4.75rem; }
.pw-eye {
    position: absolute;
    right: .75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: .76rem;
    font-weight: 700;
    color: var(--gray);
    padding: .2rem;
    line-height: 1;
    min-width: 2.75rem;
    transition: color .2s;
}
.pw-eye:hover { color: var(--primary); }

/* GOOGLE BUTTON */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    width: 100%;
    padding: .7rem 1rem;
    border-radius: 8px;
    border: 1.5px solid #dadce0;
    background: #fff;
    color: #3c4043;
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .2s, box-shadow .2s;
    margin-bottom: .75rem;
}
.btn-google:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .75rem 0;
    color: #94a3b8;
    font-size: .78rem;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.captcha-widget {
    margin-bottom: 1rem;
}

.captcha-visual {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}

.captcha-image {
    width: 210px;
    max-width: 100%;
    height: 74px;
    display: block;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #f0fdf4;
}

.captcha-refresh {
    min-width: 88px;
    justify-content: center;
}

.captcha-input {
    text-transform: uppercase;
    letter-spacing: .24em;
    font-weight: 700;
    text-align: center;
    font-size: 1rem;
}

.captcha-input.is-valid {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22,163,74,.15);
}

.captcha-input.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}

.captcha-hint {
    margin-top: .45rem;
    font-size: .75rem;
    color: var(--gray);
    line-height: 1.5;
}

.captcha-status {
    min-height: 1.15rem;
    margin-top: .45rem;
    font-size: .78rem;
    font-weight: 600;
}

.captcha-status.is-valid {
    color: #15803d;
}

.captcha-status.is-invalid {
    color: #b91c1c;
}

.captcha-status.is-neutral {
    color: var(--gray);
}

/* SETTINGS */
.settings-brand-block {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: .75rem 0;
}
.settings-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    flex-shrink: 0;
}
.settings-brand-text { flex: 1; }
.settings-brand-title { font-size: .95rem; font-weight: 700; color: var(--primary); line-height: 1.3; }
.settings-brand-sub { font-size: .78rem; color: var(--secondary); font-weight: 600; margin: .2rem 0 .4rem; }
.settings-brand-desc { font-size: .8rem; color: #64748b; line-height: 1.5; }
.settings-divider { border: none; border-top: 1px solid var(--border); margin: .75rem 0; }

/* LAYOUT */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.25s ease;
    will-change: transform;
    -webkit-overflow-scrolling: touch;
}

.sidebar-logo {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand-row {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-brand-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.sidebar-brand-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.sidebar-brand-tagline {
    font-size: .6rem;
    opacity: .55;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-section {
    padding: 0.6rem 1.25rem 0.2rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.45;
    font-family: var(--font);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.18s;
    border-left: 3px solid transparent;
    letter-spacing: -0.01em;
    min-width: 0;
}

.nav-link span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--accent);
}

.nav-link .icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: .85; }
.nav-link:hover .nav-icon, .nav-link.active .nav-icon { opacity: 1; }

.page-tabs {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.page-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: #475569;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.18s;
}

.page-tab:hover {
    color: var(--primary);
    border-color: #86efac;
    transform: translateY(-1px);
}

.page-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.status-card {
    padding: 1.2rem;
}

.status-kicker {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gray);
    margin-bottom: 0.7rem;
}

.status-value {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.status-note {
    margin-top: 0.75rem;
    color: #475569;
    font-size: 0.84rem;
    line-height: 1.6;
}

.status-dot {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 999px;
    flex-shrink: 0;
}

.status-dot.ok {
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.14);
}

.status-dot.warn {
    background: #f59e0b;
    box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.14);
}

.status-dot.error {
    background: #ef4444;
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.14);
}

.status-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8rem;
    opacity: 0.7;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* push footer to bottom when content is short */
.page-content {
    flex: 1;
}

.topbar {
    background: #fff;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    touch-action: manipulation;
    gap: .5rem;
    min-height: 56px;
}

.topbar-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-shrink: 0;  /* NEVER wrap or shrink — always stays on same row */
    flex-wrap: nowrap;
    white-space: nowrap;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    min-width: 0;
    max-width: min(260px, 45vw);
}

.user-badge-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--secondary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.page-content { padding: 1.5rem; min-width: 0; }

/* FOOTER */
.app-footer {
    background: linear-gradient(100deg, #14532d 0%, #166534 40%, #1a7a3a 70%, #ca8a04 100%);
    color: rgba(255,255,255,.6);
    margin-top: auto;
    flex-shrink: 0;
    border-top: 2px solid #eab308;
}

.app-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    flex-wrap: wrap;
}

.app-footer-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

.app-footer-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,.4));
    opacity: .95;
}

.app-footer-brand-name {
    font-size: .95rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.01em;
    line-height: 1.2;
}

.app-footer-brand-sub {
    font-size: .65rem;
    color: rgba(255,255,255,.45);
    line-height: 1.4;
}

.app-footer-copy {
    font-size: .62rem;
    color: rgba(255,255,255,.3);
    margin-top: 2px;
}

.app-footer-devs {
    text-align: center;
}

.app-footer-dev-names {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.app-footer-dev-names a {
    color: #86efac;
    text-decoration: none;
    font-size: .8rem;
    font-weight: 600;
    transition: color .2s;
}

.app-footer-dev-names a:hover { color: #fff; }

.app-footer-sep {
    color: rgba(255,255,255,.2);
    font-size: .75rem;
}

.app-footer-dev-label {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255,255,255,.3);
    margin-top: .25rem;
}

/* CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    border: 1px solid var(--border);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.yellow { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }

.stat-info h3 { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.04em; }
.stat-info p { font-size: 0.78rem; color: var(--gray); font-weight: 500; }

/* CARD */
.card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    overflow: hidden;
    min-width: 0;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

.card-header h3 { font-size: 0.9rem; font-weight: 700; letter-spacing: -0.02em; }
.card-body { padding: 1.25rem; min-width: 0; }

/* TABLE */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 0.875rem; }
thead th {
    background: #f0fdf4;
    padding: 0.7rem 1rem;
    text-align: left;
    font-weight: 700;
    color: var(--gray);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow-wrap: anywhere;
    word-break: break-word;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f0fdf4; }

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-admin { background: #dcfce7; color: #166534; }
.badge-librarian { background: #dbeafe; color: #1d4ed8; }
.badge-user { background: #f1f5f9; color: #475569; }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    letter-spacing: -0.01em;
    max-width: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--secondary); color: #fff; }
.btn-primary:hover { background: #15803d; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: #475569;
}
.btn-outline:hover { background: #f8fafc; }
.btn:disabled,
.btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.4rem; letter-spacing: -0.01em; }
.form-control {
    width: 100%;
    padding: 0.6rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: var(--font);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: #1e293b;
}
.form-control:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* SEARCH BAR */
.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.search-bar .form-control { flex: 1; min-width: 200px; }

/* RESEARCH GRID */
.research-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.research-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: box-shadow 0.2s;
    min-width: 0;
}
.research-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); }

.research-card-cover {
    width: 100%;
    aspect-ratio: 2/3;
    max-height: 300px;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(135deg, #166534, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    letter-spacing: .02em;
    flex-shrink: 0;
}

.research-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.research-card h4 {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--primary);
    letter-spacing: -0.02em;
}
.research-card .meta { font-size: 0.78rem; color: var(--gray); }
.research-card .abstract {
    font-size: 0.82rem;
    color: #475569;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.research-card .actions { display: flex; gap: 0.5rem; margin-top: auto; flex-wrap: wrap; }

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    /* sit to the right of the sidebar, not over it */
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

/* PDF preview modal — portrait A4-ish proportions */
#pdfModal {
    /* on mobile the sidebar is hidden, so cover full screen */
}
#pdfModal .modal {
    /* portrait: width drives height via aspect-ratio */
    width: min(520px, 90%);
    aspect-ratio: 3 / 4;
    max-height: calc(100vh - 2rem);
}
#pdfModal .modal-body iframe {
    min-height: unset;
    height: 100%;
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 0.92rem; font-weight: 700; letter-spacing: -0.02em; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--gray);
    line-height: 1;
}
.modal-body { flex: 1; overflow: hidden; }
.modal-body iframe { width: 100%; height: 100%; min-height: 70vh; border: none; }

/* On mobile the sidebar collapses — modal covers full viewport */
@media (max-width: 768px) {
    .modal-overlay {
        left: 0;
    }
}

/* ALERTS */
.alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-wrap: anywhere;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* PAGINATION */
.pagination { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.page-btn {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    color: #475569;
    transition: all 0.2s;
}
.page-btn:hover, .page-btn.active {
    background: var(--secondary);
    color: #fff;
    border-color: var(--secondary);
    border-color: var(--secondary);
}

/* HAMBURGER */
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #475569;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1rem; margin-bottom: 0.5rem; }

/* CHART CONTAINER */
.chart-container { position: relative; height: 250px; }

/* BOOK COVER GRID */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
}

.book-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: pointer;
}
.book-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    transform: translateY(-3px);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: linear-gradient(135deg, #166534, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 3rem;
    flex-shrink: 0;
}
.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-info {
    padding: .875rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    flex: 1;
}
.book-info h4 {
    font-size: .83rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
    letter-spacing: -0.02em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.book-info .book-meta { font-size: .72rem; color: var(--gray); }
.book-info .book-actions { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }

/* DETAIL PANEL (Wattpad-style) */
.detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}
.detail-overlay.open { display: flex; }

.detail-panel {
    background: #fff;
    width: 100%;
    max-width: 680px;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.32,1,.23,1);
    padding-bottom: 2rem;
    min-width: 0;
}
.detail-overlay.open .detail-panel { transform: translateY(0); }

.detail-drag { width: 40px; height: 4px; background: #cbd5e1; border-radius: 4px; margin: .75rem auto .5rem; }

.detail-hero {
    display: flex;
    gap: 1.25rem;
    padding: 1rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.detail-cover {
    width: 100px;
    min-width: 100px;
    aspect-ratio: 2/3;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(135deg, #166534, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    flex-shrink: 0;
}
.detail-cover img { width:100%; height:100%; object-fit:cover; display:block; }
.detail-meta { display: flex; flex-direction: column; justify-content: center; gap: .4rem; }
.detail-meta h2 { font-size: 1.05rem; font-weight: 800; color: var(--primary); line-height: 1.3; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.detail-meta .detail-author { font-size: .85rem; color: var(--gray); }
.detail-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.detail-tag {
    background: #dcfce7;
    color: #166534;
    font-size: .72rem;
    font-weight: 600;
    padding: .2rem .6rem;
    border-radius: 20px;
}

.detail-body { padding: 1.25rem 1.5rem; }
.detail-section-title { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--gray); margin-bottom: .5rem; }
.detail-description { font-size: .9rem; color: #334155; line-height: 1.7; }
.detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
}
.detail-meta-item {
    padding: .75rem .85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fafc;
}
.detail-meta-label {
    font-size: .63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gray);
    margin-bottom: .3rem;
}
.detail-meta-value {
    font-size: .82rem;
    color: #1e293b;
    line-height: 1.5;
    word-break: break-word;
}
.detail-actions { display: flex; gap: .75rem; padding: 0 1.5rem 1rem; flex-wrap: wrap; }

.upload-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.5rem;
    align-items: start;
}

.upload-progress {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 8px;
    padding: .75rem;
    margin-bottom: 1rem;
}
.upload-progress[hidden] { display: none; }
.upload-progress-head {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    font-size: .78rem;
    color: #475569;
    margin-bottom: .5rem;
}
.upload-progress-track {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}
.upload-progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--secondary);
    transition: width .2s ease;
}
.upload-progress.is-error {
    border-color: #fecaca;
    background: #fff1f2;
}
.upload-progress.is-error .upload-progress-fill { background: var(--danger); }

/* RECOMMENDATIONS */
.detail-recs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: .75rem;
}
.rec-card {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    background: #fff;
}
.rec-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}
.rec-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: linear-gradient(135deg, #166534, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
}
.rec-cover img { width:100%; height:100%; object-fit:cover; display:block; }
.rec-info { padding: .4rem .5rem; }
.rec-info h5 {
    font-size: .72rem;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rec-info p { font-size: .65rem; color: var(--gray); margin-top: 2px; }

/* FAVORITES */
.fav-btn { background: transparent; border: 1px solid var(--border); color: #94a3b8; font-size: .85rem; }
.fav-btn:hover { border-color: #f43f5e; }
.fav-btn.fav-active { border-color: #f43f5e; background: #fff1f2; }

/* NOTIFICATION BELL */
.notif-bell {
    position: relative;
    font-size: 1.2rem;
    text-decoration: none;
    line-height: 1;
    padding: .25rem;
    display: flex;
    align-items: center;
}
.notif-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

/* COLLEGE BADGE */
.badge-college {
    background: #ede9fe;
    color: #5b21b6;
}

/* READING PROGRESS */
.progress-bar-wrap {
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: .35rem;
}
.progress-bar-fill {
    height: 100%;
    background: var(--secondary);
    border-radius: 4px;
    transition: width .4s;
}


/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar {
        width: min(80vw, 280px);
        transform: translateX(-100%);
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .hamburger { display: flex; align-items: center; justify-content: center; }

    /* topbar — always single row, NEVER wraps */
    .topbar { padding: .6rem .875rem; gap: .4rem; min-height: 52px; }
    .topbar > div:first-child { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; overflow: hidden; }
    .topbar-title { font-size: .82rem; }
    .topbar-right { gap: .35rem; flex-shrink: 0; flex-wrap: nowrap; }
    .topbar-right .btn { padding: .3rem .5rem; font-size: .72rem; }
    .topbar-right .btn svg + * { display: none; } /* icon-only logout on mobile */
    .user-badge-name { display: none; }
    .avatar { width: 30px; height: 30px; font-size: .75rem; }
    .notif-bell { font-size: 1rem; padding: .2rem; }

    .page-content { padding: .875rem; }
    .card-header { padding: .875rem 1rem; flex-wrap: wrap; }
    .card-body { padding: .875rem 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
    .status-grid { grid-template-columns: 1fr; }
    .research-grid { grid-template-columns: 1fr; }
    .book-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-container { height: 200px; }
    .app-footer-inner { flex-direction: column; align-items: flex-start; gap: .75rem; }
    .upload-grid { grid-template-columns: 1fr; }

    /* detail panel */
    .detail-hero { flex-direction: column; align-items: flex-start; padding: 1rem; }
    .detail-cover { width: 80px; min-width: 80px; }
    .detail-body { padding: 1rem; }
    .detail-actions { padding: 0 1rem 1rem; }
    .detail-actions .btn { flex: 1 1 calc(50% - .5rem); justify-content: center; }

    /* search bar stacks vertically on mobile */
    .search-bar { flex-direction: column; gap: .5rem; }
    .search-bar .form-control,
    .search-bar select,
    .search-bar .btn { width: 100% !important; max-width: 100% !important; }

    /* tables — card style rows on mobile */
    .table-wrap { margin: 0; }
    table { min-width: 0; width: 100%; }
    table thead { display: none; }
    table tbody tr {
        display: block;
        border-bottom: 2px solid var(--border);
        padding: .75rem 1rem;
    }
    table tbody tr:last-child { border-bottom: none; }
    table tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        padding: .3rem 0;
        border: none;
        font-size: .82rem;
        gap: .5rem;
        flex-wrap: wrap;
        min-height: 28px;
    }
    table tbody td::before {
        content: attr(data-label);
        font-size: .68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--gray);
        flex-shrink: 0;
        min-width: 72px;
        padding-top: 2px;
    }
    table tbody td[data-label=""]::before { display: none; }
    table tbody td[data-label=""] { justify-content: flex-start; }
    table tbody td:not([data-label])::before { display: none; }

    /* batch bar stacks on mobile */
    #batchBar { flex-direction: column !important; align-items: stretch !important; }
    #batchBar select, #batchBar .btn { width: 100%; justify-content: center; }

    /* modals */
    .modal-overlay { left: 0; padding: .5rem; }
    .modal { max-height: calc(100vh - 1rem); border-radius: 12px; }
    #createUserModal > div { max-width: 100% !important; margin: 0 .5rem; }

    /* page tabs scroll horizontally */
    .page-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; -webkit-overflow-scrolling: touch; }
    .page-tab { flex-shrink: 0; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .book-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
    .page-content { padding: .75rem; }
    .topbar { padding: .5rem .75rem; }
    .card-header { padding: .75rem; }
    .card-body { padding: .75rem; }
    .detail-actions .btn { flex-basis: 100%; }
    .modal-overlay { padding: .25rem; }
    .modal { border-radius: 10px; }
    .modal-header { padding: .75rem; }
    .modal-body iframe { min-height: 55vh; }
    .auth-card { padding: 1.25rem 1rem; max-width: 340px; }
    .auth-brand-logos img { height: 38px; }
    .auth-center-logo { height: 48px !important; }
    .auth-logo h1 { font-size: 1.3rem; }
    .form-group { margin-bottom: .6rem; }
    .form-control { padding: .45rem .7rem; font-size: .82rem; }
    .captcha-image { height: 60px; }
}
