/* =============================================================
   ADMIN LAYOUT — admin.css
   Single source of truth. No inline styles in blade files.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
    --sb-width:         260px;
    --sb-mobile-width:  min(280px, 85vw);
    --navbar-h:         60px;

    --sb-bg:            #ffffff;
    --sb-border:        rgba(0,0,0,0.07);
    --sb-accent:        #f08017;
    --sb-accent-soft:   rgba(240,128,23,0.10);
    --sb-accent-glow:   rgba(240,128,23,0.20);
    --sb-text:          #3a3a4a;
    --sb-muted:         #9a9aaa;
    --sb-active-bg:     rgba(240,128,23,0.10);
    --sb-hover-bg:      rgba(240,128,23,0.06);
    --sb-label:         #b0b0c0;

    --z-navbar:         1020;
    --z-sidebar:        1030;
    --z-backdrop:       1040;   /* mobile only */
    --z-sidebar-mobile: 1045;   /* above backdrop, below Bootstrap modals (1055) */
}

/* ── Hard reset — defeat Bootstrap body margin/padding ──────── */
html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background: #f8f9fa;
}

/* Scroll lock while the mobile drawer is open */
body.sb-lock {
    overflow: hidden;
    touch-action: none;
}

/* =============================================================
   SIDEBAR  (fixed, left column)
   ============================================================= */
#sidebar {
    font-family: 'DM Sans', sans-serif;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sb-width);
    height: 100vh;
    height: 100dvh;             /* no jump when mobile URL bar shows/hides */
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    overflow: hidden;
    box-shadow: 2px 0 16px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

#sidebar.sidebar-collapsed {
    transform: translateX(-100%);
}

/* Brand */
.sb-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sb-brand-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a2a;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-brand-sub {
    font-size: 0.68rem;
    color: var(--sb-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Scrollable nav */
.sb-scroll {
    flex: 1 1 auto;
    min-height: 0;              /* lets flex child actually scroll */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 10px 20px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;   /* don't scroll the page behind */
}
.sb-scroll::-webkit-scrollbar             { width: 4px; }
.sb-scroll::-webkit-scrollbar-thumb      { background: rgba(0,0,0,0.10); border-radius: 4px; }
.sb-scroll::-webkit-scrollbar-track      { background: transparent; }

/* Section labels */
.sb-section-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--sb-label);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 14px 12px 5px;
}
.sb-divider {
    height: 1px;
    background: var(--sb-border);
    margin: 6px 10px;
}

/* Nav items */
.sb-nav-list { list-style: none; margin: 0; padding: 0; }
.sb-nav-list .nav-item { margin-bottom: 1px; }

.sb-nav-list .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.sb-nav-list .nav-link i {
    color: var(--sb-muted);
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.15s;
}
.sb-nav-list .nav-link:hover,
.sb-nav-list .nav-link:hover i          { color: var(--sb-accent); }
.sb-nav-list .nav-link:hover            { background: var(--sb-hover-bg); }

.sb-nav-list .nav-link.active {
    background: var(--sb-active-bg);
    color: var(--sb-accent);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--sb-accent);
}
.sb-nav-list .nav-link.active i         { color: var(--sb-accent); }

/* Dropdown toggle */
.sb-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--sb-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
}
.sb-dropdown-toggle i.icon {
    color: var(--sb-muted);
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.15s;
}
.sb-dropdown-toggle[aria-expanded="true"] i.icon { color: var(--sb-accent); }
.sb-dropdown-toggle:hover               { background: var(--sb-hover-bg); color: var(--sb-accent); }
.sb-dropdown-toggle:hover i             { color: var(--sb-accent); }
.sb-chevron {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--sb-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.sb-dropdown-toggle[aria-expanded="true"] .sb-chevron { transform: rotate(180deg); }
.sb-dropdown-toggle[aria-expanded="true"]             { background: var(--sb-hover-bg); color: var(--sb-accent); }

/* Submenu */
.sb-submenu {
    list-style: none;
    margin: 2px 0 4px 21px;             /* aligns guide line under parent icon */
    padding: 2px 0 2px 10px;
    border-left: 1px solid var(--sb-border);
}
.sb-submenu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 7px;
    color: var(--sb-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
}
.sb-submenu li a i {
    font-size: 1.05rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.85;
}
.sb-submenu li a:hover                  { background: var(--sb-hover-bg); color: var(--sb-accent); }
.sb-submenu li a:hover i                { opacity: 1; }
.sb-submenu li a.active {
    color: var(--sb-accent);
    font-weight: 500;
    background: var(--sb-active-bg);
}
.sb-submenu li a.active i               { opacity: 1; }

/* Keyboard focus */
.sb-nav-list .nav-link:focus-visible,
.sb-dropdown-toggle:focus-visible,
.sb-submenu li a:focus-visible,
.sidebar-toggle-btn:focus-visible {
    outline: 2px solid var(--sb-accent);
    outline-offset: 2px;
}

/* Footer user strip */
.sb-footer {
    padding: 12px 14px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));   /* iPhone home bar */
    border-top: 1px solid var(--sb-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fafafa;
    min-width: 0;
}
.sb-footer > div:last-child { min-width: 0; }   /* allow name ellipsis */
.sb-avatar {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--sb-accent-soft);
    border: 1px solid var(--sb-accent-glow);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem; font-weight: 700;
    color: var(--sb-accent);
}
.sb-user-name {
    font-size: 0.82rem; font-weight: 600; color: #1a1a2a;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-role { font-size: 0.68rem; color: var(--sb-muted); }

/* Backdrop — only shown on mobile (see RESPONSIVE) */
.sb-backdrop {
    display: none;
}

/* =============================================================
   TOP NAVBAR  (fixed, right of sidebar)
   ============================================================= */
.top-navbar {
    position: fixed;
    top: 0;
    left: var(--sb-width);
    right: 0;
    height: var(--navbar-h);
    min-height: var(--navbar-h);
    max-height: var(--navbar-h);
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
    margin: 0;
    z-index: var(--z-navbar);
    transition: left 0.3s ease;
    box-sizing: border-box;
}

.top-navbar.navbar-expanded {
    left: 0;
}

.top-navbar .navbar-brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.top-navbar .navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;               /* lets brand truncate instead of pushing dropdown off-screen */
}

.top-navbar .dropdown {
    flex-shrink: 0;
}

