:root {
  --navy: #17324d;
  --navy-2: #244d6d;
  --ink: #17212b;
  --muted: #687887;
  --line: #dfe7ed;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --accent: #d9a441;
  --success: #177a58;
  --danger: #b53b46;
  --warning-bg: #fff7e3;
  --shadow: 0 14px 36px rgba(23, 50, 77, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 .45rem; font-size: .72rem; letter-spacing: .12em; font-weight: 800; color: var(--navy-2); }
.muted { color: var(--muted); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; background: var(--surface); }
.login-brand { padding: clamp(2.5rem, 7vw, 7rem); background: linear-gradient(145deg, #10283e 0%, #214e6d 70%, #2d637d 100%); color: white; display: flex; flex-direction: column; justify-content: center; gap: 1.6rem; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; width: 35rem; height: 35rem; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; right: -15rem; bottom: -15rem; box-shadow: 0 0 0 4rem rgba(255,255,255,.025), 0 0 0 8rem rgba(255,255,255,.018); }
.brand-mark { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; background: var(--accent); color: #1c2b36; font: 900 2.2rem Georgia, serif; box-shadow: 0 10px 25px rgba(0,0,0,.18); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem; box-shadow: none; flex: 0 0 auto; }
.login-brand .eyebrow { color: #d9e8f2; }
.login-brand h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2.5rem, 5.2vw, 5.3rem); line-height: .98; max-width: 8ch; }
.brand-copy { max-width: 30rem; font-size: 1.08rem; color: #dce8ef; line-height: 1.6; }
.feature-chips { display: flex; flex-wrap: wrap; gap: .7rem; z-index: 1; }
.feature-chips span { padding: .65rem .9rem; border: 1px solid rgba(255,255,255,.17); border-radius: 999px; background: rgba(255,255,255,.07); }
.login-panel { display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(100%, 420px); }
.login-card h2 { font-size: 2rem; margin: 0 0 .45rem; }
.login-card label { display: block; font-weight: 750; margin: 1.1rem 0 .45rem; }
.login-card input { width: 100%; border: 1px solid #cdd9e1; border-radius: 12px; padding: .9rem 1rem; background: #fbfcfd; outline: none; transition: .18s; }
.login-card input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 4px rgba(36,77,109,.1); background: white; }
.password-row { display: flex; gap: .5rem; }
.password-row input { flex: 1; }
.icon-button { width: 48px; border: 1px solid #cdd9e1; border-radius: 12px; background: #fff; color: var(--navy); }
.primary-button { width: 100%; border: 0; border-radius: 12px; padding: .95rem 1rem; margin-top: 1.4rem; background: var(--navy); color: white; font-weight: 800; box-shadow: 0 8px 18px rgba(23,50,77,.18); }
.primary-button:hover { background: #214866; }
.primary-button:disabled { opacity: .58; cursor: wait; }
.link-button { width: 100%; border: 0; background: transparent; color: var(--navy-2); font-weight: 700; padding: .9rem; }
.form-error { color: var(--danger); min-height: 1.25rem; font-size: .9rem; margin: .35rem 0 0; }
.mobile-logo { display: none; align-items: center; gap: .75rem; margin-bottom: 2rem; color: var(--navy); }
.loading-view { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 1rem; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #d7e3ea; border-top-color: var(--navy); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 254px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #122b40; color: white; padding: 1.2rem .85rem; display: flex; flex-direction: column; z-index: 30; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: .2rem .5rem 1.2rem; }
.sidebar-brand span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.sidebar-brand small { color: #aac1d2; margin-top: .2rem; }
.main-nav { display: flex; flex-direction: column; gap: .25rem; overflow: auto; padding-right: .15rem; }
.nav-item { width: 100%; border: 0; background: transparent; color: #d8e4ec; display: flex; align-items: center; gap: .8rem; text-align: left; padding: .78rem .8rem; border-radius: 10px; font-weight: 650; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.10); color: white; }
.nav-item[disabled] { opacity: .44; cursor: not-allowed; }
.nav-item .nav-icon { width: 1.25rem; text-align: center; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: .8rem; }
.logout { color: #ffd9dc; }
.app-main { min-width: 0; }
.topbar { min-height: 82px; background: var(--surface); border-bottom: 1px solid var(--line); padding: .95rem clamp(1rem, 3vw, 2.2rem); display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 20; }
.topbar h2 { margin: 0; font-size: 1.35rem; }
.topbar .eyebrow { margin-bottom: .2rem; }
.menu-button { display: none; border: 1px solid var(--line); background: white; width: 44px; height: 44px; border-radius: 10px; }
.profile-pill { margin-left: auto; display: flex; align-items: center; gap: .7rem; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: #e5edf2; color: var(--navy); display: grid; place-items: center; font-weight: 900; }
.profile-copy { display: flex; flex-direction: column; font-size: .88rem; }
.profile-copy span { color: var(--muted); font-size: .78rem; }
.content { padding: clamp(1rem, 3vw, 2.3rem); max-width: 1500px; margin: 0 auto; outline: none; }
.welcome-card { background: linear-gradient(120deg, #fff 0%, #f9fbfc 100%); border: 1px solid var(--line); border-radius: 18px; padding: 1.5rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center; box-shadow: 0 8px 24px rgba(23,50,77,.05); }
.welcome-card h3 { margin: 0; font-size: 1.65rem; }
.welcome-card p:last-child { margin-bottom: 0; color: var(--muted); }
.access-badge { border-radius: 999px; padding: .55rem .8rem; background: #e8f2ed; color: var(--success); font-size: .78rem; font-weight: 900; letter-spacing: .06em; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.stat-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; min-width: 0; }
.stat-card span { color: var(--muted); font-size: .86rem; }
.stat-card strong { display: block; margin-top: .5rem; font-size: 1.8rem; color: var(--navy); }
.section-block { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 1.3rem; margin-top: 1rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h3 { margin: 0; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.quick-card { border: 1px solid var(--line); background: #fbfcfd; border-radius: 14px; padding: 1rem; text-align: left; transition: .18s; min-height: 110px; }
.quick-card:hover:not(:disabled) { transform: translateY(-2px); border-color: #b4c7d5; box-shadow: 0 8px 20px rgba(23,50,77,.08); }
.quick-card:disabled { opacity: .5; cursor: not-allowed; }
.quick-card .quick-icon { font-size: 1.5rem; display: block; margin-bottom: .8rem; }
.quick-card strong { display: block; }
.quick-card small { display: block; color: var(--muted); margin-top: .25rem; line-height: 1.35; }
.catalog-alert { margin-top: 1rem; padding: 1rem 1.1rem; border-radius: 14px; background: var(--warning-bg); border: 1px solid #ecd79b; color: #67531a; }
.panel-card { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 1.3rem; }
.empty-state { text-align: center; padding: 3.5rem 1rem; }
.empty-icon { font-size: 2.5rem; }
.toast-region { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: grid; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: #122b40; color: white; padding: .85rem 1rem; border-radius: 12px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (max-width: 1050px) {
  .stats-grid, .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; }
  .mobile-logo { display: flex; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -280px; width: 254px; transition: .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .menu-button { display: grid; place-items: center; }
}
@media (max-width: 560px) {
  .login-panel { padding: 1.25rem; }
  .stats-grid, .quick-grid { grid-template-columns: 1fr; }
  .profile-copy { display: none; }
  .welcome-card { align-items: flex-start; flex-direction: column; }
  .topbar { min-height: 72px; }
  .content { padding: 1rem; }
}
.search-form { display: flex; gap: .55rem; min-width: min(100%, 430px); }
.search-form input, .stack-form input { width: 100%; border: 1px solid #cdd9e1; border-radius: 10px; padding: .78rem .9rem; background: #fbfcfd; outline: none; }
.search-form input:focus, .stack-form input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(36,77,109,.09); background: white; }
.secondary-button { border: 1px solid #bdcbd5; background: white; color: var(--navy); border-radius: 10px; padding: .72rem .9rem; font-weight: 750; white-space: nowrap; }
.secondary-button:hover { background: #f3f7f9; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { padding: .85rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { background: #f5f8fa; color: #506372; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdfe; }
.table-loading, .empty-inline, .inline-error { padding: 2rem; text-align: center; color: var(--muted); }
.inline-error { color: var(--danger); }
.status-pill { display: inline-flex; padding: .32rem .55rem; border-radius: 999px; background: #eef2f5; font-size: .7rem; font-weight: 850; letter-spacing: .04em; }
.status-pill.student { color: #1f5f91; background: #e9f3fa; }
.status-pill.staff { color: #6b4b12; background: #fff3d6; }
.status-pill.ok { color: var(--success); background: #e8f5ef; }
.status-pill.off { color: #687887; }
.status-pill.late { color: var(--danger); background: #fdecef; }
.scanner-note { margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid #b9d5e3; border-radius: 12px; background: #eef7fb; color: #2b5368; }
.circulation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.operation-card h3 { margin-top: 0; }
.stack-form { display: grid; gap: .55rem; }
.stack-form label { font-weight: 740; margin-top: .4rem; }
.primary-button.compact { margin-top: .8rem; width: auto; justify-self: start; min-width: 190px; }
.form-feedback { min-height: 1.2rem; margin: .5rem 0 0; color: var(--muted); font-size: .9rem; }
.form-feedback.success { color: var(--success); }
.form-feedback.error { color: var(--danger); }
.recent-loans { margin-top: 1rem; }
@media (max-width: 850px) {
  .circulation-grid { grid-template-columns: 1fr; }
  .responsive-heading { align-items: stretch; flex-direction: column; }
  .search-form { min-width: 0; width: 100%; }
}
@media (max-width: 520px) {
  .search-form { flex-direction: column; }
  .primary-button.compact { width: 100%; }
}
