/* AssetCare design system — dark-gray sidebar, green accent, collapsible */

:root {
    --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);

    --bs-primary: #15803d;
    --bs-primary-rgb: 21, 128, 61;
    --bs-primary-text-emphasis: #14532d;
    --bs-primary-bg-subtle: #dcfce7;
    --bs-primary-border-subtle: #86efac;

    --bs-link-color: #15803d;
    --bs-link-color-rgb: 21, 128, 61;
    --bs-link-hover-color: #14532d;
    --bs-link-hover-color-rgb: 20, 83, 45;

    --bs-border-radius: .5rem;
    --bs-border-radius-sm: .375rem;
    --bs-border-radius-lg: .75rem;

    --ac-sidebar-bg: #53585c;
    --ac-sidebar-text: #d8dadc;
    --ac-sidebar-text-muted: #a9adb0;
    --ac-sidebar-active-bg: rgba(255, 255, 255, .09);
    --ac-sidebar-icon: #4ade80;
    --ac-sidebar-width: 240px;
    --ac-sidebar-width-collapsed: 72px;
    --ac-text-muted: #6b7280;
}

body {
    background: #fbfbfa;
    color: #1f2937;
}

/* ---------- App shell ---------- */
.ac-shell {
    display: flex;
    min-height: 100vh;
}

.ac-sidebar {
    width: var(--ac-sidebar-width);
    flex: 0 0 var(--ac-sidebar-width);
    background: var(--ac-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width .15s ease, flex-basis .15s ease;
    overflow: hidden;
}

/* ---------- Sidebar header: brand on top, menu toggle beside it ---------- */
.ac-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .25rem;
    padding-right: .6rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    flex: none;
}

.ac-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: .5rem;
    color: var(--ac-sidebar-text);
    cursor: pointer;
}

.ac-menu-toggle:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.ac-menu-toggle i {
    font-size: 1.25rem;
    line-height: 1;
}

/* ---------- Brand ---------- */
.ac-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .9rem 0 .9rem 1.1rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    white-space: nowrap;
    min-width: 0;
}

.ac-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 36px;
}

.ac-nav {
    flex: 1;
    padding: .5rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.ac-nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: .5rem;
    color: var(--ac-sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.ac-nav-link i {
    font-size: 1rem;
    width: 1.1rem;
    text-align: center;
    color: var(--ac-sidebar-icon);
    flex: none;
}

.ac-nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.ac-nav-link.active {
    background: var(--ac-sidebar-active-bg);
    color: #fff;
    border-left-color: var(--ac-sidebar-icon);
    font-weight: 600;
}

.ac-nav-link.active i {
    color: var(--ac-sidebar-icon);
}

.ac-sidebar-footer {
    padding: .85rem 1.1rem;
    font-size: .75rem;
    color: var(--ac-sidebar-text-muted);
    border-top: 1px solid rgba(255, 255, 255, .08);
    white-space: nowrap;
}

/* ---------- Collapsed sidebar ---------- */
.ac-sidebar.collapsed {
    width: var(--ac-sidebar-width-collapsed);
    flex: 0 0 var(--ac-sidebar-width-collapsed);
}

.ac-sidebar.collapsed .ac-sidebar-head {
    justify-content: center;
    min-height: 58px;
    padding: 0;
}

.ac-sidebar.collapsed .ac-brand {
    display: none;
}

.ac-sidebar.collapsed .ac-brand-text,
.ac-sidebar.collapsed .ac-nav-link-text,
.ac-sidebar.collapsed .ac-nav-link .badge,
.ac-sidebar.collapsed .ac-sidebar-footer {
    display: none;
}

.ac-sidebar.collapsed .ac-nav-link {
    justify-content: center;
    padding: .6rem;
}

/* ---------- Main column ---------- */
.ac-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ac-topbar {
    height: 58px;
    flex: 0 0 58px;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    padding: 0 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ac-topbar-brand {
    display: none;
    align-items: center;
    font-weight: 700;
    color: #111827;
    font-size: .95rem;
    text-decoration: none;
    gap: .5rem;
}

body.ac-sidebar-collapsed .ac-topbar-brand {
    display: flex;
}

.ac-topbar-right {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    margin-left: auto;
}

.ac-topbar-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: .5rem;
    color: #374151;
    font-size: 1.05rem;
    text-decoration: none;
    border: none;
    background: transparent;
    padding: 0;
}

.ac-topbar-bell:focus {
    outline: 2px solid var(--bs-primary-border-subtle);
    outline-offset: 1px;
}

.ac-topbar-bell:hover {
    background: #f1f3f5;
}

.ac-topbar-bell .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: .6rem;
    padding: .2em .4em;
}

.ac-content {
    padding: 1.75rem 2rem 3rem;
}

/* ---------- Guest (logged-out) pages ---------- */
.ac-guest {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: #f8f9fb;
    padding: 2rem 1rem;
}

.ac-guest .ac-brand {
    justify-content: center;
    padding: 0 0 1.5rem;
    color: #111827;
}

/* ---------- Auth cards ---------- */
.ac-auth-card {
    border: 1px solid #e9ebee;
    border-top: 3px solid var(--bs-primary);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

.ac-auth-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: .5rem;
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary);
    font-size: 1.3rem;
    margin-bottom: .75rem;
}