/* Hamburger */
.sidebar-toggle-btn {
    background: var(--sb-accent);
    border: none;
    color: #fff;
    width: 34px; height: 34px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
    padding: 0;
}
.sidebar-toggle-btn:hover               { background: #d97214; }
.sidebar-toggle-btn i                   { font-size: 1.25rem; line-height: 1; }
.top-navbar .dropdown-toggle i,
.top-navbar .dropdown-item i            { font-size: 1.05rem; vertical-align: -0.15em; }

/* =============================================================
   MAIN CONTENT AREA
   Pushed right by sidebar, pushed down by navbar.
   No extra padding beyond what content-wrapper provides.
   ============================================================= */
.main-content {
    position: relative;
    margin-left: var(--sb-width);
    margin-top: 0;
    padding-top: var(--navbar-h);   /* exactly the navbar height — no more */
    min-height: 100vh;
    background: #f8f9fa;
    box-sizing: border-box;
    transition: margin-left 0.3s ease;
}

.main-content.content-expanded {
    margin-left: 0;
}

.content-wrapper {
    padding: 20px 24px;
}

/* =============================================================
   LEGACY ALIASES  (.content / .right_col still used in views)
   ============================================================= */
.content,
.right_col {
    margin-left: var(--sb-width);
    padding-top: var(--navbar-h);
    background-color: #f6f6f6;
    min-height: 87vh;
    flex-grow: 1;
    box-sizing: border-box;
}

/* =============================================================
   SELECT2 HEIGHT FIXES
   ============================================================= */
.select2-container .select2-selection--single   { height: 38px; }
.select2-container .select2-selection__rendered { line-height: 38px; }
.select2-container .select2-selection__arrow    { height: 38px; top: 0; }

/* =============================================================
   MISC
   ============================================================= */
.dash-link { text-decoration: none; color: gray; }

/* =============================================================
   DASHBOARD
   ============================================================= */
.dash {
    font-family: 'DM Sans', sans-serif;
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1400px;
    font-variant-numeric: tabular-nums;
}

/* Header */
.dash-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 4px;
}
.dash-date {
    margin: 0 0 4px;
    font-size: 0.8rem;
    color: var(--sb-muted);
}
.dash-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #1a1a2a;
}
.dash-sub {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--sb-muted);
}
.dash-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.dash-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #e4e4ec;
    background: #fff;
    color: var(--sb-text);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.dash-btn i { font-size: 1rem; }
