/* build: header-v8-dropdown-backdrop */
/* ============================================================
   Book Management System — base styles
   Pure CSS. Light default; dark via [data-theme="dark"].
   Dark = warm navy. Sidebar is dark in both themes.
   ============================================================ */

/* ---------- Theme tokens ---------- */

:root {
    /* Light theme content area */
    --bg:            #eef1f6;
    --bg-accent:     rgba(99, 102, 241, 0.07);
    --surface:       #ffffff;
    --surface-2:     #f4f6fa;
    --surface-3:     #e9edf3;
    --border:        #e4e8ef;
    --border-strong: #d3d9e3;
    --text:          #161b26;
    --text-muted:    #5b6573;
    --text-faint:    #99a2b2;

    /* Brand: refined indigo -> violet */
    --primary:       #6366f1;
    --primary-hover: #5457e5;
    --primary-soft:  rgba(99, 102, 241, 0.12);
    --on-primary:    #ffffff;

    /* Sidebar (dark in both themes) — warm navy */
    --side-bg:       #0e1729;
    --side-bg-2:     #16223a;
    --side-border:   #1f2d49;
    --side-text:     #aab4c8;
    --side-text-dim: #6b7689;
    --side-active-bg:rgba(99, 102, 241, 0.18);
    --side-active:   #c3c7ff;
    --side-brand:    #ffffff;

    /* Status */
    --danger-bg:     #fdecee;
    --danger-border: #f5c2c7;
    --danger-text:   #b42d3a;
    --success-bg:    #e7f6ec;
    --success-border:#bfe3cb;
    --success-text:  #1f7a44;

    --radius:        12px;
    --radius-sm:     9px;
    --radius-card:   16px;
    --shadow:        0 10px 40px rgba(20, 25, 40, 0.10);
    --shadow-sm:     0 1px 3px rgba(20, 25, 40, 0.06);
    --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition:    0.18s ease;
    --sidebar-w:     250px;
    --sidebar-mini:  64px;

    /* Sidebar icon accent colors */
    --ic-blue:   #4f7cff;
    --ic-orange: #f97316;
    --ic-green:  #16a34a;
    --ic-purple: #8b5cf6;

    /* Header action icon colors (warm, saturated) */
    --hi-bell:    #f97316;  /* warm orange */
    --hi-gear:    #a16207;  /* caramel / terracotta */
    --hi-theme:   #7c3aed;  /* violet */
    --hi-user:    #e11d48;  /* coral red */
    --hi-sidebar: #2563eb;  /* blue */
    /* Darker on-tile ink for readability */
    --hi-bell-ink:    #c2410c;
    --hi-gear-ink:    #854d0e;
    --hi-theme-ink:   #6d28d9;
    --hi-user-ink:    #be123c;
    --hi-sidebar-ink: #1d4ed8;
    --header-h:      60px;
}

[data-theme="dark"] {
    /* Warm navy content area (from reference) */
    --bg:            #0a1424;
    --bg-accent:     rgba(99, 102, 241, 0.14);
    --surface:       #0f1d33;
    --surface-2:     #16263f;
    --surface-3:     #1d3050;
    --border:        #1d2d47;
    --border-strong: #2a3d5c;
    --text:          #e6ebf4;
    --text-muted:    #9aa7bd;
    --text-faint:    #6b7689;

    --primary:       #7c80ff;
    --primary-hover: #8e92ff;
    --primary-soft:  rgba(124, 128, 255, 0.18);
    --on-primary:    #ffffff;

    /* Sidebar slightly deeper than content for separation */
    --side-bg:       #081020;
    --side-bg-2:     #101e34;
    --side-border:   #1a2942;
    --side-text:     #9aa7bd;
    --side-text-dim: #5e6b82;
    --side-active-bg:rgba(124, 128, 255, 0.20);
    --side-active:   #c3c7ff;
    --side-brand:    #ffffff;

    --danger-bg:     #2a1719;
    --danger-border: #5b2a2f;
    --danger-text:   #ff8a8a;
    --success-bg:    #14241a;
    --success-border:#27482f;
    --success-text:  #7fd39b;

    --ic-blue:   #6b8cff;
    --ic-orange: #fb923c;
    --ic-green:  #34d399;
    --ic-purple: #a78bfa;

    --hi-bell:    #fb923c;
    --hi-gear:    #d6a04a;
    --hi-theme:   #a78bfa;
    --hi-user:    #fb7185;
    --hi-sidebar: #60a5fa;
    --hi-bell-ink:    #fdba74;
    --hi-gear-ink:    #e6c07b;
    --hi-theme-ink:   #c4b5fd;
    --hi-user-ink:    #fda4af;
    --hi-sidebar-ink: #93c5fd;

    --shadow:        0 10px 40px rgba(0, 0, 0, 0.45);
    --shadow-sm:     0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ---------- Reset ---------- */

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

html { font-size: clamp(15px, 0.9rem + 0.25vw, 16.5px); }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    max-width: 100%;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

svg { display: block; }

/* ---------- Shared controls ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: clamp(0.9rem, 0.88rem + 0.15vw, 0.95rem);
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition), opacity var(--transition);
}
.btn-primary { background: var(--primary); color: var(--on-primary); padding: clamp(11px, 2vw, 13px) 18px; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { font-size: 0.825rem; padding: 7px 12px; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--border-strong); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 19px; height: 19px; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Form primitives ---------- */

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 550;
    color: var(--text-muted);
    margin-bottom: 7px;
}
.form-group input {
    width: 100%;
    padding: clamp(10px, 2vw, 13px) 14px;
    font-size: clamp(0.9rem, 0.88rem + 0.15vw, 0.95rem);
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-group input::placeholder { color: var(--text-faint); }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 0.875rem; margin-bottom: 20px; }
.alert-error   { background: var(--danger-bg);  border: 1px solid var(--danger-border);  color: var(--danger-text); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success-text); }

/* ============================================================
   Split-screen login
   ============================================================ */

.login-split { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 880px) { .login-split { grid-template-columns: 1.05fr 1fr; } }

.login-aside {
    display: none;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    color: #fff;
    background:
        radial-gradient(800px 500px at 15% 10%, rgba(255,255,255,0.14), transparent 55%),
        radial-gradient(700px 600px at 90% 100%, rgba(124,128,255,0.5), transparent 60%),
        linear-gradient(150deg, #0e1729 0%, #1a2747 55%, #2d2a6e 100%);
    overflow: hidden;
}
@media (min-width: 880px) { .login-aside { display: flex; } }

.login-aside .aside-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.login-aside .aside-brand .brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 12px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    font-size: 0.82rem; letter-spacing: 0.02em;
    backdrop-filter: blur(4px);
}
.login-aside .aside-headline { max-width: 32ch; }
.login-aside .aside-headline h2 {
    font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.4rem);
    font-weight: 680; line-height: 1.16; letter-spacing: -0.025em; margin-bottom: 16px;
}
.login-aside .aside-headline p { font-size: 1.02rem; color: rgba(255,255,255,0.78); line-height: 1.6; }
.login-aside .aside-foot { font-size: 0.85rem; color: rgba(255,255,255,0.6); }

.login-main { display: flex; align-items: center; justify-content: center; padding: clamp(24px, 6vw, 56px); position: relative; background: var(--bg); }
.login-main .login-topbar { position: absolute; top: clamp(16px, 4vw, 28px); right: clamp(16px, 4vw, 28px); }
.login-form-wrap { width: 100%; max-width: 380px; }
.login-form-wrap .form-head { margin-bottom: clamp(24px, 4vw, 32px); }
.login-form-wrap .form-head h1 { font-size: clamp(1.5rem, 1.3rem + 1vw, 1.85rem); font-weight: 680; letter-spacing: -0.02em; }
.login-form-wrap .form-head p { color: var(--text-muted); font-size: clamp(0.9rem, 0.88rem + 0.2vw, 0.95rem); margin-top: 7px; }
.login-form-wrap .form-foot { margin-top: 26px; font-size: 0.8rem; color: var(--text-faint); text-align: center; }

.login-mobile-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 24px; color: var(--text); }
.login-mobile-brand .brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--primary); color: #fff; font-size: 0.78rem;
}
@media (min-width: 880px) { .login-mobile-brand { display: none; } }

/* ============================================================
   App shell
   ============================================================ */

.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; }

/* Sidebar — dark in both themes */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--side-bg);
    border-right: 1px solid var(--side-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--transition);
}
.sidebar.is-open { transform: translateX(0); }

/* Desktop: visible by default, collapsible via .sidebar-collapsed on shell */
@media (min-width: 1024px) {
    .sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; align-self: flex-start; transform: none; transition: width var(--transition); }

    /* Collapsed = mini rail: icons only */
    .app-shell.sidebar-collapsed .sidebar { width: var(--sidebar-mini); }
    .app-shell.sidebar-collapsed .brand-text,
    .app-shell.sidebar-collapsed .nav-label,
    .app-shell.sidebar-collapsed .sidebar-footer span { display: none; }
    .app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
    .app-shell.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; }
    .app-shell.sidebar-collapsed .sidebar-footer { text-align: center; padding: 14px 0; }
}

.sidebar-brand {
    display: flex; align-items: center; gap: 11px;
    height: var(--header-h);
    padding: 0 20px;
    border-bottom: 1px solid var(--side-border);
}
.sidebar-brand .brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 0.74rem; letter-spacing: 0.02em;
}
.sidebar-brand .brand-text { font-weight: 650; letter-spacing: -0.01em; color: var(--side-brand); }

.sidebar-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--side-text); text-decoration: none;
    font-size: 0.92rem; font-weight: 550;
    transition: background var(--transition), color var(--transition);
}
.nav-item .nav-icon { display: inline-flex; flex-shrink: 0; }
.nav-item .nav-icon svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--side-bg-2); color: #fff; }
.nav-item.is-active { background: var(--side-active-bg); color: var(--side-active); }

.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--side-border); font-size: 0.75rem; color: var(--side-text-dim); }

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    opacity: 0; visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition); z-index: 35;
}
.sidebar-backdrop.is-visible { opacity: 1; visibility: visible; }
@media (min-width: 1024px) { .sidebar-backdrop { display: none; } }

/* Main column */
.app-main { flex: 1; min-width: 0; max-width: 100%; overflow-x: clip; display: flex; flex-direction: column; }

.app-header {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 10px;
    height: var(--header-h);
    padding: 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.header-home {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    color: var(--text-muted); text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.header-home:hover { background: var(--surface-2); color: var(--primary); }
.header-home svg { width: 20px; height: 20px; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.header-actions > * { flex-shrink: 0; }

/* User dropdown panel */
.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
    z-index: 50;
}
.user-menu.is-open .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }

/* Mobile: dropdown opens below the header, edge-to-edge (10px gutters) */
@media (max-width: 599px) {
    .user-dropdown {
        position: fixed;
        top: calc(var(--header-h) + 6px);
        bottom: auto;
        left: 10px;
        right: 10px;
        min-width: 0;
        width: auto;
        border-radius: var(--radius-card);
        padding: 8px;
        transform: translateY(-8px);
        z-index: 50;
    }
    .user-menu.is-open .user-dropdown { transform: translateY(0); }
    .user-dropdown .dropdown-item { padding: 13px 14px; font-size: 0.95rem; }
    .user-dropdown .dropdown-head { padding: 12px 14px; }
}

/* Dropdown backdrop — only visible on mobile when menu is open */
.dropdown-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    z-index: 45;
}
.dropdown-backdrop.is-visible { opacity: 1; visibility: visible; }
@media (min-width: 600px) { .dropdown-backdrop { display: none; } }

.dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head .dd-name { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.dropdown-head .dd-role { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }

.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--text); text-decoration: none; font-size: 0.9rem;
    transition: background var(--transition);
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-item.is-danger { color: var(--danger-text); }
.dropdown-item.is-danger svg { color: var(--danger-text); }

.app-content { flex: 1; padding: clamp(14px, 1.5vw, 18px) 10px; width: 100%; min-width: 0; max-width: 100%; display: flex; flex-direction: column; }
.app-content > * { min-width: 0; max-width: 100%; }

.app-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 10px; border-top: 1px solid var(--border);
    color: var(--text-faint); font-size: 0.8rem;
}

/* ---------- Dashboard content ---------- */

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.7rem); font-weight: 680; letter-spacing: -0.02em; }
.page-sub { color: var(--text-muted); margin-top: 5px; }

/* ---------- Compact panelled page bar (standard across pages) ---------- */
.page-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
}
.page-bar .pb-titlewrap { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.page-bar .pb-title { font-size: 1.2rem; font-weight: 650; margin: 0; white-space: nowrap; }
.page-bar .pb-sub { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 10px; border-left: 1px solid var(--border); }
.page-bar .pb-actions { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.page-bar .pb-count {
    display: inline-flex; align-items: center; gap: 5px;
    height: 28px; padding: 0 10px;
    font-size: 0.8rem; font-weight: 600;
    background: var(--primary-soft); color: var(--primary);
    border-radius: 8px;
}
.page-bar .pb-count svg { flex-shrink: 0; }
@media (max-width: 560px) {
    .page-bar { flex-wrap: wrap; }
    .page-bar .pb-sub { display: none; }
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);   /* desktop: 3-up (6 cards = 2 rows) */
    gap: 10px;
    margin-bottom: 16px;
    min-width: 0;
}
.card-grid > * { min-width: 0; }
/* Dashboard: 5 cards — 4 narrow + wider Net profit on one desktop row;
   2-up on mobile with Net profit full-width at the bottom. */
.dash-cards { grid-template-columns: repeat(4, 1fr) 1.4fr; }
@media (max-width: 900px) {
    .dash-cards { grid-template-columns: 1fr 1fr; }
    .dash-cards .dash-net { grid-column: 1 / -1; }
}
/* The 7th card spans 2 columns so it doesn't sit alone on its row */
.stat-card-wide { grid-column: span 2; }

/* 3-up variant: three cards spread evenly across the full width
   (used on the Expenses summary, which has exactly three stats). */
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* 4-up variant: four cards on desktop, two on tablet and mobile
   (used on Staff, which has exactly four stats). Self-contained so it
   doesn't inherit .card-grid's mobile 1-up rule. */
.card-grid-4 {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 10px; margin-bottom: 16px; min-width: 0;
}
.card-grid-4 > * { min-width: 0; }
@media (max-width: 1000px) { .card-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .card-grid-4 { gap: 9px; } }

/* Tablet: 2-up */
@media (max-width: 900px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
    /* A lone last card (odd count) stretches full width instead of sitting alone. */
    .card-grid-3 > .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
/* Mobile: 2-up, tighter */
@media (max-width: 640px) {
    .card-grid { gap: 9px; }
    .stat-card { padding: 10px 12px; gap: 5px; }
    .stat-icon { width: 34px; height: 34px; }
    .stat-icon svg { width: 17px; height: 17px; }
    .stat-value { font-size: 1.3rem; }
}
/* Very narrow phones: single column, wide card back to normal */
@media (max-width: 360px) {
    .card-grid { grid-template-columns: 1fr; }
    .card-grid-3 { grid-template-columns: 1fr; }
    .stat-card-wide { grid-column: span 1; }
}

/* ---- Vertical card: title (top) · icon+value (mid) · trend (bottom) ---- */
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); padding: 11px 14px;
    display: flex; flex-direction: column; gap: 6px;
    box-shadow: var(--shadow-sm); min-width: 0;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }

