/* ==========================================================================
   AssetGrid design system
   Layered on top of Bootstrap 5 so every existing view picks it up.
   Goals: calm, high-contrast, large touch targets, plain-language cues.
   ========================================================================== */

:root {
    --ag-font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* Brand */
    --ag-primary: #1f6feb;
    --ag-primary-600: #1a5fd0;
    --ag-primary-700: #154ea9;
    --ag-primary-50: #eef4ff;
    --ag-primary-100: #dbe7ff;
    --ag-accent: #14b8a6;
    --ag-primary-light: var(--ag-primary-600); /* legacy alias */

    /* Status */
    --ag-success: #16a34a;
    --ag-success-50: #ecfdf3;
    --ag-warning: #d97706;
    --ag-warning-50: #fff7e6;
    --ag-danger: #dc2626;
    --ag-danger-50: #fef1f1;
    --ag-info: #0891b2;
    --ag-info-50: #ecfbff;
    --ag-muted: #64748b;
    --ag-muted-50: #f1f5f9;

    /* Surfaces */
    --ag-canvas: #f4f6fb;
    --ag-surface: #ffffff;
    --ag-border: #e4e8f0;
    --ag-border-strong: #cfd6e3;
    --ag-text: #0f172a;
    --ag-text-2: #475569;
    --ag-text-3: #94a3b8;

    /* Sidebar */
    --ag-sidebar: #0b1730;
    --ag-sidebar-2: #102244;
    --ag-sidebar-text: #a9b6d3;
    --ag-sidebar-hover: rgba(255, 255, 255, .06);
    --ag-sidebar-w: 268px;
    --ag-sidebar-w-collapsed: 84px;

    --ag-radius: 14px;
    --ag-radius-sm: 10px;
    --ag-shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --ag-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --ag-shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
    --ag-ease: cubic-bezier(.2, .8, .2, 1);

    /* Bootstrap hooks */
    --bs-body-font-family: var(--ag-font);
    --bs-body-font-size: .9375rem;
    --bs-body-color: var(--ag-text);
    --bs-body-bg: var(--ag-canvas);
    --bs-border-color: var(--ag-border);
    --bs-primary: var(--ag-primary);
    --bs-primary-rgb: 31, 111, 235;
    --bs-link-color: var(--ag-primary);
    --bs-link-color-rgb: 31, 111, 235;
    --bs-link-hover-color: var(--ag-primary-700);
    --bs-border-radius: var(--ag-radius-sm);
    --bs-border-radius-lg: var(--ag-radius);
}

html { scroll-behavior: smooth; }
body {
    background: var(--ag-canvas);
    color: var(--ag-text);
    font-family: var(--ag-font);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.015em; color: var(--ag-text); }
code { color: var(--ag-primary-700); background: var(--ag-primary-50); padding: .15em .45em; border-radius: 6px; font-size: .85em; }
::selection { background: var(--ag-primary-100); }
:focus-visible { outline: 3px solid rgba(31, 111, 235, .35); outline-offset: 2px; }

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

.ag-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    width: var(--ag-sidebar-w);
    background:
        radial-gradient(120% 60% at 0% 0%, rgba(31, 111, 235, .28) 0%, transparent 60%),
        linear-gradient(180deg, var(--ag-sidebar-2) 0%, var(--ag-sidebar) 100%);
    color: var(--ag-sidebar-text);
    display: flex; flex-direction: column;
    transition: width .25s var(--ag-ease), transform .25s var(--ag-ease);
}
.ag-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.25rem 1.25rem 1rem; color: #fff; text-decoration: none;
}
.ag-brand:hover { color: #fff; }
.ag-brand-mark {
    width: 44px; height: 44px; flex: none; border-radius: 13px; padding: 7px;
    display: grid; place-items: center; background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}
.ag-brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; line-height: 1.1; }
.ag-brand-sub { font-size: .7rem; color: var(--ag-sidebar-text); font-weight: 500; letter-spacing: .02em; }

