/* ============================================================
   Fli8 Admin · UI System
   ------------------------------------------------------------
   Modern, refined admin panel styling.
   Class hooks (.admin-shell, .admin-sidebar, .metric-tile, etc.)
   are preserved to keep all PHP/JS integrations working.
   ============================================================ */

:root {
    --admin-font: "Cairo", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

    /* Surfaces */
    --admin-bg: #f4f6fb;
    --admin-bg-soft: #eef1f7;
    --admin-panel: #ffffff;
    --admin-panel-soft: #f8fafd;

    /* Sidebar */
    --admin-sidebar: #0f1a2e;
    --admin-sidebar-soft: #1a2942;
    --admin-sidebar-line: rgba(255, 255, 255, .08);

    /* Text */
    --admin-text: #0f172a;
    --admin-ink: #0f172a;
    --admin-muted: #64748b;
    --admin-muted-2: #94a3b8;

    /* Lines */
    --admin-border: #e2e8f0;
    --admin-border-soft: #eef2f7;

    /* Brand (overridden at runtime by admin_brand_style_block from DB) */
    --admin-accent: #4f6df5;
    --admin-accent-dark: #3f5be6;
    --admin-accent-2: #7c3aed;
    --admin-accent-rgb: 79, 109, 245;
    --admin-accent-2-rgb: 124, 58, 237;
    --admin-accent-soft: rgba(var(--admin-accent-rgb), .10);
    --admin-accent-softer: rgba(var(--admin-accent-rgb), .06);
    --admin-accent-ring: rgba(var(--admin-accent-rgb), .25);
    --admin-accent-focus: rgba(var(--admin-accent-rgb), .14);
    --admin-teal: #0ea5a4;

    /* Semantic */
    --admin-success: #16a34a;
    --admin-success-soft: rgba(22, 163, 74, .12);
    --admin-warning: #b45309;
    --admin-warning-soft: rgba(180, 83, 9, .12);
    --admin-danger: #dc2626;
    --admin-danger-soft: rgba(220, 38, 38, .12);

    /* Elevation */
    --admin-shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --admin-shadow-sm: 0 4px 12px rgba(15, 23, 42, .06);
    --admin-shadow: 0 10px 24px rgba(15, 23, 42, .08);
    --admin-shadow-lg: 0 20px 48px rgba(15, 23, 42, .12);

    /* Radii */
    --admin-radius-xs: 6px;
    --admin-radius-sm: 8px;
    --admin-radius: 12px;
    --admin-radius-lg: 16px;
    --admin-radius-xl: 20px;

    /* Bootstrap overrides */
    --bs-body-font-family: var(--admin-font);
    --bs-body-color: var(--admin-text);
    --bs-body-bg: var(--admin-bg);
    --bs-border-color: var(--admin-border);
    --bs-primary: var(--admin-accent);
    --bs-primary-rgb: var(--admin-accent-rgb);
    --bs-link-color: var(--admin-accent);
    --bs-link-hover-color: var(--admin-accent-dark);
}

* { -webkit-tap-highlight-color: transparent; }

html, body { min-height: 100%; }

body {
    color: var(--admin-text);
    background: var(--admin-bg);
    font-family: var(--admin-font);
    font-size: 14px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle ambient backdrop tint — sits behind page content without
   creating a stacking context that would trap Bootstrap modals. */
body.admin-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(900px 500px at 110% -10%, rgba(var(--admin-accent-2-rgb), .06), transparent 60%),
        radial-gradient(800px 500px at -10% 110%, rgba(14, 165, 164, .05), transparent 60%);
    z-index: -1;
}

::selection { background: rgba(var(--admin-accent-rgb), .18); color: var(--admin-text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Layout shell
   ============================================================ */

.admin-shell { display: flex; }

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    padding: 20px 14px 24px;
    background: linear-gradient(180deg, #0f1a2e 0%, #142238 60%, #0c1424 100%);
    color: #fff;
    overflow-y: auto;
    z-index: 20;
    border-right: 1px solid rgba(255, 255, 255, .06);
}

.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); }
.admin-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .22); }

.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 18px;
    margin-bottom: 14px;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid var(--admin-sidebar-line);
}

.admin-sidebar-brand strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .01em;
}

.admin-sidebar-brand small {
    display: block;
    margin-top: 2px;
    color: rgba(255, 255, 255, .55);
    font-size: 11.5px;
    max-width: 184px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-brand-mark {
    display: inline-grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-2) 100%);
    box-shadow: 0 6px 16px rgba(var(--admin-accent-rgb), .35), inset 0 1px 0 rgba(255, 255, 255, .25);
    font-weight: 800;
    overflow: hidden;
}

.admin-brand-mark.has-logo {
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .25);
    padding: 4px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
}

.admin-brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.admin-nav { display: grid; gap: 14px; }

.admin-nav-section { display: grid; gap: 2px; }

.admin-nav-heading {
    display: block;
    padding: 14px 12px 6px;
    color: rgba(255, 255, 255, .42);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.admin-nav-section.has-active .admin-nav-heading { color: rgba(255, 255, 255, .82); }

.admin-nav-items { display: grid; gap: 2px; }

.admin-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 8px 12px;
    color: rgba(255, 255, 255, .72);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 9px;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

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

.admin-nav a.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(var(--admin-accent-rgb), .28), rgba(var(--admin-accent-2-rgb), .18));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}

.admin-nav a.active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: linear-gradient(180deg, var(--admin-accent), var(--admin-accent-2));
    border-radius: 0 4px 4px 0;
}

.admin-nav i {
    width: 18px;
    font-size: 16px;
    text-align: center;
    color: rgba(255, 255, 255, .65);
    transition: color .18s ease;
}