/* Net profit card — colored by result: green in profit, red in loss */
.stat-card.dash-net.is-profit { background: #e7f6ed; border-color: #b6e2c7; }
.stat-card.dash-net.is-profit .stat-value { color: #1f7a44; }
.stat-card.dash-net.is-profit .dash-net-icon { background: #1f9d55; color: #fff; }
.stat-card.dash-net.is-loss { background: #fdecec; border-color: #f6c6cd; }
.stat-card.dash-net.is-loss .stat-value { color: #be123c; }
.stat-card.dash-net.is-loss .dash-net-icon { background: #dc2626; color: #fff; }
[data-theme="dark"] .stat-card.dash-net.is-profit { background: #11271c; border-color: #1f7a44; }
[data-theme="dark"] .stat-card.dash-net.is-profit .stat-value { color: #34d399; }
[data-theme="dark"] .stat-card.dash-net.is-loss { background: #2a1416; border-color: #7a1f2a; }
[data-theme="dark"] .stat-card.dash-net.is-loss .stat-value { color: #f87171; }

.stat-mid { display: flex; align-items: center; gap: 10px; min-width: 0; }

.stat-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon-blue   { background: #eef2ff; color: #4f46e5; }
.stat-icon-green  { background: #e7f6ed; color: #1f9d55; }
.stat-icon-amber  { background: #fef3e2; color: #d97706; }
.stat-icon-purple { background: #f3eaff; color: #7c3aed; }
[data-theme="dark"] .stat-icon-blue   { background: #1e2a4a; color: #a5b4fc; }
[data-theme="dark"] .stat-icon-green  { background: #11271c; color: #34d399; }
[data-theme="dark"] .stat-icon-amber  { background: #2a2016; color: #fbbf24; }
[data-theme="dark"] .stat-icon-purple { background: #221a38; color: #a78bfa; }

/* Title: single line, ellipsis if it ever overflows */
.stat-label {
    font-size: 0.78rem; color: var(--text-muted); font-weight: 550;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value {
    flex: 1; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
/* Trend: single line, ellipsis */
.stat-trend {
    font-size: 0.74rem; color: var(--text-faint);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); overflow: hidden; min-width: 0; }
.panel-head { padding: 15px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 1.02rem; font-weight: 640; letter-spacing: -0.01em; }
.panel-body { padding: 18px; color: var(--text-muted); }


/* ---------- Color-matched header icons (exact, from mockup) ---------- */
.icon-btn.hi, .theme-toggle.hi-theme, .header-home {
    width: 38px; height: 38px;
    border-radius: 11px;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}

/* Home — indigo */
.header-home {
    color: #4f46e5;
    background: #eef2ff;
    border-color: #c7d2fe;
}
.header-home:hover { background: #e0e7ff; border-color: #a5b4fc; }

/* Bell — orange */
.hi-bell {
    color: #ea580c;
    background: #fff1e6;
    border-color: #fed7aa;
}
.hi-bell:hover { background: #ffe4d1; border-color: #fdba74; }

/* Settings — cyan */
.hi-gear {
    color: #0891b2;
    background: #e0f7fa;
    border-color: #a5e8f0;
}
.hi-gear:hover { background: #cbeff4; border-color: #7dd3e0; }

/* Theme — violet */
.theme-toggle.hi-theme {
    color: #7c3aed;
    background: #f3eaff;
    border-color: #ddd0f7;
}
.theme-toggle.hi-theme:hover { background: #e9daff; border-color: #c9b3f0; }

/* Sidebar toggle — blue */
.hi-sidebar {
    color: #2563eb;
    background: #eff6ff;
    border-color: #bfdbfe;
}
.hi-sidebar:hover { background: #dbeafe; border-color: #93c5fd; }

/* Dark theme overrides for header icons */
[data-theme="dark"] .header-home { color: #a5b4fc; background: #1e2a4a; border-color: #2e3d63; }
[data-theme="dark"] .hi-bell     { color: #fb923c; background: #2a2016; border-color: #4a3520; }
[data-theme="dark"] .hi-gear     { color: #22d3ee; background: #122a30; border-color: #1d454e; }
[data-theme="dark"] .theme-toggle.hi-theme { color: #a78bfa; background: #221a38; border-color: #392d5c; }
[data-theme="dark"] .hi-sidebar  { color: #60a5fa; background: #13243d; border-color: #21385c; }
[data-theme="dark"] .header-home:hover { background: #243456; }

/* Notification dot */
.icon-btn .badge {
    position: absolute; top: 6px; right: 7px;
    width: 8px; height: 8px; padding: 0;
    font-size: 0; line-height: 0;
    background: #ef4444; color: transparent;
    border-radius: 50%; border: 2px solid var(--surface);
}
.icon-btn { position: relative; }

/* ---------- User chip ---------- */
.user-menu { position: relative; flex-shrink: 0; }
.user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px 0 5px;
    margin: 0;
    border: 1px solid #fecdd3;
    border-radius: 12px;
    background: #fff0f3;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background var(--transition), border-color var(--transition);
}
.user-trigger:hover,
.user-menu.is-open .user-trigger {
    background: #ffe0e6;
    border-color: #fda4af;
}
.user-trigger .user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #f43f5e, #fb7185);
    color: #fff;
    font-weight: 650;
    font-size: 0.8rem;
}
.user-trigger .user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.15;
    text-align: left;
}
.user-trigger .user-meta .u-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #161b26;
}
.user-trigger .user-meta .u-role {
    font-size: 0.68rem;
    color: #6b7280;
}
.user-trigger .u-caret {
    display: inline-flex;
    align-items: center;
    color: #9aa1ad;
    flex-shrink: 0;
}
.user-trigger .u-caret svg { width: 15px; height: 15px; }

/* On narrow screens, collapse to avatar only */
@media (max-width: 599px) {
    .user-trigger .user-meta,
    .user-trigger .u-caret { display: none; }
    .user-trigger { padding: 0; width: 38px; justify-content: center; }
}

[data-theme="dark"] .user-trigger { background: #2a1820; border-color: #4a2630; }
[data-theme="dark"] .user-trigger:hover,
[data-theme="dark"] .user-menu.is-open .user-trigger { background: #361e28; border-color: #5e3340; }
[data-theme="dark"] .user-trigger .user-meta .u-name { color: #e6ebf4; }
[data-theme="dark"] .user-trigger .user-meta .u-role { color: #9aa7bd; }

/* Divider before user chip */
.header-divider { width: 1px; height: 26px; background: var(--border); margin: 0 4px; flex-shrink: 0; }


/* ---------- Dismissible banner ---------- */
.app-banner {
    display: flex; align-items: flex-start; gap: 12px;
    background: color-mix(in srgb, var(--hi-bell) 12%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--hi-bell) 26%, transparent);
    border-radius: var(--radius-card);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.app-banner .banner-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--hi-bell) 30%, var(--surface));
    color: color-mix(in srgb, var(--hi-bell) 75%, #000);
}
.app-banner .banner-icon svg { width: 19px; height: 19px; }
.app-banner .banner-body { flex: 1; min-width: 0; }
.app-banner .banner-title {
    font-weight: 600; font-size: 0.94rem;
    color: color-mix(in srgb, var(--hi-bell) 78%, #000);
    margin-bottom: 2px;
}
.app-banner .banner-text {
    font-size: 0.86rem; line-height: 1.5;
    color: color-mix(in srgb, var(--hi-bell) 70%, var(--text-muted));
}
.app-banner .banner-actions { margin-top: 10px; }
.app-banner .banner-close {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border: none; cursor: pointer;
    border-radius: 50%; background: transparent;
    color: color-mix(in srgb, var(--hi-bell) 70%, #000);
    transition: background var(--transition);
}
.app-banner .banner-close:hover { background: color-mix(in srgb, var(--hi-bell) 22%, transparent); }
.app-banner .banner-close svg { width: 16px; height: 16px; }
.app-banner[hidden] { display: none; }

[data-theme="dark"] .app-banner .banner-icon { color: #fff; }
[data-theme="dark"] .app-banner .banner-title { color: color-mix(in srgb, var(--hi-bell) 60%, #fff); }
[data-theme="dark"] .app-banner .banner-text { color: color-mix(in srgb, var(--hi-bell) 40%, var(--text-muted)); }

/* ============================================================
   User management — card grid
   ============================================================ */

.page-head--row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* Responsive grid: wide cards, ~340px min => 1 (mobile) / 2 (tablet) / 3 (desktop) */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: clamp(12px, 1.5vw, 16px);
}
@media (max-width: 520px) {
    .user-grid { grid-template-columns: 1fr; }
}

.user-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.user-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }

.uc-top { display: flex; align-items: flex-start; gap: 13px; }
.uc-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; font-weight: 650; font-size: 1.05rem;
}
.uc-id { flex: 1; min-width: 0; }
.uc-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.uc-name { font-weight: 600; font-size: 0.98rem; color: var(--text); }
.uc-email {
    font-size: 0.85rem; color: var(--text-muted); margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.uc-foot {
    display: flex; align-items: center; gap: 12px;
    margin-top: 14px; padding-top: 13px;
    border-top: 1px solid var(--border);
}
.uc-meta {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.78rem; color: var(--text-faint);
}
.uc-meta svg { flex-shrink: 0; }
.uc-actions { margin-left: auto; display: flex; gap: 7px; }

.act {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text-muted); cursor: pointer; text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.act:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.act.del:hover { color: #be123c; border-color: #fecdd3; background: #fff0f3; }
[data-theme="dark"] .act.del:hover { color: #fb7185; border-color: #4a2630; background: #2a1820; }

/* Status as a standalone dot in cards */
.uc-top .status { flex-shrink: 0; margin-top: 4px; }

/* Role badges */
.badge-role {
    display: inline-flex; align-items: center;
    padding: 4px 10px;
    font-size: 0.76rem; font-weight: 600;
    border-radius: 7px;
    border: 1px solid transparent;
}
.badge-admin   { color: #be123c; background: #fff0f3; border-color: #fecdd3; }
.badge-partner { color: #6d28d9; background: #f3eaff; border-color: #ddd0f7; }
.badge-staff   { color: #0891b2; background: #e0f7fa; border-color: #a5e8f0; }

[data-theme="dark"] .badge-admin   { color: #fb7185; background: #2a1820; border-color: #4a2630; }
[data-theme="dark"] .badge-partner { color: #a78bfa; background: #221a38; border-color: #392d5c; }
[data-theme="dark"] .badge-staff   { color: #22d3ee; background: #122a30; border-color: #1d454e; }

/* Status indicator */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 550; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-active   { color: #1f7a44; }
.status-active .dot   { background: #1f9d55; }
.status-inactive { color: var(--text-faint); }
.status-inactive .dot { background: var(--text-faint); }

[data-theme="dark"] .status-active { color: #7fd39b; }
[data-theme="dark"] .status-active .dot { background: #34d399; }

/* ============================================================
   Split-screen form (add/edit user)
   ============================================================ */

.form-split {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
/* Desktop: form left (wider), info panel right; fill the content area height */
@media (min-width: 820px) {
    .form-split {
        grid-template-columns: 1.6fr 1fr;
        min-height: 100%;
    }
}

/* Form panel (left) */
.form-main {
    display: flex;
    flex-direction: column;
    padding: clamp(20px, 3vw, 32px);
}
.form-main form { display: flex; flex-direction: column; flex: 1; width: 100%; max-width: 640px; margin: 0 auto; }
.form-body { flex: 1; }

/* Info panel (right) */
.form-aside {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
    padding: 30px 28px;
    color: #fff;
    background:
        radial-gradient(600px 400px at 80% 10%, rgba(255,255,255,0.12), transparent 55%),
        linear-gradient(150deg, #0e1729 0%, #1a2747 55%, #2d2a6e 100%);
}
@media (min-width: 820px) { .form-aside { display: flex; } }

.form-aside-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 12px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.22);
    margin-bottom: 16px;
}
.form-aside-title { font-size: 1.25rem; font-weight: 650; line-height: 1.25; margin-bottom: 10px; letter-spacing: -0.01em; }
.form-aside-text { font-size: 0.88rem; color: rgba(255,255,255,0.78); line-height: 1.6; }
.form-aside-foot { font-size: 0.78rem; color: rgba(255,255,255,0.62); line-height: 1.6; }
.form-aside-foot strong { color: rgba(255,255,255,0.85); font-weight: 600; }

.field { margin-bottom: 16px; }
.field > label {
    display: block; font-size: 0.83rem; font-weight: 550;
    color: var(--text-muted); margin-bottom: 6px;
}
.field .req { color: #e11d48; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field input[type="date"],
.field input[type="number"],
.field input[type="tel"],
.field select {
    width: 100%;
    height: 42px;
    padding: 0 13px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}
.field textarea {
    width: 100%;
    padding: 10px 13px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}
.field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field select { cursor: pointer; }
.field input:focus,
.field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input::placeholder { color: var(--text-faint); }
.field input.has-error,
.field select.has-error,
.field textarea.has-error { border-color: #e11d48; }

.field-error { font-size: 0.78rem; color: #be123c; margin-top: 5px; }
[data-theme="dark"] .field-error { color: #fb7185; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .field-row { gap: 10px; } }

/* Password show/hide */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-eye {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border: none; background: transparent;
    color: var(--text-faint); cursor: pointer; border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.pw-eye:hover { color: var(--text); background: var(--surface-3); }

/* Switch toggle */
.switch-row { display: inline-flex; align-items: center; gap: 10px; height: 42px; cursor: pointer; }
.switch-row input {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    flex: 0 0 auto;
    pointer-events: none;
}
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    background: var(--border-strong);
    border-radius: 12px;
    transition: background var(--transition);
}
.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch-row input:checked + .switch { background: #1f9d55; }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-label { font-size: 0.9rem; color: var(--text); white-space: nowrap; }

/* Form actions */
.form-actions {
    display: flex; gap: 10px; justify-content: flex-end; align-items: center;
    margin-top: 18px; padding-top: 18px;
    border-top: 1px solid var(--border);
}
.form-actions .btn {
    flex: 0 0 auto;
    min-width: 100px;
    height: 42px;
    white-space: nowrap;
}
.form-actions .btn-outline { padding: 0 18px; }
.form-actions .btn-primary { padding: 0 20px; }
@media (max-width: 480px) {
    /* Buttons feel solid and thumb-sized on phones. */
    .form-actions .btn { flex: 1; min-width: 0; height: 46px; justify-content: center; }
}

/* ============================================================
   Flash messages
   ============================================================ */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.flash-success { background: #e7f6ed; color: #1f7a44; border-color: #b6e2c7; }
.flash-error   { background: #fdecec; color: #be123c; border-color: #f6c6cd; }
[data-theme="dark"] .flash-success { background: #11271c; color: #7fd39b; border-color: #1f4632; }
[data-theme="dark"] .flash-error   { background: #2a1418; color: #fb7185; border-color: #4a2027; }

/* ============================================================
   Modal (confirmation dialog)
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    z-index: 100;
}
.modal-overlay.is-open { opacity: 1; visibility: visible; }

.modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    padding: 26px 24px 22px;
    text-align: center;
    transform: translateY(12px) scale(0.98);
    transition: transform var(--transition);
}
.modal-overlay.is-open .modal { transform: translateY(0) scale(1); }

.modal-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; border-radius: 14px; margin-bottom: 14px;
}
.modal-icon-danger { background: #fdecec; color: #dc2626; }
[data-theme="dark"] .modal-icon-danger { background: #2a1418; color: #f87171; }

.modal-title { font-size: 1.15rem; font-weight: 650; margin-bottom: 8px; color: var(--text); }
.modal-text { font-size: 0.9rem; color: var(--text-muted); line-height: 1.55; margin-bottom: 14px; }
.modal-text strong { color: var(--text); font-weight: 600; }

.modal-user {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 20px;
}
.modal-user-line { font-size: 0.85rem; color: var(--text-muted); }

.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions > .btn,
.modal-actions > form { flex: 1 1 0; min-width: 0; }
.modal-actions form { display: flex; }
.modal-actions .btn { width: 100%; height: 42px; }

/* Danger button */
.btn-danger {
    background: #dc2626;
    color: #fff;
    border: 1px solid #dc2626;
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* ============================================================
   Trash page
   ============================================================ */
.trash-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}
.trash-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 11px 16px;
    font-size: 0.9rem; font-weight: 550;
    color: var(--text-muted);
    background: none; border: none; cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    font-family: inherit;
}
.trash-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.trash-tab:disabled { opacity: 0.45; cursor: not-allowed; }
.trash-tab .cnt {
    font-size: 0.72rem;
    background: var(--surface-3); color: var(--text-muted);
    padding: 1px 8px; border-radius: 10px;
}
.trash-tab.is-active .cnt { background: var(--primary-soft); color: var(--primary); }

.trash-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 10px;
}
.trash-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0;
    background: linear-gradient(135deg, #94a3b8, #cbd5e1);
    color: #fff; font-weight: 650; font-size: 1rem;
}
.trash-info { flex: 1; min-width: 0; }
.trash-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trash-name { font-weight: 600; font-size: 0.96rem; color: var(--text); }
.trash-meta {
    font-size: 0.8rem; color: var(--text-faint); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trash-actions { display: flex; gap: 8px; flex-shrink: 0; }
.trash-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 38px; padding: 0 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.85rem; font-weight: 550; font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.trash-btn svg { flex-shrink: 0; }
.trash-btn.restore:hover { color: #1f7a44; border-color: #b6e2c7; background: #e7f6ed; }
.trash-btn.purge:hover   { color: #be123c; border-color: #f6c6cd; background: #fdecec; }
[data-theme="dark"] .trash-btn.restore:hover { color: #7fd39b; border-color: #1f4632; background: #11271c; }
[data-theme="dark"] .trash-btn.purge:hover   { color: #fb7185; border-color: #4a2027; background: #2a1418; }

/* Collapse actions text on very narrow screens (keep icons) */
@media (max-width: 560px) {
    .trash-card { flex-wrap: wrap; }
    .trash-actions { width: 100%; }
    .trash-btn { flex: 1; justify-content: center; }
}

.trash-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-faint);
}
.trash-empty svg { margin-bottom: 12px; opacity: 0.6; }
.trash-empty p { font-size: 0.92rem; }

/* Success variant for the modal icon (restore) */
.modal-icon-success { background: #e7f6ed; color: #1f9d55; }
[data-theme="dark"] .modal-icon-success { background: #11271c; color: #34d399; }

/* ============================================================
   Users toolbar (compact, panelled)
   ============================================================ */
.users-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
}
.tb-titlewrap { display: inline-flex; align-items: center; gap: 9px; margin-right: auto; }
.tb-sub {
    font-size: 0.82rem; color: var(--text-muted); margin-left: 4px;
    padding-left: 10px; border-left: 1px solid var(--border);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
@media (max-width: 640px) { .tb-sub { display: none; } }
.tb-title {
    font-size: 1.2rem; font-weight: 650; margin: 0;
    white-space: nowrap;
}
.tb-count {
    display: inline-flex; align-items: center; gap: 5px;
    height: 28px; padding: 0 10px;
    font-size: 0.8rem; font-weight: 600;
    background: var(--primary-soft); color: var(--primary);
    border-radius: 8px;
}
.tb-count svg { flex-shrink: 0; }

.tb-search {
    display: flex; align-items: center; gap: 8px;
    height: 40px; padding: 0 12px;
    width: 260px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-faint);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.tb-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); color: var(--text-muted); }
.tb-search svg { flex-shrink: 0; }
.tb-search input {
    border: none; outline: none; background: none;
    width: 100%; font-size: 0.9rem; font-family: inherit;
    color: var(--text);
}
.tb-search input::placeholder { color: var(--text-faint); }

.tb-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.tb-icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

.tb-add { height: 40px; flex-shrink: 0; gap: 6px; }

.users-noresults { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.users-empty {
    padding: 18px 20px; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
}

/* Search bg inside the white panel — use a subtle inset surface */
.users-toolbar .tb-search { background: var(--surface-2); }

/* Responsive: stack search full-width on small screens */
@media (max-width: 600px) {
    .users-toolbar { flex-wrap: wrap; }
    .tb-titlewrap { width: auto; }
    .tb-search { order: 3; width: 100%; }
    .tb-add .tb-add-label { display: none; }
    .tb-add { width: 40px; padding: 0; justify-content: center; }
}

/* ============================================================
   Settings page (left nav + section content)
   ============================================================ */
.settings-shell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
@media (min-width: 720px) {
    .settings-shell { grid-template-columns: 220px 1fr; }
}

/* Left nav */
.settings-nav {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
@media (min-width: 720px) {
    .settings-nav { border-bottom: none; border-right: 1px solid var(--border); }
}
.settings-navitem {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-muted); text-decoration: none;
    font-size: 0.9rem; font-weight: 550;
    transition: background var(--transition), color var(--transition);
}
.settings-navitem:hover { background: var(--surface-2); color: var(--text); }
.settings-navitem.is-active { background: var(--primary-soft); color: var(--primary); }
.settings-navitem .sn-icon { display: inline-flex; flex-shrink: 0; }
.settings-navitem .sn-label { margin-right: auto; }
.settings-navitem .sn-chevron { display: none; color: var(--text-faint); }
@media (max-width: 719px) {
    .settings-navitem .sn-chevron { display: inline-flex; }
}

/* Right content */
.settings-content { padding: clamp(18px, 2.5vw, 26px); }
.settings-back {
    display: none;
    align-items: center; gap: 7px;
    font-size: 0.85rem; font-weight: 550;
    color: var(--text-muted); text-decoration: none;
    margin-bottom: 16px;
}

.ss-head { margin-bottom: 20px; }
.ss-head h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; }
.ss-head p { font-size: 0.85rem; color: var(--text-muted); margin-top: 3px; }

.ss-form { max-width: 560px; }
.ss-actions {
    margin-top: 8px; padding-top: 18px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end;
}
.ss-actions .btn { min-width: 130px; height: 42px; }

/* Mobile: list → detail behaviour */
@media (max-width: 719px) {
    /* Default (list view): show nav, hide content */
    .settings-shell:not([data-view="detail"]) .settings-content { display: none; }
    /* Detail view: hide nav, show content + back link */
    .settings-shell[data-view="detail"] .settings-nav { display: none; }
    .settings-shell[data-view="detail"] .settings-back { display: inline-flex; }
}

/* ---------- Font picker grid ---------- */
.font-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.font-option {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 16px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    text-align: center;
}
.font-option:hover { border-color: var(--border-strong); }
.font-option input { position: absolute; opacity: 0; pointer-events: none; }
.font-option.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.font-preview { font-size: 1.8rem; font-weight: 600; color: var(--text); line-height: 1; }
.font-name { font-size: 0.74rem; color: var(--text-muted); }
.font-option.is-selected .font-name { color: var(--primary); font-weight: 600; }

/* ============================================================
   Logo / color settings field
   ============================================================ */
.field-hint { font-size: 0.74rem; color: var(--text-faint); margin-top: 5px; }

.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type="color"] {
    width: 42px; height: 42px; padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 4px; }
.color-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-preview { display: inline-flex; align-items: center; }
.logo-chip {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 42px; height: 42px; padding: 0 10px; border-radius: 10px;
    color: #fff; font-weight: 700; font-size: 0.8rem; letter-spacing: 0.02em;
}
/* ============================================================
   Books / Inventory module
   ============================================================ */

/* View toggle (cards / table) in the toolbar */
.bk-viewtoggle {
    display: inline-flex; flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px; gap: 2px;
}
.bk-vt-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 32px; border: none; background: transparent;
    color: var(--text-faint); border-radius: 6px; cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.bk-vt-btn:hover { color: var(--text-muted); }
.bk-vt-btn.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* Container toggles which child layout is visible */
.bk-views[data-view="cards"] .bk-tablewrap { display: none; }
.bk-views[data-view="table"] .bk-grid { display: none; }

/* ---------- Card grid ---------- */
.bk-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
@media (min-width: 1600px) { .bk-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1080px)  { .bk-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)   { .bk-grid { grid-template-columns: 1fr; gap: 12px; } }
.bk-card {
    display: flex; flex-direction: column; gap: 9px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.bk-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.bk-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }
.bk-title {
    font-size: 0.96rem; font-weight: 620; color: var(--text);
    line-height: 1.35; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bk-author { font-size: 0.83rem; color: var(--text-muted); }
.bk-muted { color: var(--text-faint); font-style: italic; }
.bk-meta { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px 8px; margin-top: 2px; min-width: 0; overflow: hidden; }
.bk-meta-item {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.78rem; color: var(--text-faint); white-space: nowrap; min-width: 0;
}
.bk-meta-item:first-child { overflow: hidden; text-overflow: ellipsis; }
.bk-meta-item + .bk-meta-item::before {
    content: "·"; margin-right: 8px; color: var(--border-strong);
}
.bk-meta-item svg { flex-shrink: 0; }

/* Source chip in the card top row (sits just left of the status badge) */
.bk-card-source {
    display: inline-flex; align-items: center; gap: 4px;
    margin-left: auto; min-width: 0;
    font-size: 0.76rem; color: var(--primary); font-weight: 550;
}
.bk-card-source svg { flex-shrink: 0; }
.bk-card-source span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] .bk-card-source { color: #a5b4fc; }
/* When a source is present it takes the auto margin, so the status badge
   should no longer push itself — keep a small gap before it. */
.bk-card-top .bk-card-source + .bk-status { margin-left: 8px; }

/* Source column in table */
.bk-col-source { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.bk-dim { color: var(--text-faint); }
@media (max-width: 1100px) { .bk-col-source { display: none; } }
.bk-card-foot {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border);
    gap: 8px;
}
.bk-cost { font-weight: 700; font-size: 0.98rem; color: var(--text); letter-spacing: -0.01em; }
.bk-actions { display: inline-flex; gap: 7px; }

/* Reuse the .act / .del action button styling from user cards */
.bk-actions .act {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text-muted); cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.bk-actions .act:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.bk-actions .del:hover { color: #dc2626; border-color: #f6c6cd; background: #fdecec; }

/* ---------- Channel / status badges ---------- */
.bk-channel {
    display: inline-flex; align-items: center; flex-shrink: 0;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em;
    padding: 2px 8px; border-radius: 5px; border: 1px solid transparent;
}
.bk-channel-fba { color: #b45309; background: #fef3e2; border-color: #fbd9a5; }
.bk-channel-fbm { color: #1d4ed8; background: #e6efff; border-color: #c2d6fb; }

.bk-status {
    display: inline-flex; align-items: center; margin-left: auto;
    font-size: 0.72rem; font-weight: 600;
    padding: 2px 9px; border-radius: 5px; border: 1px solid transparent;
}
.bk-status-instock { color: #1f7a44; background: #e7f6ed; border-color: #b6e2c7; }
.bk-status-listed  { color: #6d28d9; background: #f3eaff; border-color: #ddd0f7; }
.bk-status-sold    { color: var(--text-muted); background: var(--surface-3); border-color: var(--border); }

/* In the table the status badge shouldn't push right */
.bk-table .bk-status { margin-left: 0; }

/* ---------- Table ---------- */
.bk-tablewrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}
.bk-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.bk-table thead th {
    text-align: left; font-weight: 600; font-size: 0.74rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-faint);
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.bk-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted); vertical-align: middle; }
.bk-table tbody tr:last-child td { border-bottom: none; }
.bk-table tbody tr:hover { background: var(--surface-2); }
.bk-cell-title { display: block; font-weight: 600; color: var(--text); }
.bk-cell-author { display: block; font-size: 0.8rem; color: var(--text-faint); margin-top: 1px; }
.bk-col-isbn { font-variant-numeric: tabular-nums; color: var(--text-faint); white-space: nowrap; }
.bk-col-cost { font-weight: 600; color: var(--text); white-space: nowrap; }
.bk-col-act { width: 1%; white-space: nowrap; }
.bk-table .bk-actions { justify-content: flex-end; }

/* Hide secondary columns on narrow screens */
@media (max-width: 720px) {
    .bk-col-cond, .bk-col-chan { display: none; }
}
@media (max-width: 520px) {
    .bk-col-isbn { display: none; }
}

/* ---------- Add/edit form bits ---------- */
.bk-optional { font-size: 0.78rem; color: var(--text-faint); font-weight: 400; }

.bk-isbn-row { display: flex; gap: 8px; align-items: stretch; }
.bk-isbn-input { position: relative; flex: 1; display: flex; align-items: center; }
.bk-isbn-input svg { position: absolute; left: 12px; color: var(--text-faint); pointer-events: none; }
.bk-isbn-input input { padding-left: 38px !important; width: 100%; }
.bk-lookup-btn { flex-shrink: 0; gap: 6px; height: auto; padding: 0 14px; }

.bk-lookup-status { font-size: 0.78rem; margin-top: 6px; }
.bk-lookup-status.is-loading { color: var(--text-muted); }
.bk-lookup-status.is-success { color: #1f7a44; }
.bk-lookup-status.is-error   { color: #be123c; }

.bk-textarea {
    width: 100%; resize: vertical; min-height: 56px;
    padding: 11px 13px;
    font: inherit; font-size: 0.92rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.bk-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.bk-textarea::placeholder { color: var(--text-faint); }
.bk-textarea.has-error { border-color: #e11d48; }

.bk-cam-btn { flex-shrink: 0; padding: 0 13px; height: auto; }

@media (max-width: 480px) {
    /* Input takes the full first line; Lookup + camera share the second. */
    .bk-isbn-row { flex-wrap: wrap; }
    .bk-isbn-input { flex: 1 1 100%; }
    .bk-lookup-btn { flex: 1; justify-content: center; min-height: 44px; }
    .bk-cam-btn { width: 52px; min-height: 44px; justify-content: center; }
}

/* ---------- Trash: book avatar ---------- */
.trash-avatar-book { background: var(--surface-3); color: var(--text-muted); }
.trash-sub { font-size: 0.8rem; color: var(--text-faint); }

/* ============================================================
   Books — detail expansion (covers, prices, profit, timeline)
   ============================================================ */

/* ---- Card: cover + clickable + prices ---- */
.bk-card { position: relative; }
.bk-card-link { position: absolute; inset: 0; z-index: 1; border-radius: var(--radius-card); }
.bk-card-body { display: flex; gap: 13px; }
.bk-card-cover {
    flex-shrink: 0; width: 58px; height: 82px; border-radius: 8px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--text-faint);
    align-self: flex-start;
}
.bk-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.bk-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bk-card-info .bk-title { -webkit-line-clamp: 2; }

.bk-card-foot { position: relative; z-index: 2; }
.bk-prices { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.bk-cost-sm { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.bk-sale { font-size: 0.82rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.bk-profit-chip {
    font-size: 0.74rem; font-weight: 700; padding: 1px 7px; border-radius: 5px; flex-shrink: 0;
}
.bk-profit-chip.is-pos { color: #1f7a44; background: #e7f6ed; }
.bk-profit-chip.is-neg { color: #be123c; background: #fdecec; }
.bk-card-foot .bk-actions { position: relative; z-index: 2; }

/* ---- Table: thumb + linked title + sale/profit ---- */
.bk-cell-main { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.bk-cell-thumb {
    flex-shrink: 0; width: 30px; height: 40px; border-radius: 5px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--text-faint);
}
.bk-cell-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bk-cell-main:hover .bk-cell-title { color: var(--primary); }
.bk-col-sale, .bk-col-profit { white-space: nowrap; }
.bk-profit-txt { font-weight: 600; }
.bk-profit-txt.is-pos { color: #1f9d55; }
.bk-profit-txt.is-neg { color: #dc2626; }
@media (max-width: 860px) { .bk-col-sale { display: none; } }
@media (max-width: 760px) { .bk-col-profit { display: none; } }

/* ---- Form: title row with cover preview ---- */
.bk-title-row { display: flex; gap: 16px; align-items: stretch; }
.bk-cover-preview {
    flex-shrink: 0; width: 116px; align-self: stretch; min-height: 158px;
    border-radius: 10px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--text-faint);
    position: relative;
}
.bk-cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.bk-cover-empty { display: inline-flex; }
.bk-title-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.bk-title-fields .field { margin-bottom: 0; }

/* ---- Form: section labels ---- */
.bk-section-label {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-faint); margin: 6px 0 12px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* ---- Form: money input with prefixed symbol ---- */
.bk-money { position: relative; display: flex; align-items: center; }
.bk-money-sym {
    position: absolute; left: 12px; color: var(--text-faint);
    font-size: 0.9rem; pointer-events: none;
}
.bk-money input { padding-left: 26px !important; width: 100%; }

/* date inputs share the field input styling */
.field input[type="date"] {
    width: 100%; padding: clamp(10px, 1.6vw, 12px) 13px;
    font: inherit; font-size: 0.92rem; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.field input[type="date"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---- Form: live profit box ---- */
.bk-profit {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; margin: 4px 0 18px;
    border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.bk-profit-label { font-size: 0.82rem; color: var(--text-muted); }
.bk-profit-value { font-size: 1.05rem; font-weight: 700; color: var(--text-faint); }
.bk-profit.is-pos { border-color: #b6e2c7; background: #e7f6ed; }
.bk-profit.is-pos .bk-profit-value { color: #1f7a44; }
.bk-profit.is-neg { border-color: #f6c6cd; background: #fdecec; }
.bk-profit.is-neg .bk-profit-value { color: #be123c; }

/* ============================================================
   Book detail page
   ============================================================ */
.bk-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 8px; margin-right: 4px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
}
.bk-back:hover { background: var(--surface-3); color: var(--text); }

.bk-detail { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 880px) { .bk-detail { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.bk-detail-left { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.bk-detail-main {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm); padding: 20px;
}
.bk-detail-head { display: flex; gap: 16px; align-items: flex-start; }
.bk-detail-cover {
    flex-shrink: 0; width: 96px; height: 132px; border-radius: 10px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--text-faint);
}
.bk-detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.bk-detail-id { flex: 1; min-width: 0; }
.bk-detail-badges { display: flex; gap: 7px; margin-bottom: 8px; }
.bk-detail-badges .bk-status { margin-left: 0; }
.bk-detail-title { font-size: 1.2rem; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; }
.bk-detail-author { font-size: 0.92rem; color: var(--text-muted); margin-top: 3px; }
.bk-detail-isbn { font-size: 0.8rem; color: var(--text-faint); margin-top: 6px; font-variant-numeric: tabular-nums; }
.bk-detail-isbns { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.bk-isbn-tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; border-radius: 7px;
    background: var(--surface-2); border: 1px solid var(--border);
}
.bk-isbn-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em; color: var(--text-faint); text-transform: uppercase; }
.bk-isbn-val { font-size: 0.8rem; color: var(--text); font-variant-numeric: tabular-nums; }

.bk-detail-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px;
    margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border);
}
@media (min-width: 560px) { .bk-detail-grid { grid-template-columns: repeat(3, 1fr); } }
.bk-dl { display: flex; flex-direction: column; gap: 2px; }
.bk-dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); font-weight: 600; }
.bk-dd { font-size: 0.9rem; color: var(--text); }
.bk-detail-notes { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.bk-detail-notes p { margin-top: 6px; font-size: 0.9rem; color: var(--text-muted); line-height: 1.55; }

.bk-detail-side { display: flex; flex-direction: column; gap: 14px; }
.bk-price-rows { padding: 6px 18px; }
.bk-price-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; color: var(--text-muted); }
.bk-price-row:last-child { border-bottom: none; }
.bk-price-row strong { color: var(--text); font-weight: 650; }
.bk-profit-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 13px 18px; border-top: 1px solid var(--border);
    font-size: 0.95rem; font-weight: 600;
}
.bk-profit-row strong { font-size: 1.05rem; }
.bk-profit-row.is-pos { background: #e7f6ed; color: #1f7a44; }
.bk-profit-row.is-neg { background: #fdecec; color: #be123c; }
.bk-profit-hint { padding: 11px 18px; font-size: 0.76rem; color: var(--text-faint); border-top: 1px solid var(--border); line-height: 1.5; }

/* ---- Price history timeline ---- */
.bk-timeline { list-style: none; padding: 14px 18px 18px; margin: 0; }
.bk-tl-item { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.bk-tl-item:not(:last-child)::before {
    content: ""; position: absolute; left: 5px; top: 16px; bottom: 0;
    width: 2px; background: var(--border);
}
.bk-tl-dot { flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%; margin-top: 3px; background: var(--text-faint); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); z-index: 1; }
.bk-h-cost { background: #94a3b8; }
.bk-h-list { background: #6366f1; }
.bk-h-discount { background: #d97706; }
.bk-h-sold { background: #1f9d55; }
.bk-tl-body { flex: 1; min-width: 0; }
.bk-tl-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.bk-tl-kind { font-size: 0.86rem; font-weight: 600; color: var(--text); }
.bk-tl-change { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.bk-tl-old { color: var(--text-faint); text-decoration: line-through; }
.bk-tl-change svg { color: var(--text-faint); }
.bk-tl-new { font-weight: 650; color: var(--text); }
.bk-tl-meta { font-size: 0.76rem; color: var(--text-faint); margin-top: 3px; }
.bk-tl-note { font-style: italic; }

@media (max-width: 480px) {
    .bk-title-row { flex-direction: column; }
    .bk-cover-preview { align-self: flex-start; width: 100px; min-height: 140px; }
}

/* ---- Cover: removable preview + manual URL field ---- */
.bk-cover-preview { position: relative; }
.bk-cover-remove {
    position: absolute; top: -7px; right: -7px;
    width: 22px; height: 22px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm); padding: 0; z-index: 2;
    transition: background var(--transition), color var(--transition);
}
.bk-cover-remove:hover { background: #fdecec; color: #dc2626; border-color: #f6c6cd; }
.bk-cover-url-field { margin-top: 4px; }
.field input[type="url"] {
    width: 100%; padding: clamp(10px, 1.6vw, 12px) 13px;
    font: inherit; font-size: 0.92rem; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.field input[type="url"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input[type="url"].has-error { border-color: #e11d48; }
.field input[type="url"]::placeholder { color: var(--text-faint); }

/* ============================================================
   Dashboard — live overview (recent list + distributions)
   ============================================================ */
.stat-value.is-neg { color: #dc2626; }
[data-theme="dark"] .stat-value.is-neg { color: #f87171; }
.bk-inline-link { color: var(--primary); font-weight: 600; }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 14px; min-width: 0; }
.dash-grid > * { min-width: 0; }
.dash-toolbar .tb-sub { font-size: 0.82rem; color: var(--text-muted); margin-left: 4px; }
@media (max-width: 560px) { .dash-toolbar .tb-sub { display: none; } }
.dash-empty {
    padding: 18px 20px; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
}
@media (min-width: 900px) { .dash-grid { grid-template-columns: 1.5fr 1fr; align-items: start; } }
@media (min-width: 900px) {
    .dash-recent { position: sticky; top: calc(var(--header-h) + 14px); align-self: start; }
}

.dash-head { display: flex; align-items: center; justify-content: space-between; }
.dash-link { font-size: 0.82rem; font-weight: 600; color: var(--primary); }

/* Recent additions list */
.dash-booklist { list-style: none; margin: 0; padding: 6px; }
.dash-book {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    color: inherit; text-decoration: none;
    transition: background var(--transition);
}
.dash-book:hover { background: var(--surface-2); }
.dash-book-cover {
    flex-shrink: 0; width: 34px; height: 46px; border-radius: 5px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--text-faint);
}
.dash-book-cover img { width: 100%; height: 100%; object-fit: cover; }
.dash-book-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dash-book-title { font-size: 0.9rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-book-sub { font-size: 0.78rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-book:hover .dash-book-title { color: var(--primary); }
.dash-book-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.dash-book-status { width: 64px; text-align: center; justify-content: center; box-sizing: border-box; }
.dash-book-cost {
    width: 64px; text-align: center; box-sizing: border-box;
    font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
    padding: 2px 8px; border-radius: 5px;
    background: var(--surface-2); border: 1px solid var(--border);
}

/* Distribution panels */
.dash-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dash-side > * { min-width: 0; }
.dash-dist { padding: 16px 18px; }
.dash-bar {
    display: flex; height: 12px; border-radius: 999px; overflow: hidden;
    background: var(--surface-3); margin-bottom: 14px;
}
.dash-bar-seg { height: 100%; transition: width var(--transition); }
.dash-bar-seg:first-child { border-top-left-radius: 999px; border-bottom-left-radius: 999px; }

.dash-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dash-legend li { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); }
.dash-legend .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dash-legend strong { color: var(--text); font-weight: 650; margin-left: auto; }
.dash-legend-pct { color: var(--text-faint); font-size: 0.78rem; min-width: 38px; text-align: right; }
.dash-legend li strong + .dash-legend-pct { margin-left: 10px; }

/* Segment colors (shared by bars + legend dots) */
.seg-instock { background: #1f9d55; }
.seg-listed  { background: #7c3aed; }
.seg-sold    { background: #94a3b8; }
.seg-fba     { background: #d97706; }
.seg-fbm     { background: #2563eb; }

/* ============================================================
   Quick status segment bar (cards + detail)
   ============================================================ */
.bk-statusbar {
    display: flex; gap: 4px; margin-top: 10px;
    padding: 4px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
    position: relative; z-index: 2;
    transition: background var(--transition), border-color var(--transition);
}
.bk-statusbar.is-loading { opacity: 0.6; pointer-events: none; }
.bk-statusbtn {
    flex: 1 1 0; min-width: 0;
    padding: 6px 8px; border: none; border-radius: 7px;
    background: transparent; color: var(--text-muted);
    font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}
.bk-statusbtn:hover { color: var(--text); background: var(--surface-3); }
.bk-statusbtn.is-active { box-shadow: var(--shadow-sm); cursor: default; font-weight: 700; }

/* ===== STYLE B: whole bar tints to the active status ===== */
/* Bar background per active status — driven by data-active (set by PHP + JS),
   with a :has() fallback for browsers that support it. */
.bk-statusbar[data-active="in_stock"],
.bk-statusbar:has(.is-active[data-set-status="in_stock"]) { background: #e7f6ed; border-color: #b6e2c7; }
.bk-statusbar[data-active="listed"],
.bk-statusbar:has(.is-active[data-set-status="listed"])   { background: #f3eaff; border-color: #ddd0f7; }
.bk-statusbar[data-active="sold"],
.bk-statusbar:has(.is-active[data-set-status="sold"])     { background: #fef3e2; border-color: #fbd9a5; }

/* Active button: solid color + white text */
.bk-statusbtn.is-active[data-set-status="in_stock"] { background: #1f9d55; color: #fff; }
.bk-statusbtn.is-active[data-set-status="listed"]   { background: #7c3aed; color: #fff; }
.bk-statusbtn.is-active[data-set-status="sold"]     { background: #d97706; color: #fff; }

/* Inactive buttons inside a tinted bar: take a muted tint of the active color */
.bk-statusbar[data-active="in_stock"] .bk-statusbtn:not(.is-active),
.bk-statusbar:has(.is-active[data-set-status="in_stock"]) .bk-statusbtn:not(.is-active) { color: #2f8055; }
.bk-statusbar[data-active="listed"] .bk-statusbtn:not(.is-active),
.bk-statusbar:has(.is-active[data-set-status="listed"]) .bk-statusbtn:not(.is-active)   { color: #7a5bb0; }
.bk-statusbar[data-active="sold"] .bk-statusbtn:not(.is-active),
.bk-statusbar:has(.is-active[data-set-status="sold"]) .bk-statusbtn:not(.is-active)     { color: #a9742f; }
.bk-statusbar .bk-statusbtn:not(.is-active):hover { background: rgba(0,0,0,0.04); }

/* Dark theme tints */
[data-theme="dark"] .bk-statusbar[data-active="in_stock"],
[data-theme="dark"] .bk-statusbar:has(.is-active[data-set-status="in_stock"]) { background: #11271c; border-color: #1d4733; }
[data-theme="dark"] .bk-statusbar[data-active="listed"],
[data-theme="dark"] .bk-statusbar:has(.is-active[data-set-status="listed"])   { background: #221a38; border-color: #3a2d5c; }
[data-theme="dark"] .bk-statusbar[data-active="sold"],
[data-theme="dark"] .bk-statusbar:has(.is-active[data-set-status="sold"])     { background: #2a2016; border-color: #4a3a1f; }
[data-theme="dark"] .bk-statusbtn.is-active[data-set-status="in_stock"] { background: #1f9d55; color: #fff; }
[data-theme="dark"] .bk-statusbtn.is-active[data-set-status="listed"]   { background: #7c3aed; color: #fff; }
[data-theme="dark"] .bk-statusbtn.is-active[data-set-status="sold"]     { background: #d97706; color: #fff; }
[data-theme="dark"] .bk-statusbar[data-active="in_stock"] .bk-statusbtn:not(.is-active) { color: #6ee7a8; }
[data-theme="dark"] .bk-statusbar[data-active="listed"] .bk-statusbtn:not(.is-active)   { color: #c4b5fd; }
[data-theme="dark"] .bk-statusbar[data-active="sold"] .bk-statusbtn:not(.is-active)     { color: #fbbf24; }

/* Larger variant on the detail page */
.bk-statusbar-lg { margin-top: 14px; max-width: 320px; }
.bk-statusbar-lg .bk-statusbtn { padding: 8px 10px; font-size: 0.82rem; }

/* Sold popover fields */
.sold-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; text-align: left; }
.sold-fields .field { margin-bottom: 0; }
@media (max-width: 380px) { .sold-fields { grid-template-columns: 1fr; } }
/* ============================================================
   Combobox — filterable picker (Source / Shelf) with add + delete
   ============================================================ */
.combo { position: relative; }
.combo-control { position: relative; display: flex; align-items: center; }
.combo-input {
    width: 100%; height: 42px;
    padding: 0 38px 0 13px;
    font-size: 0.92rem; font-family: inherit; color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.combo-input::placeholder { color: var(--text-faint); }
.combo-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.combo-input.has-error { border-color: #e11d48; }
.combo-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-faint); cursor: pointer;
    border-radius: 7px; transition: color var(--transition), transform var(--transition);
}
.combo-toggle:hover { color: var(--text-muted); }
.combo.is-open .combo-toggle { color: var(--primary); transform: translateY(-50%) rotate(180deg); }

/* Dropdown panel */
.combo-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
    max-height: 240px; overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); padding: 4px;
}
.combo-opt {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 7px; cursor: pointer;
    font-size: 0.9rem; color: var(--text);
}
.combo-opt-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt:hover, .combo-opt.is-active { background: var(--surface-2); }
.combo-opt-del {
    flex-shrink: 0; width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-faint);
    border-radius: 6px; cursor: pointer; opacity: 0;
    transition: opacity var(--transition), background var(--transition), color var(--transition);
}
.combo-opt:hover .combo-opt-del { opacity: 1; }
.combo-opt-del:hover { background: #fdecec; color: #dc2626; }
[data-theme="dark"] .combo-opt-del:hover { background: #3b1d1d; color: #f87171; }

/* "+ add new" row */
.combo-add {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 7px; cursor: pointer;
    font-size: 0.9rem; font-weight: 600; color: var(--primary);
}
.combo-add:hover { background: var(--primary-soft); }
.combo-add svg { flex-shrink: 0; }

.combo-empty { padding: 10px; font-size: 0.85rem; color: var(--text-faint); text-align: center; }

/* On touch, delete buttons are always visible (no hover) */
@media (hover: none) {
    .combo-opt-del { opacity: 1; }
}

/* ---- Copies badge + duplicate button ---- */
.bk-copies {
    display: inline-flex; align-items: center; flex-shrink: 0;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em;
    padding: 1px 7px; border-radius: 5px;
    background: var(--primary-soft); color: var(--primary);
}
[data-theme="dark"] .bk-copies { background: #2a2752; color: #a5b4fc; }
/* Duplicate form sits inline among the icon actions without extra spacing */
.bk-dup-form { display: inline-flex; margin: 0; padding: 0; }
.bk-dup-form .act { background: none; }

/* ---- Detail page: copies panel ---- */
.bk-copies-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
    font-size: 0.72rem; font-weight: 700; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary);
}
[data-theme="dark"] .bk-copies-count { background: #2a2752; color: #a5b4fc; }
.bk-copies-list { list-style: none; margin: 0; padding: 6px; }
.bk-copy-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    text-decoration: none; color: var(--text);
    transition: background var(--transition);
}
.bk-copy-row:hover { background: var(--surface-2); }
.bk-copy-row.is-current { background: var(--primary-soft); }
[data-theme="dark"] .bk-copy-row.is-current { background: #221f43; }
/* Fixed-width status column so the condition text always lines up */
.bk-copy-row .bk-status {
    width: 74px; flex-shrink: 0; margin-left: 0;
    justify-content: center; text-align: center;
}
.bk-copy-cond { font-size: 0.85rem; color: var(--text-muted); flex: 1; min-width: 0; }
.bk-copy-cost { font-size: 0.88rem; font-weight: 600; color: var(--text); flex-shrink: 0; white-space: nowrap; width: 70px; text-align: right; }
.bk-copy-here {
    font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--primary); flex-shrink: 0; white-space: nowrap;
}

/* ============================================================
   Partners & Capital
   ============================================================ */
.pt-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px; margin-top: 4px;
}
.pt-card {
    position: relative; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-card);
    padding: 16px; box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.pt-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.pt-card-link { position: absolute; inset: 0; z-index: 1; }
.pt-card-head { display: flex; align-items: center; gap: 11px; position: relative; z-index: 2; pointer-events: none; }
.pt-avatar {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary);
    font-weight: 700; font-size: 1rem;
}
.pt-id { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pt-name { font-weight: 650; font-size: 0.98rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-sub { font-size: 0.78rem; color: var(--text-faint); }
.pt-del {
    flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-faint);
    cursor: pointer; pointer-events: auto; position: relative; z-index: 3;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.pt-del:hover { background: #fdecec; color: #dc2626; border-color: #f6c6cd; }
[data-theme="dark"] .pt-del:hover { background: #3b1d1d; color: #f87171; }

.pt-balance { position: relative; z-index: 2; pointer-events: none; margin: 14px 0 12px; }
.pt-balance-label { display: block; font-size: 0.74rem; color: var(--text-faint); margin-bottom: 2px; }
.pt-balance-val { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.pt-balance-val.is-neg { color: #dc2626; }
[data-theme="dark"] .pt-balance-val.is-neg { color: #f87171; }

.pt-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    position: relative; z-index: 2; pointer-events: none;
}
.pt-stat {
    display: flex; flex-direction: column; gap: 1px; min-width: 0;
    padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.pt-stat span { font-size: 0.7rem; color: var(--text-faint); }
.pt-stat strong { font-size: 0.86rem; font-weight: 650; color: var(--text); white-space: nowrap; }

/* Partner detail summary */
.pt-summary { padding: 16px 18px; }
.pt-summary-bal { margin-bottom: 14px; }
.pt-summary-rows .bk-price-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
.pt-summary-rows .bk-price-row:last-child { border-bottom: none; }

/* Ledger timeline dots + amounts */
.pt-tl-capital { background: #7c3aed; }
.pt-tl-drawing { background: #d97706; }
.pt-tl-profit  { background: #1f9d55; }
.pt-tl-loss    { background: #dc2626; }
.pt-tl-right { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.pt-tl-amount { font-weight: 700; font-size: 0.9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pt-tl-amount.is-plus { color: #1f9d55; }
.pt-tl-amount.is-minus { color: #d97706; }
[data-theme="dark"] .pt-tl-amount.is-plus { color: #34d399; }
[data-theme="dark"] .pt-tl-amount.is-minus { color: #fbbf24; }
.bk-tl-meta { font-size: 0.76rem; color: var(--text-faint); margin-top: 2px; }
.pt-soon { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

/* ---- Partner: transaction form + ledger entry actions ---- */
.pt-type-toggle { display: flex; gap: 8px; }
.pt-type-opt { flex: 1; cursor: pointer; }
.pt-type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pt-type-pill {
    display: block; text-align: center; padding: 9px 10px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-muted);
    font-size: 0.85rem; font-weight: 600;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.pt-type-opt input:checked + .pt-type-capital { background: #f3eaff; color: #6d28d9; border-color: #ddd0f7; }
.pt-type-opt input:checked + .pt-type-drawing { background: #fef3e2; color: #b45309; border-color: #fbd9a5; }
[data-theme="dark"] .pt-type-opt input:checked + .pt-type-capital { background: #221a38; color: #c4b5fd; border-color: #3a2d5c; }
[data-theme="dark"] .pt-type-opt input:checked + .pt-type-drawing { background: #2a2016; color: #fbbf24; border-color: #4a3a1f; }
.pt-type-opt input:focus-visible + .pt-type-pill { box-shadow: 0 0 0 3px var(--primary-soft); }
.pt-tx-submit { width: 100%; justify-content: center; margin-top: 4px; }

/* Ledger row right side: amount + delete */
/* Ledger row: delete button on the left, amount aligned right */
.pt-tl-del {
    width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; margin-top: 1px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-faint);
    cursor: pointer; opacity: 0;
    transition: opacity var(--transition), background var(--transition), color var(--transition);
}
.bk-tl-item:hover .pt-tl-del { opacity: 1; }
.pt-tl-del:hover { background: #fdecec; color: #dc2626; }
[data-theme="dark"] .pt-tl-del:hover { background: #3b1d1d; color: #f87171; }
@media (hover: none) { .pt-tl-del { opacity: 1; } }

/* ---- Partners: split-method quick switch ---- */
.pt-bar-actions { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pt-method-switch { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.pt-method-label { font-size: 0.78rem; color: var(--text-faint); padding: 0 4px 0 6px; }
.pt-method-btn {
    border: none; background: transparent; cursor: pointer;
    font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    padding: 5px 10px; border-radius: 6px;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}
.pt-method-btn:hover { color: var(--text); }
.pt-method-btn.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); cursor: default; }

/* ---- Profit distribution ---- */
.pt-preview {
    margin: 4px 0 16px; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.pt-preview-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px;
}
.pt-preview-method { font-weight: 600; color: var(--primary); text-transform: none; letter-spacing: 0; font-size: 0.74rem; }
.pt-preview-list { list-style: none; margin: 0; padding: 0; }
.pt-preview-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.pt-preview-list li:last-child { border-bottom: none; }
.pt-preview-name { font-size: 0.9rem; color: var(--text); }
.pt-preview-amt { font-size: 0.9rem; font-weight: 700; color: #1f9d55; }
[data-theme="dark"] .pt-preview-amt { color: #34d399; }
.pt-preview-empty { color: var(--text-faint); font-size: 0.85rem; padding: 6px 0; }

/* Past distributions list */
.pt-dist-list { list-style: none; margin: 0; padding: 8px; }
.pt-dist-item { position: relative; padding: 11px 12px; border-radius: var(--radius-sm); }
.pt-dist-item:hover { background: var(--surface-2); }
.pt-dist-main { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-right: 26px; }
.pt-dist-period { font-weight: 650; font-size: 0.92rem; color: var(--text); }
.pt-dist-amt { font-weight: 700; font-size: 0.95rem; color: #1f9d55; }
[data-theme="dark"] .pt-dist-amt { color: #34d399; }
.pt-dist-meta { font-size: 0.76rem; color: var(--text-faint); margin-top: 2px; }
.pt-dist-del-form { position: absolute; top: 10px; right: 8px; margin: 0; }
.pt-dist-del {
    width: 24px; height: 24px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-faint); cursor: pointer; opacity: 0;
    transition: opacity var(--transition), background var(--transition), color var(--transition);
}
.pt-dist-item:hover .pt-dist-del { opacity: 1; }
.pt-dist-del:hover { background: #fdecec; color: #dc2626; }
[data-theme="dark"] .pt-dist-del:hover { background: #3b1d1d; color: #f87171; }
@media (hover: none) { .pt-dist-del { opacity: 1; } }

/* ============================================================
   Expenses
   ============================================================ */
/* Form modal (expenses, etc.): left-aligned, roomier than the default
   centered confirm modal. */
.modal.modal-wide {
    max-width: 540px;
    text-align: left;
    padding: 24px 26px 22px;
}
.modal.modal-wide .modal-title { text-align: left; margin-bottom: 18px; }
.modal.modal-wide .field { margin-bottom: 15px; }
.modal.modal-wide .field:last-of-type { margin-bottom: 0; }
.modal.modal-wide .field label {
    display: block; text-align: left;
    font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px;
}
.modal.modal-wide .field-row { display: flex; gap: 14px; }
.modal.modal-wide .field-row .field { flex: 1; min-width: 0; }
.modal.modal-wide .field input[type="text"],
.modal.modal-wide .field input[type="date"],
.modal.modal-wide .field select {
    width: 100%; height: 42px; padding: 0 13px;
    font-size: 0.92rem; font-family: inherit; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); outline: none; box-sizing: border-box;
    text-align: left;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.modal.modal-wide .field select { cursor: pointer; }
.modal.modal-wide .field input:focus,
.modal.modal-wide .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.modal.modal-wide .bk-money input { padding-left: 26px; }
/* A field can opt into a fixed narrow width via a modifier instead of inline styles */
.modal.modal-wide .field-amount { flex: 0 0 150px; }
.modal.modal-wide .field-date { flex: 0 0 175px; }
.modal.modal-wide .modal-actions { margin-top: 20px; }
.exp-check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 0.9rem; color: var(--text); }
.exp-check input { width: 16px; height: 16px; flex-shrink: 0; }

/* Paid-by toggle */
.exp-paidby-toggle { display: flex; gap: 8px; }
.exp-paidby-opt { flex: 1; cursor: pointer; }
.exp-paidby-opt input { position: absolute; opacity: 0; pointer-events: none; }
.exp-paidby-pill {
    display: block; text-align: center; padding: 9px 10px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-muted);
    font-size: 0.85rem; font-weight: 600;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.exp-paidby-opt input:checked + .exp-paidby-pill { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.exp-paidby-opt input:focus-visible + .exp-paidby-pill { box-shadow: 0 0 0 3px var(--primary-soft); }

/* Table */
.exp-empty {
    padding: 20px; text-align: center; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
}

/* Expense cards — inventory design language, fixed height. */
.exp-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.exp-card {
    display: flex; flex-direction: column;
    min-width: 0;
    height: 150px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.exp-card:hover { border-color: var(--border-strong, var(--border)); box-shadow: var(--shadow-md, var(--shadow-sm)); }
/* Body flexes and clips overflow so the footer stays pinned at a fixed height. */
.exp-card-body { min-width: 0; flex: 1; overflow: hidden; }
.exp-card-desc {
    font-weight: 600; color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word;
}
.exp-card-note {
    font-size: 0.82rem; color: var(--text-faint); margin-top: 3px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word;
}

/* Bottom row: pills + divider + action buttons, all on ONE line. */
.exp-card-foot {
    display: flex; align-items: center; gap: 6px;
    margin-top: 12px; padding-top: 11px;
    border-top: 0.5px solid var(--border);
    min-width: 0; flex-shrink: 0;
}
/* Pills and buttons share the SAME height (28px). */
.exp-pill {
    display: inline-flex; align-items: center; gap: 4px;
    height: 28px; padding: 0 8px;
    border-radius: 5px;
    font-size: 0.75rem; font-weight: 600;
    min-width: 0;                 /* allow shrinking to avoid overflow */
    box-sizing: border-box;
}
.exp-pill svg { flex-shrink: 0; }
/* The text inside a pill truncates instead of overflowing the row. */
.exp-pill-text {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Date fixed, amount never shrinks; category yields first. */
.exp-pill-date { background: var(--bg-accent, #e6f1fb); color: var(--text-accent, #185fa5); flex-shrink: 0; }
.exp-pill-cat  { background: #eeedfe; color: #3c3489; flex: 0 1 auto; min-width: 40px; }
.exp-pill-amt  { background: #e1f5ee; color: #0f6e56; flex-shrink: 0; }
.exp-pill-trip { background: #faeeda; color: #854f0b; flex: 0 1 auto; }
[data-theme="dark"] .exp-pill-cat  { background: #26215c; color: #cecbf6; }
[data-theme="dark"] .exp-pill-amt  { background: #04342c; color: #9fe1cb; }
[data-theme="dark"] .exp-pill-trip { background: #412402; color: #fac775; }

/* Action buttons: divider on the left, fixed size, same 28px height. */
.exp-card-act {
    display: flex; align-items: center; gap: 4px;
    margin-left: auto; padding-left: 8px;
    border-left: 0.5px solid var(--border);
    flex-shrink: 0;
}
.exp-edit,
.exp-del {
    width: 28px; height: 28px; border-radius: 5px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0.5px solid var(--border); background: transparent;
    color: var(--text-faint); cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.exp-edit:hover { background: var(--surface-1); color: var(--accent, #4f46e5); border-color: var(--border-strong, var(--border)); }
[data-theme="dark"] .exp-edit:hover { background: #1e293b; color: #a5b4fc; }
.exp-del:hover { background: #fdecec; color: #dc2626; border-color: #f0999955; }
[data-theme="dark"] .exp-del:hover { background: #3b1d1d; color: #f87171; }

@media (max-width: 900px) { .exp-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
    .exp-cards { grid-template-columns: 1fr; }
    .exp-card { height: 130px; }
}

/* ============================================================
   Staff & Payroll page
   ============================================================ */
/* Toolbar (inventory language) */
.stf-toolbar { flex-wrap: wrap; row-gap: 10px; }
.stf-toolbar .tb-sub { font-size: 0.82rem; color: var(--text-muted); margin-left: 4px; }
.trash-toolbar .tb-sub { font-size: 0.82rem; color: var(--text-muted); margin-left: 4px; }
@media (max-width: 560px) { .trash-toolbar .tb-sub { display: none; } }
.stf-search { width: 260px; max-width: 320px; margin-left: auto; }
.stf-tb-btn { width: auto; gap: 6px; padding: 0 13px; font-size: 0.88rem; font-weight: 600; }
.stf-tb-push { margin-left: auto; }

/* Plain section heading (no panel box) */
.stf-section-head { margin: 22px 2px 12px; }
.stf-section-head h2 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin: 0; }
.stf-empty {
    padding: 18px 20px; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
}

/* Staff cards — auto-fill so 1-2 staff don't leave odd gaps */
.stf-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.stf-card {
    display: flex; flex-direction: column; gap: 13px; min-width: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); padding: 15px 16px; box-shadow: var(--shadow-sm);
}
.stf-card-head { display: flex; align-items: center; gap: 11px; min-width: 0; }
.stf-avatar {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.stf-card-id { min-width: 0; display: flex; flex-direction: column; }
.stf-card-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stf-card-email { font-size: 0.78rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stf-owed {
    margin-left: auto; flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 9px; border-radius: 6px; font-size: 0.82rem; font-weight: 700; white-space: nowrap;
}
.stf-owed-lbl { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
.stf-owed.is-owed  { background: #fdecec; color: #c0392b; }
.stf-owed.is-clear { background: #e1f5ee; color: #0f6e56; }
[data-theme="dark"] .stf-owed.is-owed  { background: #3b1d1d; color: #f5a3a3; }
[data-theme="dark"] .stf-owed.is-clear { background: #04342c; color: #9fe1cb; }

/* Inline rate editor */
.stf-rate-form { display: flex; align-items: center; gap: 8px; }
.stf-rate-label { font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.stf-rate-money { width: 108px; flex-shrink: 0; }
.stf-rate-money input { height: 34px; }
.stf-rate-per { font-size: 0.8rem; color: var(--text-faint); margin-left: -2px; flex-shrink: 0; }
.stf-rate-set { flex-shrink: 0; }
.stf-rate-static { font-size: 0.88rem; color: var(--text-muted); }

.stf-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 13px; border-top: 1px solid var(--border); }
.stf-stat { display: flex; flex-direction: column; gap: 2px; }
.stf-stat-lbl { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); }
.stf-stat-val { font-weight: 600; color: var(--text); }

/* Compact rows (time entries + payments) */
.stf-rows {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm); overflow: hidden;
}
.stf-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-bottom: 1px solid var(--border); min-width: 0;
}
.stf-row:last-child { border-bottom: none; }
.stf-row:hover { background: var(--surface-2); }
.stf-row-icon {
    flex-shrink: 0; width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.stf-row-icon-hours { background: #faeeda; color: #854f0b; }
.stf-row-icon-pay   { background: #e1f5ee; color: #0f6e56; }
[data-theme="dark"] .stf-row-icon-hours { background: #412402; color: #fac775; }
[data-theme="dark"] .stf-row-icon-pay   { background: #04342c; color: #9fe1cb; }
.stf-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.stf-row-title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stf-row-sub { font-size: 0.8rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stf-row-amt { font-weight: 700; color: var(--text); white-space: nowrap; flex-shrink: 0; }
.stf-row-del {
    flex-shrink: 0; width: 30px; height: 30px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0.5px solid var(--border); background: transparent; color: var(--text-faint); cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.stf-row-del:hover { background: #fdecec; color: #dc2626; border-color: #f0999955; }
[data-theme="dark"] .stf-row-del:hover { background: #3b1d1d; color: #f87171; }

@media (max-width: 560px) {
    .stf-toolbar .tb-sub { display: none; }
    .stf-search { width: 100%; max-width: none; margin-left: 0; order: 3; flex-basis: 100%; }
    .stf-tb-btn .stf-tb-label { display: none; }
    .stf-tb-btn { width: 40px; padding: 0; justify-content: center; }
}

/* ============================================================
   404 / error page (standalone)
   ============================================================ */
.err-body {
    margin: 0; min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); padding: 24px;
}
.err-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
.err-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow);
    padding: 40px 36px; max-width: 440px; width: 100%; text-align: center;
}
.err-badge {
    width: 56px; height: 56px; margin: 0 auto 20px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 16px;
    background: color-mix(in srgb, var(--err-accent) 14%, transparent);
    color: var(--err-accent);
}
.err-code {
    font-size: 3.4rem; font-weight: 800; line-height: 1;
    letter-spacing: -0.02em; color: var(--text);
    margin-bottom: 10px;
}
.err-title { font-size: 1.25rem; font-weight: 650; color: var(--text); margin: 0 0 8px; }
.err-text { font-size: 0.92rem; color: var(--text-muted); line-height: 1.55; margin: 0 0 24px; }
.err-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.err-actions .btn { min-width: 130px; justify-content: center; }
.err-foot { font-size: 0.8rem; color: var(--text-faint); margin: 0; }

/* ============================================================
   Period tabs (shared by partner activity report + reports page)
   ============================================================ */
.pt-period-tab {
    font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
    padding: 6px 12px; border-radius: 999px; text-decoration: none;
    border: 1px solid var(--border); background: var(--surface-2);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.pt-period-tab:hover { color: var(--text); border-color: var(--border-strong); }
.pt-period-tab.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Ledger reimbursement dot color */
.bk-tl-dot.pt-tl-expense { background: #0891b2; }

/* ---- Expenses: owed-to-staff payday panel ---- */
.exp-owed { margin-bottom: 16px; }
.exp-owed-hint { font-size: 0.78rem; color: var(--text-faint); font-weight: 400; }
.exp-owed-list { list-style: none; margin: 0; padding: 8px; }
.exp-owed-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
}
.exp-owed-item:hover { background: var(--surface-2); }
.exp-owed-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.exp-owed-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: #e6f1fb; color: #185fa5; font-size: 0.8rem; font-weight: 700;
}
[data-theme="dark"] .exp-owed-avatar { background: #102132; color: #7fb6f0; }
.exp-owed-name { font-weight: 600; font-size: 0.92rem; color: var(--text); }
.exp-owed-count { font-size: 0.78rem; color: var(--text-faint); }
.exp-owed-amt { font-weight: 700; font-size: 1rem; color: #b45309; white-space: nowrap; }
[data-theme="dark"] .exp-owed-amt { color: #fbbf24; }

/* ============================================================
   Reports page
   ============================================================ */
/* Toolbar holds title + period tabs + custom range, matching Inventory */
.rp-toolbar { flex-wrap: wrap; row-gap: 10px; }
/* Period segment pushed right (inventory language, like Sales) */
.rp-toolbar .rp-seg { margin-left: 0; }
.rp-toolbar .tb-titlewrap { margin-right: 9px; }
.rp-toolbar .rp-range-badge { margin-right: auto; }
.rp-datepanel { justify-content: flex-start; }
/* Plain section heading + block container (no panel box) */
.rp-section-head { margin: 22px 2px 12px; }
.rp-section-head h2 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin: 0; }

/* Reports vertical rhythm: consistent spacing between major blocks */
.rp-cards-grid,
.rp-block,
.sls-channels,
.rp-channel-note { margin-bottom: 18px; }
.rp-cards-grid { margin-bottom: 18px; }

/* Bars wrapped as a standalone card (matches the card language) */
.rp-block-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
    padding: 16px 18px; min-width: 0;
}
.rp-block {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
    padding: 16px 18px;
}
@media (max-width: 760px) {
    .rp-toolbar .rp-seg { order: 6; margin-left: 0; flex: 1 1 100%; }
    .rp-toolbar .bk-filter-btn { margin-left: auto; }
}
@media (max-width: 560px) {
    /* Reports title + Date on row 1; date badge full-width row 2; period tabs row 3 */
    .rp-toolbar .rp-range-badge { order: 5; flex: 1 1 100%; height: 30px; justify-content: center; }
    .rp-toolbar .rp-seg { order: 6; }
    .rp-toolbar .bk-filter-btn .bk-filter-label { display: none; }
    .rp-toolbar .bk-filter-btn { width: 40px; padding: 0; justify-content: center; margin-left: auto; }
    .rp-toolbar .tb-titlewrap { margin-right: auto; }
}
.rp-range-badge {
    display: inline-flex; align-items: center; height: 24px; padding: 0 9px;
    font-size: 0.74rem; font-weight: 600; color: var(--text-muted);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
}
.rp-period { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; }

/* Compact period buttons with a uniform 5px radius (override the pill style) */
.rp-period .pt-period-tab {
    font-size: 0.78rem; font-weight: 600;
    padding: 5px 10px; border-radius: 5px;
    text-align: center; line-height: 1.2;
}

.rp-custom { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.rp-custom input[type="date"] {
    height: 32px; padding: 0 8px; font-size: 0.8rem; color: var(--text); font-family: inherit;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
    min-width: 0;
}
.rp-custom input[type="date"]:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.rp-custom-dash { color: var(--text-faint); flex-shrink: 0; }
.rp-custom .btn { border-radius: 5px; padding: 6px 11px; flex-shrink: 0; }

/* --- Mobile: tabs become a full-width 3-per-row grid --- */
@media (max-width: 640px) {
    .rp-period {
        display: grid; grid-template-columns: repeat(3, 1fr);
        width: 100%; gap: 6px;
    }
    .rp-period .pt-period-tab { padding: 7px 6px; }
    /* Date pickers + Apply stay on one row, no overflow */
    .rp-custom { width: 100%; margin-left: 0; gap: 5px; }
    .rp-custom input[type="date"] { flex: 1 1 0; }
}

/* P&L: five equal cards on one row */
.rp-pl {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px;
}
@media (max-width: 1000px) { .rp-pl { grid-template-columns: repeat(3, 1fr); } }
/* Mobile: 2-up; a lone last card (odd count) spans the full width */
@media (max-width: 640px) {
    .rp-pl { grid-template-columns: repeat(2, 1fr); gap: 9px; }
    .rp-pl > .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* highlight net profit card */
.rp-pl .stat-card.rp-net { background: var(--primary-soft); border: 1px solid transparent; }
.rp-pl .stat-card.rp-net .stat-value { color: var(--primary); }
.rp-pl .stat-card.rp-net.is-neg .stat-value { color: #dc2626; }
[data-theme="dark"] .rp-pl .stat-card.rp-net.is-neg .stat-value { color: #f87171; }

/* Five narrow cards: trim icon + value a touch so nothing overflows */
.rp-pl .stat-icon { width: 36px; height: 36px; }
.rp-pl .stat-icon svg { width: 18px; height: 18px; }
.rp-pl .stat-value { font-size: 1.4rem; }
.rp-pl .stat-mid { gap: 10px; }

/* Six-card variant (partner activity report): 3-up desktop, 2-up mobile */
.rp-pl-6 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1000px) { .rp-pl-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .rp-pl-6 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px)  { .rp-pl-6 { grid-template-columns: 1fr; } }

.rp-empty { color: var(--text-faint); font-size: 0.88rem; margin: 0; }

/* Category bars */
.rp-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.rp-bar-row { display: flex; align-items: center; gap: 12px; }
.rp-bar-label { width: 120px; flex-shrink: 0; font-size: 0.86rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-bar-track { flex: 1; height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.rp-bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.rp-bar-val { flex-shrink: 0; font-size: 0.85rem; font-weight: 700; color: var(--text); white-space: nowrap; }

/* Channel cards */
.rp-channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.rp-channel { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.rp-channel-name { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.rp-channel-rev { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.rp-channel-sub { font-size: 0.78rem; color: var(--text-faint); }

/* Per-partner list */
.rp-people { list-style: none; margin: 0; padding: 8px; }
.rp-person { padding: 10px 12px; border-radius: var(--radius-sm); }
.rp-person:hover { background: var(--surface-2); }
.rp-person-name { font-weight: 650; font-size: 0.92rem; color: var(--text); text-decoration: none; }
.rp-person-name:hover { color: var(--primary); text-decoration: underline; }
.rp-person-rows { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 5px; }
.rp-person-rows span { font-size: 0.8rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.rp-person-rows strong { color: var(--text); font-weight: 650; margin-left: 2px; }
.rp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rp-dot-profit { background: #16a34a; }
.rp-dot-exp { background: #d97706; }

/* ---- Partner: latest activity in account summary ---- */
.pt-last { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.pt-last-title { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); margin-bottom: 10px; }
.pt-last-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; }
.pt-last-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pt-last-label { font-size: 0.85rem; color: var(--text-muted); }
.pt-last-val { margin-left: auto; font-size: 0.85rem; color: var(--text); text-align: right; }
.pt-last-val strong { font-weight: 700; }
.pt-last-date { font-size: 0.76rem; color: var(--text-faint); margin-left: 4px; }
.pt-last-none { color: var(--text-faint); }
/* reuse ledger dot colors */
.pt-last-dot.pt-tl-capital { background: #6366f1; }
.pt-last-dot.pt-tl-profit  { background: #16a34a; }
.pt-last-dot.pt-tl-drawing { background: #d97706; }

/* ---- Reports: channel note ---- */
.rp-channel-note {
    font-size: 0.8rem; color: var(--text-muted); line-height: 1.5;
    margin: 0 2px 18px;
}

/* ============================================================
   Sources (book-buying locations)
   ============================================================ */

/* Filter toggle button (in toolbar, left of search) */
.src-filter-toggle { width: auto; gap: 7px; padding: 0 13px; font-size: 0.88rem; font-weight: 600; cursor: pointer; }
.src-filter-toggle.is-active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
@media (max-width: 560px) { .src-filter-label { display: none; } .src-filter-toggle { width: 40px; padding: 0; } }

/* Collapsible filter panel */
.src-filterpanel {
    display: flex; align-items: flex-end; flex-wrap: wrap; gap: 14px;
    margin: -6px 0 16px; padding: 16px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
    animation: srcPanelIn 0.18s ease;
}
.src-filterpanel[hidden] { display: none; }
@keyframes srcPanelIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.src-filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.src-filter-field label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.src-filter-field select {
    height: 40px; padding: 0 12px; font-size: 0.9rem; font-family: inherit;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.src-filter-field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.src-filter-reset { height: 40px; }

.src-note {
    margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
    background: #fef3e2; border: 1px solid #f6d9a8; color: #92500a; font-size: 0.86rem; line-height: 1.5;
}
[data-theme="dark"] .src-note { background: #2c2011; border-color: #5c4419; color: #f0c07a; }
.src-note code { background: rgba(0,0,0,0.08); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
[data-theme="dark"] .src-note code { background: rgba(255,255,255,0.1); }
.src-empty { color: var(--text-faint); font-size: 0.9rem; margin: 0; }
.src-empty-block {
    padding: 18px 20px; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
}

.src-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
/* Very wide screens: allow a 4th column */
@media (min-width: 1600px) {
    .src-grid { grid-template-columns: repeat(4, 1fr); }
}
/* Tablet: 2 across */
@media (max-width: 1024px) {
    .src-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Mobile: single column */
@media (max-width: 680px) {
    .src-grid { grid-template-columns: 1fr; gap: 12px; }
}
/* Hidden by search filter */
.src-card.is-hidden { display: none; }
.src-empty-search { color: var(--text-faint); font-size: 0.9rem; padding: 20px 4px; margin: 0; }
.src-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
    padding: 16px; box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.src-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.src-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.src-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.src-name { font-weight: 650; font-size: 1rem; color: var(--text); }
.src-type { font-size: 0.78rem; color: var(--text-faint); }
.src-del-form { flex-shrink: 0; }
.src-actions { display: flex; gap: 6px; flex-shrink: 0; }
.src-edit {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-faint); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.src-edit:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.src-del {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-faint); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.src-del:hover { background: #fdecec; color: #dc2626; border-color: #f5c2c2; }
[data-theme="dark"] .src-del:hover { background: #3b1d1d; color: #f87171; border-color: #5c2b2b; }

.src-where { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 0.82rem; color: var(--text-muted); }
.src-where svg { flex-shrink: 0; color: var(--text-faint); }
.src-distance { margin-top: 4px; font-size: 0.78rem; color: var(--text-faint); }

.src-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.src-stat {
    display: flex; flex-direction: column; gap: 1px; min-width: 0;
    padding: 9px 10px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.src-stat-label { font-size: 0.68rem; color: var(--text-faint); font-weight: 600; }
.src-stat-val { font-size: 0.95rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.src-stat-sub { font-size: 0.68rem; color: var(--text-faint); }

.src-note-text {
    margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
    font-size: 0.82rem; color: var(--text-muted); line-height: 1.45;
}

/* Add-source modal field widths */
.modal.modal-wide .field-type { flex: 0 0 170px; }
.modal.modal-wide .field-state { flex: 0 0 90px; }
.modal.modal-wide .field-zip { flex: 0 0 110px; }
.modal.modal-wide .field-distance { flex: 0 0 200px; }

/* ---- Sources: Google Places autocomplete widget ---- */
.src-ac-host { width: 100%; }
/* The new PlaceAutocompleteElement is a web component; style its host box to
   match our other modal inputs. */
gmp-place-autocomplete {
    width: 100%;
    --gmp-mat-color-surface: var(--surface-2);
    --gmp-mat-color-on-surface: var(--text);
    --gmp-mat-color-outline: var(--border);
    font-family: inherit;
}
/* ============================================================
   Inventory: toolbar (search + filters + status tabs), filter
   panel, pagination
   ============================================================ */

/* Books toolbar — scoped overrides so other .users-toolbar pages
   (Users, Sources) keep their own layout. */
.bk-toolbar { flex-wrap: wrap; row-gap: 10px; }
.bk-toolbar .tb-titlewrap { margin-right: 0; }
.bk-toolbar .tb-search { width: auto; flex: 1 1 200px; max-width: 340px; }
.bk-toolbar .bk-viewtoggle { margin-left: auto; }

/* Filters toggle button (right of search) */
.bk-filter-btn {
    display: inline-flex; align-items: center; gap: 7px;
    height: 40px; padding: 0 13px;
    font-size: 0.88rem; font-weight: 600; font-family: inherit;
    color: var(--text-muted);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer; flex-shrink: 0;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.bk-filter-btn:hover { border-color: var(--border-strong); color: var(--text); }
.bk-filter-btn.is-active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.bk-filter-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }

/* Status tabs — segmented pills inside the toolbar */
.bk-seg {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    scrollbar-width: none;
}
.bk-seg::-webkit-scrollbar { display: none; }
.bk-seg-item {
    display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 11px;
    font-size: 0.85rem; font-weight: 550;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: calc(var(--radius-sm) - 3px);
    white-space: nowrap;
    transition: color var(--transition), background var(--transition);
}
.bk-seg-item:hover { color: var(--text); }
.bk-seg-item.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.bk-seg-item .cnt {
    font-size: 0.72rem;
    background: var(--surface-3); color: var(--text-muted);
    padding: 1px 7px; border-radius: 10px;
}
.bk-seg-item.is-active .cnt { background: var(--primary-soft); color: var(--primary); }

/* Forced line break for the two-row mobile layout (hidden on desktop) */
.bk-tb-break { display: none; }

/* Mobile: exactly two rows.
   Row 1: search · Filters · trash · Add
   Row 2: status tabs (original sizing, scrollable if needed).
   The count chip and the card/table view toggle are hidden on mobile. */
@media (max-width: 700px) {
    .bk-toolbar > * { order: 9; }
    .bk-toolbar .tb-titlewrap   { display: none; }
    .bk-toolbar .tb-search      { order: 1; flex: 1 1 90px; min-width: 0; max-width: none; }
    .bk-toolbar .bk-filter-btn  { order: 2; width: 40px; padding: 0; justify-content: center; }
    .bk-toolbar .bk-filter-label { display: none; }
    .bk-toolbar .tb-icon-btn    { order: 3; }
    .bk-toolbar .tb-add         { order: 4; width: 40px; padding: 0; justify-content: center; }
    .bk-toolbar .tb-add .tb-add-label { display: none; }
    .bk-toolbar .bk-tb-break    { order: 5; display: block; flex-basis: 100%; height: 0; }
    .bk-toolbar .bk-seg         { order: 6; flex: 1 1 auto; min-width: 0; }
    .bk-toolbar .bk-viewtoggle  { display: none; }
}
/* With the toggle hidden, mobile always shows cards — even if the saved
   preference (localStorage) is the table view. */
@media (max-width: 700px) {
    .bk-views[data-view="table"] .bk-grid { display: grid; }
    .bk-views .bk-tablewrap { display: none; }
}

/* Filter panel (toggled by the Filters button; server renders it
   visible when any panel filter is active) */
.bk-filterpanel {
    display: flex; align-items: flex-end; flex-wrap: wrap; gap: 14px;
    margin: -10px 0 16px; padding: 16px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
    animation: srcPanelIn 0.18s ease;
}
.bk-filterpanel[hidden] { display: none; }
.bk-filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.bk-filter-field label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.bk-filter-field select,
.bk-filter-field input {
    height: 40px; padding: 0 12px; font-size: 0.9rem; font-family: inherit;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    outline: none; width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.bk-filter-field select { cursor: pointer; }
.bk-filter-field select:focus,
.bk-filter-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.bk-filter-field .bk-money { width: 100%; }
.bk-filter-actions { display: flex; gap: 8px; }
.bk-filter-actions .btn { height: 40px; }

/* Sales toolbar — same design language as the inventory toolbar.
   Reuses .users-toolbar, .bk-seg, .bk-filter-btn and .bk-filterpanel. */
.sls-toolbar { flex-wrap: wrap; row-gap: 10px; }
.sls-range-badge {
    display: inline-flex; align-items: center;
    height: 28px; padding: 0 10px;
    font-size: 0.8rem; font-weight: 600;
    background: var(--primary-soft); color: var(--primary);
    border-radius: 8px; white-space: nowrap;
}
/* Push the period segment + actions to the right of the title. */
.sls-toolbar .sls-seg { margin-left: 0; }
.sls-toolbar .tb-titlewrap { margin-right: 9px; }
.sls-toolbar .sls-range-badge { margin-right: auto; }
/* Import / Export: text pill buttons built on the icon-button base. */
.sls-tb-btn { width: auto; gap: 6px; padding: 0 13px; font-size: 0.88rem; font-weight: 600; }
.sls-datepanel { justify-content: flex-start; }

/* Responsive: below ~760px let the segment wrap to its own row. */
@media (max-width: 760px) {
    .sls-toolbar .sls-seg { order: 6; margin-left: 0; flex: 1 1 100%; }
    .sls-toolbar .bk-filter-btn { margin-left: auto; }
}
@media (max-width: 560px) {
    .sls-tb-btn .sls-tb-label { display: none; }
    .sls-tb-btn { width: 40px; padding: 0; justify-content: center; }
    /* Keep Sales + Date + Import + Export on ONE row: date range badge
       drops to its own full-width row below (before the period tabs),
       and Date collapses to an icon. */
    .sls-toolbar .sls-range-badge { order: 6; flex: 1 1 100%; height: 30px; justify-content: center; }
    .sls-toolbar .sls-seg { order: 7; }
    .sls-toolbar .bk-filter-btn .bk-filter-label { display: none; }
    .sls-toolbar .bk-filter-btn { width: 40px; padding: 0; justify-content: center; margin-left: auto; }
    .sls-toolbar .tb-titlewrap { margin-right: auto; }
}

/* Expenses toolbar — inventory design language (search + Filters + Add). */
.exp-toolbar { flex-wrap: wrap; row-gap: 10px; }
/* Search hugs the right-side buttons (no flex-grow); the whole cluster
   is pushed right so search sits right next to the Filters button. */
.exp-toolbar .tb-search { width: 300px; max-width: 340px; margin-left: auto; }
.exp-toolbar .tb-add { flex-shrink: 0; }
.exp-filterpanel { justify-content: flex-end; }

@media (max-width: 600px) {
    /* Hide the "Expenses" word (like inventory) so search + Filters + Add
       stay on one line; the count badge remains for context. */
    .exp-toolbar .tb-title { display: none; }
    .exp-toolbar .tb-search { order: 3; flex-basis: 100%; width: 100%; max-width: none; margin-left: 0; }
    .exp-toolbar .tb-add .tb-add-label { display: none; }
    .exp-toolbar .tb-add { width: 40px; padding: 0; justify-content: center; }
    .exp-toolbar .bk-filter-label { display: none; }
    .exp-toolbar .bk-filter-btn { margin-left: auto; }
}
@media (max-width: 560px) {
    .bk-filter-field { min-width: calc(50% - 7px); }
}

/* Pagination footer */
.bk-pager {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    margin-top: 18px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
}
.bk-pager-info { font-size: 0.85rem; color: var(--text-muted); }
.bk-pager-info strong { color: var(--text); font-weight: 600; }
.bk-pager-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.bk-page {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 8px;
    font-size: 0.86rem; font-weight: 550;
    color: var(--text-muted);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.bk-page:hover { border-color: var(--border-strong); color: var(--text); }
.bk-page.is-current {
    background: var(--primary); border-color: var(--primary); color: #fff;
    cursor: default;
}
.bk-page.is-disabled { opacity: 0.45; pointer-events: none; }
.bk-page-gap {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 34px;
    color: var(--text-faint); font-size: 0.86rem;
}
@media (max-width: 560px) {
    .bk-pager { justify-content: center; }
}

/* ============================================================
   Scan mode — fast barcode intake
   ============================================================ */
.intake-label {
    display: block;
    font-size: 0.85rem; font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.intake-scanbox {
    display: block; width: 100%;
    height: 64px; padding: 0 18px;
    font-size: 1.5rem; font-weight: 600; letter-spacing: 2px;
    font-family: inherit;
    color: var(--text); background: var(--surface-2);
    border: 2px solid var(--border); border-radius: var(--radius-card);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.intake-scanbox:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.intake-scanbox::placeholder { color: var(--text-faint); font-weight: 400; letter-spacing: 2px; }

.intake-status {
    margin-top: 10px;
    font-size: 0.88rem; font-weight: 550;
    color: var(--text-muted);
    min-height: 1.4em;
}
.intake-status.is-busy { color: var(--primary); }
.intake-status.is-ok   { color: #16a34a; }
.intake-status.is-warn { color: #b45309; }
.intake-status.is-err  { color: #dc2626; }
[data-theme="dark"] .intake-status.is-ok   { color: #4ade80; }
[data-theme="dark"] .intake-status.is-warn { color: #fbbf24; }
[data-theme="dark"] .intake-status.is-err  { color: #f87171; }

.intake-manual {
    margin-top: 16px; padding-top: 16px;
    border-top: 1px dashed var(--border);
}
.intake-manual[hidden] { display: none; }

/* Session defaults — 3 columns on desktop; exact 2-column pairs on
   mobile (condition·channel / cost·date / source·shelf). */
.intake-defaults {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
@media (max-width: 768px) {
    .intake-defaults { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* Label row above the scan box (label left, camera button right) */
.intake-scanhead {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 8px;
}
.intake-scanhead .intake-label { margin-bottom: 0; }

/* Camera scanner (BarcodeDetector) */
.intake-cam { margin-top: 14px; }
.intake-cam[hidden] { display: none; }
.intake-cam video {
    display: block; width: 100%; max-width: 480px;
    border-radius: var(--radius-card);
    border: 2px solid var(--primary);
    background: #000;
}
.intake-cam .intake-cam-hint {
    margin-top: 8px; font-size: 0.85rem; color: var(--text-muted);
}

/* ============================================================
   Sales — 12-month trend chart (pure SVG)
   ============================================================ */
.sls-chart-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.sls-chart-title { font-size: 0.95rem; font-weight: 650; margin: 0; }
.sls-legend { display: flex; gap: 14px; }
.sls-legend-item {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.8rem; color: var(--text-muted);
}
.sls-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sls-swatch-rev { background: var(--primary); opacity: 0.45; }
.sls-swatch-net { background: var(--primary); }

.sls-chart svg { display: block; width: 100%; height: auto; max-height: 280px; }
.sls-chart-empty { color: var(--text-muted); font-size: 0.9rem; margin: 6px 0; }

.sls-grid  { stroke: var(--border); stroke-width: 1; }
.sls-zero  { stroke: var(--text-faint); stroke-width: 1; stroke-dasharray: 4 4; }
.sls-ytick, .sls-xtick { fill: var(--text-faint); font-size: 10px; font-family: inherit; }
.sls-bar   { fill: var(--primary); opacity: 0.4; }
.sls-bar:hover { opacity: 0.65; }
.sls-netline {
    fill: none; stroke: var(--primary); stroke-width: 2.5;
    stroke-linecap: round; stroke-linejoin: round;
}
.sls-netdot { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.sls-netdot:hover { fill: var(--primary); }

/* ---- Sold books: inventory-style separated cards ---- */
.sls-list-head { font-size: 1.02rem; font-weight: 640; letter-spacing: -0.01em; margin: 4px 2px 12px; }
.sls-grid { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px) { .sls-grid { grid-template-columns: 1fr; } }
.sls-card { gap: 12px; }
.sls-card-title { display: block; font-size: 0.92rem; font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sls-card:hover .sls-card-title { color: var(--primary); }
.sls-card-author { display: block; font-size: 0.8rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sls-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; min-width: 0; }
.sls-card-date { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.sls-card-figures {
    display: flex; flex-wrap: nowrap; align-items: baseline; gap: 10px;
    position: relative; z-index: 2;
    padding-top: 11px; border-top: 1px solid var(--border); min-width: 0;
}
.sls-fig { display: inline-flex; align-items: baseline; gap: 4px; font-size: 0.8rem; white-space: nowrap; min-width: 0; }
.sls-fig-k { font-size: 0.68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.02em; }
.sls-fig-v { font-weight: 650; color: var(--text); }
.sls-fig-net { margin-left: auto; }
@media (max-width: 380px) {
    .sls-card-figures { gap: 7px; }
    .sls-fig { font-size: 0.76rem; gap: 3px; }
    .sls-fig-k { font-size: 0.64rem; }
}

/* ---- Sales by channel: standalone cards (no outer panel wrapper) ---- */
.sls-channels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; min-width: 0; }
@media (max-width: 640px) { .sls-channels { grid-template-columns: 1fr; } }
.sls-channel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
    padding: 15px 16px; display: flex; flex-direction: column; gap: 5px; min-width: 0;
}
.sls-channel-top { display: flex; align-items: center; gap: 8px; }
.sls-channel-count { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }
.sls-channel-rev { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.sls-channel-sub { font-size: 0.82rem; color: var(--text-muted); }

/* ---- Overhead / fully-loaded panel ---- */
.sls-loaded-panel { padding: 16px 18px; }
.sls-loaded { display: flex; flex-direction: column; gap: 14px; }
.sls-loaded-row { display: flex; flex-wrap: wrap; gap: 14px 40px; }
.sls-loaded-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sls-loaded-label {
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.sls-loaded-value { font-size: 1.35rem; font-weight: 750; letter-spacing: -0.02em; color: var(--text); }
.sls-loaded-value.is-neg { color: #dc2626; }
.sls-loaded-value.is-pos { color: #16a34a; }
[data-theme="dark"] .sls-loaded-value.is-neg { color: #f87171; }
[data-theme="dark"] .sls-loaded-value.is-pos { color: #4ade80; }
.sls-loaded-sub { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.sls-loaded-note {
    font-size: 0.82rem; color: var(--text-faint); line-height: 1.5;
    padding-top: 12px; border-top: 1px solid var(--border);
}

/* ---- Sales page vertical rhythm: consistent spacing between major blocks ---- */
.sls-cards-grid,
.sls-loaded-panel,
.sls-chart-panel,
.sls-list-head,
.sls-channels,
.sls-months,
.sls-grid { margin-bottom: 18px; }
.sls-cards-grid { margin-bottom: 18px; }
.sls-list-head { margin-top: 4px; }

/* ---- Monthly breakdown: compact rows ---- */
.sls-months { display: flex; flex-direction: column; padding: 6px; min-width: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm); }
.sls-month { padding: 11px 12px; border-radius: var(--radius-sm); min-width: 0; }
.sls-month + .sls-month { border-top: 1px solid var(--border); }
.sls-month-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.sls-month-name { font-size: 0.9rem; font-weight: 650; color: var(--text); }
.sls-month-net { font-size: 0.9rem; }
.sls-month-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.82rem; color: var(--text); }
.sls-month-stats .sls-fig-k { margin-right: 3px; }



/* ============================================================
   Activity log
   ============================================================ */
.al-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px; align-items: end;
}
.al-badge {
    display: inline-block; padding: 3px 9px;
    font-size: 0.72rem; font-weight: 650; letter-spacing: 0.02em;
    border-radius: 999px;
    background: var(--surface-2); color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.al-badge-green  { background: rgba(22, 163, 74, 0.12);  color: #15803d; border-color: rgba(22, 163, 74, 0.25); }
.al-badge-red    { background: rgba(220, 38, 38, 0.10);  color: #b91c1c; border-color: rgba(220, 38, 38, 0.25); }
.al-badge-amber  { background: rgba(217, 119, 6, 0.12);  color: #b45309; border-color: rgba(217, 119, 6, 0.25); }
.al-badge-purple { background: rgba(124, 58, 237, 0.10); color: #6d28d9; border-color: rgba(124, 58, 237, 0.25); }
[data-theme="dark"] .al-badge-green  { color: #4ade80; }
[data-theme="dark"] .al-badge-red    { color: #f87171; }
[data-theme="dark"] .al-badge-amber  { color: #fbbf24; }
[data-theme="dark"] .al-badge-purple { color: #c4b5fd; }
.al-when { white-space: nowrap; font-size: 0.85rem; color: var(--text-muted); }
.al-ip   { font-size: 0.8rem; color: var(--text-faint); }

/* Activity toolbar + filter panel */
.al-toolbar { flex-wrap: wrap; row-gap: 10px; }
.al-push { margin-left: auto; }
.al-filterpanel { justify-content: flex-start; }
.al-empty {
    padding: 18px 20px; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm);
}

/* Activity as compact rows (audit log) */
.al-rows {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-card); box-shadow: var(--shadow-sm); overflow: hidden;
    min-width: 0; max-width: 100%;
}
.al-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-bottom: 1px solid var(--border); min-width: 0;
}
.al-row:last-child { border-bottom: none; }
.al-row:hover { background: var(--surface-2); }
.al-row .al-cdot {
    flex-shrink: 0; align-self: flex-start; margin-top: 7px;
    width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint);
}
.al-row .al-cdot.al-dot-green  { background: #1f9d55; }
.al-row .al-cdot.al-dot-red    { background: #dc2626; }
.al-row .al-cdot.al-dot-amber  { background: #d97706; }
.al-row .al-cdot.al-dot-purple { background: #7c3aed; }
.al-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.al-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-actor { font-weight: 650; color: var(--text); }
.al-verb { font-weight: 500; margin: 0 3px; }
.al-verb.al-dot-green  { color: #15803d; }
.al-verb.al-dot-red    { color: #b91c1c; }
.al-verb.al-dot-amber  { color: #b45309; }
.al-verb.al-dot-purple { color: #6d28d9; }
[data-theme="dark"] .al-verb.al-dot-green  { color: #34d399; }
[data-theme="dark"] .al-verb.al-dot-red    { color: #f87171; }
[data-theme="dark"] .al-verb.al-dot-amber  { color: #fbbf24; }
[data-theme="dark"] .al-verb.al-dot-purple { color: #a78bfa; }
.al-what { color: var(--text-muted); }
.al-sub { font-size: 0.8rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-meta { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; }
@media (max-width: 560px) {
    .al-meta .al-ip { display: none; }
}

/* ============================================================
   Bottom mobile bar (PWA, app-like navigation)
   ============================================================ */
.bb {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.12);
    align-items: stretch;
    justify-content: space-around;
}
[data-theme="dark"] .bb { box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4); }

/* When the menu sheet is open, the bottom bar becomes the visual base of
   the sheet: its top corners flatten so the sheet reads as one continuous
   surface rising out of it, and the bar lifts above the sheet so the
   raised Scan button floats over BOTH layers. */
body.bb-sheet-open .bb {
    z-index: 96;
    border-radius: 0;
    box-shadow: none;
}
[data-theme="dark"] body.bb-sheet-open .bb { box-shadow: none; }

/* ============================================================
   App-style menu sheet — slides up from above the bottom bar.
   Mobile only (shown alongside .bb at <=768px). Toggled in app.js.
   ============================================================ */
.bb-sheet-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 94;
    background: rgba(15, 23, 42, 0.34);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    opacity: 0; transition: opacity 0.28s ease;
}
.bb-sheet-backdrop.is-visible { opacity: 1; }

.bb-sheet {
    display: none;
    position: fixed; left: 0; right: 0; z-index: 95;
    bottom: calc(59px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border: 1px solid var(--border); border-bottom: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -14px 44px rgba(15, 23, 42, 0.20);
    padding: 8px 14px 20px;
    transform: translateY(115%);
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    max-height: calc(100vh - 60px - var(--header-h) - 40px);
    overflow-y: auto;
}
.bb-sheet.is-open { transform: translateY(0); }
.bb-sheet-grid {
    opacity: 0; transform: translateY(8px);
    transition: opacity 0.3s ease 0.08s, transform 0.3s ease 0.08s;
}
.bb-sheet.is-open .bb-sheet-grid { opacity: 1; transform: translateY(0); }
[data-theme="dark"] .bb-sheet { box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5); }

.bb-sheet-handle {
    width: 38px; height: 4px; border-radius: 99px;
    background: var(--border-strong); margin: 6px auto 12px;
}
.bb-sheet-title {
    font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; margin: 0 4px 12px;
}
.bb-sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }

.bb-tile {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 4px; border-radius: 14px; text-decoration: none;
    transition: background 0.15s ease;
}
.bb-tile:active { background: var(--surface-2); }
.bb-tile.is-active { background: var(--primary-soft); }
.bb-tile-ic {
    width: 44px; height: 44px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
}
.bb-tile-ic svg { width: 22px; height: 22px; }
.bb-tile-lbl {
    font-size: 0.72rem; font-weight: 600; color: var(--text);
    text-align: center; line-height: 1.2;
}
.bb-tile.is-active .bb-tile-lbl { color: var(--primary); }

/* Tile icon color themes (match the dashboard stat-icon palette) */
.bb-tile-blue   { background: #eef2ff; color: #4f46e5; }
.bb-tile-green  { background: #e7f6ed; color: #1f9d55; }
.bb-tile-amber  { background: #fef3e2; color: #d97706; }
.bb-tile-purple { background: #f3eaff; color: #7c3aed; }
.bb-tile-teal   { background: #e0f2f1; color: #0d9488; }
.bb-tile-rose   { background: #fdecec; color: #dc2626; }
.bb-tile-slate  { background: #f1f5f9; color: #475569; }
[data-theme="dark"] .bb-tile-blue   { background: rgba(99,102,241,0.18);  color: #a5b4fc; }
[data-theme="dark"] .bb-tile-green  { background: rgba(31,157,85,0.18);   color: #6ee7a8; }
[data-theme="dark"] .bb-tile-amber  { background: rgba(217,119,6,0.18);   color: #fcd34d; }
[data-theme="dark"] .bb-tile-purple { background: rgba(124,58,237,0.20);  color: #c4b5fd; }
[data-theme="dark"] .bb-tile-teal   { background: rgba(13,148,136,0.20);  color: #5eead4; }
[data-theme="dark"] .bb-tile-rose   { background: rgba(220,38,38,0.18);   color: #fca5a5; }
[data-theme="dark"] .bb-tile-slate  { background: rgba(71,85,105,0.22);   color: #cbd5e1; }

@media (max-width: 768px) {
    .bb-sheet-backdrop:not([hidden]) { display: block; }
    .bb-sheet:not([hidden]) { display: block; }
}
.bb-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    font: inherit; font-size: 0.72rem; font-weight: 700;
    color: var(--text-muted); text-decoration: none;
    background: none; border: 0; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition);
}
.bb-item svg { width: 24px; height: 24px; stroke-width: 2.2; }
.bb-item.is-active { color: var(--primary); }
.bb-item:active { color: var(--primary); }

/* Raised center scan button */
.bb-scan {
    flex: 0 0 auto; align-self: flex-start;
    width: 54px; height: 54px; margin-top: -17px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; text-decoration: none;
    background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #a855f7));
    border-radius: 50%;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 45%, transparent),
                0 0 0 5px var(--surface);
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--transition);
}
.bb-scan svg { width: 24px; height: 24px; }
.bb-scan:active { transform: scale(0.94); }

@media (max-width: 768px) {
    .bb { display: flex; }
    /* Header: pinned to the top of the viewport, always visible while scrolling */
    .app-header {
        position: fixed; top: 0; left: 0; right: 0;
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    }
    /* Content clears the fixed header (top) and the bottom bar (bottom) */
    .app-main {
        padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0px)) !important;
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .app-footer { display: none; }
}

/* Standalone (installed PWA): a touch more breathing room at the top on iOS */
@media (display-mode: standalone) {
    .app-header { padding-top: max(0px, env(safe-area-inset-top, 0px)); }
}

/* ============================================================
   PWA install banner (slides down from the top)
   ============================================================ */
.pwa-banner {
    position: fixed; z-index: 120;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: 50%;
    width: min(480px, calc(100vw - 20px));
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 34px rgba(2, 6, 23, 0.25);
    transform: translate(-50%, -130%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1), opacity 0.3s ease;
}
.pwa-banner.is-in { transform: translate(-50%, 0); opacity: 1; }

.pwa-banner-icon { border-radius: 10px; flex: 0 0 auto; }
.pwa-banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-banner-title { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.pwa-banner-sub   { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.pwa-banner-sub strong { color: var(--text); }

.pwa-banner-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.pwa-banner-btn {
    font: inherit; font-size: 0.8rem; font-weight: 650;
    padding: 8px 14px; border-radius: 10px; border: 0; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.pwa-banner-install { color: #fff; background: var(--primary); }
.pwa-banner-install:active { transform: scale(0.97); }
.pwa-banner-ok { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); }
.pwa-banner-x {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0;
    background: none; border: 0; border-radius: 8px;
    color: var(--text-faint); cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.pwa-banner-x svg { width: 15px; height: 15px; }
.pwa-banner-x:hover { color: var(--text); background: var(--surface-2); }


/* Login: forgot-password link */
.login-forgot { text-align: center; margin-top: 14px; font-size: 0.85rem; }
.login-forgot a { color: var(--text-muted); text-decoration: none; }
.login-forgot a:hover { color: var(--primary); text-decoration: underline; }

/* ============================================================
   Dashboard — recent activity mini-feed
   ============================================================ */
.dash-activity { list-style: none; margin: 0; padding: 6px 16px 12px; }
.dash-activity li {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid var(--border);
    font-size: 0.84rem;
}
.dash-activity li:last-child { border-bottom: 0; }
.dash-activity .al-badge { flex: 0 0 auto; width: 88px; text-align: center; padding-left: 4px; padding-right: 4px; box-sizing: border-box; }
/* Option A row: colored dot + "User verb object" sentence + full datetime */
.dash-activity .al-dot {
    flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%;
    margin: 0; background: var(--text-faint);
}
.dash-activity .al-dot.al-dot-green  { background: #1f9d55; }
.dash-activity .al-dot.al-dot-red    { background: #dc2626; }
.dash-activity .al-dot.al-dot-amber  { background: #d97706; }
.dash-activity .al-dot.al-dot-purple { background: #7c3aed; }
.dash-act-verb { font-weight: 500; }
.dash-act-verb.al-dot-green  { color: #15803d; }
.dash-act-verb.al-dot-red    { color: #b91c1c; }
.dash-act-verb.al-dot-amber  { color: #b45309; }
.dash-act-verb.al-dot-purple { color: #6d28d9; }
.dash-act-obj { color: var(--text-muted); }
[data-theme="dark"] .dash-act-verb.al-dot-green  { color: #34d399; }
[data-theme="dark"] .dash-act-verb.al-dot-red    { color: #f87171; }
[data-theme="dark"] .dash-act-verb.al-dot-amber  { color: #fbbf24; }
[data-theme="dark"] .dash-act-verb.al-dot-purple { color: #a78bfa; }
.dash-activity-text {
    flex: 1; min-width: 0; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-activity-text strong { color: var(--text); font-weight: 650; }
.dash-activity-when { flex: 0 0 auto; font-size: 0.75rem; color: var(--text-faint); }


/* ============================================================
   Amazon import
   ============================================================ */
.imp-help { font-size: 0.86rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 14px; }
.imp-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.imp-upload input[type="file"] {
    flex: 1; min-width: 220px;
    font: inherit; font-size: 0.88rem; color: var(--text);
    background: var(--surface-2); border: 1px dashed var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer;
}
.imp-row-unmatched { opacity: 0.62; }
.imp-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
@media (max-width: 480px) {
    .imp-actions .btn { flex: 1; justify-content: center; min-height: 44px; }
}


/* Intake debug console (?debug=1) */
.intake-debug {
    margin: 0; padding: 12px 16px; min-height: 90px; max-height: 40vh; overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem;
    line-height: 1.6; color: var(--text-muted); white-space: pre-wrap; word-break: break-all;
}


/* Intake — offline queue */
.intake-queue { list-style: none; margin: 0; padding: 0; }
.intake-queue li {
    padding: 8px 0; border-bottom: 1px solid var(--border);
    font-size: 0.85rem; color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.intake-queue li:last-child { border-bottom: 0; }
.intake-queue li.iq-err { color: #dc2626; }
[data-theme="dark"] .intake-queue li.iq-err { color: #f87171; }

/* ============================================================
   Notification center
   ============================================================ */
.ntf-menu { position: relative; }
.ntf-dropdown {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 90;
    width: 340px; max-width: calc(100vw - 24px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    overflow: hidden;
}
.ntf-dd-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    font-weight: 700; font-size: 0.9rem;
}
.ntf-dd-readall {
    font: inherit; font-size: 0.78rem; font-weight: 650; color: var(--primary);
    background: none; border: 0; cursor: pointer; padding: 0;
}
.ntf-dd-empty { padding: 22px 14px; font-size: 0.85rem; color: var(--text-faint); text-align: center; }
.ntf-dd-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.ntf-dd-list li { border-bottom: 1px solid var(--border); }
.ntf-dd-list li:last-child { border-bottom: 0; }
.ntf-dd-list a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; text-decoration: none; color: var(--text);
}
.ntf-dd-list a:hover { background: var(--surface-2); }
.ntf-dd-list li.is-unread a { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.ntf-dd-list li.is-unread .ntf-dd-title { font-weight: 700; }
.ntf-dd-title { flex: 1; min-width: 0; font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ntf-dd-when { flex: 0 0 auto; font-size: 0.72rem; color: var(--text-faint); }
.ntf-dd-all {
    display: block; text-align: center; padding: 10px;
    font-size: 0.82rem; font-weight: 650; color: var(--primary);
    text-decoration: none; border-top: 1px solid var(--border);
}
.ntf-dd-all:hover { background: var(--surface-2); }

/* Notifications page */
.ntf-list { list-style: none; margin: 0; padding: 0; }
.ntf-list li { border-bottom: 1px solid var(--border); }
.ntf-list li:last-child { border-bottom: 0; }
.ntf-item {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px; text-decoration: none; color: var(--text);
}
.ntf-item:hover { background: var(--surface-2); }
.ntf-list li.is-unread { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.ntf-list li.is-unread .ntf-title { font-weight: 700; }
.ntf-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ntf-title { font-size: 0.9rem; }
.ntf-body { font-size: 0.8rem; color: var(--text-muted); }
.ntf-when { flex: 0 0 auto; font-size: 0.76rem; color: var(--text-faint); }
.ntf-pager { display: flex; justify-content: space-between; margin-top: 14px; }

@media (max-width: 520px) {
    .ntf-dropdown { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}

/* ============================================================
   Buying-trip allocation
   ============================================================ */
.exp-trip { margin-top: 4px; }
.exp-trip .field-row { margin-bottom: 0; }
.exp-trip-tag {
    display: inline-block; margin-top: 3px;
    font-size: 0.72rem; font-weight: 650; color: var(--text-muted);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 2px 9px;
}
.bk-trip-row span, .bk-trip-row strong { color: var(--text-muted); }
.bk-trip-info { cursor: help; font-size: 0.8em; margin-left: 4px; }
.bk-landed-row { border-top: 1px dashed var(--border); padding-top: 8px; }
.bk-landed-row strong { color: var(--text); }


/* Sources toolbar — merge duplicates button */
.tb-merge-form { flex-shrink: 0; }
.tb-merge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 40px; padding: 0 16px;
    font: inherit; font-size: 0.875rem; font-weight: 650;
    color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; white-space: nowrap;
}
.tb-merge:hover { border-color: var(--primary); color: var(--primary); }
@media (max-width: 720px) {
    .tb-merge { padding: 0 12px; }
    .tb-merge-label { display: none; }  /* icon-only on small screens, like the toolbar icons */
}

/* Sources modal — visible autocomplete failure hint */
.src-ac-hint-err { color: #dc2626 !important; }
[data-theme="dark"] .src-ac-hint-err { color: #f87171 !important; }
/* ============================================================
   Mobile overflow safety net — guarantee content fits any screen
   ============================================================ */
@media (max-width: 560px) {
    /* Modals: stack side-by-side fields so fixed-width ones can't overflow */
    .modal.modal-wide .field-row { flex-wrap: wrap; }
    .modal.modal-wide .field-row .field,
    .modal.modal-wide .field-amount,
    .modal.modal-wide .field-date,
    .modal.modal-wide .field-type,
    .modal.modal-wide .field-state,
    .modal.modal-wide .field-zip,
    .modal.modal-wide .field-distance { flex: 1 1 100%; min-width: 0; }

    /* Filter panel fields: never wider than the screen */
    .bk-filter-field { min-width: 0; flex: 1 1 100%; }
    .bk-filterpanel { padding: 14px; }

    /* Long unbroken strings (ISBN, source, URLs) must wrap, never push width */
    .bk-card-source span,
    .bk-cell-title,
    .bk-cell-author { overflow-wrap: anywhere; }
}

/* Belt-and-suspenders: no descendant may force horizontal scroll.
   Fit content rather than clip it — .app-main already has overflow-x:hidden
   as the final safety net. */
.bk-views, .bk-grid, .bk-filterpanel, .users-toolbar { max-width: 100%; }
.bk-grid { min-width: 0; }

/* ============================================================
   Profile page — equal-height cards + account info as toolbar chips
   ============================================================ */
.pf-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 880px) {
    .pf-grid { grid-template-columns: 1fr 1fr; align-items: stretch; }
}
/* Cards stretch to equal height; body flexes so the submit button
   sits at the bottom of both cards regardless of field count. */
.pf-card { display: flex; flex-direction: column; }
.pf-card .panel-body { flex: 1; display: flex; flex-direction: column; }
.pf-form { display: flex; flex-direction: column; flex: 1; }
.pf-actions { margin-top: auto; padding-top: 6px; justify-content: flex-start; }

/* Read-only account info chips in the toolbar (Role, Member since) */
.pf-chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 11px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.8rem; white-space: nowrap;
}
.pf-chip-k { color: var(--text-faint); }
.pf-chip-v { color: var(--text); font-weight: 650; }
.pf-chip-v.is-role { color: var(--primary); }
@media (max-width: 560px) {
    .users-toolbar .pf-chip { display: none; }
}