/* ---------- Cards & tables ---------- */
.card {
    border-color: #e9ebee;
}

.card.border-success    { background: var(--bs-success-bg-subtle);   border-color: var(--bs-success-border-subtle) !important; }
.card.border-warning    { background: var(--bs-warning-bg-subtle);   border-color: var(--bs-warning-border-subtle) !important; }
.card.border-danger     { background: var(--bs-danger-bg-subtle);    border-color: var(--bs-danger-border-subtle) !important; }
.card.border-secondary  { background: var(--bs-secondary-bg-subtle); border-color: var(--bs-secondary-border-subtle) !important; }
.card.border-primary    { background: var(--bs-primary-bg-subtle);   border-color: var(--bs-primary-border-subtle) !important; }
.card.border-dark       { background: #f8f9fa; border-color: #dee2e6 !important; }

.table thead {
    background: #f8f9fb;
}

/* ---------- Dashboard ---------- */
body:has(.ac-dash) {
    background: #eef0f3;
}

.ac-dash-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.ac-dash-head h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.ac-dash-date {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
    color: var(--ac-text-muted);
}

.ac-stat {
    --ac-accent: #6b7280;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 100%;
    padding: 1rem 1.15rem;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-top: 3px solid var(--ac-accent);
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    color: inherit;
    text-decoration: none;
    transition: box-shadow .15s ease, transform .15s ease;
}

.ac-stat:hover {
    color: inherit;
    box-shadow: 0 4px 12px rgba(16, 24, 40, .1);
    transform: translateY(-1px);
}

.ac-stat.gray  { --ac-accent: #6b7280; }
.ac-stat.red   { --ac-accent: #dc2626; }
.ac-stat.amber { --ac-accent: #f59e0b; }
.ac-stat.blue  { --ac-accent: #2563eb; }

.ac-stat-label {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ac-text-muted);
}

.ac-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

.ac-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: .5rem;
    font-size: 1.3rem;
    color: var(--ac-accent);
    background: color-mix(in srgb, var(--ac-accent) 12%, white);
}

.ac-panel {
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    overflow: hidden;
}

.row > [class*="col"] > .ac-panel {
    height: 100%;
}

.ac-panel-danger {
    border-top: 3px solid #dc2626;
}

.ac-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1.1rem;
    background: #f8f9fb;
    border-bottom: 1px solid #dfe3e8;
}

.ac-panel-title {
    margin: 0;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #374151;
}

.ac-panel-meta {
    font-size: .78rem;
    color: var(--ac-text-muted);
}

.ac-panel-body {
    padding: 1.1rem 1.25rem;
}

.ac-chart-box {
    position: relative;
    height: 260px;
}

.ac-panel .table {
    margin: 0;
}

.ac-panel .table thead th {
    padding: .65rem 1.1rem;
    background: #fff;
    border-bottom: 1px solid #dfe3e8;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #6b7280;
}

.ac-panel .table td {
    padding: .7rem 1.1rem;
}

.ac-panel-form {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

.ac-tag {
    padding: .1rem .45rem;
    background: #f1f3f5;
    border: 1px solid #e1e5ea;
    border-radius: .3rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
}

/* ---------- Detail grid (label/value pairs on show pages) ---------- */
.ac-detail-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: .65rem 1rem;
}

/* ---------- Notifications dropdown ---------- */
.ac-notif-dropdown {
    width: 320px;
    padding: 0;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .08);
}
.ac-notif-dropdown-head {
    padding: .7rem 1rem;
    font-weight: 600;
    font-size: .85rem;
    border-bottom: 1px solid #f1f3f5;
}
.ac-notif-item {
    padding: .6rem 1rem;
    border-bottom: 1px solid #f6f7f8;
    font-size: .825rem;
}
.ac-notif-item.unread {
    background: var(--bs-primary-bg-subtle);
}
.ac-notif-item-text {
    color: #374151;
    line-height: 1.4;
}
.ac-notif-item-time {
    color: var(--ac-text-muted);
    font-size: .7rem;
    margin-top: .15rem;
}
.ac-notif-empty {
    padding: 1.25rem 1rem;
    text-align: center;
    color: var(--ac-text-muted);
    font-size: .85rem;
}
.ac-notif-dropdown-footer {
    display: block;
    text-align: center;
    padding: .6rem 1rem;
    font-size: .825rem;
    font-weight: 600;
    color: var(--bs-primary);
    text-decoration: none;
    border-top: 1px solid #f1f3f5;
}
.ac-notif-dropdown-footer:hover {
    background: #f8f9fb;
}

.ac-detail-grid dt {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ac-text-muted);
    margin: 0;
}
.ac-detail-grid dd {
    margin: 0;
    padding-bottom: .65rem;
    border-bottom: 1px solid #f1f3f5;
}
@media (max-width: 576px) {
    .ac-detail-grid { grid-template-columns: 1fr; }
}

