/* ==========================================================================
   DigiLibrary design system
   - Inter variable font (vendored, OFL), light + dark themes
   - Motion: short, eased transitions; everything disabled under
     prefers-reduced-motion
   - No inline styles anywhere (strict CSP): animation delays use classes
   ========================================================================== */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url('../vendor/inter/inter-latin-wght-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url('../vendor/inter/inter-latin-ext-wght-normal.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
    --dl-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
    --dl-primary: #4f46e5;
    --dl-primary-2: #7c3aed;
    --dl-primary-rgb: 79, 70, 229;
    --dl-accent: #06b6d4;
    --dl-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #c026d3 100%);
    --dl-grad-soft: linear-gradient(135deg, rgba(79,70,229,.12), rgba(124,58,237,.10));

    --dl-bg: #f5f6fb;
    --dl-surface: #ffffff;
    --dl-surface-2: #f8f9fd;
    --dl-border: #e6e8f0;
    --dl-text: #111827;
    --dl-muted: #6b7280;

    --dl-sidebar-bg: #0f1226;
    --dl-sidebar-bg-2: #171a3a;
    --dl-sidebar-fg: #a9afd6;
    --dl-sidebar-fg-hover: #ffffff;

    --dl-radius: 14px;
    --dl-radius-sm: 10px;
    --dl-shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --dl-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .12);
    --dl-shadow-lg: 0 20px 45px -20px rgba(30, 27, 75, .35);

    --dl-ease: cubic-bezier(.22, 1, .36, 1);
    --dl-ease-in-out: cubic-bezier(.65, 0, .35, 1);
    --dl-fast: 160ms;
    --dl-med: 320ms;
    --dl-slow: 600ms;

    --dl-topbar-h: 52px;
    --dl-rail-w: 72px;
    --dl-sidebar-w: 236px;
    --dl-sidebar-w-collapsed: 0px;
    --dl-header-bg: #242447;

    --bs-body-font-family: var(--dl-font);
    --bs-primary: var(--dl-primary);
    --bs-primary-rgb: var(--dl-primary-rgb);
    --bs-link-color: var(--dl-primary);
    --bs-link-color-rgb: var(--dl-primary-rgb);
    --bs-link-hover-color: var(--dl-primary-2);
    --bs-border-radius: var(--dl-radius-sm);
    --bs-border-radius-lg: var(--dl-radius);
}

/* Platform area gets a distinct (amber/teal) identity so operators never confuse it with a tenant. */
body.platform {
    --dl-primary: #0d9488;
    --dl-primary-2: #0891b2;
    --dl-primary-rgb: 13, 148, 136;
    --dl-grad: linear-gradient(135deg, #0d9488 0%, #0891b2 60%, #2563eb 100%);
    --dl-grad-soft: linear-gradient(135deg, rgba(13,148,136,.12), rgba(8,145,178,.10));
    --dl-sidebar-bg: #071a1f;
    --dl-sidebar-bg-2: #0c2a31;
    --dl-sidebar-fg: #9cc9c6;
    --dl-header-bg: #12343b;
}

[data-bs-theme="dark"] {
    --dl-bg: #0b0d17;
    --dl-surface: #12152a;
    --dl-surface-2: #171b35;
    --dl-border: #242a4a;
    --dl-text: #e6e8f5;
    --dl-muted: #9aa0c3;
    --dl-shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -12px rgba(0,0,0,.6);
    --dl-shadow-lg: 0 24px 50px -20px rgba(0,0,0,.8);
    --bs-body-bg: var(--dl-bg);
    --bs-body-color: var(--dl-text);
    --bs-border-color: var(--dl-border);
    --bs-secondary-color: var(--dl-muted);
    --bs-tertiary-bg: var(--dl-surface-2);
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
body {
    font-family: var(--dl-font);
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    color: var(--dl-text);
    background: var(--dl-bg);
    letter-spacing: -0.006em;
}
h1, h2, h3, .h1, .h2, .h3, .h4 { letter-spacing: -0.022em; font-weight: 700; }
::selection { background: rgba(var(--dl-primary-rgb), .18); }
a { transition: color var(--dl-fast) ease; }
.text-gradient { background: var(--dl-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.skip-link { position: absolute; left: 1rem; top: .5rem; z-index: 2000; background: var(--dl-surface); padding: .5rem 1rem; border-radius: 8px; }
code { color: var(--dl-primary-2); }

/* Page load: fade/slide in; page leave: fade out (set by JS). */
.app-main, .auth-card, .landing { animation: dl-page-in var(--dl-slow) var(--dl-ease) both; }
body.is-leaving .app-main, body.is-leaving .auth-card { opacity: 0; transform: translateY(6px); transition: opacity 180ms ease, transform 180ms ease; }
@keyframes dl-page-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Staggered reveal for direct children marked .stagger (cards, list rows, table rows). */
.stagger > *, .stagger tbody > tr { animation: dl-rise var(--dl-slow) var(--dl-ease) both; }
.stagger > *:nth-child(1), .stagger tbody > tr:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2), .stagger tbody > tr:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3), .stagger tbody > tr:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4), .stagger tbody > tr:nth-child(4) { animation-delay: 160ms; }
.stagger > *:nth-child(5), .stagger tbody > tr:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6), .stagger tbody > tr:nth-child(6) { animation-delay: 240ms; }
.stagger > *:nth-child(7), .stagger tbody > tr:nth-child(7) { animation-delay: 280ms; }
.stagger > *:nth-child(8), .stagger tbody > tr:nth-child(8) { animation-delay: 320ms; }
.stagger > *:nth-child(n+9), .stagger tbody > tr:nth-child(n+9) { animation-delay: 360ms; }
@keyframes dl-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

/* Scroll-triggered reveal (IntersectionObserver adds .is-visible). */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity var(--dl-slow) var(--dl-ease), transform var(--dl-slow) var(--dl-ease); }
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Top bar ---------- */
.app-body { min-height: 100vh; }
.app-main:focus { outline: none; }
.app-body::before {
    content: ''; position: fixed; z-index: 2000; top: 0; left: 0; width: 100%; height: 3px;
    background: var(--dl-grad); transform: scaleX(0); transform-origin: left; opacity: 0;
    transition: opacity var(--dl-fast) ease, transform var(--dl-med) var(--dl-ease);
}
.app-body.is-navigating::before { opacity: 1; transform: scaleX(.72); animation: dl-nav-progress 1.2s var(--dl-ease) infinite alternate; }
.app-body.is-navigating .app-main { opacity: .68; transition: opacity var(--dl-fast) ease; }
@keyframes dl-nav-progress { from { transform: scaleX(.12); } to { transform: scaleX(.88); } }
/* PJAX transitions belong to the changing content only. The shell must never
   blink, slide or cross-fade when a sidebar link is used. */
