/* ============================================
   ASSURCRM — Design System v2
   Moderne · Ergonomique · Premium SaaS
   ============================================ */

/* ── Variables ─────────────────────────────── */
:root {
    /* Surfaces */
    --bo-bg:        #f4f6f9;
    --bo-bg-alt:    #eef0f4;
    --bo-card:      #ffffff;
    --bo-card-alt:  #fafbfc;

    /* Borders */
    --bo-border:    #e8eaed;
    --bo-border-strong: #d1d5db;

    /* Text */
    --bo-text:      #0f1117;
    --bo-text-soft: #6c737f;
    --bo-text-muted:#9ca3af;

    /* Brand */
    --bo-primary:   #0f1117;
    --bo-accent:    #d6fc51;
    --bo-accent-dark: #b8e032;
    --bo-accent-text: #4d6b00; /* accent color as readable text on light backgrounds */

    /* Semantic */
    --bo-success:   #16a34a;
    --bo-success-bg:#dcfce7;
    --bo-warning:   #d97706;
    --bo-warning-bg:#fef3c7;
    --bo-danger:    #dc2626;
    --bo-danger-bg: #fee2e2;
    --bo-info:      #2563eb;
    --bo-info-bg:   #dbeafe;
    --bo-purple:    #7c3aed;
    --bo-purple-bg: #ede9fe;

    /* Radius */
    --bo-radius-sm: 6px;
    --bo-radius:    10px;
    --bo-radius-lg: 14px;
    --bo-radius-xl: 20px;

    /* Shadows */
    --bo-shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --bo-shadow:    0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
    --bo-shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
    --bo-shadow-lg: 0 12px 40px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.05);

    /* Sidebar */
    --bo-sidebar-w: 248px;
    --bo-sidebar-bg: #ffffff;

    /* Transition */
    --bo-ease: cubic-bezier(.22,.68,0,1.2);
}

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bo-bg);
    color: var(--bo-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img, svg { display: block; max-width: 100%; }
input, select, textarea { font-family: inherit; }

/* ── Layout ─────────────────────────────────── */
.bo-wrap {
    display: grid;
    grid-template-columns: var(--bo-sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────── */
.bo-sidebar {
    background: var(--bo-sidebar-bg);
    color: #1f2937;
    border-right: 1px solid var(--bo-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
}
.bo-sidebar::-webkit-scrollbar { display: none; }

/* Logo */
.bo-sidebar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    padding: 20px 18px 18px;
    letter-spacing: -.01em;
    color: #111827;
    border-bottom: 1px solid rgba(0,0,0,.07);
    margin-bottom: 8px;
    flex-shrink: 0;
}
.bo-sidebar .logo-mark {
    width: 32px;
    height: 32px;
    background: var(--bo-accent);
    color: #000;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 14px;
    flex-shrink: 0;
}

/* Nav */
.bo-nav {
    list-style: none;
    padding: 0 10px;
    flex: 1;
}
.bo-nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #9ca3af;
    padding: 18px 10px 6px;
    font-weight: 700;
}
.bo-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: #5a6474;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .14s, color .14s;
    margin-bottom: 1px;
    position: relative;
}
.bo-nav li a:hover {
    background: rgba(0,0,0,.05);
    color: #0f1117;
}
.bo-nav li a.active {
    background: rgba(0,0,0,.06);
    color: #1f2937;
}
.bo-nav li a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--bo-accent);
    border-radius: 0 3px 3px 0;
}
.bo-nav svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    opacity: .8;
}
.bo-nav li a.active svg { opacity: 1; }
.bo-nav .badge {
    margin-left: auto;
    background: var(--bo-accent);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 20px;
    line-height: 1.4;
    min-width: 18px;
    text-align: center;
}

/* Sidebar footer */
.bo-sidebar > div[style*="border-top"] {
    margin-top: auto;
    flex-shrink: 0;
}

