.admin-body { background: #f1eee7; }
.admin-shell { display: grid; min-height: 100vh; grid-template-columns: 245px 1fr; }
.admin-sidebar { position: sticky; z-index: 80; top: 0; display: flex; height: 100vh; flex-direction: column; background: #173f36; color: #edf2ef; }
.admin-brand { display: flex; min-height: 88px; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.13); padding: 14px 22px; }
.admin-brand img { width: 40px; height: 50px; object-fit: contain; }
.admin-brand strong, .admin-brand small { display: block; }
.admin-brand strong { font-family: var(--font-serif); font-size: 1.13rem; }
.admin-brand small { color: #a9beb6; font-size: .68rem; letter-spacing: .11em; text-transform: uppercase; }
.admin-sidebar nav { flex: 1; overflow-y: auto; padding: 22px 12px; }
.nav-section-label { display: block; margin: 18px 12px 7px; color: #8da69c; font-size: .64rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.nav-section-label:first-child { margin-top: 0; }
.admin-sidebar nav a { display: flex; min-height: 44px; align-items: center; gap: 11px; border-left: 2px solid transparent; padding: 8px 12px; color: #bdcec7; font-size: .87rem; font-weight: 600; }
.admin-sidebar nav a:hover { color: #fff; }
.admin-sidebar nav a[aria-current="page"] { border-left-color: #d7ad5f; background: rgba(255,255,255,.08); color: #fff; }
.nav-mark { display: grid; width: 24px; height: 24px; place-items: center; border: 1px solid #5f7e73; color: #c5d2cd; font-family: var(--font-serif); font-size: .78rem; }
.sidebar-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid rgba(255,255,255,.13); padding: 18px; }
.sidebar-bottom small, .sidebar-bottom strong { display: block; }
.sidebar-bottom small { color: #91aaa0; font-size: .64rem; }
.sidebar-bottom strong { overflow: hidden; max-width: 125px; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-bottom button { border: 0; background: transparent; color: #ddc384; font-size: .75rem; font-weight: 700; }
.admin-main { min-width: 0; }
.admin-topbar { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #d7d1c6; background: rgba(255,253,248,.82); padding: 12px 32px; backdrop-filter: blur(10px); }
.admin-topbar > div span, .admin-topbar > div strong { display: block; }
.admin-topbar span { color: var(--muted); font-size: .69rem; }
.admin-topbar strong { font-size: .85rem; }
.admin-topbar > a { color: var(--green); font-size: .78rem; font-weight: 700; }
.admin-menu-toggle { display: none; width: 44px; height: 44px; border: 1px solid var(--line); background: transparent; }
.admin-content { padding: 38px 32px 70px; }
.admin-flash .flash-wrap { width: auto; margin: 14px 32px 0; }
.admin-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.admin-page-head h1 { margin: 5px 0 2px; font-size: clamp(2.2rem,4vw,3.45rem); }
.admin-page-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.admin-card { border: 1px solid #d4cec2; background: #fffdf8; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 20px; }
.card-head h2, .form-card h2 { margin: 5px 0 0; font-size: 1.75rem; }
.card-head > span { color: var(--muted); font-size: .7rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); margin-bottom: 24px; }
.stat-grid article { min-height: 138px; border: 1px solid #d4cec2; border-right: 0; background: #fffdf8; padding: 22px; }
.stat-grid article:last-child { border-right: 1px solid #d4cec2; }
.stat-grid span, .stat-grid strong, .stat-grid small { display: block; }
.stat-grid span { color: var(--muted); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat-grid strong { margin: 7px 0 4px; font-family: var(--font-serif); font-size: 2.7rem; line-height: 1; }
.stat-grid small { color: var(--muted); }
.stat-grid .stat-warm { border-top: 4px solid var(--mustard); }
.stat-grid .stat-alert { border-top: 4px solid var(--terracotta); }
.dashboard-grid { display: grid; grid-template-columns: 1.5fr .75fr; gap: 24px; margin-bottom: 24px; }
.chart-card, .popular-card, .detail-card, .action-card, .timeline-card { padding: 24px; }
.bar-chart { display: flex; height: 210px; align-items: flex-end; gap: 5%; border-bottom: 1px solid var(--line); padding: 30px 3% 0; }
.bar-column { display: flex; height: 100%; flex: 1; flex-direction: column; justify-content: flex-end; text-align: center; }
.bar-column strong { margin-bottom: 5px; color: var(--green); font-size: .72rem; }
.bar-column > span { width: 100%; min-height: 8px; background: var(--green); }
.bar-column small { margin: 7px 0 -25px; color: var(--muted); font-size: .66rem; text-transform: uppercase; }
.chart-empty { align-self: center; width: 100%; color: var(--muted); text-align: center; }
.popular-list { margin: 0; padding: 0; list-style: none; }
.popular-list li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 12px 0; }
.popular-list li > span { color: var(--terracotta); font-family: var(--font-serif); }
.popular-list strong, .popular-list small { display: block; }
.popular-list strong { font-size: .8rem; }
.popular-list small { overflow: hidden; max-width: 180px; color: var(--muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.popular-list em { color: var(--green); font-size: .72rem; font-style: normal; font-weight: 700; }
.table-card { overflow: hidden; padding-top: 22px; }
.table-card > .card-head { padding: 0 22px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th { background: #eeeae1; color: #59625d; font-size: .66rem; letter-spacing: .07em; text-align: left; text-transform: uppercase; white-space: nowrap; }
th, td { border-bottom: 1px solid #e0dbd1; padding: 13px 15px; vertical-align: middle; }
tbody tr:nth-child(even) { background: #faf8f2; }
tbody tr:hover { background: #f0f3ef; }
td strong, td small { display: block; }
td small { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.table-action, .row-actions a, .row-actions button { color: var(--green); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.empty-row { color: var(--muted); padding: 32px !important; text-align: center; }
.filter-card { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; padding: 18px; }
.admin-filter { display: flex; flex: 1; align-items: flex-end; gap: 12px; }
.admin-filter .form-field { width: min(340px,40vw); margin: 0; }
.admin-filter .form-field:nth-child(2) { width: 210px; }
.admin-filter > a { color: var(--green); font-size: .78rem; text-decoration: underline; }
.table-book { display: flex; min-width: 245px; align-items: center; gap: 10px; }
.table-book img, .mini-cover { width: 34px; height: 48px; flex: 0 0 auto; object-fit: cover; box-shadow: 2px 3px 4px rgba(0,0,0,.14); }
.mini-cover { display: grid; place-items: center; background: var(--green); color: #fff; font-family: var(--font-serif); font-size: 1.1rem; }
.row-actions { display: flex; align-items: center; gap: 9px; }
.row-actions form { margin: 0; }
.row-actions button { border: 0; background: transparent; color: var(--red); padding: 0; font-size: inherit; }
.table-card .pagination { margin: 0; padding: 18px; }
.admin-form-grid { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 24px; align-items: start; }
.form-card { padding: 25px; }
.form-sidebar { display: grid; gap: 18px; }
.cover-preview { width: 150px; aspect-ratio: 2/3; margin: 12px auto 20px; object-fit: cover; box-shadow: var(--shadow-book); }
.category-admin-grid { display: grid; grid-template-columns: 310px 1fr; gap: 24px; align-items: start; }
.sticky-card { position: sticky; top: 20px; }
.category-edit-list { display: grid; grid-template-columns: repeat(2,1fr); gap: 18px; }
.category-edit-card { position: relative; padding: 20px; }
.category-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; color: var(--muted); font-size: .72rem; }
.category-swatch { width: 30px; height: 5px; }
.danger-link { position: absolute; right: 20px; bottom: 27px; border: 0; background: transparent; color: var(--red); font-size: .76rem; font-weight: 700; text-decoration: underline; }
.export-box { position: relative; }
.export-box summary { min-height: 46px; border: 1px solid var(--green); padding: 10px 14px; color: var(--green); font-size: .8rem; font-weight: 700; list-style: none; }
.export-box form { position: absolute; z-index: 20; top: calc(100% + 5px); right: 0; width: 285px; border: 1px solid var(--line); background: #fff; padding: 17px; box-shadow: var(--shadow-float); }
.export-box .form-field { margin-bottom: 10px; }
.subsection-head { margin-top: 22px; }
.subsection-head h3 { margin: 0; }
.admin-choice-list { max-height: 470px; }
.admin-form-grid .camera-stage, .admin-form-grid .camera-stage video, .admin-form-grid .camera-stage img { min-height: 225px; }
.admin-form-grid .camera-placeholder { padding: 18px; }
.loan-detail-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(285px,.7fr); gap: 24px; align-items: start; }
.loan-detail-grid > div, .loan-detail-grid > aside { display: grid; gap: 24px; }
.student-profile { display: grid; grid-template-columns: 150px 1fr; gap: 24px; align-items: start; }
.student-profile img, .photo-empty { width: 150px; aspect-ratio: 4/5; object-fit: cover; border: 1px solid var(--line); }
.photo-empty { display: grid; place-items: center; background: #ede9df; color: var(--muted); font-size: .75rem; text-align: center; }
.student-profile dl { margin: 0; }
.student-profile dl div { display: grid; grid-template-columns: 120px 1fr; border-top: 1px solid var(--line); padding: 10px 0; }
.student-profile dt { color: var(--muted); font-size: .7rem; }
.student-profile dd { margin: 0; font-size: .84rem; font-weight: 600; }
.loan-book-list > div { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 13px; border-top: 1px solid var(--line); padding: 13px 0; }
.loan-book-list strong, .loan-book-list small { display: block; }
.loan-book-list strong { font-size: .84rem; }
.loan-book-list small { color: var(--muted); font-size: .68rem; }
.action-card form + form { margin-top: 20px; }
.reject-form { border-top: 1px solid var(--line); padding-top: 20px; }
.action-facts { margin: 18px 0; }
.action-facts div { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 9px 0; }
.action-facts dt { color: var(--muted); font-size: .72rem; }
.action-facts dd { margin: 0; font-weight: 700; }
.timeline-card ol { margin: 18px 0 0; padding: 0; list-style: none; }
.timeline-card li { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 20px; }
.timeline-card li::before { position: absolute; top: 8px; bottom: -8px; left: 4px; width: 1px; background: var(--line); content: ""; }
.timeline-card li:last-child::before { display: none; }
.timeline-card li > span { z-index: 1; width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; background: var(--green); }
.timeline-card strong { font-size: .82rem; }
.timeline-card p { margin: 2px 0; color: var(--muted); font-size: .74rem; }
.timeline-card small { color: #89918c; font-size: .65rem; }
.student-detail-grid { display: grid; grid-template-columns: 390px 1fr; gap: 24px; align-items: start; }
.student-profile.large { grid-template-columns: 1fr; }
.student-profile.large img, .student-profile.large .photo-empty { width: min(100%,260px); margin: auto; }
.block-title { display: block; color: var(--ink); }
.settings-grid { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 24px; align-items: start; }
.password-card { position: sticky; top: 20px; }

/* Auth */
.auth-body { background: #f2eee5; }
.auth-shell { display: grid; min-height: 100vh; grid-template-columns: 1.05fr .95fr; }
.auth-identity { display: flex; flex-direction: column; justify-content: space-between; background: #173f36; color: #fff; padding: clamp(30px,6vw,75px); }
.brand-light small { color: #a9beb6; }
.auth-identity > div { max-width: 660px; }
.auth-identity h1 { margin: 14px 0 20px; font-size: clamp(3rem,6vw,5.3rem); }
.auth-identity p { color: #b9c9c3; }
.auth-identity > small { color: #829d92; }
.auth-form-wrap { display: grid; place-items: center; padding: 28px; }
.auth-form-card { width: min(100%,460px); border: 1px solid var(--line); background: var(--surface); padding: clamp(28px,5vw,50px); box-shadow: 10px 10px 0 #d9d2c3; }
.auth-form-card .back-link { display: block; margin-bottom: 38px; color: var(--green); font-size: .76rem; font-weight: 700; }
.auth-form-card h2 { margin: 12px 0 7px; font-size: 2.5rem; }
.auth-form-card > p { margin-bottom: 30px; color: var(--muted); }
.auth-form-card .flash-wrap { width: auto; margin: 0 0 18px; }
.password-field { position: relative; }
.password-field input { padding-right: 60px; }
.password-field button { position: absolute; top: 50%; right: 10px; border: 0; background: transparent; color: var(--green); font-size: .72rem; font-weight: 700; transform: translateY(-50%); }
.login-help { margin: 22px 0 0 !important; font-size: .72rem; text-align: center; }

@media (max-width: 1100px) {
    .admin-shell { grid-template-columns: 215px 1fr; }
    .admin-form-grid { grid-template-columns: minmax(0,1fr) 290px; }
    .category-edit-list { grid-template-columns: 1fr; }
    .student-detail-grid { grid-template-columns: 320px 1fr; }
}

@media (max-width: 880px) {
    .admin-shell { display: block; }
    .admin-sidebar { position: fixed; left: 0; width: 245px; transform: translateX(-105%); transition: transform .25s ease; }
    .admin-sidebar.is-open { transform: none; box-shadow: 20px 0 40px rgba(0,0,0,.22); }
    .admin-menu-toggle { display: block; }
    .admin-topbar { justify-content: flex-start; padding-inline: 20px; }
    .admin-topbar > a { margin-left: auto; }
    .admin-content { padding: 30px 20px 60px; }
    .admin-flash .flash-wrap { margin-inline: 20px; }
    .stat-grid { grid-template-columns: repeat(2,1fr); }
    .stat-grid article:nth-child(2) { border-right: 1px solid #d4cec2; }
    .stat-grid article:nth-child(n+3) { border-top: 0; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .admin-form-grid, .loan-detail-grid, .student-detail-grid, .settings-grid { grid-template-columns: 1fr; }
    .form-sidebar { grid-template-columns: repeat(2,1fr); }
    .form-sidebar > .button { grid-column: 1/-1; }
    .password-card { position: static; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-identity { min-height: 38vh; }
    .auth-identity > small { display: none; }
}

@media (max-width: 640px) {
    .admin-page-head { align-items: flex-start; flex-direction: column; }
    .admin-page-head > .button { width: 100%; }
    .head-actions { width: 100%; justify-content: space-between; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-grid article { min-height: 120px; padding: 16px; }
    .stat-grid strong { font-size: 2.1rem; }
    .filter-card { align-items: stretch; flex-direction: column; }
    .admin-filter { align-items: stretch; flex-direction: column; }
    .admin-filter .form-field, .admin-filter .form-field:nth-child(2) { width: 100%; }
    .category-admin-grid { grid-template-columns: 1fr; }
    .sticky-card { position: static; }
    .form-sidebar { grid-template-columns: 1fr; }
    .form-sidebar > .button { grid-column: auto; }
    .student-profile { grid-template-columns: 1fr; }
    .student-profile img, .photo-empty { width: 130px; }
    .student-profile dl div { grid-template-columns: 100px 1fr; }
    .loan-book-list > div { grid-template-columns: 34px 1fr; }
    .loan-book-list .shelf-tag { grid-column: 2; width: max-content; }
    .auth-identity { padding: 30px 24px; }
    .auth-identity h1 { font-size: 2.8rem; }
    .auth-form-wrap { padding: 18px; }
    .auth-form-card { padding: 25px 20px; box-shadow: 5px 5px 0 #d9d2c3; }
}