html, body, .app-topbar, .app-rail, .app-sidebar { view-transition-name: none; }
.app-main { view-transition-name: main-content; }
::view-transition-old(main-content) { animation: dl-view-out 120ms ease both; }
::view-transition-new(main-content) { animation: dl-view-in 220ms var(--dl-ease) both; }
@keyframes dl-view-out { to { opacity: .4; } }
@keyframes dl-view-in { from { opacity: .55; transform: translateY(3px); } }
.app-topbar {
    height: var(--dl-topbar-h);
    background: var(--dl-header-bg);
    color: #fff;
    border-bottom: 0;
    box-shadow: 0 1px 0 rgba(255,255,255,.08);
    transition: box-shadow var(--dl-med) ease, background var(--dl-med) ease;
    z-index: 1030;
}
.app-topbar.is-scrolled { box-shadow: 0 5px 18px rgba(10,12,30,.2); }
.topbar-brand { width: 292px; display: flex; align-items: center; gap: .65rem; font-weight: 650; font-size: .92rem; color: #fff; min-width: 0; }
.topbar-brand-mark { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.12); flex: 0 0 auto; }
.topbar-command { width: min(46vw, 560px); height: 34px; display: flex; align-items: center; gap: .55rem; padding: 0 .75rem; border-radius: 6px; color: rgba(255,255,255,.76); background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.06); transition: background var(--dl-fast), box-shadow var(--dl-fast); }
.topbar-command:focus-within { background: #fff; color: #475569; box-shadow: 0 0 0 2px rgba(255,255,255,.22); }
.topbar-command input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: inherit; font-size: .86rem; }
.topbar-command input::placeholder { color: inherit; opacity: .78; }
.topbar-command kbd { border: 0; border-radius: 4px; padding: .12rem .35rem; color: inherit; background: rgba(0,0,0,.14); font: 500 .68rem/1 var(--dl-font); }
.topbar-command:focus-within kbd { background: #eef0f5; }
.app-topbar .icon-btn { width: 34px; height: 34px; border: 0; border-radius: 7px; background: transparent; color: rgba(255,255,255,.86); }
.app-topbar .icon-btn:hover { color: #fff; background: rgba(255,255,255,.12); box-shadow: none; transform: none; }
.app-topbar .user-chip { padding: .15rem .5rem .15rem .15rem; border: 0; border-radius: 7px; background: transparent; color: #fff; }
.app-topbar .user-chip:hover, .app-topbar .user-chip[aria-expanded="true"] { border-color: transparent; background: rgba(255,255,255,.1); box-shadow: none; }
.app-topbar .avatar { width: 30px; height: 30px; }
.icon-btn {
    width: 40px; height: 40px; display: inline-grid; place-items: center;
    border-radius: 12px; border: 1px solid var(--dl-border); background: var(--dl-surface);
    color: var(--dl-text); transition: transform var(--dl-fast) var(--dl-ease), background var(--dl-fast), border-color var(--dl-fast), box-shadow var(--dl-fast);
}
.icon-btn:hover { transform: translateY(-1px); border-color: rgba(var(--dl-primary-rgb), .35); box-shadow: var(--dl-shadow); color: var(--dl-primary); }
.icon-btn:active { transform: translateY(0) scale(.96); }
.theme-toggle .bi-sun { display: none; }
[data-bs-theme="dark"] .theme-toggle .bi-sun { display: inline; }
[data-bs-theme="dark"] .theme-toggle .bi-moon-stars { display: none; }

.user-chip {
    display: inline-flex; align-items: center; gap: .6rem; padding: .3rem .75rem .3rem .3rem;
    border-radius: 999px; border: 1px solid var(--dl-border); background: var(--dl-surface); color: var(--dl-text);
    transition: box-shadow var(--dl-fast), border-color var(--dl-fast);
}
.user-chip:hover, .user-chip[aria-expanded="true"] { border-color: rgba(var(--dl-primary-rgb), .4); box-shadow: var(--dl-shadow); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
    background: var(--dl-grad); color: #fff; font-weight: 700; font-size: .8rem; flex: 0 0 auto;
}
.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }

.dropdown-menu {
    --bs-dropdown-border-radius: 14px;
    --bs-dropdown-link-active-bg: rgba(var(--dl-primary-rgb), .12);
    --bs-dropdown-link-active-color: var(--dl-primary);
    border: 1px solid var(--dl-border); box-shadow: var(--dl-shadow-lg); padding: .4rem; background: var(--dl-surface);
    transform-origin: top right;
}
.dropdown-menu.show { animation: dl-pop 220ms var(--dl-ease) both; }
.dropdown-item { border-radius: 9px; padding: .5rem .75rem; transition: background var(--dl-fast); }
@keyframes dl-pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- Teams-inspired rail + contextual sidebar ---------- */
.app-shell { display: flex; min-height: calc(100vh - var(--dl-topbar-h)); }
.app-rail {
    width: var(--dl-rail-w); flex: 0 0 var(--dl-rail-w); position: sticky; top: var(--dl-topbar-h);
    height: calc(100vh - var(--dl-topbar-h)); z-index: 1010; flex-direction: column; align-items: center;
    padding: .55rem .35rem; background: #f0f0f6; border-right: 1px solid #dedfe8; color: #4b4d62;
}
[data-bs-theme="dark"] .app-rail { background: #15172a; border-right-color: #292d49; color: #bec3dc; }
.app-rail-brand { width: 42px; height: 38px; display: grid; place-items: center; margin-bottom: .45rem; border-radius: 9px; color: #fff; background: var(--dl-grad); font-size: 1.12rem; }
.app-rail-button { position: relative; cursor: pointer; width: 64px; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; padding: .35rem .15rem; border: 0; border-radius: 7px; background: transparent; color: inherit; font-size: .65rem; line-height: 1.1; transition: color var(--dl-fast), background var(--dl-fast); }
.app-rail-button .bi { font-size: 1.25rem; }
.app-rail-button:hover { color: var(--dl-primary); background: rgba(var(--dl-primary-rgb),.07); }
.app-rail-button.active { color: var(--dl-primary); background: var(--dl-surface); box-shadow: 0 1px 4px rgba(16,24,40,.1); }
.app-rail-button.active::before { content: ''; position: absolute; left: 0; width: 3px; height: 28px; border-radius: 0 3px 3px 0; background: var(--dl-primary); }
.app-rail-button:last-child { margin-top: auto; }
.app-sidebar { background: var(--dl-surface) !important; color: var(--dl-text); border-right: 1px solid var(--dl-border); }
@media (min-width: 992px) {
    .app-sidebar {
        width: var(--dl-sidebar-w); flex: 0 0 var(--dl-sidebar-w);
        position: sticky; top: var(--dl-topbar-h); height: calc(100vh - var(--dl-topbar-h));
        overflow: hidden;
        transition: width var(--dl-med) var(--dl-ease), flex-basis var(--dl-med) var(--dl-ease);
    }
    body.sidebar-collapsed .app-sidebar { width: var(--dl-sidebar-w-collapsed); flex-basis: var(--dl-sidebar-w-collapsed); }
    body.sidebar-collapsed .app-sidebar > * { visibility: hidden; }
}
@media (max-width: 991.98px) {
    .app-sidebar.offcanvas-lg { --bs-offcanvas-width: 288px; --bs-offcanvas-color: var(--dl-text); --bs-offcanvas-bg: var(--dl-surface); --bs-offcanvas-transition: transform .38s var(--dl-ease); }
    .offcanvas-backdrop.show { opacity: .45; backdrop-filter: blur(2px); }
    .sidebar-menu-panel { display: block !important; }
    .topbar-brand { width: auto; max-width: 170px; margin-right: auto; }
    .topbar-command { order: 5; width: min(48vw, 360px); margin-left: auto !important; margin-right: 0 !important; }
}
.app-sidebar .offcanvas-body { display: flex; flex-direction: column; min-height: 100%; }
.sidebar-panel-heading { height: 62px; flex: 0 0 62px; align-items: center; justify-content: space-between; padding: .65rem .75rem .65rem 1.15rem; border-bottom: 1px solid var(--dl-border); }
.sidebar-panel-heading small { display: block; color: var(--dl-muted); font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-panel-heading strong { display: block; margin-top: .08rem; font-size: 1rem; }
.sidebar-panel-close { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--dl-muted); }
.sidebar-panel-close:hover { background: var(--dl-surface-2); color: var(--dl-primary); }
.sidebar-menu-scroll { overflow-y: auto; flex: 1; min-height: 0; padding-top: .35rem; }
.sidebar-menu-panel { display: none; }
.sidebar-menu-panel.active { display: block; }
.app-sidebar.is-searching .sidebar-menu-panel { display: block; }
.app-sidebar .nav { padding: .2rem .65rem .6rem; gap: 2px; }
.app-sidebar .nav-link {
    position: relative; display: flex; align-items: center; gap: .8rem;
    padding: .56rem .7rem; border-radius: 6px; color: var(--dl-text); font-weight: 500; font-size: .87rem;
    transition: color var(--dl-fast) ease, background var(--dl-fast) ease, transform var(--dl-fast) var(--dl-ease);
    white-space: nowrap;
}
.app-sidebar .nav-link span { transition: opacity var(--dl-fast) ease; }
.app-sidebar .nav-link .bi { width: 20px; text-align: center; font-size: 1rem; color: var(--dl-muted); transition: color var(--dl-fast); }
.app-sidebar .nav-link:hover { color: var(--dl-text); background: var(--dl-surface-2); }
.app-sidebar .nav-link:hover .bi { color: var(--dl-primary); }
.app-sidebar .nav-link:active { transform: scale(.98); }
.app-sidebar .nav-link.active {
    color: var(--dl-primary); background: rgba(var(--dl-primary-rgb),.09); box-shadow: none; font-weight: 650;
}
.app-sidebar .nav-link.active::before { content: ''; position: absolute; left: -.65rem; width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--dl-primary); }
.app-sidebar .nav-link.active .bi { color: var(--dl-primary); }
.app-sidebar .nav-section {
    text-transform: uppercase; font-size: .66rem; font-weight: 650; letter-spacing: .1em; color: var(--dl-muted);
    padding: .8rem 1.35rem .35rem;
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; color: var(--dl-text); font-weight: 700; border-bottom: 1px solid var(--dl-border); }
.brand-mark {
    width: 36px; height: 36px; border-radius: 11px; display: inline-grid; place-items: center;
    background: var(--dl-grad); color: #fff; box-shadow: 0 8px 20px -8px rgba(var(--dl-primary-rgb), .8); flex: 0 0 auto;
}
.sidebar-card {
    margin: .7rem; padding: .8rem .9rem; border-radius: 8px;
    background: var(--dl-surface-2); border: 1px solid var(--dl-border); color: var(--dl-muted); font-size: .75rem;
    transition: opacity var(--dl-fast);
}
.sidebar-card strong { color: var(--dl-text); }
.sidebar-no-results { margin: 2rem 1rem; display: grid; place-items: center; gap: .35rem; color: var(--dl-muted); text-align: center; }
.sidebar-no-results[hidden] { display: none; }
.sidebar-no-results .bi { font-size: 1.5rem; }
.sidebar-no-results span { font-size: .78rem; }

.app-main { flex: 1; min-width: 0; padding: 1.75rem 2rem 3rem; }
@media (max-width: 575.98px) { .topbar-brand span:last-child { display: none; }.topbar-command { width: auto; flex: 1; }.topbar-command input { width: 100%; }.app-main { padding: 1.1rem 1rem 2.5rem; } }

/* ---------- Page header ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--dl-muted); margin: .25rem 0 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 600; color: var(--dl-primary); }

/* ---------- Cards ---------- */
.card {
    --bs-card-bg: var(--dl-surface);
    --bs-card-border-color: var(--dl-border);
    --bs-card-border-radius: var(--dl-radius);
    --bs-card-cap-bg: transparent;
    box-shadow: var(--dl-shadow-sm);
    transition: box-shadow var(--dl-med) var(--dl-ease), transform var(--dl-med) var(--dl-ease), border-color var(--dl-med);
}
.card-header { font-weight: 650; padding: 1rem 1.25rem; border-bottom-color: var(--dl-border); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--dl-shadow-lg); border-color: rgba(var(--dl-primary-rgb), .25); }

.stat-card { position: relative; overflow: hidden; }
.stat-card::after {
    content: ''; position: absolute; inset: auto -40px -60px auto; width: 160px; height: 160px; border-radius: 50%;
    background: var(--dl-grad-soft); transition: transform var(--dl-slow) var(--dl-ease);
}
.stat-card:hover::after { transform: scale(1.25); }
.stat-icon {
    width: 44px; height: 44px; border-radius: 12px; display: inline-grid; place-items: center; font-size: 1.25rem;
    background: rgba(var(--dl-primary-rgb), .1); color: var(--dl-primary); margin-bottom: .9rem;
    transition: transform var(--dl-med) var(--dl-ease);
}
.stat-card:hover .stat-icon { transform: rotate(-8deg) scale(1.08); }
.stat-icon.tone-teal { background: rgba(13,148,136,.12); color: #0d9488; }
.stat-icon.tone-amber { background: rgba(217,119,6,.12); color: #d97706; }
.stat-icon.tone-pink { background: rgba(219,39,119,.12); color: #db2777; }
.stat-label { color: var(--dl-muted); font-size: .84rem; font-weight: 500; }
.stat-value { font-size: 2.1rem; font-weight: 750; line-height: 1.1; margin-top: .2rem; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-link { position: relative; z-index: 1; font-size: .83rem; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; margin-top: .6rem; }
.stat-link .bi { transition: transform var(--dl-fast) var(--dl-ease); }
.stat-link:hover .bi { transform: translateX(3px); }

.hero-card {
    position: relative; overflow: hidden; border: 0; color: #fff; background: var(--dl-grad);
    box-shadow: 0 24px 50px -24px rgba(var(--dl-primary-rgb), .8);
}
.hero-card .card-body { position: relative; z-index: 1; padding: 1.6rem 1.75rem; }
.hero-card::before, .hero-card::after {
    content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.12);
    animation: dl-float 12s var(--dl-ease-in-out) infinite alternate;
}
.hero-card::before { width: 260px; height: 260px; right: -60px; top: -120px; }
.hero-card::after { width: 180px; height: 180px; right: 140px; bottom: -110px; animation-duration: 15s; }
.hero-card .text-white-75 { color: rgba(255,255,255,.82); }
@keyframes dl-float { from { transform: translate(0, 0) scale(1); } to { transform: translate(-24px, 18px) scale(1.08); } }

/* Checklist */
.checklist .list-group-item { display: flex; gap: .8rem; align-items: center; padding: .9rem 1.25rem; background: transparent; border-color: var(--dl-border); }
.check-dot { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: 0 0 auto; font-size: .85rem; border: 2px solid var(--dl-border); color: var(--dl-muted); }
.check-dot.done { border-color: transparent; background: #10b981; color: #fff; animation: dl-check 500ms var(--dl-ease) both; }
@keyframes dl-check { 0% { transform: scale(.4); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* Activity timeline */
.timeline { list-style: none; margin: 0; padding: .5rem 1.25rem 1rem; }
.timeline li { position: relative; padding: .6rem 0 .6rem 1.4rem; border-left: 2px solid var(--dl-border); margin-left: .35rem; }
.timeline li::before {
    content: ''; position: absolute; left: -7px; top: .95rem; width: 12px; height: 12px; border-radius: 50%;
    background: var(--dl-surface); border: 3px solid var(--dl-primary);
}
.timeline .meta { color: var(--dl-muted); font-size: .8rem; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(var(--dl-primary-rgb), .045); margin: 0; }
.table > thead th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--dl-muted);
    background: var(--dl-surface-2); border-bottom: 1px solid var(--dl-border); padding: .8rem 1rem; white-space: nowrap;
}
.table > tbody td { padding: .85rem 1rem; border-color: var(--dl-border); }
.table > tbody tr { transition: background var(--dl-fast) ease; }
.table-card { overflow: hidden; }
.person { display: flex; align-items: center; gap: .75rem; }
.person .avatar { width: 36px; height: 36px; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; letter-spacing: .01em; padding: .42em .7em; border-radius: 999px; }
.badge-soft { background: rgba(var(--dl-primary-rgb), .1); color: var(--dl-primary); }
.status-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px; }
.status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-success { background: rgba(16,185,129,.12); color: #059669; }
.status-success::before { animation: dl-pulse 2s ease-out infinite; }
.status-info { background: rgba(59,130,246,.12); color: #2563eb; }
.status-warning { background: rgba(245,158,11,.14); color: #b45309; }
.status-danger { background: rgba(239,68,68,.12); color: #dc2626; }
.status-secondary { background: rgba(107,114,128,.14); color: #4b5563; }
.status-dark { background: rgba(17,24,39,.12); color: #111827; }
[data-bs-theme="dark"] .status-secondary { color: #b6bcd6; }
[data-bs-theme="dark"] .status-dark { background: rgba(255,255,255,.1); color: #e5e7eb; }
@keyframes dl-pulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.55); } 70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }

/* ---------- Buttons ---------- */
.btn {
    --bs-btn-font-weight: 600; --bs-btn-border-radius: 11px;
    position: relative; overflow: hidden;
    transition: transform var(--dl-fast) var(--dl-ease), box-shadow var(--dl-fast) ease, background-color var(--dl-fast), border-color var(--dl-fast), color var(--dl-fast);
}
.btn:active { transform: scale(.97); }
.btn-primary {
    --bs-btn-bg: var(--dl-primary); --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: var(--dl-primary-2); --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: var(--dl-primary-2); --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-bg: var(--dl-primary); --bs-btn-disabled-border-color: transparent;
    background-image: var(--dl-grad); background-size: 160% 160%; background-position: 0% 50%;
    box-shadow: 0 8px 20px -10px rgba(var(--dl-primary-rgb), .9);
}
.btn-primary:hover { background-position: 100% 50%; transform: translateY(-1px); box-shadow: 0 14px 28px -12px rgba(var(--dl-primary-rgb), .9); }
.btn-outline-primary { --bs-btn-color: var(--dl-primary); --bs-btn-border-color: rgba(var(--dl-primary-rgb), .35); --bs-btn-hover-bg: var(--dl-primary); --bs-btn-hover-border-color: var(--dl-primary); }
.btn-outline-secondary { --bs-btn-color: var(--dl-text); --bs-btn-border-color: var(--dl-border); --bs-btn-hover-bg: var(--dl-surface-2); --bs-btn-hover-color: var(--dl-text); --bs-btn-hover-border-color: var(--dl-border); background: var(--dl-surface); }
.btn-ghost { --bs-btn-color: var(--dl-muted); --bs-btn-hover-color: var(--dl-text); --bs-btn-hover-bg: var(--dl-surface-2); border: 0; }
.btn .bi { transition: transform var(--dl-fast) var(--dl-ease); }
.btn:hover .bi-plus-lg, .btn:hover .bi-person-plus { transform: rotate(90deg); }
.btn:hover .bi-arrow-right { transform: translateX(3px); }
.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading::after {
    content: ''; position: absolute; inset: 0; margin: auto; width: 1.1rem; height: 1.1rem; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: dl-spin 700ms linear infinite;
}
.btn-outline-primary.is-loading::after, .btn-outline-secondary.is-loading::after, .btn-outline-danger.is-loading::after, .btn-outline-success.is-loading::after { border-color: rgba(var(--dl-primary-rgb), .25); border-top-color: var(--dl-primary); }
@keyframes dl-spin { to { transform: rotate(360deg); } }
/* Ripple (span injected by JS) */
.ripple { position: absolute; border-radius: 50%; transform: scale(0); background: currentColor; opacity: .22; pointer-events: none; animation: dl-ripple 600ms var(--dl-ease) forwards; }
.btn-primary .ripple { background: #fff; opacity: .35; }
@keyframes dl-ripple { to { transform: scale(2.6); opacity: 0; } }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .86rem; margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: 11px; border-color: var(--dl-border); background-color: var(--dl-surface); padding: .62rem .9rem;
    transition: border-color var(--dl-fast) ease, box-shadow var(--dl-fast) ease, background-color var(--dl-fast);
}
.form-control:hover, .form-select:hover { border-color: rgba(var(--dl-primary-rgb), .35); }
.form-control:focus, .form-select:focus { border-color: var(--dl-primary); box-shadow: 0 0 0 4px rgba(var(--dl-primary-rgb), .14); }
.form-control.is-invalid, .form-select.is-invalid { animation: dl-shake 420ms var(--dl-ease) 1; }
@keyframes dl-shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
.form-check-input { cursor: pointer; transition: background-color var(--dl-fast), border-color var(--dl-fast), box-shadow var(--dl-fast); }
.form-check-input:checked { background-color: var(--dl-primary); border-color: var(--dl-primary); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(var(--dl-primary-rgb), .14); border-color: var(--dl-primary); }
.input-icon { position: relative; }
.input-icon > .bi { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--dl-muted); pointer-events: none; transition: color var(--dl-fast); }
.input-icon > .form-control { padding-left: 2.5rem; }
.input-icon:focus-within > .bi { color: var(--dl-primary); }
.password-toggle { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--dl-muted); padding: .3rem .5rem; border-radius: 8px; }
.password-toggle:hover { color: var(--dl-primary); }

/* Selectable option tiles (roles, scope) */
.option-tile { position: relative; display: block; height: 100%; cursor: pointer; }
.option-tile input { position: absolute; opacity: 0; pointer-events: none; }
.option-tile .tile {
    display: block; position: relative; height: 100%; padding: .9rem 1rem .9rem 3rem; border-radius: 13px; border: 1.5px solid var(--dl-border); background: var(--dl-surface);
    transition: border-color var(--dl-fast) ease, box-shadow var(--dl-fast) ease, transform var(--dl-fast) var(--dl-ease), background var(--dl-fast);
}
.option-tile .tile::before {
    content: ''; position: absolute; left: 1rem; top: 1.05rem; width: 20px; height: 20px; border-radius: 6px;
    border: 2px solid var(--dl-border); background: var(--dl-surface) center/12px no-repeat;
    transition: background-color var(--dl-fast), border-color var(--dl-fast), transform var(--dl-fast) var(--dl-ease);
}
.option-tile input[type=radio] + .tile::before { border-radius: 50%; }
.option-tile:hover .tile { border-color: rgba(var(--dl-primary-rgb), .45); transform: translateY(-1px); }
.option-tile input:focus-visible + .tile { box-shadow: 0 0 0 4px rgba(var(--dl-primary-rgb), .18); }
.option-tile input:checked + .tile { border-color: var(--dl-primary); background: rgba(var(--dl-primary-rgb), .05); box-shadow: 0 10px 24px -16px rgba(var(--dl-primary-rgb), .8); }
.option-tile input:checked + .tile::before {
    background-color: var(--dl-primary); border-color: var(--dl-primary); transform: scale(1.05);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}
.option-tile .tile-title { font-weight: 650; display: block; }
.option-tile .tile-desc { display: block; font-size: .8rem; color: var(--dl-muted); margin-top: .15rem; }

/* Collapsible region (branch picker) */
.collapse-smooth { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--dl-med) var(--dl-ease), opacity var(--dl-med) ease; }
.collapse-smooth > .collapse-inner { overflow: hidden; }
.collapse-smooth.is-collapsed { grid-template-rows: 0fr; opacity: 0; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--dl-muted); background: var(--dl-surface); border: 1.5px dashed var(--dl-border); border-radius: var(--dl-radius); }
.empty-state .empty-icon { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 18px; display: grid; place-items: center; font-size: 1.7rem; background: var(--dl-grad-soft); color: var(--dl-primary); animation: dl-bob 3s ease-in-out infinite; }
@keyframes dl-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- Filter bar ---------- */
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end !important; gap: .75rem !important;
    background: var(--dl-surface); border: 1px solid var(--dl-border);
    border-radius: var(--dl-radius); padding: 1rem; margin: 0 0 1.25rem;
    box-shadow: var(--dl-shadow-sm); --bs-gutter-x: 0; --bs-gutter-y: 0;
}
.filter-bar > [class*="col-"] { flex: 1 1 180px; width: auto; max-width: 300px; padding: 0; margin: 0; min-width: 0; }
.filter-bar > [class*="col-"]:has(input[type="search"]) { flex-basis: 280px; max-width: 440px; }
.filter-bar > .col-auto { flex: 0 0 auto; max-width: none; }
.filter-bar > .form-select { flex: 0 1 300px; width: auto; min-width: 180px; }
.filter-bar .form-control, .filter-bar .form-select { min-height: 42px; border-radius: 9px; }
.filter-bar .btn { min-height: 42px; padding-inline: 1.1rem; white-space: nowrap; border-radius: 9px; }
.filter-bar .form-label { display: block; margin-bottom: .4rem; font-size: .75rem; font-weight: 600; color: var(--dl-muted); }
@media (max-width: 575.98px) {
    .filter-bar { padding: .875rem; gap: .75rem !important; }
    .filter-bar > [class*="col-"], .filter-bar > .form-select { flex: 1 1 100%; max-width: none; width: 100%; }
    .filter-bar > .col-auto { flex: 1 1 100%; }
    .filter-bar > .col-auto > .btn, .filter-bar > .btn { width: 100%; }
}

/* ---------- Pagination ---------- */
.pagination { --bs-pagination-border-radius: 10px; --bs-pagination-active-bg: var(--dl-primary); --bs-pagination-active-border-color: var(--dl-primary); --bs-pagination-color: var(--dl-text); --bs-pagination-bg: var(--dl-surface); --bs-pagination-border-color: var(--dl-border); gap: 4px; }
.pagination .page-link { border-radius: 10px !important; transition: transform var(--dl-fast) var(--dl-ease), background var(--dl-fast); }
.pagination .page-link:hover { transform: translateY(-1px); }

/* ---------- Toasts (flash messages) ---------- */
.toast-stack { position: fixed; top: calc(var(--dl-topbar-h) + 12px); right: 16px; z-index: 1090; display: flex; flex-direction: column; gap: .6rem; width: min(380px, calc(100vw - 32px)); }
.auth-body .toast-stack { top: 16px; }
.dl-toast {
    display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1rem; border-radius: 14px; background: var(--dl-surface);
    border: 1px solid var(--dl-border); box-shadow: var(--dl-shadow-lg); position: relative; overflow: hidden;
    animation: dl-toast-in 480ms var(--dl-ease) both;
}
.dl-toast.is-hiding { animation: dl-toast-out 320ms var(--dl-ease) forwards; }
.dl-toast .toast-icon { font-size: 1.25rem; line-height: 1; margin-top: .05rem; }
.dl-toast .toast-msg { flex: 1; font-size: .9rem; }
.dl-toast .btn-close { font-size: .7rem; }
.dl-toast .toast-progress { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: dl-progress 6s linear forwards; }
.dl-toast:hover .toast-progress { animation-play-state: paused; }
.dl-toast.toast-success .toast-icon, .dl-toast.toast-success .toast-progress { color: #10b981; background-color: transparent; }
.dl-toast.toast-success .toast-progress { background: #10b981; }
.dl-toast.toast-info .toast-icon { color: #3b82f6; } .dl-toast.toast-info .toast-progress { background: #3b82f6; }
.dl-toast.toast-warning .toast-icon { color: #f59e0b; } .dl-toast.toast-warning .toast-progress { background: #f59e0b; }
.dl-toast.toast-danger .toast-icon { color: #ef4444; } .dl-toast.toast-danger .toast-progress { background: #ef4444; }
@keyframes dl-toast-in { from { opacity: 0; transform: translateX(40px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes dl-toast-out { to { opacity: 0; transform: translateX(40px) scale(.96); } }
@keyframes dl-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Inline notice (non-flash alerts in pages) */
.notice { display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1.1rem; border-radius: 14px; border: 1px solid var(--dl-border); background: var(--dl-surface); margin-bottom: 1.25rem; }
.notice .bi { font-size: 1.15rem; }
.notice-info { background: rgba(59,130,246,.07); border-color: rgba(59,130,246,.25); } .notice-info .bi { color: #3b82f6; }
.notice-warning { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.3); } .notice-warning .bi { color: #d97706; }
.notice-muted { background: var(--dl-surface-2); }

/* ---------- Modal (confirm dialog) ---------- */
.modal-content { border-radius: 18px; border: 1px solid var(--dl-border); background: var(--dl-surface); box-shadow: var(--dl-shadow-lg); }
.modal.fade .modal-dialog { transform: translateY(12px) scale(.96); transition: transform var(--dl-med) var(--dl-ease); }
.modal.show .modal-dialog { transform: none; }
.confirm-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.5rem; background: rgba(239,68,68,.1); color: #ef4444; margin-bottom: 1rem; }
.modal-backdrop.show { opacity: .4; }

/* ---------- Auth pages ---------- */
.auth-body { min-height: 100vh; background: var(--dl-bg); }
.auth-split { display: grid; min-height: 100vh; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth-split { grid-template-columns: minmax(380px, 46%) 1fr; } }
.auth-aside {
    position: relative; overflow: hidden; color: #fff; padding: 3rem; display: none; flex-direction: column; justify-content: space-between;
    background: var(--dl-grad); background-size: 200% 200%; animation: dl-gradient 14s ease infinite;
}
@media (min-width: 992px) { .auth-aside { display: flex; } }
@keyframes dl-gradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.blob { position: absolute; border-radius: 50%; filter: blur(2px); background: rgba(255,255,255,.14); animation: dl-float 14s var(--dl-ease-in-out) infinite alternate; }
.blob-1 { width: 420px; height: 420px; top: -140px; right: -120px; }
.blob-2 { width: 260px; height: 260px; bottom: -80px; left: -60px; animation-duration: 18s; }
.blob-3 { width: 140px; height: 140px; bottom: 30%; right: 18%; animation-duration: 11s; background: rgba(255,255,255,.1); }
.auth-aside > :not(.blob) { position: relative; z-index: 1; }
@media (min-width: 992px) { .auth-aside { position: sticky; top: 0; height: 100vh; } }
.auth-aside h2 { font-size: 2.3rem; line-height: 1.15; font-weight: 750; }
.feature-list { list-style: none; padding: 0; margin: 1.75rem 0 0; display: grid; gap: .9rem; }
.feature-list li { display: flex; gap: .75rem; align-items: center; color: rgba(255,255,255,.9); animation: dl-rise var(--dl-slow) var(--dl-ease) both; }
.feature-list li:nth-child(2) { animation-delay: 120ms; } .feature-list li:nth-child(3) { animation-delay: 240ms; } .feature-list li:nth-child(4) { animation-delay: 360ms; }
.feature-list .bi { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: rgba(255,255,255,.16); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.1rem; position: relative; }
.auth-card { width: 100%; max-width: 460px; }
.auth-card.wide { max-width: 620px; }
.auth-card .brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--dl-text); font-weight: 750; text-decoration: none; font-size: 1.1rem; margin-bottom: 2rem; }
.auth-card h1 { font-size: 1.75rem; }
.auth-card .lead-muted { color: var(--dl-muted); margin-bottom: 1.75rem; }
.divider-text { display: flex; align-items: center; gap: .75rem; color: var(--dl-muted); font-size: .8rem; margin: 1.5rem 0; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--dl-border); }
.auth-theme { position: absolute; top: 1rem; right: 1rem; }
.step-legend { display: flex; align-items: center; gap: .6rem; font-weight: 650; font-size: .95rem; margin-bottom: 1rem; }
.step-legend .num { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--dl-grad); color: #fff; font-size: .8rem; }
.strength { height: 6px; border-radius: 999px; background: var(--dl-border); overflow: hidden; margin-top: .5rem; }
.strength > span { display: block; height: 100%; width: 0; border-radius: inherit; transition: width var(--dl-med) var(--dl-ease), background-color var(--dl-med); }
.strength[data-level="1"] > span { width: 25%; background: #ef4444; }
.strength[data-level="2"] > span { width: 50%; background: #f59e0b; }
.strength[data-level="3"] > span { width: 75%; background: #3b82f6; }
.strength[data-level="4"] > span { width: 100%; background: #10b981; }

/* ---------- Landing ---------- */
.landing-wrap { min-height: 100vh; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.landing-wrap .blob { background: var(--dl-grad-soft); filter: blur(10px); }
.landing-nav { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 0; position: relative; z-index: 10; }
.landing-nav .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.landing-links a { color: var(--dl-muted); text-decoration: none; font-size: .9rem; font-weight: 600; }
.landing-links a:hover { color: var(--dl-primary); }
.landing { position: relative; z-index: 1; text-align: center; padding: 5rem 0 3rem; }
.landing h1 { font-size: clamp(2.7rem, 5vw, 4.8rem); font-weight: 820; letter-spacing: -0.055em; line-height: .98; }
.landing .lead { color: var(--dl-muted); max-width: 640px; margin: 1.25rem auto 0; }
.pill { display: inline-flex; gap: .4rem; align-items: center; padding: .35rem .85rem; border-radius: 999px; background: var(--dl-surface); border: 1px solid var(--dl-border); font-size: .82rem; font-weight: 600; color: var(--dl-primary); box-shadow: var(--dl-shadow-sm); }
.feature-grid .card { height: 100%; text-align: left; }
.feature-grid .stat-icon { margin-bottom: .75rem; }

.landing-page { position: relative; z-index: 1; }
.landing-hero { min-height: calc(100vh - 78px); display: flex; align-items: center; padding: 4rem 0 6rem; }
.landing-hero .lead { font-size: 1.15rem !important; line-height: 1.7; }
.hero-trust { display: flex; flex-wrap: wrap; gap: .8rem 1.1rem; color: var(--dl-muted); font-size: .82rem; font-weight: 600; }
.hero-trust .bi { color: #10b981; margin-right: .25rem; }
.product-preview { position: relative; padding: 9px; border-radius: 24px; background: linear-gradient(145deg, rgba(255,255,255,.9), rgba(var(--dl-primary-rgb),.15)); border: 1px solid rgba(var(--dl-primary-rgb),.18); box-shadow: 0 36px 80px -35px rgba(49,46,129,.55); transform: perspective(1200px) rotateY(-4deg) rotateX(2deg); }
.product-preview::before { content: ''; position: absolute; inset: 14% -8% -10% 20%; z-index: -1; border-radius: 50%; background: rgba(var(--dl-primary-rgb),.25); filter: blur(50px); }
.preview-top { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: #11142c; color: #fff; border-radius: 16px 16px 0 0; }
.preview-brand { font-size: .72rem; font-weight: 700; display: flex; gap: .45rem; align-items: center; }
.preview-avatar { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: var(--dl-grad); font-size: .55rem; font-weight: 800; }
.preview-body { display: grid; grid-template-columns: 46px 1fr; min-height: 330px; background: #f6f7fb; color: #111827; border-radius: 0 0 16px 16px; overflow: hidden; }
.preview-side { background: #171a3a; padding: 16px 8px; display: flex; flex-direction: column; gap: 9px; align-items: center; }
.preview-side span { width: 29px; height: 29px; border-radius: 8px; color: #949bc4; display: grid; place-items: center; font-size: .78rem; }
.preview-side span.active { color: #fff; background: rgba(255,255,255,.12); }
.preview-main { padding: 22px; min-width: 0; }
.preview-heading { display: flex; justify-content: space-between; align-items: end; gap: 8px; margin-bottom: 18px; }
.preview-heading small, .preview-heading strong { display: block; }
.preview-heading small { color: #8b91a7; font-size: .47rem; letter-spacing: .08em; margin-bottom: 3px; }
.preview-heading strong { font-size: .88rem; }
.preview-action { color: #fff; background: var(--dl-primary); border-radius: 7px; font-size: .53rem; font-weight: 700; padding: 6px 8px; white-space: nowrap; }
.preview-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.preview-stats article { padding: 12px; background: #fff; border: 1px solid #ebecef; border-radius: 10px; }
.preview-stats i { color: var(--dl-primary); display: block; margin-bottom: 9px; }
.preview-stats span, .preview-stats strong { display: block; }
.preview-stats span { color: #8b91a7; font-size: .48rem; }
.preview-stats strong { font-size: 1.12rem; margin-top: 2px; }
.preview-panel { margin-top: 12px; background: #fff; border: 1px solid #ebecef; border-radius: 10px; padding: 12px; }
.preview-panel-head { display: flex; justify-content: space-between; font-size: .58rem; margin-bottom: 7px; }
.preview-panel-head span { color: var(--dl-primary); }
.preview-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #f0f1f4; }
.preview-row strong, .preview-row small { display: block; }
.preview-row strong { font-size: .53rem; }
.preview-row small { color: #8b91a7; font-size: .43rem; }
.preview-row b { font-size: .48rem; color: #d97706; }
.mini-cover { width: 24px; height: 30px; border-radius: 4px; background: linear-gradient(135deg,#4f46e5,#a78bfa); }
.mini-cover.alt { background: linear-gradient(135deg,#0d9488,#5eead4); }
.preview-caption { color: var(--dl-muted); font-size: .72rem; text-align: center; margin: .8rem 0 0; }

.landing-section { padding: 6.5rem 0; scroll-margin-top: 2rem; }
.landing-intro { text-align: center; max-width: 840px; margin: 0 auto; }
.landing-section h2 { font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.045em; line-height: 1.06; }
.section-kicker { color: var(--dl-primary); font-weight: 750; font-size: .77rem; text-transform: uppercase; letter-spacing: .11em; margin-bottom: .85rem; }
.section-lead { max-width: 700px; margin: 1.2rem auto 0; color: var(--dl-muted); font-size: 1.05rem; line-height: 1.75; }
.feature-bento { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.bento-card { min-height: 310px; position: relative; overflow: hidden; padding: clamp(1.5rem,3vw,2.5rem); border-radius: 24px; border: 1px solid var(--dl-border); background: var(--dl-surface); box-shadow: var(--dl-shadow); }
.bento-card h3 { font-size: clamp(1.35rem,2.2vw,2rem); max-width: 560px; margin: .45rem 0 .8rem; }
.bento-card p { color: var(--dl-muted); max-width: 570px; line-height: 1.7; margin: 0; }
.bento-wide { grid-column: span 2; display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: 2rem; }
.feature-icon { width: 46px; height: 46px; display: grid; place-items: center; color: var(--dl-primary); background: rgba(var(--dl-primary-rgb),.1); border-radius: 14px; font-size: 1.25rem; margin-bottom: 1.5rem; }
.feature-icon.tone-teal { color: #0d9488; background: rgba(13,148,136,.1); }
.feature-icon.tone-pink { color: #db2777; background: rgba(219,39,119,.1); }
.catalog-stack { display: grid; gap: 9px; transform: rotate(-2deg); }
.catalog-stack span { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--dl-surface-2); border: 1px solid var(--dl-border); font-size: .8rem; font-weight: 650; }
.catalog-stack b { color: #059669; font-size: .7rem; white-space: nowrap; }
.bento-dark { color: #fff; background: radial-gradient(circle at 90% 10%, #302e77, #11142c 62%); border-color: transparent; }
.bento-dark .section-kicker { color: #a5b4fc; }
.bento-dark p { color: #b7bbd6; }
.bento-dark .feature-icon { color: #fff; background: rgba(255,255,255,.1); }
.mini-flow { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: 2.4rem; color: #aeb3d3; font-size: .7rem; }
.mini-flow span, .mini-flow strong { border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: .45rem .7rem; }
.mini-flow strong { color: #6ee7b7; background: rgba(16,185,129,.12); }
.branch-map { display: grid; grid-template-columns: repeat(3,58px); grid-template-rows: 55px 48px 55px; justify-content: center; align-items: center; position: relative; }
.branch-map i { grid-column: 1 / 4; grid-row: 2; height: 2px; background: var(--dl-border); position: relative; }
.branch-node { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; color: var(--dl-primary); background: var(--dl-surface); border: 1px solid var(--dl-border); box-shadow: var(--dl-shadow); font-size: .72rem; font-weight: 800; z-index: 1; }
.branch-node.main { grid-column: 2; justify-self: center; background: var(--dl-grad); color: #fff; border: 0; }
.branch-node:nth-of-type(2) { grid-column: 1; grid-row: 3; }.branch-node:nth-of-type(3) { grid-column: 2; grid-row: 3; justify-self: center; }.branch-node:nth-of-type(4) { grid-column: 3; grid-row: 3; justify-self: end; }
.workflow-section { border-top: 1px solid var(--dl-border); }
.workflow-list { list-style: none; margin: 0; padding: 0; }
.workflow-list li { display: grid; grid-template-columns: 58px 1fr; gap: 1rem; padding: 0 0 2.2rem; position: relative; }
.workflow-list li:not(:last-child)::before { content: ''; position: absolute; left: 25px; top: 48px; bottom: 5px; width: 1px; background: var(--dl-border); }
.workflow-list > li > span { width: 50px; height: 50px; display: grid; place-items: center; border: 1px solid var(--dl-border); border-radius: 16px; color: var(--dl-primary); background: var(--dl-surface); font-size: .72rem; font-weight: 800; box-shadow: var(--dl-shadow-sm); }
.workflow-list h3 { font-size: 1.08rem; margin: .1rem 0 .4rem; }.workflow-list p { color: var(--dl-muted); line-height: 1.65; margin: 0; }
.security-section { padding: clamp(2rem,5vw,4.5rem); display: grid; grid-template-columns: .8fr 1.2fr; gap: clamp(2rem,6vw,5rem); align-items: center; color: #fff; background: radial-gradient(circle at 0 0,#4338ca,#15172f 58%); border-radius: 30px; }
.security-section .section-kicker { color: #c7d2fe; }.security-section p { color: #c2c6df; line-height: 1.75; }.security-section .feature-icon { color: #fff; background: rgba(255,255,255,.12); }
.security-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }.security-grid > div { padding: 1.25rem; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; }.security-grid i,.security-grid strong,.security-grid span { display: block; }.security-grid i { color: #a5b4fc; font-size: 1.25rem; margin-bottom: 1rem; }.security-grid strong { margin-bottom: .35rem; }.security-grid span { color: #afb4d2; font-size: .8rem; line-height: 1.55; }
.landing-cta { margin: 6rem 0 3rem; padding: clamp(2rem,5vw,4rem); display: flex; align-items: center; justify-content: space-between; gap: 2rem; color: #fff; background: var(--dl-grad); border-radius: 28px; box-shadow: 0 25px 60px -30px rgba(var(--dl-primary-rgb),.7); }.landing-cta .section-kicker { color: rgba(255,255,255,.75); }.landing-cta h2 { max-width: 700px; }.landing-cta p { color: rgba(255,255,255,.78); margin: .8rem 0 0; }
.landing-footer { min-height: 100px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 2rem; border-top: 1px solid var(--dl-border); color: var(--dl-muted); font-size: .78rem; }.landing-footer p { margin: 0; }

.book-thumb { width: 42px; height: 52px; flex: 0 0 auto; display: grid; place-items: center; color: #fff; border-radius: 6px 10px 10px 6px; background: var(--dl-grad); box-shadow: 3px 4px 10px rgba(var(--dl-primary-rgb),.18); }
.book-cover-lg { width: 96px; height: 126px; flex: 0 0 auto; display: grid; place-items: center; color: #fff; border-radius: 8px 16px 16px 8px; background: var(--dl-grad); font-size: 2rem; box-shadow: 8px 12px 25px rgba(var(--dl-primary-rgb),.22); }
.book-meta { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem 2rem; }.book-meta div { min-width: 0; }.book-meta dt { color: var(--dl-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }.book-meta dd { margin: .1rem 0 0; font-size: .88rem; font-weight: 600; }
.date-inline { width: 165px; }.report-meter { display: block; width: 100%; height: 10px; appearance: none; border: 0; border-radius: 99px; overflow: hidden; }.report-meter::-webkit-progress-bar { background: var(--dl-border); }.report-meter::-webkit-progress-value { background: linear-gradient(90deg,#10b981,#34d399); border-radius: 99px; }.report-meter::-moz-progress-bar { background: linear-gradient(90deg,#10b981,#34d399); border-radius: 99px; }

@media (max-width: 991.98px) {
    .landing-hero { min-height: auto; padding-top: 3rem; }.product-preview { transform: none; max-width: 650px; margin: 0 auto; }.bento-wide,.security-section { grid-template-columns: 1fr; }.landing-cta { align-items: flex-start; flex-direction: column; }.landing-footer { grid-template-columns: 1fr; gap: .8rem; padding: 2rem 0; }
}
@media (max-width: 575.98px) {
    .landing-nav .btn { padding-left: .75rem; padding-right: .75rem; }.landing-hero { padding: 2.4rem 0 4rem; }.landing h1 { font-size: 2.7rem; }.product-preview { margin-left: -.5rem; margin-right: -.5rem; }.preview-main { padding: 15px 10px; }.preview-body { min-height: 285px; grid-template-columns: 38px 1fr; }.preview-side { padding-left: 5px; padding-right: 5px; }.preview-stats article { padding: 8px; }.preview-stats i { margin-bottom: 5px; }.landing-section { padding: 4rem 0; }.feature-bento { grid-template-columns: 1fr; }.bento-wide { grid-column: span 1; }.bento-card { min-height: 0; }.catalog-stack,.branch-map { margin-top: 2rem; }.security-grid { grid-template-columns: 1fr; }.book-cover-lg { width: 70px; height: 96px; }.book-meta { grid-template-columns: 1fr; }
}
@media print { .app-topbar,.app-sidebar,.page-header .btn,.notice { display: none !important; }.app-main { padding: 0 !important; }.card { break-inside: avoid; box-shadow: none !important; } }

.membership-manage-card { z-index: 5; width: 330px; }
.print-sheet { max-width: 850px; margin: 2rem auto; padding: 2rem; background: #fff; color: #16181d; }
.print-actions { max-width: 850px; margin: 1rem auto; }
@media print {
    .print-actions { display: none !important; }
    .print-sheet { margin: 0; max-width: none; padding: 0; }
    body { background: #fff !important; }
}

/* ---------- Error page ---------- */
.error-code { font-size: clamp(5rem, 14vw, 8rem); font-weight: 800; line-height: 1; letter-spacing: -0.05em; }

/* ---------- Permission matrix ---------- */
.perm-group .card-header { display: flex; justify-content: space-between; align-items: center; }
.perm-row { display: flex; align-items: flex-start; gap: .6rem; padding: .45rem .25rem; border-radius: 9px; transition: background var(--dl-fast); }
.perm-row:hover { background: var(--dl-surface-2); }
.perm-row .form-check-input { margin-top: .2rem; flex: 0 0 auto; }
.perm-row code { font-size: .72rem; color: var(--dl-muted); display: block; }

details > summary { cursor: pointer; color: var(--dl-primary); font-weight: 500; }
details[open] > pre { animation: dl-rise 300ms var(--dl-ease) both; }

/* ---------- Motion safety ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
    .reveal { opacity: 1; transform: none; }
}

/* ---------- Misc ---------- */
.min-w-0 { min-width: 0; }
.sidebar-brand .nav-link-text { transition: opacity var(--dl-fast); }
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
    body.sidebar-collapsed .sidebar-brand .nav-link-text { display: none; }
}
/* Smooth colour cross-fade while switching theme (class removed by JS after 450 ms). */
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after {
    transition: background-color 400ms ease, color 400ms ease, border-color 400ms ease, box-shadow 400ms ease !important;
}
.theme-toggle .bi { transition: transform var(--dl-med) var(--dl-ease); }
.theme-toggle:hover .bi { transform: rotate(-20deg) scale(1.1); }
[data-bs-theme="dark"] .card-header, [data-bs-theme="dark"] .table > thead th { background-color: var(--dl-surface-2); }
[data-bs-theme="dark"] .hero-card { box-shadow: 0 24px 50px -24px rgba(var(--dl-primary-rgb), .6); }
[data-bs-theme="dark"] .btn-light { --bs-btn-bg: #fff; --bs-btn-color: #1f2937; }
@media (min-width: 992px) { .auth-card .brand { display: none; } }

/* ---------- Modals & Backdrop stacking ---------- */
.modal { z-index: 1065 !important; }
.modal-backdrop { z-index: 1060 !important; }

/* Keep all workspace sections reachable on shorter desktop screens. */
.app-rail { overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.app-rail-brand, .app-rail-button { flex-shrink: 0; }

.modal-dialog-scrollable .modal-content > form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

/* Collapse the panel wrapper, keeping Bootstrap's animation height measurable. */
.page-filter-panel.collapsing { transition: height .25s ease; }
.page-filter-panel .filter-bar { margin-bottom: 0; }
.page-filter-panel::after { content: ""; display: block; height: 1.25rem; }
.page-actions > .d-flex { flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) {
    .page-filter-panel.collapsing { transition: none; }
}

/* ==========================================================================
   Library module: desk, catalog covers, profiles, holds, fines, analytics
   ========================================================================== */

/* Compact KPI cards (icon beside the number) */
.stat-card-compact .card-body { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; }
.stat-card-compact .stat-icon { margin-bottom: 0; flex: 0 0 auto; }
.stat-card-compact .stat-value { font-size: 1.6rem; margin-top: 0; }
.stat-card-compact::after { width: 120px; height: 120px; inset: auto -50px -70px auto; }
.stat-card-stack .stat-value { font-size: 1.6rem; }
.stat-value-sm { font-size: 1.35rem !important; }
a.stat-card { color: inherit; }

/* Toolbar: segmented tabs + inline search */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.toolbar-search { flex: 0 1 320px; min-width: 220px; }
.seg-tabs { display: inline-flex; flex-wrap: wrap; gap: .25rem; padding: .25rem; border-radius: 12px; background: var(--dl-surface); border: 1px solid var(--dl-border); box-shadow: var(--dl-shadow-sm); }
.seg-tab { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border-radius: 9px; font-size: .86rem; font-weight: 600; color: var(--dl-muted); text-decoration: none; transition: background var(--dl-fast), color var(--dl-fast); }
.seg-tab:hover { color: var(--dl-text); background: var(--dl-surface-2); }
.seg-tab.active { color: #fff; background: var(--dl-primary); box-shadow: 0 6px 16px -8px rgba(var(--dl-primary-rgb), .8); }
.seg-count { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.25rem; padding: 0 .35rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: rgba(var(--dl-primary-rgb), .1); color: var(--dl-primary); font-variant-numeric: tabular-nums; }
.seg-tab.active .seg-count { background: rgba(255,255,255,.22); color: #fff; }
.seg-count.is-danger { background: rgba(239,68,68,.14); color: #dc2626; }
.nav-underline { --bs-nav-underline-link-active-color: var(--dl-primary); --bs-nav-link-color: var(--dl-muted); --bs-nav-link-hover-color: var(--dl-text); border-bottom: 1px solid var(--dl-border); gap: 1.25rem; }
.nav-underline .nav-link { font-weight: 600; font-size: .92rem; padding: .6rem 0; display: inline-flex; align-items: center; gap: .4rem; }

/* Tags */
.tag { display: inline-flex; align-items: center; padding: .18rem .55rem; border-radius: 6px; font-size: .75rem; font-weight: 600; color: var(--dl-muted); background: var(--dl-surface-2); border: 1px solid var(--dl-border); white-space: nowrap; }
.tag-info { color: #2563eb; background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.2); }
.tag-overdue { color: #b45309; background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.25); }
.tag-lost { color: #dc2626; background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.22); }
.tag-damaged { color: #9333ea; background: rgba(147,51,234,.08); border-color: rgba(147,51,234,.2); }

/* Availability meters */
.avail { display: flex; align-items: center; gap: .6rem; min-width: 120px; }
.avail-meter, .rank-meter { display: block; width: 72px; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 99px; overflow: hidden; background: var(--dl-border); }
.avail-meter-lg { width: 100%; height: 8px; }
.avail-meter::-webkit-progress-bar, .rank-meter::-webkit-progress-bar { background: var(--dl-border); }
.avail-meter::-webkit-progress-value { background: #10b981; border-radius: 99px; }
.avail-meter::-moz-progress-bar { background: #10b981; border-radius: 99px; }
.rank-meter { width: 100%; height: 4px; margin-top: .4rem; }
.rank-meter::-webkit-progress-value { background: var(--dl-primary); border-radius: 99px; }
.rank-meter::-moz-progress-bar { background: var(--dl-primary); border-radius: 99px; }
.avail-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.avail-summary > div { display: flex; flex-direction: column-reverse; padding: .75rem; border-radius: 12px; background: var(--dl-surface-2); }
.avail-summary .stat-value { font-size: 1.6rem; }

/* Generated book covers (deterministic tone per title) */
.cover-tone-1 { --cover: linear-gradient(150deg, #4f46e5, #7c3aed); }
.cover-tone-2 { --cover: linear-gradient(150deg, #0f766e, #14b8a6); }
.cover-tone-3 { --cover: linear-gradient(150deg, #b45309, #f59e0b); }
.cover-tone-4 { --cover: linear-gradient(150deg, #be185d, #ec4899); }
.cover-tone-5 { --cover: linear-gradient(150deg, #1d4ed8, #38bdf8); }
.cover-tone-6 { --cover: linear-gradient(150deg, #166534, #4ade80); }
.cover-tone-7 { --cover: linear-gradient(150deg, #9a3412, #fb7185); }
.cover-tone-8 { --cover: linear-gradient(150deg, #334155, #64748b); }
.book-thumb[class*="cover-tone-"] { background: var(--cover); font-weight: 750; font-size: 1.05rem; text-shadow: 0 1px 2px rgba(0,0,0,.25); box-shadow: 3px 4px 10px rgba(15,23,42,.14); }
.cover-art { position: relative; display: flex; flex-direction: column; justify-content: space-between; aspect-ratio: 2 / 3; padding: .8rem .75rem .7rem 1rem; border-radius: 6px 12px 12px 6px; color: #fff; background: var(--cover, var(--dl-grad)); overflow: hidden; box-shadow: 6px 10px 22px -10px rgba(15,23,42,.45); }
.cover-art::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 7px; background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(255,255,255,.12)); }
.cover-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.14), transparent 40%); pointer-events: none; }
.cover-title { position: relative; font-weight: 750; font-size: .95rem; line-height: 1.2; letter-spacing: -.01em; overflow-wrap: anywhere; text-shadow: 0 1px 2px rgba(0,0,0,.2); }
.cover-author { position: relative; font-size: .72rem; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.cover-art-lg { width: 150px; flex: 0 0 auto; padding: 1rem 1rem 1rem 1.2rem; }
.cover-art-lg .cover-title { font-size: 1.1rem; }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.25rem; }
.cover-card { display: flex; flex-direction: column; gap: .6rem; text-decoration: none; color: inherit; min-width: 0; }
.cover-card .cover-art { transition: transform var(--dl-med) var(--dl-ease), box-shadow var(--dl-med) var(--dl-ease); }
.cover-card:hover .cover-art, .cover-card:focus-visible .cover-art { transform: translateY(-4px) rotate(-1deg); box-shadow: 10px 16px 30px -12px rgba(15,23,42,.5); }
.cover-meta { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.avail-chip { align-self: flex-start; margin-top: .25rem; font-size: .72rem; font-weight: 600; padding: .15rem .5rem; border-radius: 999px; }
.avail-chip.is-in { background: rgba(16,185,129,.12); color: #059669; }
.avail-chip.is-out { background: rgba(239,68,68,.1); color: #dc2626; }
.avail-chip.is-muted { background: var(--dl-surface-2); color: var(--dl-muted); }
.book-description { max-width: 70ch; }
.book-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1.5rem; }
.book-meta dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--dl-muted); font-weight: 600; }
.book-meta dd { margin: 0; font-weight: 500; }

/* Circulation desk */
.desk-card .card-header { display: flex; }
.desk-step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: .78rem; font-weight: 700; color: #fff; background: var(--dl-primary); }
.desk-step.tone-teal { background: #0d9488; }
.scan-input { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.input-icon .form-control-lg { padding-left: 2.6rem; }
.input-icon:has(.form-control-lg) > .bi { left: 1rem; font-size: 1.1rem; }
.desk-member { padding: 1.1rem 1.25rem; border-top: 1px solid var(--dl-border); background: linear-gradient(180deg, rgba(var(--dl-primary-rgb), .05), transparent); }
.desk-kpis { display: flex; flex-wrap: wrap; gap: .5rem; }
.desk-kpis > div { display: flex; flex-direction: column; min-width: 84px; padding: .45rem .7rem; border-radius: 10px; background: var(--dl-surface); border: 1px solid var(--dl-border); }
.desk-kpis strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.desk-kpis span { font-size: .72rem; color: var(--dl-muted); }
.desk-result { border-left: 4px solid var(--dl-primary); }
.desk-line { display: flex; gap: .55rem; align-items: baseline; padding: .2rem 0; font-size: .9rem; }
.desk-line.ok .bi { color: #10b981; }
.desk-line.info .bi { color: #2563eb; }
.desk-line.err .bi { color: #dc2626; }
.desk-damage summary { cursor: pointer; color: var(--dl-muted); }
.activity-dot { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: .9rem; }
.activity-dot.is-out { background: rgba(var(--dl-primary-rgb), .1); color: var(--dl-primary); }
.activity-dot.is-in { background: rgba(16,185,129,.12); color: #059669; }
.avatar-xl { width: 56px; height: 56px; font-size: 1.15rem; border-radius: 16px; flex: 0 0 auto; }
.select-filter { max-width: 100%; }
.is-autofilled { background-color: rgba(16,185,129,.07); border-color: rgba(16,185,129,.45); }

/* Borrower profile */
.profile-list { display: grid; gap: .6rem; }
.profile-list > div { display: flex; gap: .7rem; align-items: baseline; min-width: 0; }
.profile-list dt { color: var(--dl-muted); width: 1.1rem; flex: 0 0 auto; font-weight: 400; }
.profile-list dd { margin: 0; min-width: 0; }

/* Ranked lists (analytics) */
.rank-list { list-style: none; counter-reset: rank; margin: 0; padding: .4rem 1.25rem 1rem; }
.rank-list li { counter-increment: rank; display: flex; align-items: center; gap: .9rem; padding: .6rem 0; border-bottom: 1px solid var(--dl-border); }
.rank-list li:last-child { border-bottom: 0; }
.rank-list li::before { content: counter(rank); flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--dl-muted); background: var(--dl-surface-2); }
.rank-list li:nth-child(-n+3)::before { color: var(--dl-primary); background: rgba(var(--dl-primary-rgb), .1); }
.rank-list .min-w-0 { flex: 1; }
.rank-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Line chart (validated categorical slots 1-2, light + dark steps) */
.viz-card { --series-1: #2a78d6; --series-2: #eb6834; --viz-grid: #e9eaf0; --viz-axis: #6b7280; }
[data-bs-theme="dark"] .viz-card { --series-1: #3987e5; --series-2: #d95926; --viz-grid: #262b48; --viz-axis: #9aa0c3; }
.viz-wrap { position: relative; }
.viz-svg { display: block; width: 100%; height: auto; max-height: 300px; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { fill: var(--viz-axis); font-size: 11px; font-family: var(--dl-font); }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.viz-line-1 { stroke: var(--series-1); }
.viz-line-2 { stroke: var(--series-2); }
.viz-hit { fill: transparent; cursor: crosshair; }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; vector-effect: non-scaling-stroke; }
.viz-cross.is-on { opacity: .7; }
.viz-legend { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 500; color: var(--dl-muted); }
.viz-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: .3rem; }
.viz-key-1 { background: var(--series-1); }
.viz-key-2 { background: var(--series-2); }
.viz-tip { position: absolute; top: 4px; transform: translateX(12px); pointer-events: none; display: flex; flex-direction: column; gap: .15rem; padding: .5rem .7rem; border-radius: 10px; font-size: .8rem; background: var(--dl-surface); border: 1px solid var(--dl-border); box-shadow: var(--dl-shadow); color: var(--dl-text); white-space: nowrap; z-index: 2; }
.viz-tip.flip { transform: translateX(calc(-100% - 12px)); }
.viz-tip b { font-variant-numeric: tabular-nums; margin-left: .25rem; }
.viz-table { max-height: 260px; overflow: auto; }

/* Option tiles used by the import form (radio cards) */
.option-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }
.option-tiles .option-tile > span { display: flex; flex-direction: column; gap: .15rem; height: 100%; padding: .9rem 1rem; border: 1.5px solid var(--dl-border); border-radius: 12px; background: var(--dl-surface); transition: border-color var(--dl-fast), background var(--dl-fast); }
.option-tiles .option-tile > span .bi { font-size: 1.25rem; color: var(--dl-primary); margin-bottom: .25rem; }
.option-tiles .option-tile small { color: var(--dl-muted); }
.option-tiles .option-tile input:checked + span { border-color: var(--dl-primary); background: rgba(var(--dl-primary-rgb), .05); }
.option-tiles .option-tile input:focus-visible + span { box-shadow: 0 0 0 4px rgba(var(--dl-primary-rgb), .18); }
.import-errors { max-height: 260px; overflow: auto; }

/* Header global search dropdown */
.topbar-command { position: relative; }
.search-pop { position: absolute; top: calc(100% + 8px); left: 0; right: 0; max-height: min(70vh, 560px); overflow: auto; padding: .4rem; border-radius: 12px; background: var(--dl-surface); color: var(--dl-text); border: 1px solid var(--dl-border); box-shadow: 0 24px 60px -18px rgba(15,23,42,.45); z-index: 1060; }
.search-pop-section + .search-pop-section { border-top: 1px solid var(--dl-border); margin-top: .3rem; padding-top: .3rem; }
.search-pop-heading { display: flex; align-items: center; gap: .45rem; padding: .45rem .6rem .25rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--dl-muted); }
.search-pop-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .6rem; border-radius: 8px; color: inherit; text-decoration: none; }
.search-pop-item > .min-w-0 { display: flex; flex-direction: column; }
.search-pop-title { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-pop-meta { font-size: .78rem; color: var(--dl-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-pop-item:hover, .search-pop-item.active, .search-pop-all:hover, .search-pop-all.active { background: rgba(var(--dl-primary-rgb), .08); color: inherit; }
.search-pop-all { display: flex; justify-content: space-between; align-items: center; margin-top: .3rem; padding: .55rem .6rem; border-top: 1px solid var(--dl-border); border-radius: 0 0 8px 8px; font-size: .84rem; font-weight: 600; color: var(--dl-primary); text-decoration: none; }
.search-pop-all kbd { background: var(--dl-surface-2) !important; color: var(--dl-muted) !important; }
.search-pop-empty { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 1.4rem 1rem; text-align: center; color: var(--dl-muted); font-size: .88rem; }
.search-pop-empty .bi { font-size: 1.3rem; }
[data-bs-theme="dark"] .topbar-command:focus-within { background: var(--dl-surface); color: var(--dl-text); }
[data-bs-theme="dark"] .topbar-command:focus-within kbd { background: var(--dl-surface-2); }
@media (max-width: 575.98px) { .search-pop { position: fixed; top: calc(var(--dl-topbar-h) + 4px); left: .5rem; right: .5rem; } }

/* Printables: library card, spine labels, overdue letters */
.library-card { width: 85.6mm; height: 54mm; border-radius: 3.5mm; padding: 4mm 4.5mm; display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: linear-gradient(135deg, #312e81, #4f46e5 55%, #7c3aed); box-shadow: 0 10px 30px -12px rgba(30,27,75,.6); overflow: hidden; print-color-adjust: exact; -webkit-print-color-adjust: exact; break-inside: avoid; }
.print-cards { display: flex; flex-wrap: wrap; gap: 8mm; }
.library-card-head { display: flex; gap: 2.5mm; align-items: center; }
.library-card-mark { width: 7mm; height: 7mm; border-radius: 2mm; display: grid; place-items: center; background: rgba(255,255,255,.18); font-size: 3.6mm; }
.library-card-org { font-weight: 700; font-size: 3.4mm; line-height: 1.1; }
.library-card-sub { font-size: 2.4mm; opacity: .8; }
.library-card-body { display: flex; gap: 3mm; align-items: center; }
.library-card-avatar { width: 11mm; height: 11mm; border-radius: 3mm; display: grid; place-items: center; font-weight: 700; font-size: 4mm; background: rgba(255,255,255,.2); flex: 0 0 auto; }
.library-card-name { font-weight: 700; font-size: 4mm; line-height: 1.15; }
.library-card-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 3mm; letter-spacing: .05em; }
.library-card-meta { font-size: 2.3mm; opacity: .85; }
.library-card-barcode { background: #fff; border-radius: 1.5mm; padding: 1mm 2mm; }
.library-card-barcode .barcode { display: block; width: 100%; height: 9mm; }
.library-card-back { color: #1f2937; background: #fff; border: 1px solid #d1d5db; box-shadow: none; justify-content: flex-start; }
.label-sheet { display: grid; grid-template-columns: repeat(3, 63.5mm); gap: 3mm; }
.book-label { height: 33.9mm; padding: 2mm 3mm; border: 1px dashed #cbd5e1; border-radius: 2mm; display: flex; flex-direction: column; justify-content: space-between; color: #111827; background: #fff; break-inside: avoid; overflow: hidden; }
.book-label-org { font-size: 2.2mm; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; }
.book-label-title { font-size: 3mm; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-label-barcode .barcode { display: block; width: 100%; height: 11mm; }
.book-label-foot { display: flex; justify-content: space-between; gap: 2mm; font-size: 2.5mm; }
.book-label-acc { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; }
.notice-letter { padding-bottom: 2rem; margin-bottom: 2rem; border-bottom: 1px dashed #cbd5e1; break-after: page; }
.notice-letter:last-child { border-bottom: 0; break-after: auto; }
@media print {
    .print-hint { display: none !important; }
    .book-label { border-color: transparent; }
    .label-sheet { gap: 0 3mm; }
}

/* Small screens */
@media (max-width: 767.98px) {
    .toolbar-search { flex: 1 1 100%; }
    .seg-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .seg-tab { white-space: nowrap; }
    .cover-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1rem; }
    .cover-art-lg { width: 110px; }
    .desk-kpis > div { min-width: 0; flex: 1 1 40%; }
    .label-sheet { grid-template-columns: repeat(auto-fill, minmax(60mm, 1fr)); }
}

/* ==========================================================================
   App-wide polish
   ========================================================================== */
/* Quieter decorative blobs on KPI cards so numbers lead. */
.stat-card::after { opacity: .6; width: 130px; height: 130px; inset: auto -46px -64px auto; }
/* Long menu labels truncate instead of overflowing the sidebar. */
.app-sidebar .nav-link { min-width: 0; }
.app-sidebar .nav-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Consistent "no records" rows inside tables. */
.table > tbody > tr:only-child > td[colspan] { padding: 2.25rem 1rem; text-align: center; color: var(--dl-muted); font-size: .92rem; }
/* Page header actions stay tidy on small screens. */
.page-header .subtitle { max-width: 72ch; }
@media (max-width: 767.98px) {
    .page-header { align-items: stretch; }
    .page-header > div:last-child:not(:first-child) { width: 100%; }
    .page-header .page-actions, .page-header > .d-flex { justify-content: flex-start; }
    .stat-value { font-size: 1.7rem; }
}
/* Clear keyboard focus everywhere. */
.btn:focus-visible, .seg-tab:focus-visible, .nav-link:focus-visible, .cover-card:focus-visible, .search-pop-item:focus-visible, a.list-group-item:focus-visible {
    outline: 2px solid var(--dl-primary); outline-offset: 2px; box-shadow: none;
}
.list-group-item-action { transition: background var(--dl-fast); }
.card-header .bi { color: var(--dl-muted); }
.dropdown-menu { border-color: var(--dl-border); box-shadow: 0 16px 40px -16px rgba(15,23,42,.35); padding: .35rem; }
.dropdown-item { border-radius: 7px; font-size: .9rem; padding: .45rem .7rem; }
.modal-content { border: 0; border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(15,23,42,.5); }
.modal-header { border-bottom-color: var(--dl-border); padding: 1.1rem 1.4rem; }
.modal-body { padding: 1.25rem 1.4rem; }
.modal-footer { border-top-color: var(--dl-border); padding: .9rem 1.4rem; }
.form-text { color: var(--dl-muted); }
code { font-size: .82em; }

/* Dashboard "today" strip */
.today-strip .card-body { padding: .8rem 1.1rem; }
.today-strip-title { display: inline-flex; align-items: center; gap: .45rem; font-weight: 650; margin-right: .25rem; }
.today-strip-title .bi { color: var(--dl-primary); }
.today-chip { display: inline-flex; align-items: baseline; gap: .35rem; padding: .35rem .75rem; border-radius: 999px; font-size: .85rem; color: var(--dl-muted); text-decoration: none; background: var(--dl-surface-2); border: 1px solid var(--dl-border); transition: border-color var(--dl-fast), color var(--dl-fast); }
.today-chip strong { color: var(--dl-text); font-variant-numeric: tabular-nums; }
.today-chip:hover { border-color: rgba(var(--dl-primary-rgb), .45); color: var(--dl-text); }
.today-chip.is-warn { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); }
.today-chip.is-warn strong { color: #b45309; }
[data-bs-theme="dark"] .today-chip.is-warn strong { color: #fbbf24; }
[data-bs-theme="dark"] .seg-count.is-danger, [data-bs-theme="dark"] .avail-chip.is-out { color: #f87171; }
[data-bs-theme="dark"] .avail-chip.is-in { color: #34d399; }
[data-bs-theme="dark"] .tag-info { color: #93c5fd; }
[data-bs-theme="dark"] .tag-overdue { color: #fbbf24; }
[data-bs-theme="dark"] .tag-lost { color: #f87171; }
[data-bs-theme="dark"] .tag-damaged { color: #d8b4fe; }

/* ---------- Live demo + plan reminder ---------- */
.demo-banner { background: linear-gradient(90deg, #f59e0b, #f97316); color: #1f1300; font-size: .85rem; text-align: center; padding: .35rem .75rem; line-height: 1.35; }
.demo-banner a { color: #1f1300; font-weight: 700; text-decoration: underline; }
.demo-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }
.demo-overlay-card { background: var(--bs-body-bg); color: var(--bs-body-color); padding: 1rem 1.4rem; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600; }
.plan-card { border: 1px solid var(--bs-border-color); border-radius: 18px; padding: 1.5rem; height: 100%; background: var(--bs-body-bg); }
.plan-card.featured { border-color: #4f46e5; box-shadow: 0 10px 30px rgba(79, 70, 229, .15); }
.plan-card .price { font-size: 2rem; font-weight: 800; }
.plan-card ul { list-style: none; padding: 0; margin: 1rem 0 0; }
.plan-card li { padding: .2rem 0; }
.plan-card li i { color: #16a34a; margin-right: .4rem; }

/* ---------- Cloudflare Turnstile (public forms) ---------- */
.ts-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; margin: 0 0 1rem; }
.ts-wrap .cf-turnstile { width: 100%; max-width: 100%; display: flex; justify-content: center; }
.ts-hint { margin-top: .35rem; text-align: center; color: var(--bs-secondary-color); }
.ts-hint[hidden] { display: none; }
.ts-hint.ts-hint-error { color: var(--bs-danger-text-emphasis, #b02a37); }
.ts-wrap .invalid-feedback { text-align: center; }