/* ── Light theme: accent as text color override ──
   On a white/light bg, the default lime (#d6fc51) is illegible as text.
   Any element in the main area or a card that uses color:var(--bo-accent)
   inline is overridden to the darker readable variant.              ──── */
.bo-main [style*="color:var(--bo-accent)"],
.bo-sidebar [style*="color:var(--bo-accent)"],
.bo-login-card [style*="color:var(--bo-accent)"] {
    color: var(--bo-accent-text) !important;
}

/* ── Main area ───────────────────────────────── */
.bo-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ──────────────────────────────────── */
.bo-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px 0;
    margin-bottom: 24px;
    gap: 16px;
}
.bo-topbar h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.2;
}
.bo-topbar .muted {
    color: var(--bo-text-soft);
    font-size: 13px;
    margin-top: 3px;
    font-weight: 400;
}
.bo-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.bo-user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 12px 6px 6px;
    background: var(--bo-card);
    border: 1px solid var(--bo-border);
    border-radius: 999px;
    cursor: default;
    transition: border-color .15s;
}
.bo-user:hover { border-color: var(--bo-border-strong); }
.bo-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bo-primary);
    color: var(--bo-accent);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0;
    flex-shrink: 0;
}

/* Page content padding */
.bo-main > *:not(.bo-topbar) { padding-left: 32px; padding-right: 32px; }
.bo-main > .bo-topbar { padding-top: 24px; }

/* ── Card ────────────────────────────────────── */
.bo-card {
    background: var(--bo-card);
    border: 1px solid var(--bo-border);
    border-radius: var(--bo-radius-lg);
    box-shadow: var(--bo-shadow-xs);
    overflow: hidden;
    margin-bottom: 20px;
}
.bo-card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--bo-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bo-card);
}
.bo-card-header h2 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--bo-text);
}
.bo-card-body { padding: 22px; }
.bo-card-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--bo-border);
    background: var(--bo-card-alt);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Stats grid ──────────────────────────────── */
.bo-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.bo-stat {
    background: var(--bo-card);
    border: 1px solid var(--bo-border);
    border-radius: var(--bo-radius-lg);
    padding: 20px 22px;
    box-shadow: var(--bo-shadow-xs);
    transition: box-shadow .2s, border-color .2s;
    position: relative;
    overflow: hidden;
}
.bo-stat::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: transparent;
    transition: background .2s;
}
.bo-stat:hover {
    box-shadow: var(--bo-shadow-md);
    border-color: var(--bo-border-strong);
}
.bo-stat:hover::after { background: var(--bo-accent); }
.bo-stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--bo-text-soft);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 14px;
}
.bo-stat-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--bo-bg);
    border: 1px solid var(--bo-border);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.bo-stat-icon svg { width: 14px; height: 14px; }
.bo-stat-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1;
    color: var(--bo-text);
}
.bo-stat-trend {
    font-size: 12px;
    margin-top: 8px;
    color: var(--bo-text-muted);
    font-weight: 500;
}
.bo-stat-trend.up   { color: var(--bo-success); }
.bo-stat-trend.down { color: var(--bo-danger); }

/* ── Table ───────────────────────────────────── */
.bo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.bo-table th {
    padding: 10px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--bo-text-soft);
    background: var(--bo-card-alt);
    border-bottom: 1px solid var(--bo-border);
    white-space: nowrap;
}
.bo-table td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--bo-border);
    color: var(--bo-text);
    vertical-align: middle;
}
.bo-table tbody tr {
    transition: background .1s;
}
.bo-table tbody tr:hover td {
    background: #f8f9fb;
}
.bo-table tbody tr:last-child td { border-bottom: none; }