.ag-nav { flex: 1; overflow-y: auto; padding: .5rem .75rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.ag-nav-section {
    font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: rgba(169, 182, 211, .55); padding: 1.1rem .75rem .45rem;
}
.ag-nav-link {
    position: relative; display: flex; align-items: center; gap: .85rem;
    padding: .7rem .8rem; margin-bottom: 2px; border-radius: 10px;
    color: var(--ag-sidebar-text); text-decoration: none; font-weight: 500; font-size: .92rem;
    transition: background .15s, color .15s;
}
.ag-nav-link i { font-size: 1.15rem; width: 1.4rem; text-align: center; flex: none; }
.ag-nav-link:hover { background: var(--ag-sidebar-hover); color: #fff; }
.ag-nav-link.active {
    color: #fff; background: linear-gradient(90deg, rgba(31, 111, 235, .9), rgba(31, 111, 235, .55));
    box-shadow: 0 6px 20px rgba(31, 111, 235, .35);
}
.ag-nav-link.active::before {
    content: ''; position: absolute; left: -.75rem; top: 22%; bottom: 22%;
    width: 4px; border-radius: 0 4px 4px 0; background: var(--ag-accent);
}
.ag-nav-hint { margin-left: auto; font-size: .7rem; color: rgba(169, 182, 211, .6); }

.ag-sidebar-foot { padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.ag-help-card {
    background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px; padding: .85rem; color: var(--ag-sidebar-text); font-size: .8rem;
}
.ag-help-card strong { color: #fff; display: block; margin-bottom: .15rem; font-size: .85rem; }

/* Collapsed (desktop) */
body.ag-collapsed .ag-sidebar { width: var(--ag-sidebar-w-collapsed); }
body.ag-collapsed .ag-main { margin-left: var(--ag-sidebar-w-collapsed); }
body.ag-collapsed .ag-brand-text,
body.ag-collapsed .ag-nav-section,
body.ag-collapsed .ag-nav-link span,
body.ag-collapsed .ag-nav-hint,
body.ag-collapsed .ag-help-card { display: none; }
body.ag-collapsed .ag-brand { justify-content: center; padding-inline: 0; }
body.ag-collapsed .ag-nav-link { justify-content: center; padding: .8rem 0; }
body.ag-collapsed .ag-nav-section + .ag-nav-link,
body.ag-collapsed .ag-nav-group:not(:first-child) { margin-top: .6rem; }

.ag-main {
    flex: 1; min-width: 0; margin-left: var(--ag-sidebar-w);
    transition: margin-left .25s var(--ag-ease);
    display: flex; flex-direction: column; min-height: 100vh;
}

/* Topbar */
.ag-topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 1rem;
    padding: .75rem 1.75rem; min-height: 68px;
    background: rgba(244, 246, 251, .82);
    backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid transparent; transition: border-color .2s, box-shadow .2s;
}
.ag-topbar.scrolled { border-bottom-color: var(--ag-border); box-shadow: 0 4px 20px rgba(15, 23, 42, .04); }
.ag-icon-btn {
    width: 42px; height: 42px; flex: none; border-radius: 12px; border: 1px solid var(--ag-border);
    background: var(--ag-surface); color: var(--ag-text-2); display: grid; place-items: center;
    font-size: 1.15rem; position: relative; text-decoration: none; transition: all .15s;
}
.ag-icon-btn:hover { color: var(--ag-primary); border-color: var(--ag-primary-100); background: var(--ag-primary-50); }
.ag-icon-btn .ag-dot {
    position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%;
    background: var(--ag-danger); border: 2px solid #fff;
}
.ag-search {
    position: relative; flex: 1; max-width: 460px;
}
/* Direct child only: the results panel lives inside .ag-search too, and a bare
   `.ag-search i` also matched every result icon — absolutely positioning all of them
   at left:14px / top:50% and stacking them into one blob in the middle of the panel. */
.ag-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ag-text-3); }
.ag-search input {
    width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--ag-border);
    background: var(--ag-surface); padding: 0 4.5rem 0 2.6rem; font-size: .9rem; transition: all .15s;
}
.ag-search input:focus { outline: none; border-color: var(--ag-primary); box-shadow: 0 0 0 4px rgba(31, 111, 235, .12); }
.ag-search kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: var(--ag-muted-50); color: var(--ag-text-3); border: 1px solid var(--ag-border);
    font-size: .7rem; padding: .15rem .45rem; border-radius: 6px; font-family: var(--ag-font);
}
.ag-search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 10;
    background: var(--ag-surface); border: 1px solid var(--ag-border); border-radius: 14px;
    box-shadow: var(--ag-shadow-lg); padding: .4rem; display: none; max-height: min(520px, 70vh); overflow-y: auto;
}
.ag-search-results.show { display: block; animation: ag-pop .16s var(--ag-ease); }
.ag-search-results a {
    display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 10px;
    color: var(--ag-text); text-decoration: none; font-weight: 500;
}
.ag-search-results a i { color: var(--ag-primary); font-size: 1.05rem; }
.ag-search-results a small { margin-left: auto; color: var(--ag-text-3); font-weight: 400; }
.ag-search-results a:hover, .ag-search-results a.active { background: var(--ag-primary-50); }
.ag-search-results a span { min-width: 0; }
.ag-search-results mark { background: var(--ag-warning-50); color: inherit; padding: 0 .12em; border-radius: 3px; font-weight: 700; }
/* Quick-create targets (new work order, new asset, …) read differently from plain navigation */
.ag-search-results a.ag-quick-create i { color: var(--ag-success); }
.ag-search-empty { padding: .9rem; color: var(--ag-text-3); font-size: .85rem; text-align: center; }
.ag-search-group { padding: .55rem .9rem .2rem; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ag-text-3); }
.ag-search-group:not(:first-child) { border-top: 1px solid var(--ag-border, #e8ecf3); margin-top: .25rem; }
.ag-search-results a span em { display: block; font-style: normal; font-weight: 400; font-size: .76rem; color: var(--ag-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-search-loading { display: flex; align-items: center; justify-content: center; gap: .5rem; }

.ag-user {
    display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem .3rem .3rem;
    border-radius: 14px; border: 1px solid var(--ag-border); background: var(--ag-surface);
    text-decoration: none; color: var(--ag-text);
}
.ag-user:hover { border-color: var(--ag-primary-100); color: var(--ag-text); }
.ag-avatar {
    width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    font-weight: 700; font-size: .85rem; color: #fff;
    background: linear-gradient(135deg, var(--ag-primary), var(--ag-accent));
}
.ag-user-name { font-weight: 600; font-size: .875rem; line-height: 1.15; }
.ag-user-role { font-size: .72rem; color: var(--ag-text-3); }

.ag-content { padding: 1.5rem 1.75rem 2.5rem; flex: 1; animation: ag-fade-up .35s var(--ag-ease); }
.ag-footer { padding: 1rem 1.75rem 1.5rem; color: var(--ag-text-3); font-size: .8rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* Page header (auto-rendered by layout) */
.ag-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.ag-crumbs { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--ag-text-3); margin-bottom: .35rem; flex-wrap: wrap; }
.ag-crumbs a { color: var(--ag-text-2); text-decoration: none; }
.ag-crumbs a:hover { color: var(--ag-primary); }
.ag-crumbs i { font-size: .65rem; }
.ag-page-title { font-size: 1.6rem; font-weight: 800; margin: 0; letter-spacing: -.025em; }
.ag-page-sub { color: var(--ag-text-2); margin: .25rem 0 0; font-size: .92rem; }

/* Mobile */
.ag-backdrop { display: none; }
@media (max-width: 991.98px) {
    .ag-sidebar { transform: translateX(-100%); width: var(--ag-sidebar-w) !important; box-shadow: var(--ag-shadow-lg); }
    body.ag-nav-open .ag-sidebar { transform: none; }
    body.ag-nav-open .ag-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1035;
        background: rgba(11, 23, 48, .45); backdrop-filter: blur(2px); animation: ag-fade .2s;
    }
    .ag-main, body.ag-collapsed .ag-main { margin-left: 0; }
    body.ag-collapsed .ag-brand-text, body.ag-collapsed .ag-nav-section,
    body.ag-collapsed .ag-nav-link span, body.ag-collapsed .ag-help-card { display: revert; }
    .ag-topbar { padding: .65rem 1rem; }
    .ag-content { padding: 1.1rem 1rem 2rem; }
    .ag-page-title { font-size: 1.35rem; }
}
@media (max-width: 575.98px) {
    .ag-search kbd, .ag-user-meta { display: none; }
}

/* ==========================================================================
   Bootstrap component overrides (applies to every existing view)
   ========================================================================== */

/* Cards */
.card {
    border: 1px solid var(--ag-border); border-radius: var(--ag-radius);
    box-shadow: var(--ag-shadow); background: var(--ag-surface);
}
.card[style*="max-width"] { width: 100%; }
.card-header {
    background: transparent; border-bottom: 1px solid var(--ag-border);
    padding: 1rem 1.25rem; border-radius: var(--ag-radius) var(--ag-radius) 0 0 !important;
}
.card-header h6, .card-header .h6 { font-weight: 700; font-size: 1rem; }
.card-body { padding: 1.25rem; }
.card-footer {
    background: #fbfcfe; border-top: 1px solid var(--ag-border);
    padding: .85rem 1.25rem; border-radius: 0 0 var(--ag-radius) var(--ag-radius) !important;
}
.card-footer:has(nav:empty), .card-footer:empty { display: none; }

/* Buttons — generous size for touch/older users */
.btn {
    --bs-btn-padding-y: .6rem; --bs-btn-padding-x: 1.1rem; --bs-btn-font-weight: 600;
    --bs-btn-border-radius: 10px; --bs-btn-font-size: .9rem;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    transition: transform .12s var(--ag-ease), box-shadow .15s, background .15s, color .15s, border-color .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn i.me-1, .btn i.me-2 { margin-right: 0 !important; }
.btn-sm { --bs-btn-padding-y: .4rem; --bs-btn-padding-x: .7rem; --bs-btn-font-size: .82rem; --bs-btn-border-radius: 8px; }
.btn-lg { --bs-btn-padding-y: .8rem; --bs-btn-padding-x: 1.4rem; --bs-btn-font-size: 1rem; --bs-btn-border-radius: 12px; }
.btn-primary, .btn-ag {
    --bs-btn-bg: var(--ag-primary); --bs-btn-border-color: var(--ag-primary); --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--ag-primary-600); --bs-btn-hover-border-color: var(--ag-primary-600); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--ag-primary-700); --bs-btn-active-border-color: var(--ag-primary-700);
    --bs-btn-disabled-bg: var(--ag-primary); --bs-btn-disabled-border-color: var(--ag-primary);
    background: var(--bs-btn-bg); color: #fff; border: 1px solid var(--bs-btn-border-color);
    box-shadow: 0 4px 14px rgba(31, 111, 235, .28);
}
.btn-primary:hover, .btn-ag:hover { box-shadow: 0 6px 20px rgba(31, 111, 235, .38); color: #fff; background: var(--ag-primary-600); }
.btn-outline-primary {
    --bs-btn-color: var(--ag-primary); --bs-btn-border-color: var(--ag-primary-100); --bs-btn-bg: var(--ag-primary-50);
    --bs-btn-hover-bg: var(--ag-primary); --bs-btn-hover-border-color: var(--ag-primary); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--ag-primary-700); --bs-btn-active-border-color: var(--ag-primary-700);
}
.btn-outline-secondary {
    --bs-btn-color: var(--ag-text-2); --bs-btn-border-color: var(--ag-border-strong); --bs-btn-bg: #fff;
    --bs-btn-hover-bg: var(--ag-muted-50); --bs-btn-hover-border-color: var(--ag-border-strong); --bs-btn-hover-color: var(--ag-text);
    --bs-btn-active-bg: #e2e8f0; --bs-btn-active-color: var(--ag-text); --bs-btn-active-border-color: var(--ag-border-strong);
}
.btn-outline-danger {
    --bs-btn-color: var(--ag-danger); --bs-btn-border-color: #fbd0d0; --bs-btn-bg: var(--ag-danger-50);
    --bs-btn-hover-bg: var(--ag-danger); --bs-btn-hover-border-color: var(--ag-danger);
}
.btn-outline-success {
    --bs-btn-color: var(--ag-success); --bs-btn-border-color: #bfe9cf; --bs-btn-bg: var(--ag-success-50);
    --bs-btn-hover-bg: var(--ag-success); --bs-btn-hover-border-color: var(--ag-success);
}
.btn-success { --bs-btn-bg: var(--ag-success); --bs-btn-border-color: var(--ag-success); }
.btn-danger { --bs-btn-bg: var(--ag-danger); --bs-btn-border-color: var(--ag-danger); }
.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading::before {
    content: ''; width: 1em; height: 1em; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: ag-spin .7s linear infinite;
}
.btn.is-loading > i { display: none; }

/* Forms — big, clear, friendly */
.form-label { font-weight: 600; font-size: .875rem; color: var(--ag-text); margin-bottom: .4rem; }
.form-label .text-danger { font-weight: 700; }
.form-control, .form-select {
    min-height: 46px; border-radius: 10px; border: 1.5px solid var(--ag-border);
    padding: .6rem .9rem; font-size: .95rem; color: var(--ag-text); background-color: #fff;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
textarea.form-control { min-height: 96px; }
.form-control:hover, .form-select:hover { border-color: var(--ag-border-strong); }
.form-control:focus, .form-select:focus {
    border-color: var(--ag-primary); box-shadow: 0 0 0 4px rgba(31, 111, 235, .12); background-color: #fff;
}
.form-control::placeholder { color: var(--ag-text-3); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--ag-danger); background-color: var(--ag-danger-50); }
.invalid-feedback { font-weight: 500; }
.invalid-feedback::before { content: '\F33A'; font-family: 'bootstrap-icons'; margin-right: .35rem; vertical-align: -1px; }
.input-group-text { background: var(--ag-muted-50); border: 1.5px solid var(--ag-border); color: var(--ag-text-3); border-radius: 10px; padding-inline: .9rem; }
.input-group > .form-control { min-height: 46px; }
.form-check-input { width: 1.2em; height: 1.2em; border: 1.5px solid var(--ag-border-strong); }
.form-check-input:checked { background-color: var(--ag-primary); border-color: var(--ag-primary); }
.form-check-label { cursor: pointer; }
.form-text { color: var(--ag-text-3); }

/* Form sticky action bar (added by JS to long forms) */
.ag-form-actions {
    position: sticky; bottom: 0; z-index: 5; margin: 1.25rem -1.25rem -1.25rem; padding: .9rem 1.25rem;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
    border-top: 1px solid var(--ag-border); border-radius: 0 0 var(--ag-radius) var(--ag-radius);
}

/* Tables */
.table { --bs-table-hover-bg: #f6f9ff; margin-bottom: 0; vertical-align: middle; font-size: .9rem; }
.table > :not(caption) > * > * { padding: .9rem 1.1rem; border-bottom-color: var(--ag-border); }
.table thead th, .table-light th, .table > thead > tr > th {
    background: #f8fafd !important; color: var(--ag-text-2) !important;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
    border-bottom: 1px solid var(--ag-border); white-space: nowrap;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td:first-child { font-weight: 600; }
.table tr[data-href] { cursor: pointer; }
.card > .card-body.p-0 > .table, .card > .card-body.p-0 > .table-responsive { border-radius: var(--ag-radius); }
.card > .card-body.p-0:first-child .table thead th:first-child { border-top-left-radius: var(--ag-radius); }
.card > .card-body.p-0:first-child .table thead th:last-child { border-top-right-radius: var(--ag-radius); }
.ag-table-empty { padding: 3rem 1rem !important; text-align: center; color: var(--ag-text-3) !important; font-weight: 400 !important; }
.ag-table-empty i { display: block; font-size: 2.4rem; margin-bottom: .5rem; color: var(--ag-border-strong); }

/* Definition lists (detail pages) */
dl.row { margin: 0; }
dl.row > dt {
    font-size: .8rem; font-weight: 600; color: var(--ag-text-3); text-transform: uppercase; letter-spacing: .05em;
    padding: .8rem 0; border-bottom: 1px dashed var(--ag-border); margin: 0;
}
dl.row > dd { padding: .8rem 0; margin: 0; border-bottom: 1px dashed var(--ag-border); font-weight: 500; word-break: break-word; }
dl.row > dt:nth-last-of-type(1), dl.row > dd:last-child { border-bottom: 0; }
@media (max-width: 575.98px) { dl.row > dt { border-bottom: 0; padding-bottom: 0; } }

/* List groups */
.list-group-item { border-color: var(--ag-border); padding: .85rem 1.25rem; }
.list-group-item-action:hover { background: #f6f9ff; }

/* Alerts */
.alert { border: 0; border-radius: 12px; padding: .9rem 1.1rem; font-weight: 500; display: flex; gap: .65rem; align-items: flex-start; }
.alert ul { padding-left: 1rem; }
.alert-success { background: var(--ag-success-50); color: #146c35; }
.alert-danger { background: var(--ag-danger-50); color: #a01b1b; }
.alert-warning { background: var(--ag-warning-50); color: #8a4b04; }
.alert-info { background: var(--ag-info-50); color: #0b6178; }

/* Badges & status pills */
.badge { font-weight: 600; border-radius: 999px; padding: .4em .75em; }
.ag-pill, .ag-badge {
    display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
    padding: .32rem .7rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
    background: var(--ag-muted-50); color: var(--ag-text-2);
}
.ag-pill::before, .ag-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ag-pill-success { background: var(--ag-success-50); color: #15803d; }
.ag-pill-warning { background: var(--ag-warning-50); color: #b45309; }
.ag-pill-danger { background: var(--ag-danger-50); color: #b91c1c; }
.ag-pill-info { background: var(--ag-info-50); color: #0e7490; }
.ag-pill-primary { background: var(--ag-primary-50); color: var(--ag-primary-700); }
.ag-pill-muted { background: var(--ag-muted-50); color: var(--ag-muted); }
/* legacy classes */
.badge-status-open { background: var(--ag-warning-50); color: #b45309; }
.badge-status-progress { background: var(--ag-primary-50); color: var(--ag-primary-700); }
.badge-status-closed { background: var(--ag-success-50); color: #15803d; }
.badge-status-pending { background: var(--ag-danger-50); color: #b91c1c; }

/* Pagination */
.pagination { margin: 0; gap: .3rem; flex-wrap: wrap; }
.page-link { border-radius: 9px !important; border: 1px solid var(--ag-border); color: var(--ag-text-2); min-width: 38px; text-align: center; font-weight: 600; font-size: .85rem; }
.page-item.active .page-link { background: var(--ag-primary); border-color: var(--ag-primary); box-shadow: 0 4px 12px rgba(31,111,235,.3); }
.page-link:hover { background: var(--ag-primary-50); color: var(--ag-primary); }
nav[role="navigation"] p.small { margin: 0; color: var(--ag-text-3); }

/* Dropdowns / modals */
.dropdown-menu {
    border: 1px solid var(--ag-border); border-radius: 14px; box-shadow: var(--ag-shadow-lg);
    padding: .4rem; animation: ag-pop .16s var(--ag-ease);
}
.dropdown-item { border-radius: 8px; padding: .55rem .75rem; font-weight: 500; display: flex; align-items: center; gap: .6rem; }
.dropdown-item:active { background: var(--ag-primary); }
.modal-content { border: 0; border-radius: 18px; box-shadow: var(--ag-shadow-lg); }
.modal-header, .modal-footer { border-color: var(--ag-border); }

/* Legacy stat card (settings, etc.) */
.ag-stat-card { transition: transform .2s var(--ag-ease), box-shadow .2s; }
a .ag-stat-card:hover, a.ag-stat-card:hover { transform: translateY(-3px); box-shadow: var(--ag-shadow-lg); }
.ag-stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
    background: var(--ag-primary-50); font-size: 1.35rem !important; opacity: 1 !important; flex: none;
}

/* ==========================================================================
   AssetGrid components
   ========================================================================== */

/* KPI tiles */
.ag-kpi {
    position: relative; overflow: hidden; display: block; height: 100%;
    background: var(--ag-surface); border: 1px solid var(--ag-border); border-radius: var(--ag-radius);
    padding: 1.2rem 1.25rem; box-shadow: var(--ag-shadow); color: var(--ag-text); text-decoration: none;
    transition: transform .2s var(--ag-ease), box-shadow .2s, border-color .2s;
}
a.ag-kpi:hover { transform: translateY(-3px); box-shadow: var(--ag-shadow-lg); border-color: var(--ag-primary-100); color: var(--ag-text); }
.ag-kpi::after {
    content: ''; position: absolute; right: -40px; top: -40px; width: 130px; height: 130px; border-radius: 50%;
    background: var(--kpi-tint, var(--ag-primary-50)); opacity: .7; transition: transform .35s var(--ag-ease);
}
a.ag-kpi:hover::after { transform: scale(1.15); }
.ag-kpi-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.ag-kpi-icon {
    width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem;
    color: var(--kpi-color, var(--ag-primary)); background: #fff; box-shadow: var(--ag-shadow-sm); border: 1px solid var(--ag-border);
}
.ag-kpi-value { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; margin-top: 1rem; position: relative; z-index: 1; }
.ag-kpi-label { color: var(--ag-text-2); font-weight: 600; font-size: .875rem; margin-top: .35rem; position: relative; z-index: 1; }
.ag-kpi-foot { font-size: .78rem; color: var(--ag-text-3); margin-top: .6rem; display: flex; align-items: center; gap: .3rem; position: relative; z-index: 1; }
.ag-kpi-go { color: var(--ag-text-3); transition: transform .2s, color .2s; }
a.ag-kpi:hover .ag-kpi-go { color: var(--ag-primary); transform: translateX(3px); }
.ag-tone-primary { --kpi-color: var(--ag-primary); --kpi-tint: var(--ag-primary-50); }
.ag-tone-success { --kpi-color: var(--ag-success); --kpi-tint: var(--ag-success-50); }
.ag-tone-warning { --kpi-color: var(--ag-warning); --kpi-tint: var(--ag-warning-50); }
.ag-tone-danger  { --kpi-color: var(--ag-danger);  --kpi-tint: var(--ag-danger-50); }
.ag-tone-info    { --kpi-color: var(--ag-info);    --kpi-tint: var(--ag-info-50); }
.ag-tone-muted   { --kpi-color: var(--ag-muted);   --kpi-tint: var(--ag-muted-50); }

/* Hero / welcome */
.ag-hero {
    position: relative; overflow: hidden; border-radius: 20px; padding: 1.75rem 2rem; color: #fff;
    background:
        radial-gradient(80% 140% at 100% 0%, rgba(20, 184, 166, .55) 0%, transparent 55%),
        radial-gradient(60% 120% at 0% 100%, rgba(99, 102, 241, .45) 0%, transparent 60%),
        linear-gradient(120deg, #0b1f4d 0%, #1f6feb 100%);
    box-shadow: 0 18px 40px rgba(31, 111, 235, .25);
}
.ag-hero::before {
    content: ''; position: absolute; inset: 0; opacity: .14; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px);
    background-size: 28px 28px; mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
}
.ag-hero h2 { color: #fff; font-size: 1.65rem; font-weight: 800; margin: 0 0 .35rem; position: relative; }
.ag-hero p { color: rgba(255, 255, 255, .82); margin: 0; position: relative; max-width: 560px; }
.ag-hero .ag-hero-date { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.7); margin-bottom: .5rem; position: relative; }
.ag-hero-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.25rem; position: relative; }
.ag-hero .btn-light { --bs-btn-bg: #fff; --bs-btn-color: var(--ag-primary-700); --bs-btn-border-color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.ag-hero .btn-glass { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(6px); }
.ag-hero .btn-glass:hover { background: rgba(255,255,255,.24); color: #fff; }

/* Quick actions */
.ag-action {
    display: flex; align-items: center; gap: .9rem; height: 100%;
    padding: 1rem 1.1rem; border-radius: var(--ag-radius); text-decoration: none; color: var(--ag-text);
    background: var(--ag-surface); border: 1px solid var(--ag-border); box-shadow: var(--ag-shadow-sm);
    transition: all .18s var(--ag-ease);
}
.ag-action:hover { border-color: var(--kpi-color, var(--ag-primary)); transform: translateY(-2px); box-shadow: var(--ag-shadow); color: var(--ag-text); }
.ag-action-icon {
    width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; flex: none;
    color: var(--kpi-color, var(--ag-primary)); background: var(--kpi-tint, var(--ag-primary-50));
}
.ag-action strong { display: block; font-size: .95rem; }
.ag-action small { color: var(--ag-text-3); }

/* Progress bars / breakdown */
.ag-bar { height: 10px; border-radius: 999px; background: var(--ag-muted-50); overflow: hidden; display: flex; }
.ag-bar > span { display: block; height: 100%; transition: width .9s var(--ag-ease); }
.ag-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-top: 1rem; font-size: .82rem; color: var(--ag-text-2); }
.ag-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.ag-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ag-breakdown-row { display: grid; grid-template-columns: 120px 1fr 48px; align-items: center; gap: .9rem; padding: .55rem 0; }
.ag-breakdown-row .lbl { font-weight: 600; font-size: .875rem; }
.ag-breakdown-row .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Donut */
.ag-donut { --size: 168px; width: var(--size); height: var(--size); border-radius: 50%; position: relative; flex: none; }
.ag-donut::after { content: ''; position: absolute; inset: 22px; border-radius: 50%; background: var(--ag-surface); }
.ag-donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; z-index: 1; }
.ag-donut-center strong { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ag-donut-center small { color: var(--ag-text-3); font-weight: 600; font-size: .75rem; }

/* Activity feed */
.ag-feed { list-style: none; margin: 0; padding: 0; }
.ag-feed li { display: flex; gap: .85rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--ag-border); align-items: center; }
.ag-feed li:last-child { border-bottom: 0; }
.ag-feed a { color: inherit; text-decoration: none; }
.ag-feed-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; font-size: 1.05rem; color: var(--ag-primary); background: var(--ag-primary-50); }
.ag-feed-main { min-width: 0; flex: 1; }
.ag-feed-main strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-feed-main small { color: var(--ag-text-3); }

/* Empty state */
.ag-empty { text-align: center; padding: 2.5rem 1rem; color: var(--ag-text-3); }
.ag-empty-icon {
    width: 64px; height: 64px; margin: 0 auto .9rem; border-radius: 18px; display: grid; place-items: center;
    font-size: 1.7rem; color: var(--ag-primary); background: var(--ag-primary-50);
}
.ag-empty h6 { color: var(--ag-text); margin-bottom: .25rem; }

/* Section heading */
.ag-section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 0 .9rem; }
.ag-section-title h5 { font-size: 1.05rem; margin: 0; }

/* Toasts */
.ag-toasts { position: fixed; top: 84px; right: 20px; z-index: 1090; display: flex; flex-direction: column; gap: .6rem; max-width: min(400px, calc(100vw - 40px)); }
.ag-toast {
    display: flex; align-items: flex-start; gap: .75rem; padding: .95rem 1rem; border-radius: 14px;
    background: var(--ag-surface); border: 1px solid var(--ag-border); box-shadow: var(--ag-shadow-lg);
    animation: ag-slide-in .35s var(--ag-ease); font-weight: 500;
}
.ag-toast.hide { animation: ag-slide-out .3s var(--ag-ease) forwards; }
.ag-toast-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: 1.1rem; }
.ag-toast-success .ag-toast-icon { background: var(--ag-success-50); color: var(--ag-success); }
.ag-toast-error .ag-toast-icon { background: var(--ag-danger-50); color: var(--ag-danger); }
.ag-toast strong { display: block; font-size: .9rem; }
.ag-toast span { font-size: .85rem; color: var(--ag-text-2); }
.ag-toast button { margin-left: auto; background: none; border: 0; color: var(--ag-text-3); font-size: 1.1rem; padding: 0 .2rem; }

/* Settings tiles */
.ag-tile {
    display: flex; align-items: center; gap: 1rem; padding: 1.1rem; height: 100%;
    background: var(--ag-surface); border: 1px solid var(--ag-border); border-radius: var(--ag-radius);
    box-shadow: var(--ag-shadow-sm); color: var(--ag-text); text-decoration: none; transition: all .18s var(--ag-ease);
}
.ag-tile:hover { transform: translateY(-2px); border-color: var(--ag-primary-100); box-shadow: var(--ag-shadow); color: var(--ag-text); }
.ag-tile-icon { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; font-size: 1.3rem; background: var(--ag-primary-50); color: var(--ag-primary); flex: none; }
.ag-tile strong { display: block; }
.ag-tile small { color: var(--ag-text-3); }
.ag-tile .bi-chevron-right { margin-left: auto; color: var(--ag-text-3); transition: transform .2s; }
.ag-tile:hover .bi-chevron-right { transform: translateX(3px); color: var(--ag-primary); }

/* Detail page header */
.ag-detail-head { display: flex; align-items: center; gap: 1rem; }
.ag-detail-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.5rem; flex: none;
    background: linear-gradient(135deg, var(--ag-primary-50), #e6fffb); color: var(--ag-primary); border: 1px solid var(--ag-primary-100); }

/* Toolbar for list pages */
.ag-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ag-toolbar .input-group { max-width: 420px !important; flex: 1 1 260px; }

/* ==========================================================================
   Auth (login / guest)
   ========================================================================== */
.ag-auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.ag-auth-visual {
    position: relative; overflow: hidden; color: #fff; padding: 3rem 3.5rem; display: flex; flex-direction: column;
    background:
        radial-gradient(60% 50% at 85% 10%, rgba(20, 184, 166, .55) 0%, transparent 60%),
        radial-gradient(70% 60% at 10% 95%, rgba(99, 102, 241, .5) 0%, transparent 60%),
        linear-gradient(150deg, #071431 0%, #0d2a66 55%, #1f6feb 120%);
}
.ag-auth-visual::before {
    content: ''; position: absolute; inset: -2px; pointer-events: none; opacity: .18;
    background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(70% 60% at 60% 45%, #000 0%, transparent 75%);
    -webkit-mask-image: radial-gradient(70% 60% at 60% 45%, #000 0%, transparent 75%);
    animation: ag-grid-pan 30s linear infinite;
}
.ag-orb { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .55; animation: ag-float 14s ease-in-out infinite; pointer-events: none; }
.ag-orb-1 { width: 320px; height: 320px; background: #14b8a6; right: -80px; top: 20%; }
.ag-orb-2 { width: 260px; height: 260px; background: #6366f1; left: -60px; bottom: 5%; animation-delay: -6s; }
.ag-auth-brand { display: flex; align-items: center; gap: .8rem; position: relative; z-index: 1; }
.ag-auth-brand .ag-brand-mark { width: 46px; height: 46px; font-size: 1.3rem; border-radius: 14px; }
.ag-auth-brand span { font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.ag-auth-copy { position: relative; z-index: 1; margin-top: auto; max-width: 520px; }
.ag-auth-copy .eyebrow { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .8rem; border-radius: 999px;
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); font-size: .78rem; font-weight: 600; margin-bottom: 1.25rem; }
.ag-auth-copy .eyebrow i { color: #5eead4; }
.ag-auth-copy h1 { color: #fff; font-size: clamp(2rem, 3.2vw, 2.9rem); font-weight: 800; line-height: 1.08; letter-spacing: -.035em; margin-bottom: 1rem; }
.ag-auth-copy h1 em { font-style: normal; background: linear-gradient(90deg, #5eead4, #93c5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ag-auth-copy p { color: rgba(255,255,255,.75); font-size: 1.02rem; }
.ag-auth-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 2rem; position: relative; z-index: 1; }
.ag-auth-feature { padding: 1rem; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(8px);
    transition: transform .25s var(--ag-ease), background .25s; }
.ag-auth-feature:hover { transform: translateY(-4px); background: rgba(255,255,255,.12); }
.ag-auth-feature i { font-size: 1.3rem; color: #5eead4; }
.ag-auth-feature strong { display: block; margin-top: .5rem; font-size: .9rem; }
.ag-auth-feature small { color: rgba(255,255,255,.65); font-size: .78rem; }
.ag-auth-live {
    position: absolute; top: 2.5rem; right: 3rem; z-index: 1; display: flex; flex-direction: column; gap: .6rem;
}
.ag-auth-chip {
    display: flex; align-items: center; gap: .6rem; padding: .6rem .85rem; border-radius: 12px; font-size: .8rem; font-weight: 600;
    background: rgba(255,255,255,.95); color: var(--ag-text); box-shadow: 0 12px 30px rgba(0,0,0,.25);
    animation: ag-float 8s ease-in-out infinite;
}
.ag-auth-chip:nth-child(2) { animation-delay: -3s; margin-left: 2.5rem; }
.ag-auth-chip .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }

.ag-auth-panel { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: #fff; }
.ag-auth-form { width: 100%; max-width: 420px; animation: ag-fade-up .5s var(--ag-ease); }
.ag-auth-form h2 { font-size: 1.85rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .35rem; }
.ag-auth-form .lead { color: var(--ag-text-2); font-size: .98rem; margin-bottom: 2rem; }
.ag-field { position: relative; }
.ag-field > i.lead-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ag-text-3); font-size: 1.1rem; pointer-events: none; transition: color .15s; }
.ag-field .form-control { min-height: 54px; padding-left: 2.85rem; border-radius: 12px; font-size: 1rem; }
.ag-field .form-control:focus ~ i.lead-icon, .ag-field:focus-within > i.lead-icon { color: var(--ag-primary); }
.ag-field .ag-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--ag-text-3); width: 40px; height: 40px; border-radius: 10px; font-size: 1.1rem; }
.ag-field .ag-eye:hover { background: var(--ag-muted-50); color: var(--ag-text); }
.ag-field .form-control.has-eye { padding-right: 3.2rem; }
.ag-caps { display: none; font-size: .8rem; color: var(--ag-warning); font-weight: 600; margin-top: .4rem; }
.ag-caps.show { display: block; }
.ag-auth-form .btn-lg { width: 100%; min-height: 54px; font-size: 1rem; border-radius: 12px; }
.ag-auth-foot { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--ag-border); display: flex; align-items: center; gap: .6rem; color: var(--ag-text-3); font-size: .82rem; }
.ag-auth-foot i { color: var(--ag-success); font-size: 1rem; }
.ag-auth-mobile-brand { display: none; }

@media (max-width: 991.98px) {
    .ag-auth { grid-template-columns: 1fr; }
    .ag-auth-visual { display: none; }
    .ag-auth-mobile-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 2rem; font-weight: 800; font-size: 1.25rem; }
    .ag-auth-panel { align-items: flex-start; padding-top: 3rem;
        background: radial-gradient(100% 40% at 50% 0%, var(--ag-primary-50) 0%, #fff 70%); }
}

/* ==========================================================================
   Motion
   ========================================================================== */
@keyframes ag-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ag-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* NOTE: this must not animate `transform`. Popper positions dropdown/tooltip elements with
   an inline transform: translate3d(...), and a running animation outranks an inline style —
   the menu would ignore Popper for the length of the animation and then jump into place.
   The independent translate/scale properties compose with transform instead of replacing it. */
@keyframes ag-pop { from { opacity: 0; translate: 0 -4px; scale: .98; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes ag-spin { to { transform: rotate(360deg); } }
@keyframes ag-slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes ag-slide-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes ag-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes ag-grid-pan { to { background-position: 44px 44px; } }
.ag-js .ag-reveal { opacity: 0; transform: translateY(10px); transition: opacity .45s var(--ag-ease), transform .45s var(--ag-ease); }
.ag-js .ag-reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .ag-js .ag-reveal { opacity: 1; transform: none; }
}

/* Print */
@media print {
    .ag-sidebar, .ag-topbar, .ag-footer, .ag-toasts, .btn { display: none !important; }
    .ag-main { margin-left: 0 !important; }
    .card { box-shadow: none; }
}
.ag-pill-noicon::before { display: none; }

/* Stepped form sections */
.ag-form-step { display: flex; align-items: center; gap: .65rem; font-size: 1rem; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--ag-border); }
.ag-form-step span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--ag-primary), var(--ag-accent)); }
.form-control-lg { min-height: 52px; font-size: 1.02rem; }

/* Column chart (pure CSS, data from Blade) */
.ag-cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .75rem; align-items: end; height: 220px; padding-top: 1rem; }
.ag-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: .4rem; }
.ag-col-bars { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.ag-col-bar { width: min(22px, 40%); border-radius: 6px 6px 2px 2px; height: 0; transition: height .9s var(--ag-ease); position: relative; min-height: 2px; }
.ag-col-bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ag-text); color: #fff; font-size: .72rem; font-weight: 600; padding: .25rem .5rem; border-radius: 6px; white-space: nowrap; z-index: 2; }
.ag-col small { color: var(--ag-text-3); font-weight: 600; font-size: .75rem; }
.ag-stat-mini { padding: 1rem 1.1rem; border-radius: 12px; background: var(--kpi-tint, var(--ag-muted-50)); height: 100%; }
.ag-stat-mini .v { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--kpi-color, var(--ag-text)); line-height: 1.1; }
.ag-stat-mini .l { font-size: .8rem; font-weight: 600; color: var(--ag-text-2); }

.ag-brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ag-auth-logo { display: inline-block; background: #fff; border-radius: 16px; padding: .85rem 1.25rem; box-shadow: 0 12px 34px rgba(0,0,0,.28); }
.ag-auth-logo img { height: 46px; width: auto; display: block; }
.ag-auth-mobile-brand img { height: 44px; width: auto; }

/* Super admin: which client am I working in? */
.ag-ctx { align-items: center; gap: .45rem; height: 42px; padding: 0 .9rem; border-radius: 12px; font-size: .82rem; font-weight: 600; text-decoration: none; max-width: 260px; }
.ag-ctx span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ctx-on { background: var(--ag-success-50); color: #15803d; border: 1px solid #bfe9cf; }
.ag-ctx-off { background: var(--ag-warning-50); color: #b45309; border: 1px solid #f6d9a8; }
.ag-ctx:hover { filter: brightness(.97); }

/* Action column stays visible when a table scrolls sideways */
.table-responsive > .table > tbody > tr > td:last-child.text-end,
.table-responsive > .table > thead > tr > th:last-child {
    position: sticky; right: 0; z-index: 1; background-color: #fff;
    box-shadow: -10px 0 10px -10px rgba(15, 23, 42, .12);
}
.table-responsive > .table > thead > tr > th:last-child { background-color: #f8fafd !important; }
.table-hover > tbody > tr:hover > td:last-child.text-end { background-color: #f6f9ff; }
/* The sticky action cell creates a stacking context, so a dropdown opened from it would
   otherwise paint under the sticky cells of the rows below. assetgrid.js raises the owning
   cell while its menu is open (and Popper uses the fixed strategy to escape the scroll clip).
   !important is required: the sticky rule above is (0,4,3) because of its :last-child.text-end
   part, which outranks a plain .ag-cell-raised selector. */
.table-responsive > .table > tbody > tr > td.ag-cell-raised,
.table-responsive > .table > thead > tr > th.ag-cell-raised { z-index: 4 !important; }
.flex-none { flex: none; }

/* Keep the top bar usable when space is tight */
.ag-topbar { gap: .6rem; }
.ag-search { min-width: 150px; }
@media (max-width: 1199.98px) {
    .ag-ctx { max-width: 190px; }
    .ag-user { padding-right: .3rem; }
}
@media (max-width: 991.98px) {
    .ag-search { min-width: 0; }
}

/* Pagination layout (Bootstrap 5 markup from Laravel) */
.card-footer nav > .d-flex, .card-footer nav .d-none.flex-sm-fill { gap: .75rem; }
.card-footer nav p.small { margin: 0; color: var(--ag-text-3); }
.pagination .page-item.disabled .page-link { background: var(--ag-muted-50); color: var(--ag-text-3); }
.pagination .page-link svg { width: 1em; height: 1em; }

/* Pagination footer: summary on top, pager below on tighter screens, never a stray wrapped arrow */
@media (max-width: 1399.98px) {
    .card-footer nav > div.d-sm-flex { flex-direction: column; align-items: flex-start !important; gap: .6rem; }
}
.pagination { gap: .25rem; }
.pagination .page-link { min-width: 34px; padding: .35rem .5rem; line-height: 1.3; }
.card-footer nav .pagination { flex-wrap: wrap; }
.card-footer nav > div.d-flex.d-sm-none { width: 100%; justify-content: space-between; }

/* Segmented filter (links, keeps the search term) */
.ag-seg-wrap { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ag-seg-label { font-size: .8rem; font-weight: 600; color: var(--ag-text-2); }
.ag-seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--ag-surface); border: 1px solid var(--ag-border); border-radius: 12px; flex-wrap: wrap; }
.ag-seg-item { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .85rem; border-radius: 9px; font-size: .85rem; font-weight: 600; color: var(--ag-text-2); text-decoration: none; transition: background .15s, color .15s; }
.ag-seg-item:hover { background: var(--ag-muted-50); color: var(--ag-text); }
.ag-seg-item.active { background: var(--ag-primary); color: #fff; box-shadow: 0 3px 10px rgba(31, 111, 235, .3); }
.ag-seg-count { font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; background: var(--ag-muted-50); color: var(--ag-text-2); }
.ag-seg-item.active .ag-seg-count { background: rgba(255, 255, 255, .25); color: #fff; }

/* Dashboard: clickable status rows */
.ag-status-row { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; border-radius: 10px; padding: .6rem .6rem; text-align: left; color: inherit; transition: background .15s; }
.ag-status-row:hover { background: var(--ag-muted-50); }
.ag-status-row .ag-status-go { color: var(--ag-text-3); opacity: 0; transition: opacity .15s; }
.ag-status-row:hover .ag-status-go { opacity: 1; }
.ag-status-row.active { background: var(--ag-primary-50); box-shadow: inset 3px 0 0 var(--ag-primary); }
.ag-status-row.active .ag-status-go { opacity: 1; color: var(--ag-primary); }
.ag-status-row:focus-visible { outline: 3px solid rgba(31, 111, 235, .35); }
#ag-wo-results { transition: opacity .15s; }

/* Click-to-filter tiles / rows (Jobs Summary) */
#ag-wo-panel { scroll-margin-top: 90px; }
.ag-click { cursor: pointer; transition: transform .15s var(--ag-ease), box-shadow .15s, outline-color .15s; outline: 2px solid transparent; outline-offset: 2px; }
.ag-click:hover { transform: translateY(-2px); }
.ag-click.active { outline-color: var(--ag-primary); }
a.ag-stat-mini { color: inherit; }
.ag-click-row { width: 100%; background: none; border: 0; border-radius: 10px; text-align: left; color: inherit; padding-inline: .5rem; transition: background .15s; }
.ag-click-row:hover { background: var(--ag-muted-50); }
.ag-click-row.active { background: var(--ag-primary-50); box-shadow: inset 3px 0 0 var(--ag-primary); }
.ag-click-row:focus-visible, .ag-click:focus-visible { outline: 3px solid rgba(31, 111, 235, .35); }
#ag-wo-overdue.active { background: var(--ag-danger); border-color: var(--ag-danger); color: #fff; }

/* Clickable numbers / legend rows inside tables and cards */
.ag-cell-link { background: none; border: 0; padding: .15rem .45rem; margin: -.15rem -.45rem; border-radius: 8px; font: inherit; color: inherit; font-weight: inherit; cursor: pointer; transition: background .15s; }
.ag-cell-link:hover { background: var(--ag-muted-50); text-decoration: underline; text-underline-offset: 3px; }
.ag-cell-link.active { background: var(--ag-primary-50); box-shadow: 0 0 0 2px var(--ag-primary); }
.ag-legend-btn { display: flex; justify-content: space-between; align-items: center; gap: 1rem; width: 100%; background: none; border: 0; border-radius: 10px; padding: .45rem .6rem; color: inherit; text-align: left; transition: background .15s; }
.ag-legend-btn:hover { background: var(--ag-muted-50); }
.ag-legend-btn.active { background: var(--ag-primary-50); box-shadow: inset 3px 0 0 var(--ag-primary); }

/* Sidebar status dot (System health) */
/* Pending-count badge on a nav item (e.g. access requests awaiting a decision) */
.ag-nav-count {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px; background: var(--ag-danger); color: #fff;
    font-size: .7rem; font-weight: 700; line-height: 1;
}
.ag-nav-dot { width: 9px; height: 9px; border-radius: 50%; margin-left: auto; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.ag-dot-success { background: #22c55e; }
.ag-dot-warning { background: #f59e0b; }
.ag-dot-danger { background: #ef4444; animation: ag-pulse 1.6s ease-in-out infinite; }
@keyframes ag-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(239,68,68,.25); } 50% { box-shadow: 0 0 0 6px rgba(239,68,68,.05); } }
body.ag-collapsed .ag-nav-dot { position: absolute; top: 9px; right: 14px; margin: 0; }