/* ---------- Mobile menu (hidden on desktop) ---------- */
.ac-topbar-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-left: -.4rem;
    background: transparent;
    border: none;
    border-radius: .5rem;
    color: #374151;
    font-size: 1.5rem;
    line-height: 1;
}

.ac-topbar-menu:hover {
    background: #f1f3f5;
}

.ac-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1039;
    background: rgba(17, 24, 39, .5);
}

/* ---------- Tablet and phone ---------- */
@media (max-width: 768px) {
    body.ac-no-scroll { overflow: hidden; }

    /* Sidebar becomes a slide-in drawer */
    .ac-sidebar,
    .ac-sidebar.collapsed {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        width: 260px;
        height: 100%;
        flex: none;
        flex-direction: column;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .ac-sidebar.open {
        transform: none;
        box-shadow: 0 0 30px rgba(0, 0, 0, .3);
    }
    .ac-backdrop.show { display: block; }

    /* The drawer always shows the full menu, even if collapsed on desktop */
    .ac-menu-toggle { display: none; }
    .ac-sidebar-head,
    .ac-sidebar.collapsed .ac-sidebar-head {
        justify-content: flex-start;
        min-height: 58px;
        padding: 0;
    }
    .ac-sidebar.collapsed .ac-brand {
        display: flex;
        justify-content: flex-start;
        padding: .9rem 0 .9rem 1.1rem;
    }
    .ac-sidebar.collapsed .ac-brand-text,
    .ac-sidebar.collapsed .ac-nav-link-text { display: inline; }
    .ac-sidebar.collapsed .ac-nav-link .badge { display: inline-block; }
    .ac-sidebar.collapsed .ac-sidebar-footer { display: block; }
    .ac-sidebar.collapsed .ac-nav-link {
        justify-content: flex-start;
        padding: .55rem .75rem;
    }
    .ac-nav-link { padding-top: .7rem; padding-bottom: .7rem; }

    /* Top bar */
    .ac-topbar { padding: 0 1rem; gap: .5rem; }
    .ac-topbar-menu { display: inline-flex; }
    .ac-topbar-brand,
    body.ac-sidebar-collapsed .ac-topbar-brand { display: flex; }
    .ac-topbar-right { gap: .5rem; }

    /* Content */
    .ac-content { padding: 1.25rem 1rem 2rem; }
    .ac-content h1 { font-size: 1.5rem; }
    .ac-content table.w-50 { width: 100% !important; }
    .ac-content .table-responsive > .table:has(thead) { min-width: 620px; }
}

@media (max-width: 576px) {
    .ac-stat-icon { display: none; }
    .ac-stat-value { font-size: 1.7rem; }
}

/* ---------- Logo ---------- */
:root {
    --logo-shield: #15803d;
    --logo-inner: #4b5563;
    --logo-bg: #fff;
}

.ac-sidebar {
    --logo-shield: #4ade80;
    --logo-inner: #e5e7eb;
    --logo-bg: var(--ac-sidebar-bg);
}

.ac-guest {
    --logo-bg: #f8f9fb;
}

.ac-logo {
    display: block;
    width: auto;
}

.ac-brand-icon .ac-logo { height: 36px; }
.ac-topbar-brand .ac-logo { height: 28px; }

/* ---------- Icon action buttons (table row actions) ---------- */
.ac-action-group {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.ac-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: .5rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    text-decoration: none;
    font-size: .85rem;
    cursor: pointer;
}
.ac-btn-icon:hover {
    background: #f8f9fb;
    color: #111827;
}
.ac-btn-icon.view:hover   { color: #2563eb; border-color: #bfdbfe; background: #eff6ff; }
.ac-btn-icon.edit:hover   { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.ac-btn-icon.delete:hover { color: #dc2626; border-color: #fecaca; background: #fef2f2; }

/* ---------- Log Service pill button (urgency-colored) ---------- */
.ac-btn-log {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    white-space: nowrap;
}
.ac-btn-log.red {
    color: #b91c1c;
    background: var(--bs-danger-bg-subtle);
    border-color: var(--bs-danger-border-subtle);
}
.ac-btn-log.red:hover { background: #fecaca; color: #7f1d1d; }
.ac-btn-log.amber {
    color: #92400e;
    background: var(--bs-warning-bg-subtle);
    border-color: var(--bs-warning-border-subtle);
}
.ac-btn-log.amber:hover { background: #fde68a; color: #78350f; }

.ac-report-icon {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: .65rem;
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* ---------- Users: avatar + role pill ---------- */
.ac-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
}
.ac-role {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.ac-role.super_admin {
    color: var(--bs-primary-text-emphasis);
    background: var(--bs-primary-bg-subtle);
    border-color: var(--bs-primary-border-subtle);
}

.ac-role.asset_admin {
    color: #374151;
    background: #f1f3f5;
    border-color: #e1e5ea;
}
.ac-role.audit_admin {
    color: #92400e;
    background: var(--bs-warning-bg-subtle);
    border-color: var(--bs-warning-border-subtle);
}
.ac-role.user {
    color: #1d4ed8;
    background: #dbeafe;
    border-color: #bfdbfe;
}

/* ---------- Notifications page: activity feed rows ---------- */
.ac-feed-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid #f1f3f5;
    color: inherit;
    text-decoration: none;
}
.ac-feed-row:last-child { border-bottom: none; }
.ac-feed-row:hover {
    background: #f8f9fb;
    color: inherit;
}
.ac-feed-row.unread {
    background: var(--bs-primary-bg-subtle);
    border-left: 3px solid var(--bs-primary);
    padding-left: calc(1.1rem - 3px);
}
.ac-feed-row.unread:hover {
    background: #cbf5d9;
}
.ac-feed-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f3f5;
    color: #6b7280;
    font-size: .95rem;
}
.ac-feed-row.unread .ac-feed-icon {
    background: #fff;
    color: var(--bs-primary);
}
.ac-feed-text {
    flex: 1;
    min-width: 0;
    font-size: .9rem;
    color: #374151;
    line-height: 1.4;
}
.ac-feed-time {
    font-size: .75rem;
    color: var(--ac-text-muted);
    margin-top: .1rem;
}
.ac-feed-chevron {
    color: #9ca3af;
    flex: none;
}

/* ---------- Wordmark: caps + tracking so it reads as a logo ---------- */
.ac-brand-text,
.ac-topbar-brand > span {
    text-transform: uppercase;
    letter-spacing: .14em;
    font-weight: 700;
    font-size: .88rem;
}

/* ---------- Floating theme toggle (bottom-right bubble) ---------- */
.ac-theme-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1030;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #dfe3e8;
    color: #374151;
    font-size: 1.2rem;
    box-shadow: 0 4px 14px rgba(16, 24, 40, .15);
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}
.ac-theme-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 24, 40, .22);
}
[data-bs-theme="dark"] .ac-theme-fab {
    background: var(--ac-surface);
    border-color: var(--ac-border);
    color: #fbbf24;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}

/* =====================================================
   DARK MODE  (html[data-bs-theme="dark"])
   ===================================================== */
[data-bs-theme="dark"] {
    --ac-bg: #111418;
    --ac-surface: #1a1e23;
    --ac-surface-2: #20252b;
    --ac-border: #2d343b;
    --ac-hover: #252b32;
    --ac-text: #e5e7eb;
    --ac-text-strong: #f3f4f6;
    --ac-text-muted: #9ca3af;

    --ac-sidebar-bg: #15181b;
    --ac-sidebar-text: #d1d5db;
    --ac-sidebar-text-muted: #8b9096;

    --logo-shield: #4ade80;
    --logo-inner: #d1d5db;
    --logo-bg: var(--ac-surface);

    /* Bootstrap's own variables, so cards, tables, modals, dropdowns match */
    --bs-body-bg: #1a1e23;
    --bs-body-bg-rgb: 26, 30, 35;
    --bs-body-color: #e5e7eb;
    --bs-body-color-rgb: 229, 231, 235;
    --bs-secondary-bg: #20252b;
    --bs-tertiary-bg: #20252b;
    --bs-border-color: #2d343b;

    /* Brighter green so it stays readable on dark */
    --bs-primary: #22c55e;
    --bs-primary-rgb: 34, 197, 94;
    --bs-primary-text-emphasis: #86efac;
    --bs-primary-bg-subtle: #0f2e1c;
    --bs-primary-border-subtle: #166534;
    --bs-link-color: #4ade80;
    --bs-link-color-rgb: 74, 222, 128;
    --bs-link-hover-color: #86efac;
    --bs-link-hover-color-rgb: 134, 239, 172;
}

[data-bs-theme="dark"] body,
[data-bs-theme="dark"] body:has(.ac-dash) {
    background: var(--ac-bg);
    color: var(--ac-text);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--ac-bg);
}
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
}
[data-bs-theme="dark"] .table thead {
    background: var(--ac-surface-2);
}

/* Shell */
[data-bs-theme="dark"] .ac-sidebar { border-right: 1px solid var(--ac-border); }
[data-bs-theme="dark"] .ac-topbar {
    background: var(--ac-surface);
    border-bottom-color: var(--ac-border);
}
[data-bs-theme="dark"] .ac-topbar-brand { color: var(--ac-text-strong); }
[data-bs-theme="dark"] .ac-topbar-bell,
[data-bs-theme="dark"] .ac-topbar-menu { color: var(--ac-text); }
[data-bs-theme="dark"] .ac-topbar-bell:hover,
[data-bs-theme="dark"] .ac-topbar-menu:hover { background: var(--ac-hover); }

/* Guest / auth */
[data-bs-theme="dark"] .ac-guest {
    background: var(--ac-bg);
    --logo-bg: var(--ac-bg);
}
[data-bs-theme="dark"] .ac-guest .ac-brand { color: var(--ac-text-strong); }
[data-bs-theme="dark"] .card {
    --bs-card-bg: var(--ac-surface);
    border-color: var(--ac-border);
}
[data-bs-theme="dark"] .ac-auth-card {
    border-color: var(--ac-border);
    border-top-color: var(--bs-primary);
}
[data-bs-theme="dark"] .card.border-dark {
    background: var(--ac-surface-2);
    border-color: var(--ac-border) !important;
}

/* Stat tiles and panels */
[data-bs-theme="dark"] .ac-stat {
    background: var(--ac-surface);
    border-color: var(--ac-border);
    border-top-color: var(--ac-accent);
    box-shadow: none;
}
[data-bs-theme="dark"] .ac-stat:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, .4); }
[data-bs-theme="dark"] .ac-stat-value { color: var(--ac-text-strong); }
[data-bs-theme="dark"] .ac-stat-icon {
    background: color-mix(in srgb, var(--ac-accent) 20%, var(--ac-surface));
}