/* ── Badge ───────────────────────────────────── */
.bo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1.3;
    white-space: nowrap;
}
.bo-badge.gray   { background: #f1f3f5; color: #5a6172; border: 1px solid #e2e5ea; }
.bo-badge.blue   { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.bo-badge.green  { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.bo-badge.orange { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.bo-badge.red    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.bo-badge.purple { background: #faf5ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.bo-badge.yellow { background: #fefce8; color: #a16207; border: 1px solid #fef08a; }

/* ── Buttons ─────────────────────────────────── */
.bo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--bo-radius);
    font-size: 13px;
    font-weight: 600;
    transition: all .15s;
    border: 1px solid transparent;
    white-space: nowrap;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: -.01em;
}
.bo-btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.bo-btn-primary {
    background: var(--bo-primary);
    color: #fff;
    border-color: var(--bo-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.bo-btn-primary:hover {
    background: #1f2733;
    box-shadow: 0 3px 8px rgba(0,0,0,.18);
    transform: translateY(-1px);
}
.bo-btn-primary:active { transform: translateY(0); }

.bo-btn-accent {
    background: var(--bo-accent);
    color: #000;
    border-color: var(--bo-accent-dark);
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
    font-weight: 700;
}
.bo-btn-accent:hover {
    background: var(--bo-accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(214,252,81,.4);
}

.bo-btn-ghost {
    background: var(--bo-card);
    color: var(--bo-text);
    border-color: var(--bo-border);
}
.bo-btn-ghost:hover {
    background: var(--bo-bg);
    border-color: var(--bo-border-strong);
}

.bo-btn-danger {
    background: var(--bo-danger-bg);
    color: var(--bo-danger);
    border-color: #fca5a5;
}
.bo-btn-danger:hover {
    background: var(--bo-danger);
    color: #fff;
    border-color: var(--bo-danger);
}

.bo-btn-sm {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: var(--bo-radius-sm);
}
.bo-btn-xs {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 5px;
}
.bo-btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--bo-radius);
}
.bo-btn-icon.bo-btn-sm { width: 28px; height: 28px; }

/* ── Form elements ───────────────────────────── */
.bo-form-group {
    margin-bottom: 16px;
}
.bo-form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--bo-text);
    margin-bottom: 6px;
    letter-spacing: -.005em;
}
.bo-form-group .help {
    font-size: 11.5px;
    color: var(--bo-text-soft);
    margin-top: 5px;
    line-height: 1.4;
}
.bo-input,
.bo-select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bo-card);
    border: 1.5px solid var(--bo-border);
    border-radius: var(--bo-radius);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--bo-text);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
    appearance: none;
    -webkit-appearance: none;
}
.bo-input:focus,
.bo-select:focus {
    outline: none;
    border-color: var(--bo-primary);
    box-shadow: 0 0 0 3px rgba(15,17,23,.07);
}
.bo-input::placeholder { color: var(--bo-text-muted); }
textarea.bo-input {
    resize: vertical;
    min-height: 90px;
    line-height: 1.6;
}
select.bo-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c737f' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}
.bo-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.bo-form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

/* ── Flash messages ──────────────────────────── */
.bo-flash {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--bo-radius);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
    line-height: 1.4;
}
.bo-flash::before {
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 1px;
}
.bo-flash.success {
    background: var(--bo-success-bg);
    color: #14532d;
    border-color: #86efac;
}
.bo-flash.success::before { content: '✓'; color: var(--bo-success); font-weight: 800; }
.bo-flash.error {
    background: var(--bo-danger-bg);
    color: #7f1d1d;
    border-color: #fca5a5;
}
.bo-flash.error::before { content: '!'; color: var(--bo-danger); font-weight: 800; }
.bo-flash.warning {
    background: var(--bo-warning-bg);
    color: #78350f;
    border-color: #fcd34d;
}
.bo-flash.warning::before { content: '⚠'; color: var(--bo-warning); }
.bo-flash.info {
    background: var(--bo-info-bg);
    color: #1e3a8a;
    border-color: #93c5fd;
}
.bo-flash.info::before { content: 'i'; color: var(--bo-info); font-weight: 800; font-style: italic; }