.admin-nav a:hover i,
.admin-nav a.active i { color: #fff; }

.admin-main {
    width: 100%;
    min-height: 100vh;
    margin-left: 270px;
    /* As a flex child, min-width:auto would let a wide table push the whole
       column (and the page) past the viewport. min-width:0 lets it shrink so
       the inner .table-responsive becomes the horizontal scroll container. */
    min-width: 0;
}

/* ============================================================
   Topbar
   ============================================================ */

.admin-topbar {
    min-height: 76px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 16px 26px;
    background: rgba(255, 255, 255, .82);
    border-bottom: 1px solid var(--admin-border);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-topbar h1 {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--admin-ink);
}

.admin-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    color: var(--admin-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    margin-bottom: 3px;
}
.admin-breadcrumb a { color: var(--admin-muted); text-decoration: none; }
.admin-breadcrumb a:hover { color: var(--admin-accent, #3b7cf7); text-decoration: underline; }
.admin-breadcrumb [aria-current="page"] { color: var(--admin-ink, #0f172a); }
.admin-breadcrumb-sep { opacity: .55; }

.admin-topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ============================================================
   User menu
   ============================================================ */

.admin-user-menu { position: relative; }

.admin-user-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 5px 12px 5px 6px;
    color: var(--admin-text);
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 999px;
    box-shadow: var(--admin-shadow-xs);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.admin-user-button::after { margin-left: 4px; }

.admin-user-button:hover,
.admin-user-button.show {
    color: var(--admin-text);
    border-color: rgba(var(--admin-accent-rgb), .42);
    box-shadow: 0 8px 22px rgba(var(--admin-accent-rgb), .14);
}

.admin-user-avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
    font-size: 12px;
    font-weight: 800;
}

.admin-user-avatar-lg {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 15px;
}

.admin-user-button-label {
    display: grid;
    min-width: 0;
    text-align: left;
    line-height: 1.15;
}

.admin-user-button-label strong {
    max-width: 145px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
}

.admin-user-button-label small { color: var(--admin-muted); font-size: 11px; }

.admin-user-dropdown {
    width: 312px;
    padding: 8px;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    box-shadow: var(--admin-shadow-lg);
}

.admin-user-dropdown-head {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px;
    margin-bottom: 4px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(var(--admin-accent-rgb), .08), rgba(var(--admin-accent-2-rgb), .06));
}

.admin-user-dropdown-head span:last-child { display: grid; min-width: 0; }

.admin-user-dropdown-head strong,
.admin-user-dropdown-head small,
.admin-user-dropdown-head em {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-dropdown-head strong { font-weight: 800; font-size: 14px; }

.admin-user-dropdown-head small,
.admin-user-dropdown-head em {
    color: var(--admin-muted);
    font-size: 12px;
    font-style: normal;
}

.admin-user-dropdown .dropdown-header {
    padding: 8px 10px 4px;
    color: var(--admin-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.admin-user-dropdown .dropdown-divider { margin: 6px 4px; border-color: var(--admin-border-soft); }

.admin-user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background-color .14s ease, color .14s ease;
}

.admin-user-menu-item:hover { background: var(--admin-bg-soft); }

.admin-user-menu-item i {
    display: inline-grid;
    place-items: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    color: var(--admin-accent);
    background: var(--admin-accent-soft);
    border-radius: 9px;
}

.admin-user-menu-item span { display: grid; min-width: 0; }

.admin-user-menu-item strong,
.admin-user-menu-item small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-menu-item strong { font-size: 13px; font-weight: 700; }
.admin-user-menu-item small { color: var(--admin-muted); font-size: 11.5px; }

.admin-user-menu-item.text-danger i { color: var(--admin-danger); background: var(--admin-danger-soft); }

/* ============================================================
   Global search
   ============================================================ */

.admin-global-search { position: relative; width: min(520px, 42vw); }

.admin-global-search .input-group {
    border-radius: 999px;
    overflow: hidden;
    box-shadow: var(--admin-shadow-xs);
    background: #fff;
    border: 1px solid var(--admin-border);
    transition: border-color .16s ease, box-shadow .16s ease;
}

.admin-global-search .input-group:focus-within {
    border-color: rgba(var(--admin-accent-rgb), .55);
    box-shadow: 0 0 0 3px rgba(var(--admin-accent-rgb), .14);
}

.admin-global-search .input-group-text {
    background: transparent;
    border: 0;
    color: var(--admin-muted);
    padding-left: 16px;
}

.admin-global-search .form-control {
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 9px 14px 9px 6px;
    font-size: 13.5px;
}

.admin-global-search .form-control:focus { box-shadow: none; }

.admin-global-search-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(720px, 88vw);
    max-height: 72vh;
    overflow: auto;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    box-shadow: var(--admin-shadow-lg);
    z-index: 40;
}

.admin-global-search-loading { color: var(--admin-muted); padding: 14px; }

.admin-global-result {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background-color .14s ease, border-color .14s ease;
}

.admin-global-result-compact {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 9px;
    padding: 8px;
    border-radius: 8px;
}

.admin-global-result + .admin-global-result { border-top-color: var(--admin-border-soft); }

.admin-global-result:hover { background: var(--admin-bg-soft); border-color: var(--admin-border); }

.admin-global-result-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: var(--admin-accent);
    background: var(--admin-accent-soft);
    border-radius: 10px;
    font-size: 16px;
}

.admin-global-result-compact .admin-global-result-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 14px;
}

.admin-global-result-main { min-width: 0; }

.admin-global-result-meta,
.admin-global-result-subtitle,
.admin-global-result-matches {
    color: var(--admin-muted);
    font-size: 12px;
}

.admin-global-result-compact .admin-global-result-meta,
.admin-global-result-compact .admin-global-result-subtitle,
.admin-global-result-compact .admin-global-result-matches {
    font-size: 11px;
    line-height: 1.25;
}

.admin-global-result-title {
    display: inline-block;
    color: var(--admin-text);
    font-weight: 800;
    text-decoration: none;
    font-size: 14px;
}

.admin-global-result-compact .admin-global-result-title {
    font-size: 13px;
    line-height: 1.25;
}

.admin-global-result-title:hover { color: var(--admin-accent); }

.admin-global-result-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-global-result-matches { display: grid; gap: 3px; margin-top: 6px; }
.admin-global-result-matches span { color: #334155; font-weight: 700; }

.admin-global-result-compact .admin-global-result-matches {
    gap: 1px;
    margin-top: 3px;
}

.admin-global-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.admin-global-result-compact .admin-global-result-actions {
    gap: 4px;
    margin-top: 6px;
}

.admin-global-result-compact .admin-global-result-actions .btn {
    font-size: 11.5px;
    line-height: 1.15;
    padding: 4px 8px;
}

.admin-global-view-all {
    display: block;
    padding: 12px;
    margin-top: 4px;
    color: var(--admin-accent);
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    border-top: 1px solid var(--admin-border-soft);
}

.admin-global-search-panel .admin-global-group + .admin-global-group { margin-top: 8px; }
.admin-global-search-panel .admin-global-group-head { margin-bottom: 4px; padding: 3px 2px 5px; }
.admin-global-search-panel .admin-global-view-all { padding: 9px 10px; }

.admin-global-search-form { max-width: 980px; }
.admin-global-search-results { display: grid; gap: 10px; }
.admin-global-search-results .admin-global-result { border: 1px solid var(--admin-border); }

.admin-global-detail-grid { display: grid; gap: 10px; }

.admin-global-detail-row {
    display: grid;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
    gap: 14px;
    padding: 12px;
    background: var(--admin-bg-soft);
    border: 1px solid var(--admin-border-soft);
    border-radius: 10px;
}

.admin-global-detail-key {
    color: var(--admin-muted);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.admin-global-detail-value {
    min-width: 0;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ============================================================
   Content surfaces
   ============================================================ */

.admin-content {
    padding: 26px;
    /* Final guard against page-level horizontal overflow: clip on the X axis
       only (keeps overflow-y visible, unlike `hidden`). Any wide child — tables,
       long IDs, pre blocks — is contained inside the content column. Bootstrap
       modals (fixed) and body-attached Select2 dropdowns are unaffected. */
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
}

/* Wide operational tables scroll inside their own panel, never the page. */
.admin-panel { max-width: 100%; }
.admin-panel > .table-responsive,
.table-responsive { max-width: 100%; }

.admin-panel,
.metric-tile,
.report-tile,
.admin-login-card {
    background: var(--admin-panel);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    box-shadow: var(--admin-shadow-xs);
}

.admin-panel {
    padding: 20px;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.admin-panel:hover,
.metric-tile:hover,
.report-tile:hover {
    border-color: #d6deeb;
    box-shadow: var(--admin-shadow-sm);
}

.dashboard-chart-card {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dashboard-chart-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-height: 32px;
    margin-bottom: 20px;
}

.dashboard-chart-heading h2 {
    font-size: 15px;
    font-weight: 800;
    color: var(--admin-ink);
    letter-spacing: -.01em;
    margin: 0;
}

.dashboard-chart-frame {
    flex: 1 1 auto;
    min-height: 280px;
    position: relative;
}

.dashboard-chart-frame canvas { height: 100% !important; width: 100% !important; }

.admin-module-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-module-search { width: min(420px, 100%); }

.admin-filter-panel {
    background: var(--admin-panel-soft);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.admin-filter-panel .form-label {
    font-weight: 600;
    letter-spacing: .01em;
}

/* ---- Page/table stats summary cards ---- */
.admin-page-stats-panel {
    display: grid;
    gap: 12px;
}
.admin-page-stats-head {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
}
.admin-page-stats-head h2 {
    align-items: center;
    color: var(--admin-ink);
    display: inline-flex;
    font-size: 14px;
    font-weight: 800;
    gap: 8px;
    margin: 0;
}
.admin-table-summary { margin: 0 0 16px; }
.admin-table-summary-top { margin-top: 0; }
.admin-table-summary-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    padding: 0;
}
.admin-summary-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 76px;
    padding: 12px 14px;
    background: linear-gradient(180deg, #fff 0%, var(--admin-panel-soft) 100%);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .035);
}
.admin-summary-cell:last-child { border-right: 1px solid var(--admin-border); padding-right: 14px; }
.admin-summary-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--admin-muted);
}
.admin-summary-value { font-size: 18px; font-weight: 800; line-height: 1.1; color: var(--admin-ink); }
.admin-summary-cell-strong .admin-summary-value { color: var(--admin-accent-dark); }

/* ---- Row tone (subtle left accent by status) on Sales + Payments ---- */
.admin-data-table tbody tr.row-tone-ok    { box-shadow: inset 3px 0 0 0 #16a34a; }
.admin-data-table tbody tr.row-tone-warn  { box-shadow: inset 3px 0 0 0 #d97706; }
.admin-data-table tbody tr.row-tone-danger{ box-shadow: inset 3px 0 0 0 #dc2626; }
.admin-data-table tbody tr.row-tone-refund{ box-shadow: inset 3px 0 0 0 #7c3aed; }

.admin-table-thumb {
    aspect-ratio: 1;
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    height: 44px;
    object-fit: cover;
    width: 44px;
    background: #fff;
}

/* ============================================================
   Metric tiles
   ============================================================ */

.metric-tile {
    padding: 18px;
    min-height: 108px;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.metric-tile::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--admin-accent), var(--admin-accent-2), var(--admin-teal));
    opacity: .9;
}

.metric-tile::after {
    content: "";
    position: absolute;
    right: -36px;
    top: -36px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(var(--admin-accent-rgb), .10), transparent 70%);
    pointer-events: none;
}

.metric-tile:hover { transform: translateY(-2px); }

.metric-tile span {
    display: block;
    color: var(--admin-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    margin-bottom: 10px;
    text-transform: capitalize;
}

.metric-tile strong {
    display: block;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -.01em;
    color: var(--admin-ink);
}

/* Variation: each tile gets a tinted top accent (first row uses brand color) */
#dashboardMetrics > div:nth-child(4n+1) .metric-tile::before { background: linear-gradient(90deg, var(--admin-accent), var(--admin-accent-2)); }
#dashboardMetrics > div:nth-child(4n+2) .metric-tile::before { background: linear-gradient(90deg, #0ea5a4, var(--admin-accent)); }
#dashboardMetrics > div:nth-child(4n+3) .metric-tile::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
#dashboardMetrics > div:nth-child(4n)   .metric-tile::before { background: linear-gradient(90deg, #10b981, #0ea5a4); }

.metric-tile .metric-change {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    min-height: 16px;
}

/* ---- Dashboard "needs attention" banner ---- */
.dashboard-alerts { margin-bottom: 16px; }
.dashboard-alerts-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 12px 16px;
}
.dashboard-alerts-title {
    font-weight: 700;
    color: #b45309;
    margin-right: 6px;
}
.alert-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}
.alert-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(180, 83, 9, .15); color: #92400e; }
.alert-chip.alert-chip-danger { border-color: #fecaca; color: #b91c1c; background: #fff; }
.alert-chip.alert-chip-danger:hover { box-shadow: 0 4px 12px rgba(185, 28, 28, .15); color: #b91c1c; }

/* ---- Quick actions ---- */
.dashboard-quick-actions h2 { letter-spacing: .02em; }

/* ---- Top customers widget ---- */
.dashboard-top-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: topcust;
}
.dashboard-top-list li { counter-increment: topcust; border-bottom: 1px solid var(--admin-border-soft); }
.dashboard-top-list li:last-child { border-bottom: 0; }
.dashboard-top-list li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 4px;
    text-decoration: none;
    color: var(--admin-ink);
}
.dashboard-top-list li a::before {
    content: counter(topcust);
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--admin-accent-soft);
    color: var(--admin-accent-dark);
    font-size: 11px;
    font-weight: 800;
}
.dashboard-top-list .dashboard-top-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-top-list .dashboard-top-meta { color: var(--admin-muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.dashboard-top-list li a:hover .dashboard-top-name { color: var(--admin-accent-dark); }

.report-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 76px;
    padding: 16px 18px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.report-tile:hover { transform: translateY(-1px); }

/* ============================================================
   Profile / shared
   ============================================================ */

.admin-profile-summary { text-align: center; }

.admin-profile-avatar {
    display: inline-grid;
    place-items: center;
    width: 84px;
    height: 84px;
    margin-bottom: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
    border-radius: 22px;
    box-shadow: 0 14px 28px rgba(var(--admin-accent-rgb), .28), inset 0 1px 0 rgba(255, 255, 255, .25);
    font-size: 30px;
    font-weight: 800;
}

.admin-password-panel { max-width: 880px; }

/* ============================================================
   Settings overview
   ============================================================ */

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--admin-border-soft);
}

.settings-eyebrow {
    display: block;
    color: var(--admin-muted);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.settings-overview { display: grid; gap: 22px; padding: 0; }
.settings-overview-section { display: grid; gap: 12px; }

.settings-overview-section + .settings-overview-section {
    padding-top: 20px;
    border-top: 1px solid var(--admin-border-soft);
}

.settings-overview-heading {
    color: var(--admin-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    line-height: 1.2;
    text-transform: uppercase;
}

.settings-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.settings-overview-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 78px;
    padding: 14px;
    color: var(--admin-text);
    text-align: left;
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, background-color .16s ease;
}

.settings-overview-tile i {
    display: inline-grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    color: #fff;
    font-size: 19px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
    box-shadow: 0 6px 14px rgba(var(--admin-accent-rgb), .25);
}

.settings-overview-tile strong,
.settings-overview-tile small { display: block; }

.settings-overview-tile strong {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.25;
}

.settings-overview-tile small {
    color: var(--admin-muted);
    margin-top: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.settings-overview-tile:hover,
.settings-overview-tile:focus-visible {
    color: var(--admin-text);
    background: #fbfcff;
    border-color: rgba(var(--admin-accent-rgb), .38);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
    transform: translateY(-2px);
    outline: 0;
}

@media (max-width: 1199.98px) {
    .settings-overview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
    .settings-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 575.98px) {
    .settings-overview-grid { grid-template-columns: 1fr; }
}

.settings-detail-title { padding-top: 16px; }
.settings-tab-content { padding-top: 18px; }
.settings-section h3 { font-size: 15px; font-weight: 800; margin: 0 0 14px; }

.settings-color-field {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 8px;
}

.settings-color-field .form-control-color {
    width: 52px;
    min-height: 42px;
    padding: 4px;
    border-radius: 10px;
}

.settings-logo-upload {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.settings-logo-preview {
    width: 100px;
    height: 100px;
    object-fit: contain;
    padding: 10px;
    border: 1px dashed var(--admin-border);
    border-radius: var(--admin-radius);
    background: var(--admin-bg-soft);
}

.settings-logo-fields { display: grid; gap: 8px; }

/* ============================================================
   Customer CRM / profile
   ============================================================ */

.customer-crm-layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

/* Sidebar acts as a profile card with a decorative cover banner.
   Uses padding:0 so .customer-crm-identity owns the full-bleed cover. */
.customer-crm-sidebar {
    position: sticky;
    top: 100px;
    display: grid;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.customer-crm-identity {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 86px 18px 18px;
    text-align: center;
    border-bottom: 1px solid var(--admin-border-soft);
    overflow: hidden;
}

.customer-crm-identity::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 96px;
    background:
        radial-gradient(120% 100% at 0% 0%, rgba(var(--admin-accent-2-rgb), .28), transparent 60%),
        linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
}

.customer-crm-identity::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 96px;
    background-image:
        radial-gradient(circle at 18% 70%, rgba(255, 255, 255, .22) 0 1px, transparent 1.5px),
        radial-gradient(circle at 78% 28%, rgba(255, 255, 255, .14) 0 1px, transparent 1.5px);
    background-size: 22px 22px, 28px 28px;
    opacity: .55;
    pointer-events: none;
}

.customer-crm-identity > * { position: relative; z-index: 1; }

.customer-crm-identity .customer-avatar,
.customer-crm-identity .customer-avatar-lg {
    box-shadow:
        0 0 0 4px #fff,
        0 14px 28px rgba(15, 23, 42, .22),
        inset 0 1px 0 rgba(255, 255, 255, .25);
    margin-top: -42px;
}

.customer-crm-identity h2 {
    max-width: 100%;
    margin: 4px 0 0;
    font-size: 19px;
    font-weight: 800;
    overflow-wrap: anywhere;
    color: var(--admin-ink);
    line-height: 1.2;
}

.customer-crm-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 -4px;
    color: var(--admin-muted);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.customer-crm-contact {
    display: grid;
    gap: 4px;
    padding: 14px 14px 4px;
}

.customer-crm-detail {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    transition: background-color .14s ease, border-color .14s ease, transform .14s ease;
}

.customer-crm-detail:hover {
    background: var(--admin-bg-soft);
    border-color: var(--admin-border-soft);
}

.customer-crm-detail i {
    grid-row: span 2;
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--admin-accent);
    border-radius: 10px;
    background: var(--admin-accent-soft);
    font-size: 15px;
}

.customer-crm-detail span,
.customer-crm-stat span {
    color: var(--admin-muted);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.customer-crm-detail strong {
    min-width: 0;
    color: var(--admin-text);
    font-size: 13px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.customer-crm-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 6px 18px 4px;
}

.customer-crm-stat {
    position: relative;
    min-width: 0;
    padding: 14px 12px 12px;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    background: #fff;
    overflow: hidden;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.customer-crm-stat::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--admin-accent), var(--admin-accent-2));
    opacity: .85;
}

.customer-crm-stat:nth-child(2)::before { background: linear-gradient(90deg, #0ea5a4, var(--admin-accent)); }
.customer-crm-stat:nth-child(3)::before { background: linear-gradient(90deg, #16a34a, #0ea5a4); }
.customer-crm-stat:nth-child(4)::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.customer-crm-stat:hover {
    transform: translateY(-1px);
    border-color: rgba(var(--admin-accent-rgb), .35);
    box-shadow: var(--admin-shadow-sm);
}

.customer-crm-stat strong {
    display: block;
    min-width: 0;
    margin-top: 6px;
    color: var(--admin-text);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
}

.customer-crm-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 14px 18px 18px;
    margin-top: 6px;
    border-top: 1px solid var(--admin-border-soft);
}

.customer-crm-actions .btn {
    justify-content: center;
    min-height: 40px;
    border-radius: 10px;
    font-weight: 700;
}

.customer-crm-main { min-width: 0; }

.customer-crm-edit-card .form-label {
    margin-bottom: 4px;
    color: var(--admin-muted);
    font-size: 12px;
    font-weight: 700;
}

.customer-compact-form .form-control,
.customer-compact-form .form-select,
.customer-compact-form .select2-container--bootstrap-5 .select2-selection { min-height: 42px; }

.customer-profile-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px;
    background: linear-gradient(135deg, rgba(var(--admin-accent-rgb), .06), rgba(var(--admin-accent-2-rgb), .04));
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
}

.customer-profile-main {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.customer-avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 88px;
    width: 88px;
    height: 88px;
    color: #fff;
    font-size: 32px;
    font-weight: 800;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
    box-shadow: 0 14px 28px rgba(var(--admin-accent-rgb), .28), inset 0 1px 0 rgba(255, 255, 255, .25);
    overflow: hidden;
}

.customer-avatar.customer-avatar-lg {
    flex-basis: 104px;
    width: 104px;
    height: 104px;
    font-size: 38px;
    border-radius: 26px;
}

.customer-avatar img { width: 100%; height: 100%; object-fit: cover; }

.customer-profile-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.customer-profile-workspace {
    padding: 0;
    overflow: hidden;
}

/* Modern tab strip with active underline indicator */
.customer-profile-tabs {
    gap: 4px;
    padding: 6px 18px 0;
    border-bottom: 1px solid var(--admin-border);
    background: linear-gradient(180deg, var(--admin-bg-soft) 0%, #fff 100%);
}

.customer-profile-tabs .nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 16px;
    color: var(--admin-muted);
    font-weight: 700;
    background: transparent;
    border: 0;
    border-radius: 0;
    transition: color .16s ease;
}

.customer-profile-tabs .nav-link i {
    font-size: 15px;
    color: var(--admin-muted-2);
    transition: color .16s ease;
}

.customer-profile-tabs .nav-link::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: linear-gradient(90deg, var(--admin-accent), var(--admin-accent-2));
    transform: scaleX(0);
    transform-origin: center;
    transition: transform .2s ease;
}

.customer-profile-tabs .nav-link:hover {
    color: var(--admin-text);
    background: transparent;
}

.customer-profile-tabs .nav-link:hover i { color: var(--admin-accent); }

.customer-profile-tabs .nav-link.active {
    color: var(--admin-accent);
    background: transparent;
}

.customer-profile-tabs .nav-link.active i { color: var(--admin-accent); }

.customer-profile-tabs .nav-link.active::after { transform: scaleX(1); }

.customer-profile-tab-content { padding: 22px; background: var(--admin-bg-soft); }

.customer-profile-card {
    min-height: 100%;
    padding: 20px;
    border: 1px solid var(--admin-border-soft);
    border-radius: var(--admin-radius);
    background: #fff;
    box-shadow: var(--admin-shadow-xs);
    transition: box-shadow .18s ease, border-color .18s ease;
}

.customer-profile-card:hover {
    border-color: var(--admin-border);
    box-shadow: var(--admin-shadow-sm);
}

.customer-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--admin-border-soft);
}

.customer-section-header > div h2,
.customer-section-header > div h3 { font-weight: 800; }

.customer-section-header > div h2.h5,
.customer-section-header > div h3.h5 { font-size: 15px; letter-spacing: -.01em; }

.customer-field-grid-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.customer-profile-modal .modal-body { background: #fff; }

.customer-profile-modal .customer-field-grid > div,
.customer-profile-modal .customer-related-table,
.customer-profile-modal .customer-record-card { background: #fff; }

.customer-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.customer-field-grid > div {
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    background: #fff;
}

.customer-field-grid span {
    display: block;
    color: var(--admin-muted);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.customer-field-grid strong {
    display: block;
    min-width: 0;
    margin-top: 4px;
    color: var(--admin-text);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.customer-profile-table { font-size: 13px; }
.customer-profile-table td,
.customer-profile-table th { max-width: 240px; vertical-align: top; }

.customer-data-details summary {
    cursor: pointer;
    color: var(--admin-accent);
    font-weight: 800;
}

.customer-data-details pre,
.customer-record-card pre {
    max-height: 280px;
    margin: 8px 0 0;
    padding: 12px;
    color: #cbd5e1;
    white-space: pre-wrap;
    overflow: auto;
    border-radius: 10px;
    background: #0f172a;
    font-size: 12px;
}

.customer-related-grid { display: grid; gap: 10px; }

.customer-related-table,
.customer-record-card {
    border: 1px solid var(--admin-border-soft);
    border-radius: 10px;
    background: #fff;
}

.customer-related-table > summary,
.customer-record-card > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 12px 14px;
    cursor: pointer;
    font-weight: 800;
}

.customer-related-table > div,
.customer-record-card > div { padding: 0 14px 14px; }

.customer-related-table summary::marker,
.customer-record-card summary::marker { content: ''; }

.customer-related-table summary strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 26px;
    padding: 0 10px;
    color: var(--admin-accent);
    border-radius: 999px;
    background: var(--admin-accent-soft);
    font-size: 12px;
}

.customer-record-card { margin-bottom: 8px; background: var(--admin-bg-soft); }
.customer-record-card small { color: var(--admin-muted); font-weight: 700; }

@media (max-width: 1199.98px) {
    .customer-crm-layout { grid-template-columns: 290px minmax(0, 1fr); }
    .customer-field-grid-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .customer-crm-layout { grid-template-columns: 1fr; }
    .customer-crm-sidebar { position: static; }

    .customer-profile-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 12px;
    }

    .customer-profile-tabs .nav-link { white-space: nowrap; }

    .customer-section-header,
    .customer-profile-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .customer-profile-actions .btn,
    .customer-section-header .btn { width: 100%; }
}

@media (max-width: 575.98px) {
    .settings-logo-upload { grid-template-columns: 1fr; }

    .customer-profile-hero,
    .customer-profile-main {
        align-items: flex-start;
        flex-direction: column;
    }

    .customer-field-grid { grid-template-columns: 1fr; }

    .customer-avatar {
        flex-basis: 76px;
        width: 76px;
        height: 76px;
    }

    .customer-avatar.customer-avatar-lg {
        flex-basis: 76px;
        width: 76px;
        height: 76px;
        font-size: 28px;
    }

    .customer-crm-stats,
    .customer-crm-actions { grid-template-columns: 1fr; }
}

/* ============================================================
   Login
   ============================================================ */

.admin-login-bg {
    position: relative;
    background:
        radial-gradient(800px 500px at 80% 10%, rgba(var(--admin-accent-rgb), .14), transparent 60%),
        radial-gradient(700px 500px at 10% 90%, rgba(14, 165, 164, .12), transparent 60%),
        var(--admin-bg);
    min-height: 100vh;
}

.admin-login-card {
    width: min(100%, 440px);
    border-radius: 20px;
    box-shadow: var(--admin-shadow-lg);
    border: 1px solid var(--admin-border);
}

/* ============================================================
   Tables
   ============================================================ */

.table { margin-bottom: 0; color: var(--admin-text); }

.table thead th {
    color: #475569;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    vertical-align: middle;
    background: var(--admin-bg-soft);
    border-bottom: 1px solid var(--admin-border);
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    padding: .82rem .85rem;
    border-color: var(--admin-border-soft);
    vertical-align: middle;
}

.table-hover > tbody > tr:hover > * { background: #f6f9ff; }

.admin-table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--admin-border-soft);
}

.admin-table-limit { width: 90px; }

/* DataTables polish */
.dataTables_wrapper .dataTables_paginate .paginate_button,
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    border-radius: 8px !important;
}

/* ============================================================
   Skeletons & status
   ============================================================ */

.admin-skeleton {
    display: block;
    height: 18px;
    border-radius: 6px;
    background: linear-gradient(90deg, #eef2f7, #f7f9fc, #eef2f7);
    background-size: 200% 100%;
    animation: admin-skeleton 1.1s ease-in-out infinite;
}

@keyframes admin-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Stable-height skeleton + loading row so the table doesn't feel blank. */
.admin-skeleton-row td { padding-top: 12px; padding-bottom: 12px; }
.admin-loading-row td { padding: 12px 14px; }

/* ---- Empty / error states ---- */
.admin-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    padding: 34px 16px;
}
.admin-empty-state > i { font-size: 30px; color: var(--admin-muted-2, #94a3b8); }
.admin-empty-state .admin-empty-title { font-weight: 700; margin: 4px 0 0; color: var(--admin-ink, #0f172a); }
.admin-empty-state .admin-empty-hint { margin: 0; font-size: 13px; }
.admin-empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.admin-empty-error > i { color: var(--admin-danger, #dc2626); }

/* ---- Row actions: primary cluster + split-off destructive delete ---- */
.admin-row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}
.admin-row-actions .admin-row-delete { position: relative; }
.admin-row-actions .admin-row-delete::before {
    /* subtle divider so Delete is visually separated from the safe cluster */
    content: "";
    position: absolute;
    left: -4px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--admin-border, #e2e8f0);
}
.admin-data-table .btn-group .btn:focus-visible,
.admin-row-actions .btn:focus-visible,
.admin-copy-btn:focus-visible {
    outline: 2px solid var(--admin-accent, #3b7cf7);
    outline-offset: 1px;
    z-index: 3;
}

/* ---- Sticky Actions column for wide operational tables ---- */
.admin-data-table thead th:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--admin-panel-soft, #f8fafd);
}
.admin-data-table td.admin-actions-cell {
    position: sticky;
    right: 0;
    z-index: 1;
    background: #fff;
    white-space: nowrap;
    box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .12);
}
.admin-data-table tbody tr:hover td.admin-actions-cell { background: #f6f9ff; }

/* ---- Long ID cells: truncate with tooltip + copy ---- */
.admin-id-cell { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.admin-id {
    display: inline-block;
    max-width: 168px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    font-variant-numeric: tabular-nums;
}
.admin-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--admin-muted, #64748b);
    padding: 2px 4px;
    border-radius: 6px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}
.admin-copy-btn:hover { color: var(--admin-accent-dark, #3f5be6); background: var(--admin-accent-soft, rgba(59,124,247,.1)); }

/* ---- Global search result grouping + masked-field indicator ---- */
.admin-global-group + .admin-global-group { margin-top: 14px; }
.admin-global-group-head {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--admin-muted, #64748b);
    padding: 4px 2px 6px;
    border-bottom: 1px solid var(--admin-border-soft, #eef2f7);
    margin-bottom: 6px;
}
.admin-mask-lock { color: var(--admin-warning, #d97706); font-size: 11px; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .01em;
    text-transform: capitalize;
    background: #eef2f7;
    color: #334155;
    border: 1px solid transparent;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
}

.status-badge.active,
.status-badge.enabled,
.status-badge.success,
.status-badge.paid,
.status-badge.confirmed,
.status-badge.approved,
.status-badge.completed,
.status-badge.captured,
.status-badge.live,
.status-badge.paid {
    background: var(--admin-success-soft);
    color: var(--admin-success);
}

.status-badge.pending,
.status-badge.authorized,
.status-badge.processing,
.status-badge.initiated,
.status-badge.draft,
.status-badge.warning {
    background: var(--admin-warning-soft);
    color: var(--admin-warning);
}

.status-badge.failed,
.status-badge.declined,
.status-badge.cancelled,
.status-badge.canceled,
.status-badge.error,
.status-badge.expired,
.status-badge.inactive,
.status-badge.blocked,
.status-badge.suspended,
.status-badge.locked {
    background: var(--admin-danger-soft);
    color: var(--admin-danger);
}

/* Test / simulated — grey-purple (clearly not a real money state). */
.status-badge.test,
.status-badge.test-paid,
.status-badge.test-simulated,
.status-badge.simulated {
    background: #ede9fe;
    color: #6b46c1;
}

/* Needs review — orange (operations attention). */
.status-badge.needs-review {
    background: #ffedd5;
    color: #c2410c;
}

/* Manual — blue (human-entered). */
.status-badge.manual {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Refunded / reversed — blue-grey (money returned, not a failure). */
.status-badge.refunded,
.status-badge.reversed,
.status-badge.void {
    background: #e2e8f0;
    color: #475569;
}

/* CRM customer types — New (blue), Returning (teal), VIP (gold). */
.status-badge.new { background: #dbeafe; color: #1d4ed8; }
.status-badge.returning { background: #ccfbf1; color: #0f766e; }
.status-badge.vip { background: #fef3c7; color: #b45309; }

/* Provider Health states. */
.status-badge.healthy { background: var(--admin-success-soft); color: var(--admin-success); }
.status-badge.degraded { background: var(--admin-warning-soft); color: var(--admin-warning); }
.status-badge.failing { background: var(--admin-danger-soft); color: var(--admin-danger); }
.status-badge.unknown { background: #eef2f7; color: #64748b; }

/* Partial refund — same blue-grey family as refunded. */
.status-badge.partially-refunded { background: #e2e8f0; color: #475569; }

/* Product tags (Customer Segments / Refunds rows). */
.status-badge.flight { background: #e0f2fe; color: #0369a1; }
.status-badge.hotel,
.status-badge.hotels { background: #dcfce7; color: #15803d; }
.status-badge.esim { background: #f3e8ff; color: #7e22ce; }
.status-badge.insurance { background: #fef9c3; color: #a16207; }
.status-badge.package { background: #ffe4e6; color: #be123c; }
.status-badge.payment { background: #e2e8f0; color: #475569; }

/* ---- Phase 3 insight pages (Business Overview / Provider Health / etc.) ---- */
.admin-insight-table td,
.admin-insight-table th { vertical-align: middle; }
.admin-insight-table .btn { white-space: nowrap; }
.admin-insight-period { display: flex; align-items: center; gap: 6px; }
[data-insight-kpis] .kpi-card { height: 100%; }

.admin-date-filter { width: 168px; }

/* Friendly reference (e.g. Order #1042) — the internal ord_ ref is the tooltip. */
.admin-ref {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: help;
    border-bottom: 1px dotted var(--admin-border, #cbd5e1);
}

/* KPI card (business command center). */
.kpi-card {
    background: var(--admin-surface, #fff);
    border: 1px solid var(--admin-border, #e6e8ec);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 96px;
}
.kpi-card-head { display: flex; align-items: center; gap: 7px; color: var(--admin-text-muted, #6b7280); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-card-value { font-size: 24px; font-weight: 800; line-height: 1.1; color: var(--admin-text, #111827); }
.kpi-card-change { font-size: 12px; }
.kpi-card-success { border-left: 3px solid var(--admin-success, #16a34a); }
.kpi-card-danger { border-left: 3px solid var(--admin-danger, #dc2626); }
.kpi-card-warning { border-left: 3px solid var(--admin-warning, #d97706); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.modal textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

/* ============================================================
   Forms
   ============================================================ */

.form-label {
    color: #334155;
    font-size: 12.5px;
    font-weight: 700;
    margin-bottom: 6px;
}

.form-control,
.form-select,
.input-group-text,
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--admin-border);
    border-radius: 10px;
    transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}

.form-control,
.form-select,
.select2-container--bootstrap-5 .select2-selection {
    min-height: 42px;
    background: #fff;
}

.form-control:hover,
.form-select:hover { border-color: #c2cdde; }

.form-control:focus,
.form-select:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 3px rgba(var(--admin-accent-rgb), .14);
    background: #fff;
}

.form-control::placeholder { color: #94a3b8; }

.input-group-text { background: var(--admin-bg-soft); color: var(--admin-muted); }

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: var(--admin-border);
    border-radius: 12px;
    box-shadow: var(--admin-shadow);
    overflow: hidden;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--admin-accent);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0;
    transition: transform .14s ease, box-shadow .14s ease, background-color .14s ease, border-color .14s ease, color .14s ease;
}

.btn-primary {
    --bs-btn-bg: var(--admin-accent);
    --bs-btn-border-color: var(--admin-accent);
    --bs-btn-hover-bg: #3f5be6;
    --bs-btn-hover-border-color: #3f5be6;
    color: #fff;
    border: 0;
    background-image: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-2) 100%);
    background-size: 160% 160%;
    box-shadow: 0 6px 16px rgba(var(--admin-accent-rgb), .22);
}

.btn-primary,
.btn-outline-primary {
    min-height: 42px;
    padding: .56rem 1.05rem;
    font-weight: 700;
}

.btn-primary.btn-sm,
.btn-outline-primary.btn-sm {
    min-height: 36px;
    padding: .42rem .85rem;
    font-size: .85rem;
    border-radius: 8px;
}

.btn-primary i,
.btn-outline-primary i { margin-right: 4px; }

.btn-primary:hover {
    color: #fff;
    transform: translateY(-1px);
    background-position: 100% 0;
    box-shadow: 0 10px 22px rgba(var(--admin-accent-rgb), .30);
}

.btn-primary:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(var(--admin-accent-rgb), .25), 0 8px 18px rgba(var(--admin-accent-rgb), .25);
}

.btn-outline-primary {
    --bs-btn-color: var(--admin-accent);
    --bs-btn-border-color: rgba(var(--admin-accent-rgb), .55);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-border-color: transparent;
    border-width: 1px;
    background: #fff;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus-visible {
    color: #fff;
    background-image: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-2) 100%);
    box-shadow: 0 8px 18px rgba(var(--admin-accent-rgb), .22);
    transform: translateY(-1px);
}

.btn-outline-secondary {
    --bs-btn-color: #475569;
    --bs-btn-border-color: var(--admin-border);
    --bs-btn-hover-bg: var(--admin-bg-soft);
    --bs-btn-hover-color: var(--admin-text);
    --bs-btn-hover-border-color: #cbd5e1;
    background: #fff;
}

.btn-outline-secondary:hover { box-shadow: var(--admin-shadow-xs); }

.btn-success {
    --bs-btn-bg: var(--admin-success);
    --bs-btn-border-color: var(--admin-success);
    --bs-btn-hover-bg: #15803d;
    --bs-btn-hover-border-color: #15803d;
}

.btn-danger {
    --bs-btn-bg: var(--admin-danger);
    --bs-btn-border-color: var(--admin-danger);
    --bs-btn-hover-bg: #b91c1c;
    --bs-btn-hover-border-color: #b91c1c;
}

.btn-light {
    background: #fff;
    border-color: var(--admin-border);
    color: var(--admin-text);
}

.btn-light:hover {
    background: var(--admin-bg-soft);
    border-color: #cbd5e1;
}

/* ============================================================
   Modals
   ============================================================ */

.modal-content {
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius-lg);
    box-shadow: var(--admin-shadow-lg);
    overflow: hidden;
}

.modal-body {
    background: #fff;
}

.modal-header,
.modal-footer {
    background: var(--admin-bg-soft);
    border-color: var(--admin-border-soft);
}

/* Sticky footer polish for long scrollable modals (gateways, providers, AI). */
.modal-dialog-scrollable .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    box-shadow: 0 -6px 14px -10px rgba(15, 23, 42, .25);
}

/* Section heading inside long forms — groups related fields. */
.admin-field-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 2px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--admin-border, #e2e8f0);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--admin-muted, #64748b);
}
.admin-field-heading i { color: var(--admin-accent, #3b7cf7); }

/* ---- Shared JSON field UX ---- */
.admin-json-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.admin-json-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    tab-size: 2;
}
.admin-json-input.is-invalid { border-color: var(--admin-danger, #dc2626); }
.admin-json-input.is-valid { border-color: var(--admin-success, #16a34a); }
.admin-json-status { font-size: 12px; font-weight: 600; }
.admin-json-status.is-error { color: var(--admin-danger, #dc2626); }
.admin-json-status.is-ok { color: var(--admin-success, #16a34a); }
.admin-json-secret-note {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--admin-muted, #64748b);
}
.admin-json-secret-note i { color: var(--admin-warning, #d97706); }

.modal-header { padding: 1rem 1.25rem; }
.modal-title { font-weight: 800; }

.btn-close { border-radius: 8px; padding: .5rem; }

/* Frosted backdrop instead of plain opacity */
.modal-backdrop {
    background: rgba(15, 23, 42, .42);
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
}

.modal-backdrop.show { opacity: 1; }

/* Safari/older browsers without backdrop-filter support */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .modal-backdrop { background: rgba(15, 23, 42, .55); }
    .modal-backdrop.show { opacity: 1; }
}

/* ============================================================
   Toggles & switches
   ============================================================ */

.admin-toggle-field {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 10px;
    display: inline-flex;
    gap: .8rem;
    min-height: auto;
    padding: 0;
    vertical-align: middle;
}

.admin-toggle-field.form-switch { padding-left: 0; }

.admin-toggle-field .form-check-input {
    cursor: pointer;
    float: none;
    height: 1.55rem;
    margin: 0;
    width: 3.15rem;
    border: 1px solid var(--admin-border);
    background-color: #e5e9f0;
}

.admin-toggle-field .form-check-input:checked {
    background-color: var(--admin-accent);
    border-color: var(--admin-accent);
}

.admin-toggle-field .form-check-input:focus {
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 .22rem rgba(var(--admin-accent-rgb), .18);
}

.admin-toggle-field .form-check-label {
    color: var(--admin-ink);
    cursor: pointer;
    font-weight: 700;
    min-width: 84px;
}

/* ============================================================
   Wizard
   ============================================================ */

.admin-wizard { display: grid; gap: 18px; }

.admin-wizard-steps {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.admin-wizard-steps button {
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    color: var(--admin-muted);
    display: grid;
    gap: 6px;
    min-height: 96px;
    padding: 14px;
    text-align: left;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background-color .18s ease;
}

.admin-wizard-steps button:hover {
    border-color: rgba(var(--admin-accent-rgb), .35);
    background: #fbfcff;
}

.admin-wizard-steps button span {
    align-items: center;
    background: var(--admin-accent-soft);
    border-radius: 999px;
    color: var(--admin-accent);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    height: 26px;
    justify-content: center;
    width: 26px;
}

.admin-wizard-steps button strong {
    color: var(--admin-ink);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.1;
}

.admin-wizard-steps button small {
    font-size: 12px;
    line-height: 1.3;
}

.admin-wizard-steps button.active,
.admin-wizard-steps button.complete {
    border-color: rgba(var(--admin-accent-rgb), .45);
    box-shadow: 0 12px 26px rgba(var(--admin-accent-rgb), .12);
    color: var(--admin-ink);
}

.admin-wizard-steps button.active { transform: translateY(-1px); }

.admin-wizard-steps button.complete span {
    background: rgba(22, 163, 74, .14);
    color: var(--admin-success);
}

.admin-wizard-pane { display: none; }
.admin-wizard-pane.active { display: block; }

.admin-wizard-pane-heading {
    align-items: center;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 14px;
}

.admin-wizard-pane-heading i {
    align-items: center;
    background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
    border-radius: 12px;
    color: #fff;
    display: inline-flex;
    flex: 0 0 auto;
    height: 42px;
    justify-content: center;
    width: 42px;
    box-shadow: 0 6px 14px rgba(var(--admin-accent-rgb), .22);
}

.admin-wizard-pane-heading strong,
.admin-marketing-ops-title strong,
.admin-marketing-ops-card strong {
    color: var(--admin-ink);
    display: block;
    font-weight: 800;
}

.admin-wizard-pane-heading small,
.admin-marketing-ops-title div > span,
.admin-marketing-ops-card span {
    color: var(--admin-muted);
    display: block;
}

/* ============================================================
   Marketing ops
   ============================================================ */

.admin-marketing-ops-summary,
.admin-marketing-ops-card {
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 18px;
}

.admin-marketing-ops-title,
.admin-marketing-ops-card {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.admin-marketing-ops-title { margin-bottom: 14px; }

.admin-marketing-ops-card i {
    align-items: center;
    background: var(--admin-accent-soft);
    border-radius: 12px;
    color: var(--admin-accent);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 20px;
    height: 46px;
    justify-content: center;
    width: 46px;
}

.admin-marketing-ops-card > div { flex: 1 1 auto; }

.admin-marketing-ops-metrics {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 14px;
}

.admin-marketing-ops-metrics div {
    background: var(--admin-bg-soft);
    border: 1px solid var(--admin-border-soft);
    border-radius: 10px;
    padding: 12px;
}

.admin-marketing-ops-metrics span,
.admin-marketing-ops-details span {
    color: var(--admin-muted);
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.admin-marketing-ops-metrics strong {
    color: var(--admin-ink);
    display: block;
    font-size: 22px;
    font-weight: 800;
}

.admin-marketing-ops-details {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-marketing-ops-result { margin-top: 12px; }

/* ============================================================
   Toasts
   ============================================================ */

.toast {
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    box-shadow: var(--admin-shadow-lg);
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
    border: 1px solid transparent;
    border-radius: 12px;
    font-weight: 600;
}

.alert-danger {
    background: var(--admin-danger-soft);
    color: var(--admin-danger);
    border-color: rgba(220, 38, 38, .25);
}

.alert-success {
    background: var(--admin-success-soft);
    color: var(--admin-success);
    border-color: rgba(22, 163, 74, .25);
}

.alert-warning {
    background: var(--admin-warning-soft);
    color: var(--admin-warning);
    border-color: rgba(180, 83, 9, .25);
}

/* ============================================================
   Headings utility
   ============================================================ */

h1, h2, h3, h4, h5, h6 { color: var(--admin-ink); }
h2.h5, h3.h5, .h5 { font-weight: 800; }
.text-secondary { color: var(--admin-muted) !important; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1199.98px) {
    .admin-sidebar {
        position: static;
        width: 100%;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, .06);
    }

    .admin-shell { display: block; }
    .admin-main { margin-left: 0; }

    .admin-topbar {
        position: static;
        align-items: flex-start;
        flex-direction: column;
        backdrop-filter: none;
        background: #fff;
    }

    .admin-topbar-actions {
        width: 100%;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
    }

    .admin-global-search {
        flex: 1 1 320px;
        width: auto;
        min-width: min(100%, 280px);
    }

    .admin-user-menu { width: auto; margin-left: auto; }
    .admin-user-button { width: auto; }

    .admin-user-button { justify-content: flex-start; }
    .admin-user-dropdown { width: min(100%, 340px); }

    .admin-global-search-panel { left: 0; right: auto; width: 100%; }

    .admin-content { padding: 18px; }

    .admin-module-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-module-search { width: 100%; }
    .admin-module-toolbar .ms-auto { margin-left: 0 !important; justify-content: flex-end; }

    .admin-global-detail-row { grid-template-columns: 1fr; }

    .admin-table-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-marketing-ops-card {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-marketing-ops-metrics,
    .admin-marketing-ops-details { grid-template-columns: 1fr; }

    .settings-actions {
        align-items: stretch;
        flex-direction: column;
    }
}

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

/* ============================================================
   Page heads & helpers
   ============================================================ */

.admin-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 20px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(var(--admin-accent-rgb), .06), rgba(var(--admin-accent-2-rgb), .04));
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
}

.admin-page-head h2,
.admin-page-head h3 { margin: 0 0 4px; font-weight: 800; }

.admin-eyebrow {
    display: inline-block;
    margin: 0 0 6px;
    padding: 3px 10px;
    color: var(--admin-accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: var(--admin-accent-soft);
    border-radius: 999px;
}

.admin-table-info {
    color: var(--admin-muted);
    font-size: 12px;
    font-weight: 600;
}

.admin-settings-panel { padding: 22px; }

/* Select2 / toggle hooks (extra JS-bound classes need no overrides
   beyond shared form rules, but we keep them visible as anchors) */
.admin-select2,
.admin-select2-basic { width: 100%; }

.admin-toggle-input {
    cursor: pointer;
    height: 1.55rem;
    width: 3.15rem;
    border: 1px solid var(--admin-border);
    background-color: #e5e9f0;
}

.admin-toggle-input:checked {
    background-color: var(--admin-accent);
    border-color: var(--admin-accent);
}

.admin-toggle-input:focus {
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 .22rem rgba(var(--admin-accent-rgb), .18);
}

@media (max-width: 768px) {
    .admin-page-head {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ============================================================
   Sale detail card + lifecycle timeline
   (moved out of the AJAX/modal HTML in admin/includes/sale-detail.php)
   ============================================================ */
.sale-detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.sale-detail-head .sale-title { font-size: 18px; font-weight: 700; margin: 0; }
.sale-metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.sale-metric { background: var(--admin-bg-soft, #f7f8fa); border: 1px solid var(--admin-border, #e6e8ec); border-radius: 10px; padding: 12px 14px; }
.sale-metric .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--admin-muted, #8a909a); }
.sale-metric .val { font-size: 17px; font-weight: 700; margin-top: 3px; }
.sale-meta-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 6px; font-size: 13px; color: var(--admin-muted, #6b7280); }
.sale-meta-row code { font-size: 12px; word-break: break-all; }
.sale-timeline { position: relative; margin: 6px 0 0; padding: 0; list-style: none; }
.sale-timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--admin-border, #e6e8ec); }
.sale-tl-item { position: relative; padding: 0 0 18px 46px; min-height: 34px; }
.sale-tl-item:last-child { padding-bottom: 0; }
.sale-tl-dot { position: absolute; left: 4px; top: 0; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; z-index: 1; }
.sale-tl-dot.bg-secondary { background: #9aa0aa; }
.sale-tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sale-tl-phase { font-weight: 700; }
.sale-tl-time { font-size: 12px; color: var(--admin-muted, #8a909a); margin-left: auto; }
.sale-tl-amt { font-size: 13px; font-weight: 600; }
.sale-kv-wrap { margin-top: 8px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 18px; background: var(--admin-bg-soft, #f7f8fa); border: 1px solid var(--admin-border, #e6e8ec); border-radius: 8px; padding: 10px 12px; }
.sale-kv { display: flex; gap: 8px; font-size: 12.5px; line-height: 1.5; border-bottom: 1px dashed var(--admin-border, #edeff2); padding: 2px 0; }
.sale-kv-k { color: var(--admin-muted, #8a909a); min-width: 120px; flex: 0 0 auto; }
.sale-kv-v { color: var(--admin-ink, #2b2f36); word-break: break-word; }
.sale-empty-tl { background: var(--admin-bg-soft, #f7f8fa); border: 1px dashed var(--admin-border, #d8dbe0); border-radius: 10px; padding: 16px; color: var(--admin-muted, #6b7280); font-size: 13px; }
.sale-fx-steps { display: flex; flex-direction: column; gap: 2px; }
.sale-fx-step { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; padding: 7px 2px; border-bottom: 1px dashed var(--admin-border, #edeff2); }
.sale-fx-step:last-child { border-bottom: 0; }
.sale-fx-k { color: var(--admin-muted, #8a909a); font-size: 12.5px; }
.sale-fx-v { color: var(--admin-ink, #2b2f36); font-size: 14px; font-weight: 600; text-align: right; }
.sale-fx-rate { color: var(--admin-muted, #6b7280); font-weight: 500; }
.sale-fx-rid { color: var(--admin-muted, #8a909a); font-size: 11.5px; font-weight: 500; }
/* Flatten the panels when shown inside a modal (the modal IS the card). */
.modal-body .admin-panel { box-shadow: none; margin-bottom: 14px; }
.modal-body .admin-panel:last-child { margin-bottom: 0; }

/* ============================================================
   Phase 4 — polish: help tooltips, sidebar collapse, notification
   bell, global-search keyboard polish, recently-viewed, empty
   states, and responsive refinements.
   ============================================================ */

/* Help "?" tooltip — hover + focus (tap-friendly on mobile). */
.admin-help {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; padding: 0; margin-left: 4px;
    border: 0; background: transparent; color: var(--admin-muted, #94a3b8);
    font-size: 12px; line-height: 1; cursor: help; position: relative; vertical-align: middle; border-radius: 50%;
}
.admin-help:hover, .admin-help:focus-visible { color: var(--admin-accent, #4f6df5); outline: none; }
.admin-help::after {
    content: attr(data-help);
    position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    width: max-content; max-width: 240px; padding: 7px 10px;
    background: #0f172a; color: #fff; font-size: 11.5px; font-weight: 500; line-height: 1.4;
    border-radius: 6px; box-shadow: 0 6px 20px rgba(2, 6, 23, .25);
    opacity: 0; visibility: hidden; transition: opacity .12s ease; z-index: 60; white-space: normal; text-align: left; pointer-events: none;
}
.admin-help:hover::after, .admin-help:focus::after, .admin-help:focus-visible::after { opacity: 1; visibility: visible; }
.admin-unavailable { color: var(--admin-muted, #94a3b8); }

/* Empty-state extras (block helper lives in admin-ui.php; .admin-empty-state base from UX2). */
.admin-empty-state-title { font-weight: 700; margin: 6px 0 2px; }
.admin-empty-state-text { color: var(--admin-muted, #6b7280); margin: 0 0 8px; }
.admin-empty-state-inline { padding: 18px; text-align: center; }
.admin-empty-state-inline i { font-size: 22px; color: var(--admin-muted, #94a3b8); }

/* Sidebar collapse toggle button (topbar). */
.admin-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.admin-sidebar-toggle {
    flex: 0 0 auto; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--admin-border, #e2e8f0); background: #fff; color: var(--admin-ink, #334155);
    border-radius: 9px; font-size: 18px; cursor: pointer;
}
.admin-sidebar-toggle:hover { background: #f1f5f9; }
.admin-sidebar-toggle:focus-visible { outline: 2px solid var(--admin-accent, #4f6df5); outline-offset: 2px; }

.admin-sidebar-backdrop { display: none; }

/* Desktop: collapse the sidebar to an icon rail. */
@media (min-width: 1200px) {
    body.admin-sidebar-collapsed .admin-sidebar { width: 76px; padding-left: 10px; padding-right: 10px; }
    body.admin-sidebar-collapsed .admin-main { margin-left: 76px; }
    body.admin-sidebar-collapsed .admin-sidebar-brand { justify-content: center; }
    body.admin-sidebar-collapsed .admin-sidebar-brand span,
    body.admin-sidebar-collapsed .admin-nav a span,
    body.admin-sidebar-collapsed .admin-nav-heading { display: none; }
    body.admin-sidebar-collapsed .admin-nav a { justify-content: center; padding-left: 8px; padding-right: 8px; }
    body.admin-sidebar-collapsed .admin-nav a i { width: auto; }
    body.admin-sidebar-collapsed .admin-nav a.active::before { left: -10px; }
}

/* Mobile: turn the sidebar into an off-canvas drawer the toggle opens. */
@media (max-width: 1199.98px) {
    .admin-sidebar {
        position: fixed; inset: 0 auto 0 0; width: 272px; max-height: 100vh;
        transform: translateX(-100%); transition: transform .22s ease;
        z-index: 1050; border-right: 1px solid rgba(255, 255, 255, .06); border-bottom: 0;
    }
    body.admin-sidebar-open .admin-sidebar { transform: none; }
    .admin-sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(2, 6, 23, .5);
        z-index: 1040; opacity: 0; visibility: hidden; transition: opacity .2s ease;
    }
    body.admin-sidebar-open .admin-sidebar-backdrop { opacity: 1; visibility: visible; }
    .admin-main { margin-left: 0; }
}

/* Notification bell. */
.admin-notification { position: relative; }
.admin-notification-button {
    position: relative; min-width: 42px; width: 42px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--admin-border, #e2e8f0); background: #fff; color: var(--admin-ink, #334155);
    border-radius: 9px; font-size: 17px;
}
.admin-notification-button:hover { background: #f1f5f9; }
.admin-notification-badge {
    position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--admin-danger, #dc2626); color: #fff; font-size: 10px; font-weight: 800; border-radius: 999px; line-height: 1;
}
.admin-notification-menu { width: min(360px, 92vw); padding: 0; max-height: 70vh; overflow: hidden; }
.admin-notification-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--admin-border, #eef2f7); }
.admin-notification-list { max-height: 60vh; overflow-y: auto; }
.admin-notif-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; text-decoration: none; color: var(--admin-ink, #334155); border-bottom: 1px solid #f1f5f9; }
.admin-notif-item:last-child { border-bottom: 0; }
.admin-notif-item:hover { background: #f8fafc; }
.admin-notif-icon { flex: 0 0 auto; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: #eef2f7; color: #475569; }
.admin-notif-default { background: #eef2f7; color: #475569; }
.admin-notif-warning { background: var(--admin-warning-soft, #fef3c7); color: var(--admin-warning, #b45309); }
.admin-notif-danger { background: var(--admin-danger-soft, #fee2e2); color: var(--admin-danger, #dc2626); }
.admin-notif-success { background: var(--admin-success-soft, #dcfce7); color: var(--admin-success, #16a34a); }
.admin-notif-text { display: grid; min-width: 0; flex: 1; }
.admin-notif-text strong { font-size: 13px; font-weight: 600; }
.admin-notif-text small { font-size: 11.5px; color: var(--admin-muted, #6b7280); }
.admin-notif-pill { flex: 0 0 auto; background: #eef2f7; color: #475569; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.admin-notif-empty { padding: 18px 14px; text-align: center; }

/* Global search keyboard + highlight polish. */
.admin-global-result.is-active { background: rgba(var(--admin-accent-rgb, 79, 109, 245), .08); border-radius: 8px; }
.admin-global-result-title mark, .admin-global-result-subtitle mark, .admin-global-result-matches mark { background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px; }
.admin-global-group-more { display: block; padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--admin-accent, #4f6df5); text-decoration: none; }
.admin-global-group-more:hover { text-decoration: underline; }
.admin-global-ref { font-variant-numeric: tabular-nums; }

/* Recently viewed now opens inside Global Search before typing. */
.admin-global-recent-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}
.admin-global-recent-head span {
    align-items: center;
    display: inline-flex;
    gap: 7px;
}
.admin-global-recent-clear {
    align-items: center;
    background: #fff;
    border: 1px solid var(--admin-border, #e2e8f0);
    border-radius: 8px;
    color: var(--admin-muted, #64748b);
    cursor: pointer;
    display: inline-flex;
    height: 28px;
    justify-content: center;
    line-height: 1;
    width: 28px;
}
.admin-global-recent-clear:hover {
    background: var(--admin-bg-soft, #f8fafc);
    color: var(--admin-text, #0f172a);
}
.admin-global-recent-result + .admin-global-recent-result { border-top-color: var(--admin-border-soft, #eef2f7); }
.admin-global-recent-result .admin-recent-remove { flex: 0 0 auto; }
.admin-recent-empty { margin: 4px 0 2px; padding: 16px 12px; }

/* Responsive: KPI cards 1-col on phones; insight tables/filters breathe. */
@media (max-width: 575.98px) {
    .admin-topbar { padding: 14px 18px; }
    .admin-topbar-left { width: 100%; }
    .admin-topbar-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
        align-items: center;
    }
    .admin-global-search {
        width: 100%;
        min-width: 0;
        flex: none;
    }
    .admin-global-search .input-group { width: 100%; }
    .admin-user-menu {
        width: auto;
        margin-left: 0;
    }
    .admin-user-button {
        width: 42px;
        min-width: 42px;
        height: 40px;
        justify-content: center;
        padding: 4px;
    }
    .admin-user-button-label,
    .admin-user-button::after { display: none; }
    #dashboardMetrics > .col-6,
    [data-insight-kpis] .col-6 { flex: 0 0 100%; max-width: 100%; }
    .admin-insight-controls .admin-insight-filter-form .col-6 { flex: 0 0 100%; max-width: 100%; }
    .admin-notification-menu { width: min(320px, 94vw); }
}

/* RTL layout compatibility for the admin shell. Text stays as-is; this only
   mirrors structural chrome when dir=rtl is applied by the browser/app. */
[dir="rtl"] .admin-sidebar {
    inset: 0 0 0 auto;
    border-right: 0;
    border-left: 1px solid rgba(255, 255, 255, .06);
}
[dir="rtl"] .admin-main {
    margin-left: 0;
    margin-right: 270px;
}
[dir="rtl"] .admin-nav a.active::before {
    left: auto;
    right: -14px;
    border-radius: 4px 0 0 4px;
}
[dir="rtl"] .admin-user-button-label,
[dir="rtl"] .admin-user-dropdown-head,
[dir="rtl"] .admin-help::after { text-align: right; }

@media (min-width: 1200px) {
    [dir="rtl"] body.admin-sidebar-collapsed .admin-main,
    body.admin-sidebar-collapsed[dir="rtl"] .admin-main { margin-right: 76px; }
    [dir="rtl"] body.admin-sidebar-collapsed .admin-nav a.active::before,
    body.admin-sidebar-collapsed[dir="rtl"] .admin-nav a.active::before { right: -10px; }
}

@media (max-width: 1199.98px) {
    [dir="rtl"] .admin-sidebar {
        transform: translateX(100%);
        border-left: 1px solid rgba(255, 255, 255, .06);
    }
    [dir="rtl"] body.admin-sidebar-open .admin-sidebar,
    body.admin-sidebar-open[dir="rtl"] .admin-sidebar { transform: none; }
    [dir="rtl"] .admin-main { margin-right: 0; }
}