[data-bs-theme="dark"] .ac-panel {
    background: var(--ac-surface);
    border-color: var(--ac-border);
    box-shadow: none;
}
[data-bs-theme="dark"] .ac-panel-danger { border-top-color: #dc2626; }
[data-bs-theme="dark"] .ac-panel-head {
    background: var(--ac-surface-2);
    border-bottom-color: var(--ac-border);
}
[data-bs-theme="dark"] .ac-panel-title { color: #d1d5db; }
[data-bs-theme="dark"] .ac-panel .table thead th {
    background: var(--ac-surface);
    border-bottom-color: var(--ac-border);
    color: var(--ac-text-muted);
}

[data-bs-theme="dark"] .ac-tag {
    background: var(--ac-surface-2);
    border-color: var(--ac-border);
    color: var(--ac-text);
}
[data-bs-theme="dark"] .ac-detail-grid dd { border-bottom-color: var(--ac-border); }
[data-bs-theme="dark"] .ac-role.asset_admin {
    color: var(--ac-text);
    background: var(--ac-surface-2);
    border-color: var(--ac-border);
}

/* Buttons */
[data-bs-theme="dark"] .ac-btn-icon {
    background: var(--ac-surface);
    border-color: var(--ac-border);
    color: var(--ac-text-muted);
}
[data-bs-theme="dark"] .ac-btn-icon:hover {
    background: var(--ac-hover);
    color: var(--ac-text-strong);
}
[data-bs-theme="dark"] .ac-btn-icon.view:hover   { color: #60a5fa; border-color: #1e3a8a; background: #172554; }
[data-bs-theme="dark"] .ac-btn-icon.edit:hover   { color: #fbbf24; border-color: #78350f; background: #2a1d05; }
[data-bs-theme="dark"] .ac-btn-icon.delete:hover { color: #f87171; border-color: #7f1d1d; background: #2a0f0f; }

[data-bs-theme="dark"] .ac-btn-log.red { color: #fca5a5; }
[data-bs-theme="dark"] .ac-btn-log.red:hover { background: #4a1519; color: #fecaca; }
[data-bs-theme="dark"] .ac-btn-log.amber { color: #fcd34d; }
[data-bs-theme="dark"] .ac-btn-log.amber:hover { background: #3b2a07; color: #fde68a; }

/* Notifications: dropdown + feed page */
[data-bs-theme="dark"] .ac-notif-dropdown {
    border-color: var(--ac-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, .5);
}
[data-bs-theme="dark"] .ac-notif-dropdown-head,
[data-bs-theme="dark"] .ac-notif-item { border-bottom-color: var(--ac-border); }
[data-bs-theme="dark"] .ac-notif-item-text { color: var(--ac-text); }
[data-bs-theme="dark"] .ac-notif-dropdown-footer { border-top-color: var(--ac-border); }
[data-bs-theme="dark"] .ac-notif-dropdown-footer:hover { background: var(--ac-hover); }

[data-bs-theme="dark"] .ac-feed-row { border-bottom-color: var(--ac-border); }
[data-bs-theme="dark"] .ac-feed-row:hover { background: var(--ac-hover); }
[data-bs-theme="dark"] .ac-feed-row.unread { background: var(--bs-primary-bg-subtle); }
[data-bs-theme="dark"] .ac-feed-row.unread:hover { background: #134226; }
[data-bs-theme="dark"] .ac-feed-icon {
    background: var(--ac-surface-2);
    color: var(--ac-text-muted);
}
[data-bs-theme="dark"] .ac-feed-row.unread .ac-feed-icon {
    background: var(--ac-surface);
    color: var(--bs-primary);
}
[data-bs-theme="dark"] .ac-feed-text { color: var(--ac-text); }

/* =====================================================
   Mobile polish
   ===================================================== */

/* Keep the floating theme bubble from covering the last row / pagination */
.ac-content { padding-bottom: 5rem; }

/* Long names and emails wrap instead of stretching the page */
.ac-content h1,
.ac-detail-grid dd { overflow-wrap: anywhere; }

/* Pagination wraps instead of overflowing */
.pagination { flex-wrap: wrap; }

/* Notification dropdown never wider than the screen */
.ac-notif-dropdown { width: min(320px, calc(100vw - 2rem)); }

@media (max-width: 768px) {
    /* Panel headers: title on top, buttons wrap underneath */
    .ac-panel-head { flex-wrap: wrap; }
    .ac-panel-head > div {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: .4rem;
    }

    /* Bigger touch targets for the row action buttons */
    .ac-btn-icon { width: 36px; height: 36px; font-size: .95rem; }
    .ac-action-group { gap: .4rem; }

    /* Slightly smaller theme bubble, tucked closer to the corner */
    .ac-theme-fab {
        width: 42px;
        height: 42px;
        right: .9rem;
        bottom: .9rem;
        font-size: 1.1rem;
    }
}

@media (max-width: 576px) {
    /* Page title rows (title + Back button) wrap instead of squeezing */
    .ac-content .d-flex.justify-content-between.align-items-start {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .ac-panel-body { padding: .9rem 1rem; }
    .ac-panel .table td,
    .ac-panel .table thead th { padding-left: .8rem; padding-right: .8rem; }
}

@media (max-width: 420px) {
    /* Very small phones: tighten the wordmark so the top bar fits */
    .ac-topbar-brand > span { letter-spacing: .08em; }
}

/* Center the version label in the collapsed sidebar */
@media (min-width: 769px) {
    .ac-sidebar.collapsed .ac-sidebar-footer {
        display: block;
        text-align: center;
        padding: .85rem 0;
    }
}

/* ---------- Profile dropdown (top bar) ---------- */
.ac-profile-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .2rem .55rem .2rem .25rem;
    background: transparent;
    border: none;
    border-radius: 999px;
    color: #374151;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
}
.ac-profile-btn:hover { background: #f1f3f5; }
.ac-profile-btn:focus-visible {
    outline: 2px solid var(--bs-primary-border-subtle);
    outline-offset: 1px;
}
.ac-profile-btn .ac-avatar { width: 32px; height: 32px; }
.ac-profile-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ac-profile-chevron { font-size: .7rem; color: var(--ac-text-muted); }

.ac-profile-menu {
    width: min(280px, calc(100vw - 2rem));
    padding: 0;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .08);
}
.ac-profile-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid #f1f3f5;
}
.ac-profile-head .ac-avatar { width: 42px; height: 42px; font-size: 1rem; }
.ac-profile-info { min-width: 0; }
.ac-profile-fullname {
    font-weight: 600;
    font-size: .9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ac-profile-email {
    font-size: .78rem;
    color: var(--ac-text-muted);
    margin-bottom: .35rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ac-profile-logout {
    padding: .65rem 1rem;
    font-size: .875rem;
    border-radius: 0 0 .5rem .5rem;
}
.ac-profile-logout:hover { color: #dc2626; }

@media (max-width: 576px) {
    /* Phones: avatar only */
    .ac-profile-name,
    .ac-profile-chevron { display: none; }
    .ac-profile-btn { padding: .2rem; }
}

/* Dark mode */
[data-bs-theme="dark"] .ac-profile-btn { color: var(--ac-text); }
[data-bs-theme="dark"] .ac-profile-btn:hover { background: var(--ac-hover); }
[data-bs-theme="dark"] .ac-profile-menu {
    border-color: var(--ac-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, .5);
}
[data-bs-theme="dark"] .ac-profile-head { border-bottom-color: var(--ac-border); }
[data-bs-theme="dark"] .ac-profile-logout:hover { color: #f87171; }

/* Tab rows (Users, Borrow History): one swipeable line on phones instead of wrapping */
@media (max-width: 576px) {
    .ac-panel .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        scrollbar-width: none;
    }
    .ac-panel .nav-tabs::-webkit-scrollbar { display: none; }
    .ac-panel .nav-tabs .nav-link { white-space: nowrap; }
}