/* ── Empty state ─────────────────────────────── */
.bo-empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--bo-text-soft);
}
.bo-empty svg {
    margin: 0 auto 16px;
    color: var(--bo-text-muted);
    opacity: .6;
}
.bo-empty h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--bo-text);
    margin-bottom: 6px;
    letter-spacing: -.01em;
}
.bo-empty p {
    font-size: 13px;
    color: var(--bo-text-soft);
    max-width: 340px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ── Login page ──────────────────────────────── */
.bo-login-page,
body.bo-login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #f0f2f5;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
body.bo-login-page::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(214,252,81,.18) 0%, transparent 70%),
        radial-gradient(ellipse 50% 60% at 80% 70%, rgba(59,130,246,.07) 0%, transparent 70%);
    pointer-events: none;
}
.bo-login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border: 1px solid #e2e6ea;
    border-radius: 18px;
    padding: 44px 40px;
    box-shadow: 0 4px 24px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04);
    position: relative;
    z-index: 1;
    color: var(--bo-text);
}
.bo-login-card .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
    color: #111827;
}
.bo-login-card .logo-mark {
    width: 36px;
    height: 36px;
    background: var(--bo-accent);
    color: #000;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 16px;
}
.bo-login-card h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.03em;
    margin: 24px 0 5px;
    color: #111827;
}
.bo-login-card p.subtitle {
    color: #6c737f;
    font-size: 13.5px;
    margin-bottom: 28px;
    line-height: 1.4;
}
.bo-login-card .bo-form-group label { color: #374151; }
.bo-login-card .bo-input {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
}
.bo-login-card .bo-input:focus {
    border-color: var(--bo-accent-dark);
    box-shadow: 0 0 0 3px rgba(214,252,81,.25);
    background: #ffffff;
}
.bo-login-card .bo-input::placeholder { color: #9ca3af; }
.bo-login-card .bo-btn-primary {
    background: #111827;
    color: #fff;
    border-color: transparent;
    font-weight: 700;
    font-size: 14px;
    padding: 12px;
}
.bo-login-card .bo-btn-primary:hover { background: #1f2937; }
.bo-login-card .bo-flash.error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ── Inline select ───────────────────────────── */
.inline-status-form { display: inline; }
.inline-select {
    font-size: 11.5px;
    padding: 4px 8px;
    border: 1.5px solid var(--bo-border);
    border-radius: var(--bo-radius-sm);
    background: var(--bo-card);
    color: var(--bo-text);
    cursor: pointer;
    font-weight: 500;
    transition: border-color .15s;
    max-width: 140px;
    font-family: inherit;
    appearance: none;
}
.inline-select:hover, .inline-select:focus {
    border-color: var(--bo-accent);
    outline: none;
}

/* ── Toolbar ─────────────────────────────────── */
.bo-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Layouts ─────────────────────────────────── */
.bo-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
.bo-page-edit {
    display: grid;
    grid-template-columns: 1fr 310px;
    gap: 20px;
    align-items: start;
}
.bo-side-card {
    position: sticky;
    top: 24px;
}

/* ── Topbar search ───────────────────────────── */
.bo-topbar-actions form input[type="text"] {
    background: var(--bo-card);
    border: 1.5px solid var(--bo-border);
    border-radius: var(--bo-radius);
    color: var(--bo-text);
    transition: border-color .15s;
}
.bo-topbar-actions form input[type="text"]:focus {
    border-color: var(--bo-border-strong);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}

/* ── Divider ─────────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid var(--bo-border);
    margin: 20px 0;
}

/* ── Scrollbar (webkit) ──────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bo-border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--bo-text-muted); }

/* ── Animations ──────────────────────────────── */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.bo-flash { animation: slideDown .2s var(--bo-ease); }
.bo-card  { animation: fadeIn .15s ease; }

/* ── Utility ─────────────────────────────────── */
.muted { color: var(--bo-text-soft); }
code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .88em;
    background: var(--bo-bg-alt);
    border: 1px solid var(--bo-border);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--bo-text-soft);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Mobile-first improvements
   ═══════════════════════════════════════════════ */

/* ── Mobile sidebar toggle button ── */
.bo-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1.5px solid var(--bo-border);
    border-radius: var(--bo-radius);
    background: var(--bo-card);
    cursor: pointer;
    flex-shrink: 0;
    color: var(--bo-text);
    transition: background .15s, border-color .15s;
    margin-right: 8px;
}
.bo-hamburger:hover { background: var(--bo-bg); border-color: var(--bo-border-strong); }
.bo-hamburger svg { width: 18px; height: 18px; }

/* ── Sidebar overlay (mobile) ── */
.bo-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 997;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fadeIn .2s ease;
}
.bo-sidebar-overlay.active { display: block; }

