/* ============================================================
   AICAS Library — restyled onto the same design tokens and
   component language as the AICAS Examination module (single
   sticky topbar, gradient-brand accents, collapsible sidebar
   groups, soft card/table/badge system). Class names are kept
   from the original Library prototype; legacy variable names
   below are aliases so existing markup needs no changes.
   ============================================================ */
:root {
  /* ---- Exam module tokens, ported verbatim ---- */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #7c3aed;
  --accent-light: #ede9fe;
  --indigo: #4f46e5;
  --gradient-brand: linear-gradient(135deg, #2563eb 0%, #4f46e5 55%, #7c3aed 100%);
  --gradient-brand-soft: linear-gradient(135deg, #eff6ff 0%, #eef2ff 55%, #f5f3ff 100%);
  --gradient-success: linear-gradient(135deg, #16a34a, #059669);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
  --gradient-danger: linear-gradient(135deg, #f87171, #dc2626);
  --sidebar-bg: #ffffff;
  --sidebar-hover: #eff6ff;
  --sidebar-active: #eff6ff;
  --bg: #f5f7fc;
  --card: #ffffff;
  --card-alt: #f8faff;
  --border: #e7ebf3;
  --border-strong: #dbe3ee;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 14px -4px rgba(30,41,89,.09);
  --shadow-lg: 0 24px 48px -16px rgba(30,41,89,.22), 0 8px 20px -10px rgba(15,23,42,.12);
  --shadow-glow: 0 10px 24px -8px rgba(79,70,229,.4);
  --transition: .2s ease;
  --transition-slow: .35s cubic-bezier(.4,0,.2,1);

  /* ---- Legacy Library variable names kept as aliases (inline styles in
     page JS reference these by name) so no page file needs to change ---- */
  --primary-600: var(--primary-dark);
  --sidebar-text: #64748b;
  --panel: var(--bg);
  --surface: var(--card);
  --text-2: var(--text-muted);
  --text-3: var(--text-soft);
  --green: var(--success);     --green-bg: #dcfce7;
  --blue: var(--primary);      --blue-bg: #dbeafe;
  --amber: var(--warning);     --amber-bg: #fef3c7;
  --red: var(--danger);        --red-bg: #fee2e2;
  --purple: var(--accent);     --purple-bg: var(--accent-light);
  --orange: #c2410c;           --orange-bg: #ffedd5;
  --teal: #0f766e;             --teal-bg: #ccfbf1;
  --gray: var(--text-muted);   --gray-bg: #f1f5f9;
  --tile-blue: #3b82f6; --tile-purple: #8b5cf6; --tile-amber: #f59e0b; --tile-red: #ef4444;
  --tile-indigo: #6366f1; --tile-teal: #06b6d4; --tile-green: #22c55e; --tile-gray: #64748b; --tile-pink: #ec4899;
  --radius-legacy: var(--radius);
  --sidebar-w: 248px;
  --sidebar-w-min: 72px;
  --header-h: 68px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body.modal-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
button { font: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::selection { background: var(--primary-light); color: var(--primary-dark); }
.ic { vertical-align: -3px; flex-shrink: 0; }
.clickable { cursor: pointer; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Login — Exam's full-screen overlay pattern ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 50; overflow-x: hidden; overflow-y: auto; min-height: 100vh;
  background:
    radial-gradient(1200px circle at 15% 10%, rgba(124,58,237,.10), transparent 55%),
    radial-gradient(900px circle at 85% 20%, rgba(37,99,235,.14), transparent 60%),
    radial-gradient(1000px circle at 60% 95%, rgba(79,70,229,.10), transparent 55%),
    linear-gradient(135deg, #f8fafc 0%, #ffffff 45%, #eff6ff 100%);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px;
}
.login-grid { position: relative; display: flex; align-items: center; gap: 56px; max-width: 1080px; width: 100%; }
.login-marketing { flex: 1; display: none; color: var(--text); }
@media (min-width: 1024px) { .login-marketing { display: block; } }
.login-marketing-brand { display: flex; align-items: center; gap: 12px; }
.login-marketing-brand .icon-box { width: 40px; height: 40px; border-radius: 14px; background: rgba(255,255,255,.85); border: 1px solid var(--border); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--primary); font-weight: 700; }
.login-marketing-brand .brand-name { font-size: 16px; font-weight: 700; }
.login-marketing-brand .brand-sub { font-size: 12px; color: var(--text-3); }
.login-marketing h2 { margin-top: 32px; font-size: 36px; font-weight: 800; letter-spacing: -.5px; line-height: 1.15; }
.login-marketing h2 span { background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-marketing p { margin-top: 16px; max-width: 420px; color: var(--text-2); font-size: 14.5px; line-height: 1.6; }
.login-flow { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 8px; max-width: 460px; }
.login-flow span { background: var(--card); border: 1px solid var(--border); padding: 6px 11px; border-radius: var(--radius-full); font-size: 11.5px; color: var(--text-2); box-shadow: var(--shadow); }
.login-flow span.key { background: var(--gradient-brand); border-color: transparent; color: #fff; font-weight: 600; box-shadow: var(--shadow-glow); }
.login-foot { margin-top: 24px; color: var(--text-3); font-size: 12px; }
.login-card-wrap { flex-shrink: 0; width: 440px; max-width: 100%; }
.login-container { position: relative; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: var(--radius-lg); border: 1px solid rgba(226,232,240,.8); box-shadow: 0 25px 50px -12px rgba(15,23,42,.18); overflow: hidden; }
.login-header { background: #fff; padding: 30px 28px 20px; text-align: center; border-bottom: 1px solid #f1f5f9; }
.login-header .icon { width: 52px; height: 52px; background: var(--gradient-brand-soft); border: 1px solid var(--primary-100); border-radius: var(--radius); display: grid; place-items: center; margin: 0 auto 12px; font-weight: 800; color: var(--primary); font-size: 18px; }
.login-header h1 { font-size: 20px; font-weight: 800; }
.login-header .sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.login-body { padding: 22px 28px 26px; }
.login-demo-hint { background: var(--card-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 13px; font-size: 11.5px; color: var(--text-2); margin-bottom: 16px; }
.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.role-card { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: var(--card-alt); cursor: pointer; display: flex; gap: 9px; align-items: flex-start; transition: var(--transition); }
.role-card:hover { border-color: var(--primary-200); background: var(--primary-light); }
.role-card.selected { border-color: var(--primary); background: var(--gradient-brand-soft); box-shadow: 0 0 0 3px var(--primary-100); }
.role-card .role-ic { width: 28px; height: 28px; border-radius: 8px; background: var(--card); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; box-shadow: var(--shadow); }
.role-card .role-name { font-weight: 700; font-size: 12.5px; }
.role-card .role-desc { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.role-card .role-cred { font-size: 10.5px; color: var(--text-3); margin-top: 3px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.login-body .field-label { font-size: 12.5px; font-weight: 700; }
.login-body .input { padding: 10px 13px; font-size: 13.5px; background: var(--card-alt); border: 1.5px solid var(--border); border-radius: var(--radius-sm); }
.login-body .input:focus { background: #fff; }
.login-body .btn.lg.block { border-radius: var(--radius-sm); margin-top: 4px; }
.login-error { color: var(--danger); font-size: 12.5px; margin-top: 10px; text-align: center; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s; }
body.sidebar-collapsed .shell { grid-template-columns: var(--sidebar-w-min) minmax(0, 1fr); }
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

/* ---------- Sidebar ---------- */
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); border-right: 1px solid var(--border); box-shadow: 1px 0 16px rgba(30,41,89,.04); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 17px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.sidebar-brand .logo-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--gradient-brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; box-shadow: var(--shadow-glow); }
.sidebar-brand .brand-name { font-weight: 700; font-size: 14.5px; line-height: 1.1; letter-spacing: -.2px; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; font-weight: 500; }
.sidebar-brand .collapse-btn { margin-left: auto; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin: 0 14px; padding: 12px 0 14px; border-bottom: 1px solid var(--border); }
.sidebar-user .avatar { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow); }
.sidebar-user .su-id { font-size: 12.5px; font-weight: 700; line-height: 1.15; letter-spacing: .1px; }
.sidebar-user .su-role { font-size: 11.5px; color: var(--text-3); }
.sidebar-section { padding: 14px 16px 8px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-soft); font-weight: 700; border-bottom: 1px solid var(--border); margin: 0 10px 6px; }
.nav { list-style: none; margin: 0; padding: 6px 10px 16px; }
.nav-item { margin: 3px 0; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; font-weight: 600; font-size: 13px; transition: var(--transition); }
.nav-link:hover { background: var(--sidebar-hover); color: var(--primary-dark); }
.nav-link.active { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow); }
.nav-link .ic { opacity: .85; color: var(--text-soft); transition: var(--transition); }
.nav-link:hover .ic { color: var(--primary); }
.nav-link.active .ic { opacity: 1; color: #fff; }
.nav-link .nav-caret { margin-left: auto; transition: transform .15s; opacity: .7; }
.nav-item.open > .nav-link .nav-caret { transform: rotate(180deg); }
.nav-item.open > .nav-link.active .nav-caret { color: #fff; }
.nav-link .pill { margin-left: auto; background: var(--primary-100); color: var(--primary-dark); font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-full); }
.nav-link .pill.hot { background: var(--gradient-danger); color: #fff; }
.nav-link.active .pill { background: rgba(255,255,255,.25); color: #fff; }
.subnav { list-style: none; margin: 3px 0 6px; padding: 0 0 0 6px; display: none; border-left: 1.5px solid var(--border); margin-left: 24px; }
.nav-item.open > .subnav { display: block; }
.subnav a { display: flex; align-items: center; gap: 9px; padding: 8px 10px 8px 14px; margin: 0 0 2px; color: var(--text-muted); font-size: 12.5px; font-weight: 500; cursor: pointer; border-radius: var(--radius-sm); transition: var(--transition); }
.subnav a .ic { opacity: .7; color: var(--text-soft); }
.subnav a .sn-label { flex: 1; }
.subnav a:hover { color: var(--primary-dark); background: var(--sidebar-hover); }
.subnav a.active { color: var(--primary-dark); background: var(--primary-50); font-weight: 700; }
.subnav a.active .ic { color: var(--primary); }
.subnav .pill { background: var(--gray-bg); color: var(--text-2); font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-full); }
.subnav .pill.hot { background: var(--gradient-danger); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 13px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-soft); }
/* collapsed (icon-only) sidebar on desktop */
body.sidebar-collapsed .sidebar-brand { flex-direction: column; gap: 8px; padding: 12px 8px; }
body.sidebar-collapsed .sidebar-brand .brand-text, body.sidebar-collapsed .sidebar-user .su-text, body.sidebar-collapsed .sidebar-section,
body.sidebar-collapsed .nav-link span, body.sidebar-collapsed .subnav, body.sidebar-collapsed .sidebar-foot { display: none; }
body.sidebar-collapsed .sidebar-brand .collapse-btn { margin-left: 0; }
body.sidebar-collapsed .sidebar-user { justify-content: center; margin: 0 8px; }
body.sidebar-collapsed .nav { padding: 10px 8px; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 11px 0; }

/* ---------- Topbar — single sticky row, Exam-style ---------- */
.topbar { min-height: var(--header-h); background: rgba(255,255,255,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); box-shadow: 0 1px 3px rgba(15,23,42,.04); display: flex; align-items: center; gap: 16px; padding: 0 26px; position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.topbar-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar-left h1 { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.topbar-left .breadcrumb { color: var(--text-soft); font-size: 12px; }
.topbar-left .breadcrumb span { color: var(--primary); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: var(--radius-sm); width: 34px; height: 34px; display: grid; place-items: center; color: var(--text-2); cursor: pointer; position: relative; transition: var(--transition); }
.icon-btn:hover { background: var(--card-alt); border-color: var(--border); color: var(--primary-dark); }
.icon-btn .dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: var(--radius-full); }
.user-chip .avatar { width: 36px; height: 36px; font-size: 12.5px; background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow); }
.user-chip .uc-name { font-size: 13px; font-weight: 700; line-height: 1.1; }
.user-chip .uc-role { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.role-tag { font-size: 11px; font-weight: 700; padding: 5px 12px; border-radius: var(--radius-full); background: var(--gradient-brand-soft); color: var(--primary-dark); border: 1px solid var(--primary-100); }
.role-tag.readonly { background: var(--gray-bg); color: var(--gray); border-color: var(--border-strong); }
.content { padding: 22px 28px 36px; }

/* ---------- Hero banner (Library-only — recolored onto gradient-brand) ---------- */
.hero { position: relative; overflow: hidden; border-radius: var(--radius); padding: 24px 26px; background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow); }
.hero::before { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; right: -120px; top: -220px; background: rgba(255,255,255,.08); }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; position: relative; }
.hero-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; opacity: .85; }
.hero-title { font-size: 30px; font-weight: 800; letter-spacing: -.3px; line-height: 1.15; margin-top: 4px; position: relative; display: inline-block; padding-bottom: 10px; }
.hero-title::after { content: ''; position: absolute; left: 0; bottom: 0; width: 72px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.75); }
.hero-side { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-box { background: #fff; color: var(--text); border-radius: var(--radius-sm); padding: 10px 16px; min-width: 150px; box-shadow: var(--shadow-lg); }
.hero-box .hb-label { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); text-align: right; }
.hero-box .hb-value { font-size: 19px; font-weight: 800; color: var(--primary-dark); text-align: right; letter-spacing: .3px; }
.hero-box .select { margin-top: 4px; font-weight: 600; padding: 6px 8px; border-radius: 8px; }
.hero-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; position: relative; }
.hero-card { display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.95); color: var(--text); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow-lg); }
.hero-card .hc-body { min-width: 0; }
.hero-card .hc-icon { width: 44px; height: 44px; border-radius: var(--radius-sm); display: grid; place-items: center; color: #fff; flex-shrink: 0; background: var(--gradient-brand); }
.hero-card .hc-icon.blue { background: linear-gradient(135deg, #2563eb, #4f46e5); }
.hero-card .hc-icon.pink { background: linear-gradient(135deg, #7c3aed, #ec4899); }
.hero-card .hc-icon.green { background: var(--gradient-success); }
.hero-card .hc-label { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--primary-dark); }
.hero-card .hc-value { font-size: 17px; font-weight: 800; color: var(--text); margin-top: 2px; }
.hero-card .hc-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.hero-card .hc-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Section title — Exam's icon + text + thin rule ---------- */
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 14px; }
.section-title .st-icon { color: var(--primary); display: flex; }
.section-title h2 { font-size: 15px; font-weight: 700; letter-spacing: -.1px; white-space: nowrap; }
.section-title .st-line { flex: 1; height: 1px; background: var(--border); }
.section-title .st-actions { display: flex; gap: 8px; }

/* ---------- Stat tiles — Exam layout: top accent bar + icon badge ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px 20px; box-shadow: var(--shadow); overflow: hidden; transition: var(--transition-slow); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient-brand); }
.stat-card.clickable:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-100); }
.stat-icon { float: right; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--gradient-brand-soft); color: var(--primary); margin-left: 12px; margin-bottom: 8px; }
.stat-card.tone-green::before { background: var(--gradient-success); } .stat-card.tone-green .stat-icon { background: var(--green-bg); color: var(--green); }
.stat-card.tone-amber::before { background: var(--gradient-warning); } .stat-card.tone-amber .stat-icon { background: var(--amber-bg); color: var(--amber); }
.stat-card.tone-red::before { background: var(--gradient-danger); } .stat-card.tone-red .stat-icon { background: var(--red-bg); color: var(--red); }
.stat-card.tone-purple .stat-icon { background: var(--purple-bg); color: var(--purple); }
.stat-card.tone-gray .stat-icon { background: var(--gray-bg); color: var(--gray); }
.stat-card.tone-indigo .stat-icon { background: var(--primary-100); color: var(--indigo); }
.stat-card.tone-teal .stat-icon { background: var(--teal-bg); color: var(--teal); }
.stat-card.tone-pink .stat-icon { background: #fce7f3; color: #db2777; }
.stat-body { min-width: 0; }
.stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 27px; font-weight: 800; margin-top: 5px; letter-spacing: -.5px; line-height: 1.1; overflow-wrap: anywhere; }
.stat-hint { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.stat-card.compact { padding: 14px 16px 16px; }
.stat-card.compact .stat-icon { width: 34px; height: 34px; border-radius: 10px; }
.stat-card.compact .stat-value { font-size: 21px; }

/* ---------- Breadcrumb / header / tabs ---------- */
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.crumb { color: var(--text-3); cursor: pointer; }
.crumb:hover { color: var(--primary); }
.crumb.current { color: var(--text); font-weight: 500; cursor: default; }
.crumb-sep { display: inline-flex; color: var(--border-strong); }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 14px 0 18px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 700; letter-spacing: -.2px; }
.page-subtitle { color: var(--text-3); margin-top: 4px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 12.5px; margin-bottom: 6px; cursor: pointer; }
.back-link:hover { color: var(--primary); }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 16px; color: var(--text-2); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; border-radius: 8px 8px 0 0; transition: var(--transition); }
.tab:hover { color: var(--primary-dark); background: var(--card-alt); }
.tab.active { color: var(--primary); border-color: var(--primary); background: var(--primary-50); }
.tab-count { background: var(--gray-bg); color: var(--text-2); font-size: 11px; padding: 1px 7px; border-radius: var(--radius-full); font-weight: 600; }
.tab.active .tab-count { background: var(--primary-100); color: var(--primary); }
.module-tabs { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; margin-bottom: 16px; box-shadow: var(--shadow); }
.module-tabs .tab { border: 0; margin: 0; border-radius: var(--radius-sm); padding: 9px 13px; }
.module-tabs .tab.active { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow); }
.module-tabs .tab.active .tab-count { background: rgba(255,255,255,.22); color: #fff; }
.toolbar .tabs { background: var(--card-alt); border: 1px solid var(--border) !important; border-radius: var(--radius-sm); padding: 3px; gap: 3px; overflow-x: auto; }
.toolbar .tabs .tab { border: 0; margin: 0; border-radius: 8px; padding: 6px 10px; font-size: 12.5px; }
.toolbar .tabs .tab.active { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow); }
.toolbar .tabs .tab.active .tab-count { background: rgba(255,255,255,.22); color: #fff; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #f9fbff, #ffffff); border-radius: var(--radius) var(--radius) 0 0; }
.card-title { font-size: 14.5px; font-weight: 700; letter-spacing: -.1px; display: flex; align-items: center; gap: 8px; }
.card-title .ic { color: var(--primary); }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-body > .table-wrap { margin: -20px; border: 0; border-radius: 0; }
.insight-list { display: grid; gap: 12px; }
.insight-item { display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: start; padding: 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-alt); }
.insight-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-100); color: var(--primary); }
.insight-item.tone-green .insight-icon { background: var(--green-bg); color: var(--green); }
.insight-item.tone-amber .insight-icon { background: var(--amber-bg); color: var(--amber); }
.insight-item.tone-red .insight-icon { background: var(--red-bg); color: var(--red); }
.insight-item.tone-purple .insight-icon { background: var(--purple-bg); color: var(--purple); }
.insight-title { font-weight: 800; font-size: 13.5px; }
.insight-copy { color: var(--text-3); font-size: 12.5px; line-height: 1.45; margin-top: 3px; }
.report-book { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 16px; align-items: center; }
.report-book img { width: 118px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.report-book-kicker { font-size: 11px; color: var(--primary); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.report-book h3 { font-size: 20px; line-height: 1.15; margin: 6px 0 4px; }
.report-book p { color: var(--text-3); margin: 0 0 12px; }
.report-book-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--text-3); font-size: 12px; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.action-card { display: flex; align-items: center; gap: 12px; padding: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); transition: var(--transition-slow); }
.action-card.clickable:hover { border-color: var(--primary-200); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.action-card.disabled { opacity: .55; cursor: not-allowed; }
.action-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--gradient-brand-soft); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.action-card.tone-green .action-icon { background: var(--green-bg); color: var(--green); }
.action-card.tone-amber .action-icon { background: var(--amber-bg); color: var(--amber); }
.action-card.tone-red .action-icon { background: var(--red-bg); color: var(--red); }
.action-card.tone-purple .action-icon { background: var(--purple-bg); color: var(--purple); }
.action-card.tone-gray .action-icon { background: var(--gray-bg); color: var(--gray); }
.action-title { font-weight: 700; font-size: 13.5px; }
.action-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.action-go { margin-left: auto; color: var(--text-3); }
.action-body { min-width: 0; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; padding: 11px 14px; background: var(--card-alt); border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; transition: background-color .15s ease; }
.table tr:last-child td { border-bottom: 0; }
.table tr.row-link { cursor: pointer; }
.table tr.row-link:hover td, .table tr:hover td { background: var(--card-alt); }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { margin-left: 4px; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-3); }
.person { display: flex; align-items: center; gap: 10px; }
.person-name { font-weight: 600; }
.person-sub { font-size: 12px; color: var(--text-3); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); font-weight: 700; flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 60px; height: 60px; font-size: 20px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-purple { background: var(--accent-light); color: #6d28d9; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge.lg { font-size: 12px; padding: 4px 13px; }

/* ---------- Buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: var(--transition); }
.btn:hover { background: var(--card-alt); border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-primary { background: var(--gradient-brand); border-color: transparent; color: #fff; box-shadow: 0 4px 12px -3px rgba(79,70,229,.4); }
.btn-primary:hover { background: var(--gradient-brand); border-color: transparent; color: #fff; box-shadow: var(--shadow-glow); filter: brightness(1.06); }
.btn-success { background: var(--gradient-success); border-color: transparent; color: #fff; box-shadow: 0 4px 12px -3px rgba(22,163,74,.35); }
.btn-success:hover { background: var(--gradient-success); border-color: transparent; color: #fff; filter: brightness(1.06); box-shadow: 0 8px 18px -4px rgba(22,163,74,.45); }
.btn-danger { background: var(--gradient-danger); border-color: transparent; color: #fff; box-shadow: 0 4px 12px -3px rgba(220,38,38,.35); }
.btn-danger:hover { background: var(--gradient-danger); border-color: transparent; color: #fff; filter: brightness(1.06); box-shadow: 0 8px 18px -4px rgba(220,38,38,.45); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); box-shadow: none; }
.btn-ghost:hover { background: var(--primary-50); border-color: transparent; }
.btn-outline-danger { color: var(--red); border-color: #fca5a5; background: #fff; }
.btn-outline-danger:hover { background: var(--red-bg); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn.lg { padding: 11px 20px; font-size: 14px; }
.btn.block { width: 100%; justify-content: center; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 16px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.toolbar .spacer { flex: 1; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--card-alt); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 0 11px; color: var(--text-3); min-width: 260px; }
.search-box input { border: 0; outline: 0; padding: 8px 0; font: inherit; width: 100%; background: transparent; color: var(--text); }
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.select, .input { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; font: inherit; background: var(--card-alt); color: var(--text); min-width: 0; width: 100%; transition: var(--transition); }
.select:focus, .input:focus { outline: 0; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.toolbar .select { width: auto; min-width: 150px; }
.view-toggle { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-alt); }
.view-toggle button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--text-2); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.view-toggle button:hover { color: var(--primary-dark); background: var(--primary-50); }
.view-toggle button.active { color: #fff; background: var(--gradient-brand); box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.inline-edit { display: flex; gap: 8px; align-items: center; }
.inline-edit .input, .inline-edit .select { width: 90px; padding: 5px 8px; font-size: 13px; }

/* ---------- KV, callouts, checklist ---------- */
.kv { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 24px; }
.kv-row dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.kv-row dd { margin: 3px 0 0; font-weight: 500; }
.kv.vertical { grid-template-columns: 1fr; gap: 10px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid; }
.callout-info { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.callout-warn { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.callout-danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.callout-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.callout-purple { background: var(--accent-light); border-color: #ddd6fe; color: #6d28d9; }
.callout-title { font-weight: 700; }
.callout-body { margin-top: 3px; font-size: 13px; opacity: .95; }
.callout-icon { flex-shrink: 0; margin-top: 1px; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.checklist li.ok { border-color: #bbf7d0; background: #f0fdf4; }
.checklist li.fail { border-color: #fecaca; background: #fef2f2; }
.chk { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.ok .chk { background: var(--green); color: #fff; } .fail .chk { background: var(--red); color: #fff; }
.chk-label { font-weight: 600; }
.chk-note { margin-left: auto; font-size: 12px; color: var(--text-3); text-align: right; }

/* ---------- Stepper / flow ---------- */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 0; overflow-x: auto; }
.step { flex: 1; min-width: 130px; position: relative; padding: 0 8px 0 0; }
.step::after { content: ''; position: absolute; top: 13px; left: 36px; right: 0; height: 2px; background: var(--border); }
.step:last-child::after { display: none; }
.step.done::after { background: var(--green); }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-3); position: relative; z-index: 1; }
.step.done .step-dot { background: var(--gradient-success); border-color: transparent; color: #fff; }
.step.current .step-dot { background: var(--gradient-brand); border-color: transparent; color: #fff; box-shadow: 0 0 0 4px var(--primary-100); }
.step.rejected .step-dot { background: var(--gradient-danger); border-color: transparent; color: #fff; }
.step-text { margin-top: 8px; }
.step-label { font-size: 12.5px; font-weight: 700; }
.step.todo .step-label { color: var(--text-3); }
.step-sub { font-size: 11.5px; color: var(--text-3); }
.flow { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; }
.flow-node { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; font-weight: 700; display: flex; flex-direction: column; justify-content: center; min-width: 90px; text-align: center; }
.flow-node small { display: block; font-weight: 400; color: var(--text-3); font-size: 11px; margin-top: 2px; }
.flow-node.tone-blue { border-color: var(--blue); background: var(--blue-bg); color: var(--primary-dark); }
.flow-node.tone-purple { border-color: var(--purple); background: var(--purple-bg); color: #6d28d9; }
.flow-node.tone-green { border-color: var(--green); background: var(--green-bg); color: #15803d; }
.flow-node.tone-red { border-color: var(--red); background: var(--red-bg); color: #b91c1c; }
.flow-node.tone-amber { border-color: var(--amber); background: var(--amber-bg); color: #b45309; }
.flow-arrow { display: flex; align-items: center; color: var(--text-3); }
.flow.vertical { flex-direction: column; align-items: flex-start; }
.flow.vertical .flow-arrow { transform: rotate(90deg); margin-left: 40px; }

/* ---------- Charts ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 50px; align-items: center; gap: 12px; font-size: 13px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.bar-track { height: 10px; background: var(--card-alt); border: 1px solid var(--border); border-radius: var(--radius-full); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--radius-full); }
.bar-value { font-weight: 700; text-align: right; }
.tone-blue.bar-fill, .gbar.tone-blue, .progress-fill.tone-blue, .legend i.tone-blue { background: var(--gradient-brand); }
.tone-green.bar-fill, .gbar.tone-green, .progress-fill.tone-green, .legend i.tone-green { background: var(--gradient-success); }
.tone-red.bar-fill, .gbar.tone-red, .progress-fill.tone-red, .legend i.tone-red { background: var(--gradient-danger); }
.tone-amber.bar-fill, .gbar.tone-amber, .progress-fill.tone-amber, .legend i.tone-amber { background: var(--gradient-warning); }
.tone-purple.bar-fill, .gbar.tone-purple, .progress-fill.tone-purple, .legend i.tone-purple { background: var(--purple); }
.tone-gray.bar-fill, .gbar.tone-gray, .progress-fill.tone-gray, .legend i.tone-gray { background: var(--text-soft); }
.gbars-plot { display: flex; gap: 18px; align-items: flex-end; height: 180px; padding: 0 6px; border-bottom: 1px solid var(--border); }
.gbar-group { flex: 1; display: flex; flex-direction: column; height: 100%; }
.gbar-cols { flex: 1; display: flex; align-items: flex-end; gap: 4px; justify-content: center; }
.gbar { width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; }
.gbar-label { font-size: 11.5px; color: var(--text-3); text-align: center; margin-top: 6px; }
.legend { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.progress { height: 8px; background: var(--border); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; }
.donut { display: flex; align-items: center; gap: 22px; }
.donut svg { flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.donut-legend .row { gap: 8px; }
.donut-legend b { margin-left: auto; }

/* ---------- Activity / notifications / lists ---------- */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity li:last-child { border-bottom: 0; }
.act-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--gray); }
.act-dot.issue { background: var(--blue); } .act-dot.return { background: var(--green); } .act-dot.return-req { background: var(--purple); }
.act-dot.reservation { background: var(--amber); } .act-dot.fine { background: var(--red); } .act-dot.payment { background: var(--teal); }
.act-text { font-size: 13px; }
.act-time { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.notif { display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.notif.unread { border-left: 3px solid var(--primary); }
.notif-type { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; }
.notif-title { font-weight: 700; margin-top: 2px; }
.notif-body { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.notif-meta { font-size: 11.5px; color: var(--text-3); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--card-alt); color: var(--text); border: 1px solid var(--border); padding: 3px 11px; border-radius: var(--radius-full); font-size: 11px; font-weight: 600; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-soft); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.empty-title { font-weight: 700; color: var(--text-2); margin-top: 8px; }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ---------- Location tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree-node { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; cursor: pointer; transition: var(--transition); }
.tree-node:hover { border-color: var(--primary-200); box-shadow: var(--shadow); }
.tree-node.selected { border-color: var(--primary); background: var(--primary-50); }
.tree-ic { width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--gray-bg); color: var(--text-2); }
.tree-node.level-floor .tree-ic { background: var(--primary-100); color: var(--primary); }
.tree-node.level-rack .tree-ic { background: var(--purple-bg); color: var(--purple); }
.tree-node.level-shelf .tree-ic { background: var(--amber-bg); color: var(--amber); }
.tree-node.level-row .tree-ic { background: var(--teal-bg); color: var(--teal); }
.tree-title { font-weight: 700; font-size: 13.5px; }
.tree-sub { font-size: 12px; color: var(--text-3); }
.tree-meta { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tree-children { padding-left: 26px; }
.hier { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hier .lvl { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 3px 9px; font-size: 12px; font-weight: 600; }
.hier .lvl.active { background: var(--gradient-brand); color: #fff; border-color: transparent; }

/* ---------- Location manager ---------- */
.loc-guide { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 11px 14px; background: var(--primary-50); color: var(--primary-dark); border: 1px solid var(--primary-100); border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.loc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); transition: var(--transition); }
.loc-card:hover { border-color: var(--primary-200); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.loc-card-head { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.loc-card-head h3 { font-size: 16px; font-weight: 800; }
.loc-card-head p { margin-top: 2px; color: var(--text-3); font-size: 12.5px; }
.loc-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-100); color: var(--primary); }
.loc-icon.rack { background: var(--purple-bg); color: var(--purple); }
.loc-icon.shelf { background: var(--amber-bg); color: var(--amber); }
.loc-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.loc-stats span { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: var(--radius-full); background: var(--card-alt); border: 1px solid var(--border); color: var(--text-2); font-size: 12px; font-weight: 700; }
.loc-stats span.ok { background: var(--green-bg); color: var(--green); border-color: transparent; }
.loc-stats span.busy { background: var(--blue-bg); color: var(--primary-dark); border-color: transparent; }
.loc-pill-row, .loc-mini-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.loc-pill { border: 1px solid var(--border); background: var(--card-alt); color: var(--primary-dark); border-radius: var(--radius-full); padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.loc-pill:hover { background: var(--primary-50); border-color: var(--primary-200); }
.loc-mini-list span { background: var(--card-alt); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.loc-path { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: -4px 0 8px; color: var(--text-3); font-size: 12.5px; }
.loc-path a { color: var(--primary); font-weight: 700; cursor: pointer; }
.loc-path span { color: var(--text); font-weight: 700; }

/* ---------- Book result cards (member search) ---------- */
.catalog-book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.catalog-book-card { position: relative; aspect-ratio: 2 / 3; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; box-shadow: var(--shadow); transition: var(--transition); }
.catalog-book-card:hover { border-color: var(--primary-200); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.catalog-book-top { display: block; }
.catalog-cover { position: absolute; inset: 0 0 50%; width: 100%; height: 50%; border-radius: 0; object-fit: cover; border: 0; border-bottom: 1px solid var(--border); background: var(--card-alt); box-shadow: none; }
.catalog-cover.empty { display: grid; place-items: center; color: var(--text-soft); }
.catalog-book-main { position: absolute; left: 13px; right: 13px; top: calc(50% + 12px); min-width: 0; }
.catalog-book-main .badge { position: absolute; top: -36px; left: 0; box-shadow: var(--shadow); }
.catalog-book-main .row { gap: 6px; }
.catalog-book-main h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 9px; font-size: 15px; font-weight: 800; line-height: 1.22; min-height: 36px; }
.catalog-book-main p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; color: var(--text-3); font-size: 12.5px; }
.catalog-book-meta { position: absolute; left: 13px; right: 13px; top: calc(50% + 102px); display: flex; flex-direction: column; gap: 4px; color: var(--text-2); font-size: 11.5px; }
.catalog-book-meta span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.catalog-book-meta span:nth-child(1) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.catalog-book-counts { position: absolute; left: 13px; right: 13px; bottom: 49px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.catalog-book-counts div { background: var(--card-alt); border: 1px solid var(--border); border-radius: 7px; padding: 5px 4px; text-align: center; min-width: 0; }
.catalog-book-counts b { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-book-counts b.ok { color: var(--green); }
.catalog-book-counts b.busy { color: var(--primary); }
.catalog-book-counts span { display: block; color: var(--text-3); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin-top: 1px; }
.catalog-book-card > .row.between { position: absolute; left: 13px; right: 13px; bottom: 12px; gap: 8px; }
.catalog-book-card > .row.between .btn { padding: 5px 10px; }
.catalog-book-card > .row.between .muted { max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.book-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); transition: var(--transition); }
.book-card:hover { border-color: var(--primary-200); box-shadow: var(--shadow-lg); }
.book-title { font-weight: 700; font-size: 15px; }
.book-meta { font-size: 12.5px; color: var(--text-3); }
.book-loc { background: var(--card-alt); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; }
.book-loc .loc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.book-loc .loc-cell { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px; text-align: center; }
.book-loc .loc-cell small { display: block; font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.book-loc .loc-cell b { font-size: 14px; }
.book-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.book-card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.book-thumb-sm { width: 44px; height: 58px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); background: var(--card-alt); flex-shrink: 0; }
.book-detail-head { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 18px; align-items: start; }
.book-thumb-lg, .book-thumb-empty { width: 132px; height: 176px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card-alt); }
.book-thumb-lg { object-fit: cover; display: block; }
.book-thumb-empty { display: grid; place-items: center; align-content: center; gap: 8px; color: var(--text-soft); text-align: center; font-size: 12px; padding: 12px; }
.file-input { padding: 8px 10px; }
.scan-box { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; background: var(--surface); }
.scan-box .scan-ic { width: 56px; height: 56px; border-radius: var(--radius); background: var(--gradient-brand-soft); color: var(--primary); display: grid; place-items: center; margin: 0 auto 10px; }

/* ---------- Modal / toast ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal.lg { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 17px 22px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #f9fbff, #ffffff); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--card-alt); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--text); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13.5px; opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 420px; }
.toast.show { opacity: 1; transform: none; }
.toast-success { background: #14532d; } .toast-error { background: #7f1d1d; } .toast-info { background: #1e3a8a; }

/* ---------- Misc ---------- */
.summary-strip { display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 16px; background: var(--card-alt); border-radius: var(--radius-sm); }
.summary-strip div b { display: block; font-size: 16px; }
.summary-strip div span { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.policy-table .input { width: 90px; }
.hold-banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; font-size: 13px; font-weight: 600; }
.readonly-banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--gray-bg); color: var(--gray); font-size: 13px; margin-bottom: 14px; }
.member-hero { display: flex; gap: 18px; align-items: center; }
.member-hero h2 { font-size: 20px; }
.demo-note { font-size: 11.5px; color: var(--text-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); } .grid-main { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .shell, body.sidebar-collapsed .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; z-index: 50; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open::after { content: ''; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 40; }
  body.sidebar-collapsed .sidebar-brand { flex-direction: row; gap: 10px; padding: 14px 14px 12px; }
  body.sidebar-collapsed .sidebar-brand .brand-text, body.sidebar-collapsed .sidebar-user .su-text, body.sidebar-collapsed .sidebar-section,
  body.sidebar-collapsed .nav-link span, body.sidebar-collapsed .sidebar-foot { display: block; }
  body.sidebar-collapsed .nav-item.open > .subnav { display: block; }
  body.sidebar-collapsed .sidebar-user { justify-content: flex-start; margin: 0 14px; }
  body.sidebar-collapsed .nav { padding: 0 10px 16px; }
  body.sidebar-collapsed .nav-link { justify-content: flex-start; padding: 9px 11px; }
  .sidebar-brand .collapse-btn { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .menu-btn { display: grid; }
  .topbar .role-tag, .topbar .icon-btn[title="Reset demo data"] { display: none; }
  .topbar-right { gap: 4px; }
  .hero-card { flex-wrap: wrap; }
  .hero-card .hc-actions { margin-left: 0; width: 100%; }
  .content { padding: 16px; }
  .hero { padding: 18px; }
  .hero-title { font-size: 24px; }
  .hero-cards { grid-template-columns: 1fr; }
  .hero-box { min-width: 0; flex: 1; }
  .section-title h2 { font-size: 14px; white-space: normal; }
  .login-grid { gap: 0; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .book-detail-head { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 44px; }
  .user-chip .uc-text { display: none; }
}
@media (max-width: 560px) { .role-cards { grid-template-columns: 1fr; } .hero-side { width: 100%; } }