.dash-btn:hover { border-color: var(--sb-accent); color: var(--sb-accent); }
.dash-btn-primary { background: var(--sb-accent); border-color: var(--sb-accent); color: #fff; }
.dash-btn-primary:hover { background: #d97214; border-color: #d97214; color: #fff; }

/* Shared surface */
.kpi,
.panel {
    background: #fff;
    border: 1px solid #ececf2;
    border-radius: 12px;
}

/* KPIs */
.dash-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.kpi {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}
a.kpi:hover { border-color: var(--sb-accent-glow); transform: translateY(-1px); color: inherit; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 0.8rem; font-weight: 500; color: var(--sb-muted); }
.kpi-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: #f4f4f8;
    color: #6a6a7a;
    font-size: 1.05rem;
}
.kpi-icon.is-warn { background: #fff4e5; color: #c46a00; }
.kpi-value {
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #1a1a2a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-foot { font-size: 0.78rem; color: var(--sb-muted); }

/* The one emphasised tile */
.kpi-accent { background: var(--sb-accent); border-color: var(--sb-accent); color: #fff; }
.kpi-accent .kpi-label,
.kpi-accent .kpi-foot  { color: rgba(255,255,255,0.85); }
.kpi-accent .kpi-value { color: #fff; }
.kpi-accent .kpi-icon  { background: rgba(255,255,255,0.18); color: #fff; }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.trend.is-up   { color: #1f8a4c; }
.trend.is-down { color: #c0392b; }

/* Progress (native <progress>, no inline widths) */
.dash-progress {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border: none;
    border-radius: 99px;
    overflow: hidden;
    background: #f0f0f5;
    margin: 2px 0;
}
.dash-progress::-webkit-progress-bar   { background: #f0f0f5; border-radius: 99px; }
.dash-progress::-webkit-progress-value { background: var(--sb-accent); border-radius: 99px; }
.dash-progress::-moz-progress-bar      { background: var(--sb-accent); border-radius: 99px; }
.kpi-accent .dash-progress,
.kpi-accent .dash-progress::-webkit-progress-bar   { background: rgba(255,255,255,0.25); }
.kpi-accent .dash-progress::-webkit-progress-value { background: #fff; }
.kpi-accent .dash-progress::-moz-progress-bar      { background: #fff; }
.dash-progress.is-thin { height: 4px; }

/* Rows */
.dash-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 14px;
}
.dash-row-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Panels */
.panel { padding: 18px; min-width: 0; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.panel-title { margin: 0; font-size: 0.95rem; font-weight: 600; color: #1a1a2a; }
.panel-hint  { font-size: 0.78rem; color: var(--sb-muted); }
.panel-link {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.8rem; font-weight: 500;
    color: var(--sb-accent);
    text-decoration: none;
}
.panel-link:hover { color: #d97214; }

/* Pipeline (a real sequence: draft → quotation → invoice) */
.pipeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    counter-reset: none;
}
.pipeline-step { position: relative; }
.pipeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -9px;
    width: 8px; height: 8px;
    border-top: 1.5px solid #cfcfda;
    border-right: 1.5px solid #cfcfda;
    transform: translateY(-50%) rotate(45deg);
}
.pipeline-step a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
    padding: 14px;
    border-radius: 10px;
    background: #fafafc;
    color: inherit;
    text-decoration: none;
    transition: background 0.15s;
}
.pipeline-step a:hover { background: var(--sb-hover-bg); }
.pipeline-icon  { font-size: 1.2rem; color: var(--sb-accent); margin-bottom: 4px; }
.pipeline-count { font-size: 1.6rem; font-weight: 600; color: #1a1a2a; line-height: 1.1; }
.pipeline-label { font-size: 0.82rem; color: var(--sb-muted); }
.pipeline-meta  { font-size: 0.75rem; color: var(--sb-text); margin-top: 4px; }

/* Ops list */
.panel-ops { display: flex; flex-direction: column; padding: 8px; }
.ops-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    transition: background 0.15s;
}
.ops-item + .ops-item { border-top: 1px solid #f2f2f6; }
.ops-item:hover { background: var(--sb-hover-bg); color: inherit; }
.ops-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: #f4f4f8;
    color: #6a6a7a;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.ops-icon.is-warn { background: #fff4e5; color: #c46a00; }
.ops-body  { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ops-value { font-size: 1.1rem; font-weight: 600; color: #1a1a2a; line-height: 1.2; }
.ops-label { font-size: 0.8rem; color: var(--sb-muted); }
.ops-meta  { font-size: 0.8rem; font-weight: 500; color: #c46a00; white-space: nowrap; }
.ops-caret { color: #c0c0cc; }

/* Chart */
.chart-box { position: relative; height: 280px; }

/* Debtors */
.panel-debtors { display: flex; flex-direction: column; }
.debtor {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
    color: inherit;
    text-decoration: none;
}
.debtor + .debtor { border-top: 1px solid #f2f2f6; }
.debtor:hover .debtor-name { color: var(--sb-accent); }
.debtor-row  { display: flex; justify-content: space-between; gap: 10px; }
.debtor-name {
    font-size: 0.87rem; font-weight: 500; color: #1a1a2a;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: color 0.15s;
}
.debtor-due  { font-size: 0.87rem; font-weight: 600; color: #1a1a2a; white-space: nowrap; }
.debtor-meta { font-size: 0.75rem; color: var(--sb-muted); }

/* Tables */
.dash-table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dash-table th {
    padding: 8px 18px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--sb-muted);
    text-align: left;
    background: #fafafc;
    border-top: 1px solid #f0f0f5;
    border-bottom: 1px solid #f0f0f5;
}
.dash-table td { padding: 10px 18px; border-bottom: 1px solid #f4f4f8; vertical-align: middle; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table .num { text-align: right; white-space: nowrap; }
.dash-ref { display: block; font-weight: 600; color: #1a1a2a; text-decoration: none; }
.dash-ref:hover { color: var(--sb-accent); }
.dash-subtext { display: block; font-size: 0.75rem; color: var(--sb-muted); }
.dash-truncate { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
}
a.pill:hover { filter: brightness(0.96); }
.pill.is-paid    { background: #e7f6ed; color: #1f8a4c; }
.pill.is-partial { background: #fff4e5; color: #c46a00; }
.pill.is-unpaid  { background: #fdecea; color: #c0392b; }

/* Payments list */
.pay-list { list-style: none; margin: 0; padding: 0; }
.pay-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.pay-item + .pay-item { border-top: 1px solid #f2f2f6; }
.pay-icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: #e7f6ed;
    color: #1f8a4c;
    flex-shrink: 0;
}
.pay-body   { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pay-client {
    font-size: 0.87rem; font-weight: 500; color: #1a1a2a;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pay-amount { font-size: 0.87rem; font-weight: 600; color: #1f8a4c; white-space: nowrap; }

.dash-empty {
    display: flex; align-items: center; gap: 6px;
    margin: 0;
    padding: 18px 0;
    font-size: 0.85rem;
    color: var(--sb-muted);
}

/* ── Shared page components (wallet & other pages on the dashboard pattern) ── */

/* KPI states */
.kpi-value.is-muted  { color: #b0b0c0; }
.kpi-value.is-danger { color: #c0392b; }
.kpi-alert           { border-color: #f5c6c0; background: #fffafa; }
.kpi-icon.is-danger  { background: #fdecea; color: #c0392b; }
.text-alert          { display: inline-flex; align-items: center; gap: 4px; color: #c0392b; }

/* Pill variants */
.pill.is-success { background: #e7f6ed; color: #1f8a4c; }
.pill.is-pending { background: #fff4e5; color: #c46a00; }
.pill.is-failed  { background: #fdecea; color: #c0392b; }
.pill.is-neutral { background: #f1f1f5; color: #4a4a5a; }
.pill.is-info    { background: #eaf2fd; color: #1f5fbf; }
.pill-link {
    display: inline-flex; align-items: center; gap: 3px;
    margin-left: 4px;
    text-decoration: none;
}
.pill-link:hover { background: var(--sb-accent-soft); color: var(--sb-accent); }

/* Codes, amounts, text helpers */
.dash-code {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    background: #eaf2fd;
    color: #1f5fbf;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.dash-code.is-neutral { background: #f1f1f5; color: #4a4a5a; }
.amt-out { font-weight: 600; color: #c0392b; }
.amt-in  { font-weight: 600; color: #1f8a4c; }
.dash-strong { font-weight: 500; color: #1a1a2a; }
.dash-nowrap { white-space: nowrap; }
.dash-wrap   { min-width: 180px; max-width: 280px; }

/* Button loading state */
.dash-btn:disabled { opacity: 0.7; cursor: progress; }
.dash-btn.is-loading i { animation: dash-spin 0.8s linear infinite; }
@keyframes dash-spin { to { transform: rotate(360deg); } }

/* Panel head that holds a toolbar */
.panel-head-wrap { flex-wrap: wrap; }

/* Search field */
.dash-search {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 260px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e4e4ec;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-search:focus-within {
    border-color: var(--sb-accent);
    box-shadow: 0 0 0 3px var(--sb-accent-soft);
}
.dash-search > i { color: var(--sb-muted); }
.dash-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.85rem;
    color: var(--sb-text);
}
.dash-search input::-webkit-search-cancel-button { display: none; }
.dash-search-clear {
    display: grid; place-items: center;
    width: 22px; height: 22px;
    border-radius: 6px;
    color: var(--sb-muted);
    text-decoration: none;
}
.dash-search-clear:hover { background: #f1f1f5; color: #1a1a2a; }

/* Action tiles */
.action-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.action-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 14px;
    border: 1px solid #ececf2;
    border-radius: 10px;
    background: #fafafc;
    color: inherit;
    text-align: left;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.action-tile:hover { border-color: var(--sb-accent-glow); background: var(--sb-hover-bg); color: inherit; }
.action-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: grid; place-items: center;
    font-size: 1.15rem;
    margin-bottom: 8px;
}
.action-icon.is-green  { background: #e7f6ed; color: #1f8a4c; }
.action-icon.is-blue   { background: #eaf2fd; color: #1f5fbf; }
.action-icon.is-purple { background: #f1ecfd; color: #6b3fd4; }
.action-icon.is-amber  { background: #fff4e5; color: #c46a00; }
.action-label { font-size: 0.87rem; font-weight: 600; color: #1a1a2a; }
.action-sub   { font-size: 0.75rem; color: var(--sb-muted); }

/* Centered empty state */
.dash-empty.is-centered {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 40px 16px;
}
.dash-empty.is-centered i      { font-size: 1.8rem; color: #c8c8d4; margin-bottom: 4px; }
.dash-empty.is-centered strong { font-size: 0.9rem; color: #1a1a2a; font-weight: 600; }

/* Modal */
.dash-modal .modal-content {
    font-family: 'DM Sans', sans-serif;
    border: 1px solid #ececf2;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
}
.dash-modal .modal-body { padding: 24px; text-align: center; }
.dash-modal-icon {
    display: grid; place-items: center;
    width: 52px; height: 52px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--sb-accent-soft);
    color: var(--sb-accent);
    font-size: 1.4rem;
}
.dash-modal-title { margin: 0 0 4px; font-size: 1rem; font-weight: 600; color: #1a1a2a; }
.dash-modal-text  { margin: 0 0 18px; font-size: 0.85rem; color: var(--sb-muted); }

/* ── Page header extras ── */
.dash-crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 4px;
    font-size: 0.8rem;
    color: var(--sb-muted);
}
.dash-crumbs a { color: var(--sb-muted); text-decoration: none; }
.dash-crumbs a:hover { color: var(--sb-accent); }
.dash-crumbs i { font-size: 0.7rem; }

.dash-period {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: -6px 0 0;
    font-size: 0.82rem;
    color: var(--sb-muted);
}
.dash-period strong { color: #1a1a2a; font-weight: 600; }

/* ── KPI extras ── */
.dash-kpis.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-value.is-success { color: #1f8a4c; }
.kpi-value.is-pending { color: #c46a00; }
.kpi-icon.is-success  { background: #e7f6ed; color: #1f8a4c; }
.kpi-icon.is-info     { background: #eaf2fd; color: #1f5fbf; }

.panel-count {
    display: inline-block;
    min-width: 26px;
    padding: 1px 8px;
    border-radius: 99px;
    background: #f1f1f5;
    color: #4a4a5a;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

/* ── Buttons extras ── */
.dash-btn.is-icon  { padding: 8px 10px; }
.dash-btn.is-block { width: 100%; justify-content: center; height: 46px; font-size: 0.95rem; }
.dash-btn[disabled] { pointer-events: none; }
.dash-link-btn {
    border: 0;
    background: none;
    padding: 0;
    margin-left: 6px;
    color: var(--sb-accent);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
}
.dash-link-btn:hover { text-decoration: underline; }

/* ── Forms ── */
.dash-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}
.dash-field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 160px; min-width: 0; }
.dash-field.is-grow { flex: 2 1 220px; }
.dash-filters-actions { display: flex; gap: 8px; }

.dash-label { font-size: 0.78rem; font-weight: 600; color: #3a3a4a; margin: 0; }
.dash-label .opt { font-weight: 400; color: var(--sb-muted); }
.dash-label .req { color: #c0392b; }

.dash-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #e4e4ec;
    border-radius: 8px;
    background: #fff;
    color: #1a1a2a;
    font: inherit;
    font-size: 0.87rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-input:focus {
    outline: none;
    border-color: var(--sb-accent);
    box-shadow: 0 0 0 3px var(--sb-accent-soft);
}
textarea.dash-input { height: auto; padding: 10px 12px; resize: vertical; }
.dash-input.is-lg { height: 48px; font-size: 1.1rem; font-weight: 600; }

.dash-input-group { position: relative; }
.dash-input-group > i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sb-muted);
    pointer-events: none;
}
.dash-input-group > .dash-input { padding-left: 36px; }
.dash-hint { display: block; margin-top: 4px; font-size: 0.75rem; color: var(--sb-muted); }

.form-stack { display: flex; flex-direction: column; gap: 18px; }
.dash-form-page { width: 100%; max-width: 640px; margin: 0 auto; }

/* Segmented radio control */
.seg {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    background: #f4f4f8;
}
.seg.is-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 6px;
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--sb-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.seg input:checked + label { background: #fff; color: #1a1a2a; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.seg input:checked + label i { color: var(--sb-accent); }
.seg input:focus-visible + label { outline: 2px solid var(--sb-accent); outline-offset: 1px; }

/* Search suggestions */
.dash-suggest {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    background: #fff;
    border: 1px solid #ececf2;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
.dash-suggest-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    background: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
}
.dash-suggest-item:hover,
.dash-suggest-item:focus-visible { background: var(--sb-hover-bg); outline: none; }
.dash-suggest-name { display: block; font-size: 0.87rem; font-weight: 600; color: #1a1a2a; }
.dash-suggest-sub  { display: block; font-size: 0.75rem; color: var(--sb-muted); }
.dash-suggest-empty { padding: 10px; font-size: 0.82rem; color: var(--sb-muted); }

.dash-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--sb-accent-glow);
    border-radius: 10px;
    background: var(--sb-accent-soft);
}
.dash-selected-name { display: block; font-size: 0.87rem; font-weight: 600; color: #1a1a2a; }
.dash-selected-sub  { display: block; font-size: 0.75rem; color: var(--sb-muted); }
.dash-selected-clear {
    display: grid; place-items: center;
    width: 28px; height: 28px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--sb-muted);
    cursor: pointer;
}
.dash-selected-clear:hover { background: #fff; color: #c0392b; }

/* ── Alerts ── */
.dash-alert {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 10px;
    font-size: 0.85rem;
}
.dash-alert > i { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.dash-alert ul { margin: 0; padding-left: 18px; }
.dash-alert-body { flex: 1; min-width: 0; }
.dash-alert.is-info    { background: #f3f8fe; border-color: #d6e5fa; color: #1f4f99; }
.dash-alert.is-warn    { background: #fff9ef; border-color: #fbe1b8; color: #8a4b00; }
.dash-alert.is-danger  { background: #fdf2f1; border-color: #f5c6c0; color: #9b2c20; }
.dash-alert.is-success { background: #f0faf4; border-color: #bfe6cf; color: #17693a; }
.dash-alert.is-neutral { background: #fafafc; border-color: #ececf2; color: var(--sb-text); }

.breakdown-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 0;
}
.breakdown-row.is-deduct { color: #c0392b; }
.breakdown-row.is-total {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed rgba(138,75,0,0.3);
    font-weight: 600;
}
.breakdown-row.is-total strong { color: #1f8a4c; }

.dash-footnote {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 14px 0 0;
    font-size: 0.78rem;
    color: var(--sb-muted);
}

/* ── Tables extras ── */
.dash-table tfoot td {
    padding: 10px 18px;
    font-weight: 600;
    color: #1a1a2a;
    background: #fafafc;
    border-top: 1px solid #f0f0f5;
}
.dash-table tbody tr:hover td { background: #fcfcfd; }
.dash-table tr.is-highlight td { background: #fffaf3; }
.dash-table tr.is-highlight td:first-child { box-shadow: inset 3px 0 0 var(--sb-accent); }
.dash-table .dash-muted-num { color: var(--sb-muted); }

/* DataTables controls inside a panel table */
.dash-table-wrap .dataTables_wrapper > .row,
.dash-table-wrap .dt-layout-row { margin: 0; padding: 10px 18px; font-size: 0.82rem; }

/* Pagination */
.dash-pager { margin-top: 18px; padding-top: 14px; border-top: 1px solid #f0f0f5; }
.dash-pager nav { display: flex; justify-content: flex-end; }
.dash-pager .pagination { margin: 0; flex-wrap: wrap; }
.dash-pager .page-link { color: var(--sb-text); border-color: #ececf2; font-size: 0.82rem; }
.dash-pager .page-link:hover { color: var(--sb-accent); background: var(--sb-hover-bg); }
.dash-pager .page-item.active .page-link { background: var(--sb-accent); border-color: var(--sb-accent); color: #fff; }

/* ── Charts extras ── */
.chart-box.is-sm { height: 200px; }
.legend-list { list-style: none; margin: 12px 0 0; padding: 0; }
.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid #f2f2f6;
}
.legend-value { text-align: right; font-size: 0.85rem; font-weight: 600; color: #1a1a2a; }
.legend-value .dash-subtext { font-weight: 400; }

/* ── Loading ── */
.dash-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 0;
    font-size: 0.85rem;
    color: var(--sb-muted);
}
.dash-spinner {
    width: 28px; height: 28px;
    border: 3px solid #ececf2;
    border-top-color: var(--sb-accent);
    border-radius: 50%;
    animation: dash-spin 0.8s linear infinite;
}

/* Left-aligned modal variant */
.dash-modal.is-left .modal-body { text-align: left; }
.dash-modal .modal-header {
    padding: 18px 24px 0;
    border: 0;
}
.dash-modal .modal-header .dash-modal-title { margin: 0; }

/* ── Title with icon chip ── */
.dash-title-row { display: flex; align-items: center; gap: 12px; }
.dash-title-row .action-icon { margin-bottom: 0; width: 42px; height: 42px; font-size: 1.3rem; }

/* ── Detail list (confirmation summaries) ── */
.detail-list { margin: 0; font-size: 0.87rem; }
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 9px 0;
    border-top: 1px solid #f2f2f6;
}
.detail-row:first-child { border-top: 0; padding-top: 0; }
.detail-row dt { margin: 0; font-weight: 400; color: var(--sb-muted); }
.detail-row dd { margin: 0; font-weight: 600; color: #1a1a2a; text-align: right; word-break: break-word; }
.detail-row.is-deduct dd { color: #c0392b; }
.detail-row.is-total { border-top: 1px dashed #dcdce4; }
.detail-row.is-total dt { color: #1a1a2a; font-weight: 600; }
.detail-row.is-total dd { color: #1f8a4c; font-size: 1.05rem; }

/* ── OTP input ── */
.otp-input {
    height: 60px;
    padding-left: 0.5em;          /* balances the trailing letter-spacing */
    text-align: center;
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: 0.5em;
    font-variant-numeric: tabular-nums;
}
.otp-input::placeholder { color: #d4d4de; }
.dash-field-error { display: block; margin-top: 6px; font-size: 0.78rem; color: #c0392b; }

/* ── Small / danger buttons, row actions, modal footer ── */
.dash-btn.is-sm { padding: 5px 10px; font-size: 0.78rem; border-radius: 7px; }
.dash-btn.is-sm i { font-size: 0.9rem; }
.dash-btn.is-danger { color: #c0392b; border-color: #f0cdc8; }
.dash-btn.is-danger:hover { background: #fdecea; border-color: #c0392b; color: #c0392b; }
.dash-btn-danger { background: #c0392b; border-color: #c0392b; color: #fff; }
.dash-btn-danger:hover { background: #a93226; border-color: #a93226; color: #fff; }

.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 190px; }
.row-note { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--sb-muted); }

.dash-modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

/* Links inside notes and alerts */
.dash-footnote a,
.dash-alert a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.dash-footnote a { color: var(--sb-accent); }

/* ── Row action menus (Bootstrap dropdown, restyled) ── */
.dash-menu {
    min-width: 210px;
    padding: 6px;
    border: 1px solid #ececf2;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.10);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
}
.dash-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--sb-text);
    text-align: left;
}
.dash-menu .dropdown-item i { font-size: 1.05rem; color: var(--sb-muted); }
.dash-menu .dropdown-item:hover,
.dash-menu .dropdown-item:focus { background: var(--sb-hover-bg); color: #1a1a2a; }
.dash-menu .dropdown-item:hover i { color: var(--sb-accent); }
.dash-menu .dropdown-item.is-danger,
.dash-menu .dropdown-item.is-danger i { color: #c0392b; }
.dash-menu .dropdown-item.is-danger:hover { background: #fdecea; }
.dash-menu .dropdown-divider { margin: 5px 4px; border-color: #f0f0f5; }

/* ── Two-column form grid (modals) ── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.form-grid .is-full { grid-column: 1 / -1; }
.dash-input[readonly] { background: #f7f7fa; color: #5a5a6a; }
.dash-input.is-invalid { border-color: #c0392b; }

/* ── Toolbar select in a panel head ── */
.dash-input.is-compact { height: 34px; width: auto; min-width: 150px; font-size: 0.82rem; }
.panel-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ── Pickable list (client search results) ── */
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; margin-top: 10px; }
.pick-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ececf2;
    border-radius: 9px;
    background: #fff;
    text-align: left;
    font: inherit;
    cursor: pointer;
}
.pick-item:hover { border-color: var(--sb-accent-glow); background: var(--sb-hover-bg); }

/* ── DataTables controls, restyled to match ── */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.dt-container .dt-search input,
.dt-container .dt-length select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid #e4e4ec;
    border-radius: 8px;
    font-size: 0.82rem;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dt-container .dt-search input:focus {
    outline: none;
    border-color: var(--sb-accent);
    box-shadow: 0 0 0 3px var(--sb-accent-soft);
}
.dataTables_wrapper .page-item.active .page-link,
.dt-container .page-item.active .page-link { background: var(--sb-accent); border-color: var(--sb-accent); }
.dataTables_wrapper .page-link,
.dt-container .page-link { color: var(--sb-text); font-size: 0.8rem; }
.dash-table.dataTable,
.dash-table.dataTable thead th { border-collapse: collapse !important; }

/* ── Confirm modal icon variant ── */
.dash-modal-icon.is-danger { background: #fdecea; color: #c0392b; }

/* =============================================================
   TABS (section switcher under a page header)
   ============================================================= */
.dash-tabs {
    display: flex;
    gap: 4px;
    margin-top: -6px;
    border-bottom: 1px solid #ececf2;
    overflow-x: auto;
    scrollbar-width: none;
}
.dash-tabs::-webkit-scrollbar { display: none; }
.dash-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--sb-muted);
    font-size: 0.87rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.dash-tab i { font-size: 1.05rem; }
.dash-tab:hover { color: #1a1a2a; }
.dash-tab.is-active { color: var(--sb-accent); border-bottom-color: var(--sb-accent); }

/* =============================================================
   MEDIA DRIVE
   ============================================================= */
.media-path {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.95rem;
    min-width: 0;
}
.media-path a,
.media-path span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 7px;
    border-radius: 6px;
    color: #1a1a2a;
    font-weight: 500;
    text-decoration: none;
}
.media-path a:hover { background: #f4f4f8; }
.media-path .is-current { font-weight: 600; }
.media-path .sep { padding: 0; color: #c0c0cc; font-size: 0.75rem; }

/* View toggle */
.view-toggle {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 8px;
    background: #f4f4f8;
}
.view-toggle button {
    display: grid; place-items: center;
    width: 30px; height: 28px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--sb-muted);
    font-size: 1rem;
    cursor: pointer;
}
.view-toggle button.is-active { background: #fff; color: var(--sb-accent); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Section heads inside the drive panel */
.media-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 6px 0 10px;
}
.media-section-label { margin: 0; font-size: 0.78rem; font-weight: 600; color: var(--sb-muted); }
.media-section-head + .media-grid,
.media-section-head + .media-list { margin-bottom: 22px; }

/* Grid vs list is driven by one attribute on the wrapper */
.media-views[data-view="grid"] .media-list { display: none; }
.media-views[data-view="list"] .media-grid { display: none; }
.media-list.dash-table-wrap { margin: 0 -18px 22px; }

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.media-card {
    position: relative;
    border: 1px solid #ececf2;
    border-radius: 10px;
    background: #fff;
    transition: border-color 0.15s;
}
.media-card:hover,
.media-card:focus-within { border-color: var(--sb-accent-glow); }
.media-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    text-align: left;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}
.media-thumb {
    position: relative;
    display: grid;
    place-items: center;
    height: 96px;
    border-radius: 9px 9px 0 0;
    background: #fafafc;
    overflow: hidden;
    font-size: 2.4rem;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-name {
    display: block;
    padding: 9px 11px 0;
    font-size: 0.83rem;
    font-weight: 500;
    color: #1a1a2a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-sub {
    display: block;
    padding: 1px 11px 10px;
    font-size: 0.72rem;
    color: var(--sb-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.star-flag { position: absolute; top: 6px; left: 7px; font-size: 0.9rem; color: #e8a400; }

/* Card menu: shows on hover / keyboard focus; always visible on touch screens */
.media-card .media-menu {
    position: absolute;
    top: 6px;
    right: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}
.media-card:hover .media-menu,
.media-card:focus-within .media-menu { opacity: 1; }
.media-card .media-menu:has(.show) { opacity: 1; }
@media (hover: none) { .media-card .media-menu { opacity: 1; } }
.media-menu-btn {
    display: grid; place-items: center;
    width: 28px; height: 28px;
    border: 0;
    border-radius: 7px;
    background: rgba(255,255,255,0.92);
    color: var(--sb-muted);
    cursor: pointer;
}
.media-menu-btn:hover { background: #f1f1f5; color: #1a1a2a; }
.dash-menu form { margin: 0; }

/* List rows */
.media-row-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: #1a1a2a;
    font: inherit;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.media-row-name:hover { color: var(--sb-accent); }
.media-row-name > i { font-size: 1.25rem; flex-shrink: 0; }
.media-row-name img { width: 24px; height: 24px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.media-row-name .star-inline { font-size: 0.8rem; color: #e8a400; margin-right: -4px; }
.media-row-name .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-row-name.is-static { cursor: default; }
.media-row-name.is-static:hover { color: #1a1a2a; }
.media-list .dash-table td:last-child,
.media-table td:last-child { width: 1%; white-space: nowrap; text-align: right; }

/* File-type tones */
.ft-folder { color: #e8a400; }
.ft-image  { color: #7c3aed; }
.ft-video  { color: #db2777; }
.ft-pdf    { color: #d93025; }
.ft-doc    { color: #2563eb; }
.ft-xls    { color: #188038; }
.ft-ppt    { color: #e8710a; }
.ft-zip,
.ft-other,
.ft-muted  { color: #9a9aaa; }

/* Drag & drop */
.media-panel { transition: border-color 0.15s, background 0.15s; }
.media-panel.is-drag {
    border: 2px dashed var(--sb-accent);
    background: var(--sb-hover-bg);
}

/* Preview modal */
.media-preview .modal-content { max-height: 90vh; }
.media-preview .modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid #f0f0f5;
}
.media-preview .modal-header .dash-modal-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-preview .modal-body { padding: 18px; overflow: auto; text-align: left; }
.media-preview-img,
.media-preview-video { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 8px; }
.media-preview-frame { display: block; width: 100%; height: 72vh; border: 0; border-radius: 8px; }
.media-docx { padding: 4px 6px; line-height: 1.6; color: #1a1a2a; }
.media-docx img { max-width: 100%; }
.media-docx[contenteditable="true"] {
    outline: 2px dashed var(--sb-accent);
    outline-offset: 6px;
    border-radius: 4px;
}

/* ── Input with a fixed prefix (e.g. KES) ── */
.dash-affix { display: flex; align-items: stretch; }
.dash-affix-label {
    display: flex;
    align-items: center;
    padding: 0 11px;
    border: 1px solid #e4e4ec;
    border-right: 0;
    border-radius: 8px 0 0 8px;
    background: #f7f7fa;
    color: var(--sb-muted);
    font-size: 0.8rem;
    font-weight: 600;
}
.dash-affix .dash-input { border-radius: 0 8px 8px 0; }
.dash-affix:focus-within .dash-affix-label { border-color: var(--sb-accent); }
.amount-words { display: block; min-height: 1.3em; margin-top: 4px; font-size: 0.75rem; font-style: italic; color: var(--sb-muted); }

/* ── Rich text editor (Quill), restyled ── */
.dash-editor {
    border: 1px solid #e4e4ec;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-editor:focus-within { border-color: var(--sb-accent); box-shadow: 0 0 0 3px var(--sb-accent-soft); }
.dash-editor .ql-toolbar.ql-snow {
    border: 0;
    border-bottom: 1px solid #f0f0f5;
    background: #fafafc;
    font-family: 'DM Sans', sans-serif;
}
.dash-editor .ql-container.ql-snow { border: 0; font-family: 'DM Sans', sans-serif; font-size: 0.9rem; }
.dash-editor .ql-editor { min-height: 220px; color: #1a1a2a; line-height: 1.6; }
.dash-editor .ql-editor.ql-blank::before { color: #b0b0c0; font-style: normal; }
.dash-editor .ql-snow .ql-stroke { stroke: #6a6a7a; }
.dash-editor .ql-snow .ql-fill { fill: #6a6a7a; }
.dash-editor .ql-snow button:hover .ql-stroke,
.dash-editor .ql-snow button.ql-active .ql-stroke { stroke: var(--sb-accent); }
.dash-editor .ql-snow button:hover .ql-fill,
.dash-editor .ql-snow button.ql-active .ql-fill { fill: var(--sb-accent); }
.dash-editor .ql-snow .ql-picker-label:hover,
.dash-editor .ql-snow .ql-picker-label.ql-active { color: var(--sb-accent); }

/* Rendered rich text (read-only) */
.rich-text { font-size: 0.9rem; line-height: 1.65; color: #1a1a2a; overflow-wrap: anywhere; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 10px; }
.rich-text h2 { font-size: 1.05rem; font-weight: 600; margin: 16px 0 8px; }
.rich-text p { margin: 0 0 10px; }
.rich-text ul,
.rich-text ol { padding-left: 22px; margin: 0 0 10px; }
.rich-text a { color: var(--sb-accent); }
.rich-text .ql-indent-1 { padding-left: 2em; }
.rich-text .ql-indent-2 { padding-left: 4em; }

/* ── Record page header extras ── */
.dash-title .pill { vertical-align: middle; margin-left: 6px; font-size: 0.72rem; }
.dash-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--sb-muted);
}
.dash-meta span { display: inline-flex; align-items: center; gap: 5px; }
.dash-row > .stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.linked-item { display: flex; align-items: center; gap: 12px; }
.linked-item .action-icon { margin-bottom: 0; }
.linked-item .linked-body { flex: 1; min-width: 0; }

.lso-form-page { max-width: 860px; }

/* =============================================================
   AUTH (login page)
   Same layout as the original page; only the theme differs.
   Everything is scoped to .auth-body so it can't touch Bootstrap
   classes (.form-control, .input-group, .alert) on other pages.
   ============================================================= */
body.auth-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: whitesmoke;
    font-family: 'DM Sans', system-ui, sans-serif;
}
.auth-body * { box-sizing: border-box; }

.auth-body .login-container {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    background: #fff;
    border: 1px solid #e4e4ec;
    border-radius: 4px;
}

.auth-body .login-header { margin-bottom: 24px; }
.auth-body .login-header h1 { margin: 0 0 8px; font-size: 24px; font-weight: 500; color: #1a1a2a; }
.auth-body .login-header p { margin: 0; font-size: 14px; color: var(--sb-muted); }

.auth-body .form-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: #1a1a2a; }
.auth-body .input-wrapper { margin-bottom: 20px; }

.auth-body .input-group {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    border: 1px solid #dcdce4;
    border-radius: 4px;
    background: #f8f8fb;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.auth-body .input-group:focus-within {
    border-color: var(--sb-accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--sb-accent-soft);
}

.auth-body .input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 12px;
    border-radius: 3px 0 0 3px;
    background: #ececf2;
    color: var(--sb-muted);
    font-size: 18px;
}
.auth-body .input-group:focus-within .input-icon { background: var(--sb-accent-soft); color: var(--sb-accent); }

.auth-body .form-control {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    color: #1a1a2a;
}
.auth-body .form-control:focus { box-shadow: none; background: transparent; }
.auth-body .form-control::placeholder { color: #8a8a9a; }

.auth-body .password-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 12px;
    border: none;
    background: none;
    color: var(--sb-muted);
    font-size: 18px;
    cursor: pointer;
}
.auth-body .password-toggle:hover { color: #1a1a2a; }

.auth-body .forgot-password { margin: -8px 0 24px; text-align: right; }
.auth-body .forgot-password a { font-size: 13px; font-weight: 500; color: var(--sb-accent); text-decoration: none; }
.auth-body .forgot-password a:hover { text-decoration: underline; }

.auth-body .btn-login {
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border: none;
    border-radius: 4px;
    background: var(--sb-accent);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.auth-body .btn-login:hover:not(:disabled) { background: #d97214; box-shadow: 0 1px 3px rgba(240,128,23,0.45); }
.auth-body .btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-body .spinner,
.auth-body .spinner-grey {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    vertical-align: -3px;
    animation: dash-spin 0.8s linear infinite;
}
.auth-body .spinner { margin-right: 8px; }
.auth-body .spinner-grey { border-color: var(--sb-muted); border-top-color: transparent; }

.auth-body .divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    font-size: 13px;
    color: #8a8a9a;
}
.auth-body .divider::before,
.auth-body .divider::after { content: ""; flex: 1; height: 1px; background: #dcdce4; }

.auth-body .btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 1px solid #dcdce4;
    border-radius: 4px;
    background: #fff;
    color: #1a1a2a;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.auth-body .btn-google:hover { background: #fafafc; box-shadow: 0 1px 3px rgba(20,20,40,0.12); }
.auth-body .btn-google.is-busy { opacity: 0.7; pointer-events: none; }

.auth-body .alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 0;
    border-left: 4px solid;
    border-radius: 4px;
    font-size: 13px;
}
.auth-body .alert-danger  { background: #fdecea; border-left-color: #c0392b; color: #c0392b; }
.auth-body .alert-success { background: #e7f6ed; border-left-color: #1f8a4c; color: #1f8a4c; }
.auth-body .alert-close {
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    opacity: 0.6;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.auth-body .alert-close:hover { opacity: 1; }

/* OTP page */
.auth-body #otp {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.5rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.auth-body .field-error,
.auth-body .input-error { margin-top: 6px; font-size: 12px; color: #c0392b; }
.auth-body .input-group.has-error { border-color: #c0392b; }
.auth-body .input-group.has-error .input-icon { background: #fdecea; color: #c0392b; }
.auth-body .form-control:read-only { cursor: not-allowed; color: var(--sb-muted); }
.auth-body .login-header p { line-height: 1.5; }

.auth-body .back-link { text-align: center; font-size: 13px; }
.auth-body .back-link a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--sb-accent);
    font-weight: 500;
    text-decoration: none;
}
.auth-body .back-link a:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .auth-body .login-container { margin: 0 10px; padding: 28px 20px; }
}

/* ── Layout: narrow side panel first (e.g. "add" form beside a list) ── */
.dash-row.is-aside-first { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

/* ── Choice cards (radio group that wraps) ── */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}
.choice-grid input { position: absolute; opacity: 0; pointer-events: none; }
.choice-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    padding: 10px 12px;
    border: 1px solid #e4e4ec;
    border-radius: 9px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--sb-text);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.choice-grid label i { font-size: 1.1rem; color: var(--sb-muted); }
.choice-grid label:hover { border-color: var(--sb-accent-glow); }
.choice-grid input:checked + label { border-color: var(--sb-accent); background: var(--sb-hover-bg); color: #1a1a2a; }
.choice-grid input:checked + label i { color: var(--sb-accent); }
.choice-grid input:focus-visible + label { outline: 2px solid var(--sb-accent); outline-offset: 1px; }

/* ── Scrollable checkbox list with a filter ── */
.check-list-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 6px 0 8px; }
.check-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #e4e4ec;
    border-radius: 9px;
}
.check-list .dash-check { display: flex; width: 100%; padding: 7px 8px; border-radius: 7px; }
.check-list .dash-check:hover { background: #fafafc; }
.check-list .dash-subtext { display: inline; margin-left: 4px; }

.dash-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--sb-text);
    cursor: pointer;
    user-select: none;
}
.dash-check input { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--sb-accent); cursor: pointer; }

/* ── Input with trailing buttons (copy / reveal) ── */
.field-actions { display: flex; gap: 6px; }
.field-actions .dash-input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }

/* ── Read-only message body ── */
.message-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 12px 14px;
    border: 1px solid #ececf2;
    border-radius: 9px;
    background: #fafafc;
    font-size: 0.87rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.message-body.is-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; }
.message-body.is-short { max-height: 140px; padding: 8px 10px; font-size: 0.8rem; background: transparent; border: 0; }

/* ── On/off toggle icon button ── */
.toggle-icon { font-size: 1.35rem; line-height: 1; }
.toggle-icon.is-on  { color: #1f8a4c; }
.toggle-icon.is-off { color: #b0b0c0; }

/* ── Inline stat strip inside modals ── */
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.mini-stat { padding: 10px 12px; border: 1px solid #ececf2; border-radius: 9px; text-align: center; }
.mini-stat span { display: block; font-size: 0.72rem; color: var(--sb-muted); }
.mini-stat strong { display: block; margin-top: 2px; font-size: 1.1rem; color: #1a1a2a; }
.mini-stat.is-success strong { color: #1f8a4c; }
.mini-stat.is-pending strong { color: #c46a00; }
.mini-stat.is-failed strong  { color: #c0392b; }

.dash-modal .modal-dialog.modal-xl .dash-table-wrap { margin: 0; border: 1px solid #ececf2; border-radius: 9px; }

@media (max-width: 991.98px) {
    .dash-row.is-aside-first { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 575.98px) {
    .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Line-items editor (quotations / invoices) ── */
.line-items .dash-table th,
.line-items .dash-table td { padding-left: 10px; padding-right: 10px; }
.line-items .dash-table th:first-child,
.line-items .dash-table td:first-child { padding-left: 18px; }
.line-items .dash-table td { vertical-align: top; }
.line-items .dash-input { height: 38px; min-width: 90px; }
.line-items .col-item { min-width: 220px; }
.line-items .col-num { width: 130px; }
.line-items .col-unit { width: 120px; }
.line-items .col-sub { width: 140px; }
.line-items .dash-input[readonly] { text-align: right; font-weight: 600; color: #1a1a2a; }
.line-items tfoot td { font-size: 0.95rem; }
.line-items .total-value { font-size: 1.1rem; color: var(--sb-accent); white-space: nowrap; }

/* Select2 inside the line items, matched to .dash-input */
.line-items .select2-container { width: 100% !important; }
.line-items .select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #e4e4ec;
    border-radius: 8px;
}
.line-items .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-left: 12px;
    color: #1a1a2a;
    font-size: 0.87rem;
}
.line-items .select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
.line-items .select2-container--default.select2-container--focus .select2-selection--single,
.line-items .select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--sb-accent);
    box-shadow: 0 0 0 3px var(--sb-accent-soft);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--sb-accent); }
.select2-dropdown { border-color: #e4e4ec; border-radius: 8px; font-size: 0.87rem; }

/* Form footer with actions split left / right */
.form-actions-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.form-actions-split > div { display: flex; gap: 8px; flex-wrap: wrap; }

/* Recurring schedule preview */
.schedule-preview {
    padding: 12px 14px;
    border-radius: 10px;
    background: #fafafc;
    border: 1px solid #ececf2;
    font-size: 0.85rem;
    line-height: 1.6;
}
.schedule-preview .dash-label { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }

/* ── Tabs driven by Bootstrap's tab plugin (buttons + .active) ── */
button.dash-tab {
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    font: inherit;
    font-size: 0.87rem;
    font-weight: 500;
    cursor: pointer;
}
.dash-tab.active { color: var(--sb-accent); border-bottom-color: var(--sb-accent); }
.dash-tab .tab-count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 99px;
    background: #f1f1f5;
    color: #4a4a5a;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
}
.dash-tab.active .tab-count { background: var(--sb-accent-soft); color: var(--sb-accent); }
.dash-tabs.in-panel { margin: 0 -18px 18px; padding: 0 12px; }

/* ── Inline "saved" indicator next to an auto-saving field ── */
.save-state { display: block; min-height: 1.1em; margin-top: 3px; font-size: 0.72rem; color: var(--sb-muted); }
.save-state.is-ok { color: #1f8a4c; }
.save-state.is-error { color: #c0392b; }
.dash-input.is-sm { height: 32px; padding: 0 8px; font-size: 0.8rem; min-width: 130px; }

/* ── Media cards showing real thumbnails (images / video / pdf) ── */
.media-thumb video,
.media-thumb iframe { width: 100%; height: 100%; object-fit: cover; border: 0; pointer-events: none; }
.media-card .media-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 0 11px 10px;
}
.media-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding: 2px 11px 0;
    font-size: 0.75rem;
    color: var(--sb-muted);
}

/* ── Task rows (milestone modal) ── */
.task-row { display: flex; gap: 6px; align-items: center; }
.task-row + .task-row { margin-top: 6px; }
.task-row > i { color: #1f8a4c; font-size: 1.1rem; flex-shrink: 0; }
.task-row .dash-input { flex: 1; }

/* Upload progress + local preview inside upload modals */
.upload-preview { margin-top: 10px; border: 1px solid #ececf2; border-radius: 9px; overflow: hidden; }
.upload-preview img,
.upload-preview video { display: block; width: 100%; max-height: 260px; object-fit: contain; background: #fafafc; }
.upload-preview iframe { display: block; width: 100%; height: 300px; border: 0; }

/* Select2 inside modals, matched to .dash-input */
.dash-modal .select2-container { width: 100% !important; }
.dash-modal .select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #e4e4ec;
    border-radius: 8px;
}
.dash-modal .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 36px; padding-left: 12px; font-size: 0.87rem; }
.dash-modal .select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
.dash-modal .select2-container--default.select2-container--open .select2-selection--single { border-color: var(--sb-accent); }
.select2-container--open { z-index: 2000; }

/* ── Permission matrix (role edit page) ──
   Modules range from 1 permission (WorkLog) to 13 (Quotations & invoices),
   so a row-locked grid left ragged gaps under the short cards next to a
   tall one. Multi-column layout packs cards of uneven height into
   balanced columns instead — each column fills top-to-bottom on its own,
   with the browser balancing column heights automatically. */
.module-grid {
    columns: 300px 3;
    column-gap: 14px;
}
.module-block {
    display: inline-block;
    width: 100%;
    margin: 0 0 14px;
    border: 1px solid #ececf2;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    break-inside: avoid;
}
.module-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.module-head h3 { margin: 0; font-size: 0.85rem; font-weight: 600; color: #1a1a2a; }
.module-block .check-list { max-height: none; border: 0; padding: 0; }
.module-block .dash-check { padding: 5px 4px; }

/* ── Sticky save bar for a long form (permission matrix, etc.) ── */
.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 18px -18px -18px;
    padding: 12px 18px;
    border-top: 1px solid #ececf2;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-radius: 0 0 14px 14px;
}
.save-bar .save-state { min-height: auto; }

/* Role badges */
.role-badge-system { margin-left: 6px; }

/* ── Client profile: running balance + avatar ── */
.avatar-lg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--sb-accent-soft);
    color: var(--sb-accent);
    font-size: 1.15rem;
    font-weight: 700;
}
.dr-cr { margin-left: 4px; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; color: var(--sb-muted); }
.dash-table tfoot td { font-weight: 600; background: #fafafc; border-top: 1px solid #ececf2; }
.dash-table-scroll { max-height: 440px; overflow: auto; }
.dash-table-scroll thead th { position: sticky; top: 0; z-index: 1; background: #fafafc; }
.pay-mode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }

/* ── Print: statements and reports print as plain pages ── */
@media print {
    #sidebar, .sb-backdrop, .top-navbar, .no-print, .dash-actions, .dash-crumbs, .dash-filters { display: none !important; }
    body, .main-content { background: #fff !important; }
    .main-content, .main-content.content-expanded { margin-left: 0 !important; padding-top: 0 !important; }
    .content-wrapper { padding: 0 !important; }
    .panel, .kpi { box-shadow: none !important; break-inside: avoid; }
    .dash-table-scroll { max-height: none !important; overflow: visible !important; }
    .dash-table thead th { position: static !important; }
}

/* Dashboard breakpoints */
@media (max-width: 1199.98px) {
    .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991.98px) {
    .dash-row,
    .dash-row-even { grid-template-columns: minmax(0, 1fr); }
    .module-grid { columns: 2; }
    .save-bar { margin: 14px -14px -14px; padding: 10px 14px; flex-direction: column; align-items: stretch; }
}
@media (max-width: 767.98px) {
    .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-kpis.is-3 { grid-template-columns: minmax(0, 1fr); }
    .dash-filters-actions { width: 100%; }
    .dash-filters-actions .dash-btn:first-child { flex: 1; justify-content: center; }
    .seg label { font-size: 0.8rem; }
    .panel-head-wrap .dash-search { min-width: 0; width: 100%; }
    .module-grid { columns: 1; }
}
@media (max-width: 575.98px) {
    .dash { gap: 14px; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .media-thumb { height: 84px; }
    .panel-tools .dash-search { min-width: 0; flex: 1; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .dash-title { font-size: 1.3rem; }
    .dash-actions { width: 100%; }
    .dash-actions .dash-btn { flex: 1 1 auto; justify-content: center; }
    .dash-kpis { gap: 10px; }
    .kpi { padding: 14px; }
    .kpi-value { font-size: 1.15rem; }
    .pipeline { gap: 8px; }
    .pipeline-step a { padding: 10px; }
    .pipeline-count { font-size: 1.3rem; }
    .pipeline-meta { display: none; }
    .chart-box { height: 220px; }
    .dash-table .hide-sm { display: none; }        /* columns marked optional on phones */
}
@media (max-width: 379.98px) {
    .dash-kpis { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    a.kpi:hover { transform: none; }
}

/* =============================================================
   RESPONSIVE
   ============================================================= */

/* ── Tablet & phone: sidebar becomes an off-canvas drawer ───── */
@media (max-width: 991.98px) {

    #sidebar {
        width: var(--sb-mobile-width);
        transform: translateX(-100%);
        z-index: var(--z-sidebar-mobile);
        box-shadow: none;
    }

    /* Declared after .sidebar-collapsed so "open" always wins */
    #sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }

    .sb-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(20, 20, 30, 0.45);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: var(--z-backdrop);
    }
    .sb-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    /* Content and navbar always full width, whatever the desktop state */
    .top-navbar,
    .top-navbar.navbar-expanded {
        left: 0;
        padding: 0 14px;
    }
    .main-content,
    .main-content.content-expanded {
        margin-left: 0;
    }
    .content,
    .right_col {
        margin-left: 0;
    }

    /* Finger-sized tap targets */
    .sb-nav-list .nav-link,
    .sb-dropdown-toggle {
        min-height: 44px;
        padding: 10px 12px;
    }
    .sb-submenu {
        padding-left: 8px;
    }
    .sb-submenu li a {
        min-height: 40px;
        font-size: 0.875rem;
    }

    .content-wrapper {
        padding: 16px;
    }
}

/* ── Small phones ───────────────────────────────────────────── */
@media (max-width: 575.98px) {
    :root { --navbar-h: 56px; }

    .top-navbar {
        padding: 0 10px;
        gap: 8px;
    }
    .top-navbar .navbar-left {
        gap: 8px;
    }
    .top-navbar .navbar-brand {
        font-size: 1rem;
    }
    .sidebar-toggle-btn {
        width: 38px;
        height: 38px;
    }

    .content-wrapper {
        padding: 12px 10px;
    }
}

/* ── Respect reduced-motion settings ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #sidebar,
    .sb-backdrop,
    .top-navbar,
    .main-content,
    .sb-chevron {
        transition: none;
    }
}