/* ── Table scroll wrapper ── */
.bo-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 0 var(--bo-radius-lg) var(--bo-radius-lg);
}

/* ── Responsive breakpoints ── */

/* Large screens: sidebar shrinks slightly */
@media (max-width: 1280px) {
    :root { --bo-sidebar-w: 230px; }
}

/* Medium: stack 4-col stats to 2, shrink sidebar */
@media (max-width: 1200px) {
    .bo-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet landscape */
@media (max-width: 1024px) {
    :root { --bo-sidebar-w: 210px; }
    .bo-main > *:not(.bo-topbar) { padding-left: 20px; padding-right: 20px; }
    .bo-topbar { padding-left: 20px; padding-right: 20px; padding-top: 18px; }
    .bo-page-edit { grid-template-columns: 1fr; }
    .bo-form-row-3 { grid-template-columns: 1fr 1fr; }
    .bo-grid-2 { grid-template-columns: 1fr; }
}

/* Tablet portrait — sidebar becomes a drawer */
@media (max-width: 860px) {
    .bo-wrap { grid-template-columns: 1fr; }

    .bo-hamburger { display: flex; }

    .bo-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 272px;
        z-index: 998;
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.22,.68,0,1.2);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }
    .bo-sidebar.is-open { transform: translateX(0); }

    .bo-main > *:not(.bo-topbar) { padding-left: 18px; padding-right: 18px; }
    .bo-topbar { padding: 16px 18px 0; gap: 10px; }

    /* Hide topbar user text label on tablet */
    .bo-user > div:last-child { display: none; }
    .bo-user { padding: 5px 8px 5px 5px; }

    /* Hide topbar search bar, use the search icon instead */
    .bo-topbar-search { display: none; }

    .bo-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .bo-form-row { grid-template-columns: 1fr; }
    .bo-form-row-3 { grid-template-columns: 1fr; }
    .bo-page-edit { grid-template-columns: 1fr; }
    .bo-grid-2 { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 600px) {
    .bo-main > *:not(.bo-topbar) { padding-left: 14px; padding-right: 14px; }
    .bo-topbar { padding: 14px 14px 0; flex-wrap: wrap; }
    .bo-topbar h1 { font-size: 17px; }
    .bo-topbar > div:first-child { flex: 1; min-width: 0; }

    .bo-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .bo-stat { padding: 14px 16px; }
    .bo-stat-value { font-size: 24px; }

    .bo-card { border-radius: var(--bo-radius); margin-bottom: 14px; }
    .bo-card-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .bo-card-body { padding: 16px; }
    .bo-table th, .bo-table td { padding: 10px 14px; font-size: 12.5px; }

    .bo-toolbar { gap: 6px; }
    .bo-btn { padding: 8px 13px; font-size: 12.5px; }
    .bo-btn-sm { padding: 5px 9px; font-size: 11px; }

    .bo-login-card { padding: 28px 20px; border-radius: 14px; }
    .bo-login-card h1 { font-size: 20px; }

    /* Stack topbar actions vertically if they overflow */
    .bo-topbar-actions { flex-wrap: wrap; gap: 6px; }
}

/* Extra small — single column everything */
@media (max-width: 420px) {
    .bo-stats { grid-template-columns: 1fr; }
    .bo-sidebar { width: 88vw; max-width: 300px; }
    .bo-topbar h1 { font-size: 16px; }
}

/* ── Print ───────────────────────────────────── */
@media print {
    .bo-sidebar, .bo-topbar { display: none; }
    .bo-main { padding: 0; }
    .bo-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ══ Additional responsive improvements ═══════════════════════════════════ */

/* Page edit layout — responsive */
.bo-page-edit {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .bo-page-edit { grid-template-columns: 1fr; }
    .bo-side-card { display: contents; }
}

/* Form rows — stack on mobile */
@media (max-width: 600px) {
    .bo-form-row, .bo-form-row-3 {
        grid-template-columns: 1fr !important;
    }
    .bo-form-row-3 {
        grid-template-columns: 1fr !important;
    }
}

/* Cards — reduce padding on mobile */
@media (max-width: 600px) {
    .bo-card-body { padding: 16px !important; }
    .bo-card-header { padding: 12px 16px !important; }
    .bo-card-footer { padding: 12px 16px !important; }
}

/* Stats grid — always single col under 420px */
@media (max-width: 420px) {
    .bo-stats { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 340px) {
    .bo-stats { grid-template-columns: 1fr !important; }
}

/* Table overflow hint on mobile */
@media (max-width: 860px) {
    .bo-table-wrap::after {
        content: '';
        position: absolute;
        right: 0; top: 0; bottom: 0;
        width: 32px;
        background: linear-gradient(to right, transparent, var(--bo-card));
        pointer-events: none;
    }
    .bo-table-wrap { position: relative; }
}

/* Kanban board mobile */
@media (max-width: 860px) {
    .kb-board {
        flex-direction: column;
        overflow-x: visible;
        min-height: auto;
    }
    .kb-col {
        width: 100%;
        min-width: 0;
        max-height: none;
    }
    .kb-col-body {
        max-height: 300px;
    }
}

/* Calendar mobile */
@media (max-width: 600px) {
    .cal-grid, .cal-header-row {
        gap: 1px;
    }
    .cal-day {
        min-height: 60px;
        padding: 4px;
    }
    .cal-day-num { font-size: 10px; }
    .cal-event { font-size: 9px; padding: 1px 3px; }
}

/* Bulk email / send email 2-col layout */
@media (max-width: 768px) {
    .send-email-layout,
    .bulk-email-layout {
        grid-template-columns: 1fr !important;
    }
}

/* FAB — hide on desktop when sidebar visible */
@media (min-width: 861px) {
    #fab-wrap { bottom: 24px !important; }
}

/* Print styles */
@media print {
    .bo-sidebar,
    .bo-topbar,
    .bo-bottom-nav,
    #fab-wrap,
    #cmdPalette,
    .bo-sidebar-overlay,
    .no-print { display: none !important; }
    .bo-main { margin: 0 !important; padding: 0 !important; }
    .bo-wrap { display: block !important; }
    body { background: white !important; color: black !important; }
    .bo-card { border: 1px solid #ddd !important; box-shadow: none !important; }
    a { color: inherit !important; text-decoration: none !important; }
}

/* Input focus ring */
.bo-input:focus, .bo-select:focus, .bo-textarea:focus {
    outline: 2px solid var(--bo-accent);
    outline-offset: 0;
    border-color: var(--bo-accent);
}

/* Smooth transitions */
.bo-btn { transition: background .15s, color .15s, border-color .15s, box-shadow .15s, opacity .15s; }
.bo-badge { transition: background .15s; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bo-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bo-text-soft); }

/* Tooltip helper */
[title]:not([title=""]) { cursor: help; }
