/* =====================================================================
   Lead CRM — Design System
   A single source of truth for colours, typography, spacing and
   component styling. Built on top of Bootstrap 5.3 (variable overrides
   where possible, thin custom layers where not).
   ===================================================================== */

/* ------------------------------------------------------------------ */
/* 1. Design tokens                                                     */
/* ------------------------------------------------------------------ */
:root {
    /* Brand */
    --primary-color:        #4f46e5;
    --primary-hover:        #4338ca;
    --primary-active:       #3730a3;
    --primary-soft:         #eef2ff;
    --primary-soft-border:  #dfe3ff;
    --secondary-color:      #64748b;
    --secondary-soft:       #f1f5f9;

    /* Surfaces */
    --background-color:     #f5f6f8;
    --card-color:           #ffffff;
    --surface-muted:        #f8fafc;
    --sidebar-color:        #0f172a;
    --sidebar-hover:        rgba(255, 255, 255, .07);
    --sidebar-text:         #94a3b8;
    --sidebar-text-strong:  #e2e8f0;

    /* Lines */
    --border-color:         #e6e8ec;
    --border-strong:        #d4d8de;

    /* Text */
    --text-color:           #0f172a;
    --text-secondary:       #475569;
    --muted-color:          #6b7280;

    /* Semantic */
    --success-color:        #15803d;
    --success-soft:         #e8f7ee;
    --warning-color:        #b45309;
    --warning-soft:         #fdf4e3;
    --danger-color:         #dc2626;
    --danger-soft:          #fdecec;
    --info-color:           #0e7490;
    --info-soft:            #e6f6fa;
    --neutral-soft:         #f1f3f6;

    /* Shape & depth */
    --radius-sm: 6px;
    --radius:    9px;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .07);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);

    /* Metrics */
    --sidebar-w: 254px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 60px;
    --control-h: 40px;
    --control-h-sm: 33px;

    /* Bootstrap variable overrides -------------------------------- */
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-body-bg: var(--background-color);
    --bs-body-color: var(--text-color);
    --bs-body-font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: .9rem;
    --bs-body-line-height: 1.55;
    --bs-border-color: var(--border-color);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: var(--radius-sm);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-link-color: var(--primary-color);
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: var(--primary-hover);
    --bs-secondary-color: var(--muted-color);
    --bs-emphasis-color: var(--text-color);
    --bs-focus-ring-color: rgba(79, 70, 229, .22);
}

/* ------------------------------------------------------------------ */
/* 2. Base & typography                                                 */
/* ------------------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--bs-body-font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: .9rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--text-color);
    font-weight: 600;
    letter-spacing: -.011em;
}

.page-title      { font-size: 1.3rem; font-weight: 650; line-height: 1.3; margin: 0; letter-spacing: -.018em; }
.page-subtitle   { font-size: .82rem; color: var(--muted-color); margin: .15rem 0 0; }
.section-title   { font-size: .95rem; font-weight: 600; margin: 0; }
.card-title      { font-size: .95rem; font-weight: 600; margin: 0; }
.eyebrow         { font-size: .68rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted-color); }
.helper-text     { font-size: .78rem; color: var(--muted-color); }
.text-muted      { color: var(--muted-color) !important; }
.text-secondary  { color: var(--text-secondary) !important; }

.numeric { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

a { text-decoration: none; }
a:hover { text-decoration: none; }

:focus-visible {
    outline: 2px solid rgba(79, 70, 229, .55);
    outline-offset: 2px;
}

::selection { background: var(--primary-soft); color: var(--primary-active); }

/* Consistent icon sizing across the app (Bootstrap Icons) */
.bi { vertical-align: -.115em; line-height: 1; }

/* Thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: var(--radius-pill); }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
*::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ */
/* 3. Application shell                                                 */
/* ------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar ------------------------------------------------------ */
.app-sidebar {
    width: var(--sidebar-w);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-color);
    color: var(--sidebar-text);
    transition: transform .22s ease, width .18s ease;
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: 0 1rem;
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    color: #fff;
    overflow: hidden;
}
.sidebar-brand .brand-mark {
    width: 32px; height: 32px;
    flex: 0 0 32px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--primary-color);
    color: #fff;
    font-size: 1rem;
}
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand .brand-name { font-weight: 650; font-size: .95rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand .brand-meta { font-size: .68rem; color: var(--sidebar-text); white-space: nowrap; }

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .75rem .625rem 1rem;
}
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); }

.nav-section {
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #64748b;
    padding: .9rem .625rem .35rem;
}
.nav-section:first-child { padding-top: .1rem; }

.sidebar-nav .nav-item + .nav-item { margin-top: 1px; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .625rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: .855rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .13s ease, color .13s ease;
}
.sidebar-nav .nav-link .nav-icon {
    flex: 0 0 18px;
    width: 18px;
    font-size: 1rem;
    text-align: center;
    color: #7c8aa1;
    transition: color .13s ease;
}
.sidebar-nav .nav-link .nav-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.sidebar-nav .nav-link:hover .nav-icon { color: var(--sidebar-text-strong); }
.sidebar-nav .nav-link.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.sidebar-nav .nav-link.active .nav-icon { color: #fff; }

/* Count pill inside the sidebar / topbar — stays solid for visibility */
.nav-count {
    flex: 0 0 auto;
    min-width: 20px;
    padding: 0 .35rem;
    height: 18px;
    border-radius: var(--radius-pill);
    background: var(--danger-color);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.sidebar-nav .nav-link.active .nav-count { background: rgba(255, 255, 255, .28); }

/* Sidebar footer / user block */
.sidebar-footer {
    flex: 0 0 auto;
    border-top: 1px solid rgba(255, 255, 255, .07);
    padding: .625rem;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .45rem .5rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text-strong);
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
}
.sidebar-user:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-user .avatar { flex: 0 0 32px; }
.sidebar-user .su-meta { min-width: 0; line-height: 1.2; }
.sidebar-user .su-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .su-role { font-size: .7rem; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-collapse-btn {
    background: transparent;
    border: 0;
    color: var(--sidebar-text);
    padding: .25rem .4rem;
    border-radius: var(--radius-sm);
    margin-left: auto;
    line-height: 1;
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: #fff; }

/* --- Collapsed (desktop, icon-only) ------------------------------- */
@media (min-width: 992px) {
    body.sidebar-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }
    body.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
    body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0 .5rem; }
    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .su-meta,
    body.sidebar-collapsed .sidebar-collapse-btn,
    body.sidebar-collapsed .nav-section { display: none; }
    /* Keep a visual placeholder for the hidden section labels. */
    body.sidebar-collapsed .nav-section + .nav-item { margin-top: .6rem; position: relative; }
    body.sidebar-collapsed .nav-section + .nav-item::before {
        content: "";
        position: absolute;
        top: -.35rem; left: 20%; right: 20%;
        height: 1px;
        background: rgba(255, 255, 255, .09);
    }
    body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding: .55rem 0; }
    body.sidebar-collapsed .sidebar-user { justify-content: center; padding: .45rem 0; }
    body.sidebar-collapsed .nav-count {
        position: absolute;
        top: 2px; right: 10px;
        min-width: 16px; height: 16px;
        font-size: .6rem;
    }
    body.sidebar-collapsed .sidebar-nav .nav-item { position: relative; }
}

/* --- Main column -------------------------------------------------- */
.app-main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    transition: margin-left .18s ease;
}

.app-topbar {
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 1035;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1rem;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border-color);
}
@media (min-width: 768px) { .app-topbar { padding: 0 1.5rem; } }

.topbar-actions { display: flex; align-items: center; gap: .35rem; }

.icon-btn {
    width: 36px; height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.05rem;
    position: relative;
    transition: background-color .13s ease, color .13s ease, border-color .13s ease;
}
.icon-btn:hover { background: var(--neutral-soft); color: var(--text-color); }
.icon-btn.bordered { border-color: var(--border-color); background: var(--card-color); }
.icon-btn .nav-count { position: absolute; top: 3px; right: 2px; height: 16px; min-width: 16px; font-size: .6rem; }

/* Topbar quick search */
.topbar-search { position: relative; max-width: 360px; flex: 1 1 260px; }
.topbar-search .bi {
    position: absolute;
    left: .7rem; top: 50%;
    transform: translateY(-50%);
    color: var(--muted-color);
    font-size: .9rem;
    pointer-events: none;
}
.topbar-search .form-control { padding-left: 2.05rem; background: var(--surface-muted); }
.topbar-search .form-control:focus { background: var(--card-color); }

/* Page content */
.app-content {
    flex: 1 1 auto;
    padding: 1.25rem 1rem 2.5rem;
    width: 100%;
    max-width: 1600px;
}
@media (min-width: 768px) { .app-content { padding: 1.5rem 1.5rem 3rem; } }

/* Mobile off-canvas behaviour */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1044;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
    body.sidebar-open { overflow: hidden; }
}
@media (min-width: 992px) { .sidebar-backdrop { display: none; } }

/* ------------------------------------------------------------------ */
/* 4. Page header & breadcrumbs                                         */
/* ------------------------------------------------------------------ */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem 1rem;
    margin-bottom: 1.25rem;
}
.page-header .page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.breadcrumb {
    font-size: .78rem;
    margin-bottom: .3rem;
    --bs-breadcrumb-divider-color: var(--border-strong);
    --bs-breadcrumb-item-padding-x: .45rem;
}
.breadcrumb-item + .breadcrumb-item::before { content: "/"; color: var(--border-strong); }
.breadcrumb-item a { color: var(--muted-color); }
.breadcrumb-item a:hover { color: var(--primary-color); }
.breadcrumb-item.active { color: var(--text-secondary); font-weight: 500; }

/* ------------------------------------------------------------------ */
/* 5. Cards                                                             */
/* ------------------------------------------------------------------ */
.card {
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card > .card-header,
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .875rem 1.125rem;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    min-height: 52px;
}
.card-head .card-title { font-size: .925rem; }
.card-head .card-subtitle { font-size: .76rem; color: var(--muted-color); margin: .1rem 0 0; }
.card-head-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.card-body { padding: 1.125rem; }
.card-footer {
    background: var(--surface-muted);
    border-top: 1px solid var(--border-color);
    padding: .75rem 1.125rem;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card.is-flush > .card-body { padding: 0; }

/* Legacy helpers used across existing views keep working */
.card.border-0 { border: 1px solid var(--border-color) !important; }
.card.shadow-sm { box-shadow: var(--shadow-xs) !important; }

/* --- Stat / KPI card ---------------------------------------------- */
.stat-card { height: 100%; }
.stat-card .card-body {
    display: flex;
    align-items: flex-start;
    gap: .875rem;
    padding: 1rem 1.125rem;
}
.stat-icon {
    width: 40px; height: 40px;
    flex: 0 0 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
}
.stat-label { font-size: .75rem; color: var(--muted-color); font-weight: 500; line-height: 1.3; }
.stat-value {
    font-size: 1.45rem;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    margin-top: .1rem;
}
.stat-hint { font-size: .72rem; color: var(--muted-color); margin-top: .15rem; }

/* Tinted icon backgrounds */
.tint-primary   { background: var(--primary-soft);  color: var(--primary-color); }
.tint-success   { background: var(--success-soft);  color: var(--success-color); }
.tint-warning   { background: var(--warning-soft);  color: var(--warning-color); }
.tint-danger    { background: var(--danger-soft);   color: var(--danger-color); }
.tint-info      { background: var(--info-soft);     color: var(--info-color); }
.tint-secondary { background: var(--neutral-soft);  color: var(--secondary-color); }
.tint-dark      { background: #e8eaee;              color: #1f2937; }

/* ------------------------------------------------------------------ */
/* 6. Buttons                                                           */
/* ------------------------------------------------------------------ */
.btn {
    --bs-btn-border-radius: var(--radius-sm);
    font-size: .855rem;
    font-weight: 500;
    padding: .48rem .875rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    line-height: 1.25;
    transition: background-color .13s ease, border-color .13s ease, color .13s ease, box-shadow .13s ease;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--bs-focus-ring-color); }
.btn:disabled, .btn.disabled { opacity: .55; }
.btn-sm { font-size: .8rem; padding: .34rem .65rem; }
.btn-lg { font-size: .95rem; padding: .7rem 1.1rem; }

.btn-primary {
    --bs-btn-bg: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-active);
    --bs-btn-active-border-color: var(--primary-active);
    --bs-btn-disabled-bg: var(--primary-color);
    --bs-btn-disabled-border-color: var(--primary-color);
    box-shadow: var(--shadow-xs);
}
.btn-success {
    --bs-btn-bg: #16a34a; --bs-btn-border-color: #16a34a;
    --bs-btn-hover-bg: #15803d; --bs-btn-hover-border-color: #15803d;
    --bs-btn-active-bg: #166534; --bs-btn-active-border-color: #166534;
    --bs-btn-disabled-bg: #16a34a; --bs-btn-disabled-border-color: #16a34a;
}
.btn-danger {
    --bs-btn-bg: #dc2626; --bs-btn-border-color: #dc2626;
    --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c;
    --bs-btn-active-bg: #991b1b; --bs-btn-active-border-color: #991b1b;
}
.btn-warning {
    --bs-btn-bg: #f59e0b; --bs-btn-border-color: #f59e0b; --bs-btn-color: #422006;
    --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706; --bs-btn-hover-color: #fff;
}

/* Neutral outline — the default "secondary action" in this app */
.btn-outline-secondary {
    --bs-btn-color: var(--text-secondary);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-bg: var(--card-color);
    --bs-btn-hover-bg: var(--surface-muted);
    --bs-btn-hover-color: var(--text-color);
    --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-bg: var(--neutral-soft);
    --bs-btn-active-color: var(--text-color);
    --bs-btn-active-border-color: var(--border-strong);
}
.btn-outline-primary {
    --bs-btn-color: var(--primary-color);
    --bs-btn-border-color: var(--primary-soft-border);
    --bs-btn-bg: var(--card-color);
    --bs-btn-hover-bg: var(--primary-soft);
    --bs-btn-hover-color: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-soft-border);
    --bs-btn-active-bg: var(--primary-soft);
    --bs-btn-active-color: var(--primary-active);
    --bs-btn-active-border-color: var(--primary-color);
}
.btn-outline-danger {
    --bs-btn-color: var(--danger-color);
    --bs-btn-border-color: #f5cccc;
    --bs-btn-bg: var(--card-color);
    --bs-btn-hover-bg: var(--danger-soft);
    --bs-btn-hover-color: #b91c1c;
    --bs-btn-hover-border-color: #f5cccc;
}
.btn-outline-success {
    --bs-btn-color: var(--success-color);
    --bs-btn-border-color: #c9e9d5;
    --bs-btn-bg: var(--card-color);
    --bs-btn-hover-bg: var(--success-soft);
    --bs-btn-hover-color: #166534;
    --bs-btn-hover-border-color: #c9e9d5;
}
.btn-outline-warning {
    --bs-btn-color: var(--warning-color);
    --bs-btn-border-color: #f0dcb4;
    --bs-btn-bg: var(--card-color);
    --bs-btn-hover-bg: var(--warning-soft);
    --bs-btn-hover-color: #92400e;
    --bs-btn-hover-border-color: #f0dcb4;
}
.btn-outline-dark {
    --bs-btn-color: var(--text-secondary);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-bg: var(--card-color);
    --bs-btn-hover-bg: var(--neutral-soft);
    --bs-btn-hover-color: var(--text-color);
    --bs-btn-hover-border-color: var(--border-strong);
}
.btn-link { --bs-btn-color: var(--primary-color); text-decoration: none; }

/* Square icon-only button used in table action columns */
.btn-icon { width: 32px; height: 32px; padding: 0; flex: 0 0 32px; }
.btn-icon.btn-sm { width: 30px; height: 30px; flex: 0 0 30px; }

/* Grouped table actions */
.table-actions { display: inline-flex; align-items: center; gap: .3rem; justify-content: flex-end; }

.btn-group > .btn { border-radius: var(--radius-sm); }
.btn-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* Loading state (applied by app.js on submit) */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 15px; height: 15px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    color: #fff;
    visibility: visible;
}
.btn.is-loading.btn-outline-secondary::after,
.btn.is-loading.btn-outline-primary::after,
.btn.is-loading.btn-outline-danger::after { color: var(--text-secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* 7. Forms                                                             */
/* ------------------------------------------------------------------ */
.form-label {
    font-size: .79rem;
    font-weight: 550;
    color: var(--text-secondary);
    margin-bottom: .3rem;
}
.form-label .req { color: var(--danger-color); margin-left: .1rem; }

.form-control,
.form-select {
    min-height: var(--control-h);
    padding: .48rem .7rem;
    font-size: .865rem;
    color: var(--text-color);
    background-color: var(--card-color);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: none;
    transition: border-color .13s ease, box-shadow .13s ease, background-color .13s ease;
}
textarea.form-control { min-height: 76px; }
.form-control::placeholder { color: #9aa3b2; }
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
    background-color: var(--card-color);
}
.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: var(--surface-muted);
    color: var(--muted-color);
    cursor: not-allowed;
}
.form-control-sm,
.form-select-sm {
    min-height: var(--control-h-sm);
    padding: .3rem .55rem;
    font-size: .8rem;
    border-radius: var(--radius-sm);
}
.form-control-lg, .form-select-lg { min-height: 46px; font-size: .95rem; }

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M4 6l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right .6rem center;
    background-size: 15px 15px;
    padding-right: 2rem;
}

.form-text { font-size: .765rem; color: var(--muted-color); margin-top: .3rem; }

/* Validation */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger-color);
    background-image: none;
}
.form-select.is-invalid {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23dc2626' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M4 6l4 4 4-4'/%3e%3c/svg%3e");
}
.form-control.is-invalid:focus,
.form-select.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }
.invalid-feedback {
    font-size: .765rem;
    color: var(--danger-color);
    display: flex;
    align-items: center;
    gap: .3rem;
    margin-top: .3rem;
}
.form-control.is-valid, .form-select.is-valid { border-color: #16a34a; background-image: none; }
.valid-feedback { font-size: .765rem; color: var(--success-color); }

/* Checks & switches */
.form-check-input {
    width: 1.05em; height: 1.05em;
    margin-top: .2em;
    border-color: var(--border-strong);
    cursor: pointer;
}
.form-check-input:checked { background-color: var(--primary-color); border-color: var(--primary-color); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--bs-focus-ring-color); border-color: var(--primary-color); }
.form-check-label { font-size: .855rem; cursor: pointer; }
.form-switch .form-check-input { width: 2.1em; height: 1.15em; margin-top: .18em; }

/* File input */
.form-control[type="file"] { padding: .32rem .5rem; line-height: 1.9; }
.form-control[type="file"]::file-selector-button {
    padding: .35rem .7rem;
    margin: 0 .7rem 0 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--neutral-soft);
    color: var(--text-secondary);
    font-size: .8rem;
    font-weight: 500;
    transition: background-color .13s ease;
}
.form-control[type="file"]:hover::file-selector-button { background: var(--border-color); }

.input-group > .form-control:focus,
.input-group > .form-select:focus { z-index: 3; }
.input-group-text {
    background: var(--surface-muted);
    border-color: var(--border-strong);
    color: var(--muted-color);
    font-size: .82rem;
}

/* Form sections — used to break long forms into logical blocks */
.form-section + .form-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); }
.form-section-head { margin-bottom: 1rem; }
.form-section-head .form-section-title { font-size: .875rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: .45rem; }
.form-section-head .form-section-title .bi { color: var(--primary-color); font-size: .95rem; }
.form-section-head .form-section-desc { font-size: .765rem; color: var(--muted-color); margin: .15rem 0 0; }

/* Sticky form action bar */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-top: 1.5rem;
    padding-top: 1.125rem;
    border-top: 1px solid var(--border-color);
}
.form-actions .spacer { flex: 1 1 auto; }

/* Password visibility toggle */
.password-field { position: relative; }
.password-field .form-control { padding-right: 2.6rem; }
.password-field .password-toggle {
    position: absolute;
    right: .3rem; top: 50%;
    transform: translateY(-50%);
    width: 30px; height: 30px;
    border: 0; background: transparent;
    color: var(--muted-color);
    border-radius: var(--radius-sm);
    display: grid; place-items: center;
}
.password-field .password-toggle:hover { color: var(--text-color); background: var(--neutral-soft); }

/* ------------------------------------------------------------------ */
/* 8. Filter bar                                                        */
/* ------------------------------------------------------------------ */
.filter-bar { margin-bottom: 1rem; }
.filter-bar .card-body { padding: .875rem 1rem; }
.filter-bar .form-label { font-size: .72rem; margin-bottom: .22rem; }
.filter-toggle-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 .3rem;
    border-radius: var(--radius-pill);
    background: var(--primary-color);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
}
.search-field { position: relative; }
.search-field .bi {
    position: absolute; left: .65rem; top: 50%;
    transform: translateY(-50%);
    color: var(--muted-color); font-size: .85rem; pointer-events: none;
}
.search-field .form-control { padding-left: 1.95rem; }

/* ------------------------------------------------------------------ */
/* 9. Tables                                                            */
/* ------------------------------------------------------------------ */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-color);
    margin-bottom: 0;
    font-size: .855rem;
}
.table > thead > tr > th {
    background: var(--surface-muted);
    color: var(--muted-color);
    font-size: .715rem;
    font-weight: 600;
    letter-spacing: .045em;
    text-transform: uppercase;
    padding: .6rem .875rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    vertical-align: middle;
}
.table > tbody > tr > td {
    padding: .7rem .875rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-secondary);
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table > tbody > tr > td strong,
.table > tbody > tr > td .cell-primary { color: var(--text-color); font-weight: 550; }
.table > tbody > tr > td a:not(.btn) { color: var(--text-color); font-weight: 550; }
.table > tbody > tr > td a:not(.btn):hover { color: var(--primary-color); }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: transparent; background-color: var(--surface-muted); }
.table thead.table-light th { background: var(--surface-muted); }
.table-sm > :not(caption) > * > * { padding: .45rem .7rem; }

/* Soft contextual rows (used by follow-ups / import preview) */
.table > tbody > tr.table-success { --bs-table-bg: var(--success-soft); }
.table > tbody > tr.table-danger  { --bs-table-bg: var(--danger-soft); }
.table > tbody > tr.table-warning { --bs-table-bg: var(--warning-soft); }

.table-responsive { border-radius: 0; }
.table-card .card-body { padding: 0; }
.table-card .table > thead > tr > th:first-child,
.table-card .table > tbody > tr > td:first-child { padding-left: 1.125rem; }
.table-card .table > thead > tr > th:last-child,
.table-card .table > tbody > tr > td:last-child { padding-right: 1.125rem; }

.table-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem 1.125rem;
    border-top: 1px solid var(--border-color);
    background: var(--card-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.table-footer .table-meta { font-size: .78rem; color: var(--muted-color); }

/* Sortable headers */
.table th.sortable { cursor: pointer; user-select: none; transition: color .13s ease; }
.table th.sortable:hover { color: var(--text-color); }
.table th.sortable.is-sorted { color: var(--primary-color); }
.table th .sort-icon { font-size: .7rem; opacity: .5; margin-left: .2rem; }
.table th.sortable.is-sorted .sort-icon { opacity: 1; }

/* Proportion meter used in report tables */
.meter {
    height: 6px;
    border-radius: var(--radius-pill);
    background: var(--neutral-soft);
    overflow: hidden;
    min-width: 60px;
}
.meter > span {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--primary-color);
}
.meter.meter-success > span { background: #16a34a; }

/* Cell helpers */
.cell-sub { font-size: .75rem; color: var(--muted-color); }
.mono { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ */
/* 10. Badges                                                           */
/* ------------------------------------------------------------------ */
.badge {
    font-size: .715rem;
    font-weight: 550;
    padding: .28em .6em;
    border-radius: var(--radius-sm);
    line-height: 1.35;
    letter-spacing: .005em;
    display: inline-flex;
    align-items: center;
    gap: .28em;
    vertical-align: middle;
    border: 1px solid transparent;
}

/* Soft tonal treatment for all Bootstrap colour badges. Existing markup
   and JS that toggles `bg-success` / `bg-secondary` keeps working. */
.badge.bg-primary   { background: var(--primary-soft) !important; color: var(--primary-hover) !important; border-color: var(--primary-soft-border); }
.badge.bg-success   { background: var(--success-soft) !important; color: var(--success-color) !important; border-color: #cdead9; }
.badge.bg-danger    { background: var(--danger-soft)  !important; color: var(--danger-color)  !important; border-color: #f7d4d4; }
.badge.bg-warning   { background: var(--warning-soft) !important; color: var(--warning-color) !important; border-color: #f2e0bd; }
.badge.bg-info      { background: var(--info-soft)    !important; color: var(--info-color)    !important; border-color: #cceaf2; }
.badge.bg-secondary { background: var(--neutral-soft) !important; color: var(--secondary-color) !important; border-color: #e2e6ec; }
.badge.bg-dark      { background: #e8eaee !important; color: #1f2937 !important; border-color: #dcdfe5; }
.badge.bg-light     { background: var(--neutral-soft) !important; color: var(--text-secondary) !important; border-color: #e2e6ec; }
.badge.text-dark    { color: var(--text-secondary) !important; }

/* Status dot prefix */
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }

/* Priority pills */
.badge-priority-high   { background: var(--danger-soft);  color: var(--danger-color);  border-color: #f7d4d4; }
.badge-priority-medium { background: var(--warning-soft); color: var(--warning-color); border-color: #f2e0bd; }
.badge-priority-low    { background: var(--neutral-soft); color: var(--secondary-color); border-color: #e2e6ec; }

/* Small counter chip next to tab labels */
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 19px;
    padding: 0 .32rem;
    height: 18px;
    border-radius: var(--radius-pill);
    font-size: .68rem;
    font-weight: 600;
    background: var(--neutral-soft);
    color: var(--text-secondary);
    margin-left: .35rem;
}
.tab-count.is-danger { background: var(--danger-soft); color: var(--danger-color); }
.nav-link.active .tab-count { background: rgba(255, 255, 255, .25); color: #fff; }

/* ------------------------------------------------------------------ */
/* 11. Avatars                                                          */
/* ------------------------------------------------------------------ */
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary-hover);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .02em;
    overflow: hidden;
    flex: 0 0 auto;
    text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: .66rem; }
.avatar-lg { width: 44px; height: 44px; font-size: .95rem; }
.avatar-dark { background: rgba(255, 255, 255, .12); color: #fff; }

/* ------------------------------------------------------------------ */
/* 12. Tabs / pills                                                     */
/* ------------------------------------------------------------------ */
.nav-pills {
    --bs-nav-pills-border-radius: var(--radius-sm);
    gap: .25rem;
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: .25rem;
    display: inline-flex;
    flex-wrap: wrap;
    max-width: 100%;
}
.nav-pills .nav-link {
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 500;
    padding: .4rem .75rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
}
.nav-pills .nav-link:hover { background: var(--surface-muted); color: var(--text-color); }
.nav-pills .nav-link.active { background: var(--primary-color); color: #fff; }

.nav-tabs { border-bottom: 1px solid var(--border-color); gap: .25rem; }
.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--muted-color);
    font-size: .855rem;
    font-weight: 500;
    padding: .55rem .3rem;
    margin-right: 1rem;
}
.nav-tabs .nav-link:hover { color: var(--text-color); border-bottom-color: var(--border-strong); }
.nav-tabs .nav-link.active { color: var(--primary-color); border-bottom-color: var(--primary-color); background: transparent; }

/* Horizontal scroll for tab strips on small screens */
.tab-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.tab-scroll::-webkit-scrollbar { height: 0; }
.tab-scroll > .nav { flex-wrap: nowrap; }

/* ------------------------------------------------------------------ */
/* 13. Dropdowns                                                        */
/* ------------------------------------------------------------------ */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .3rem;
    font-size: .855rem;
    min-width: 12rem;
}
.dropdown-item {
    border-radius: var(--radius-sm);
    padding: .45rem .6rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: .55rem;
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-muted); color: var(--text-color); }
.dropdown-item.text-danger:hover { background: var(--danger-soft); color: var(--danger-color); }
.dropdown-item .bi { font-size: .95rem; width: 16px; color: var(--muted-color); }
.dropdown-item.text-danger .bi { color: inherit; }
.dropdown-divider { margin: .3rem 0; border-color: var(--border-color); }
.dropdown-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-color); font-weight: 600; padding: .45rem .6rem .3rem; }
.dropdown-toggle::after { margin-left: .4em; opacity: .6; }

/* ------------------------------------------------------------------ */
/* 14. Alerts                                                           */
/* ------------------------------------------------------------------ */
.alert {
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: .75rem 1rem;
    font-size: .855rem;
    display: flex;
    align-items: flex-start;
    gap: .65rem;
}
.alert .alert-icon { font-size: 1rem; line-height: 1.35; flex: 0 0 auto; }
.alert .alert-content { flex: 1 1 auto; min-width: 0; }
.alert .alert-title { font-weight: 600; margin-bottom: .1rem; }
.alert-dismissible { padding-right: 2.5rem; }
.alert-success { background: var(--success-soft); border-color: #cdead9; color: #14532d; }
.alert-success .alert-icon { color: var(--success-color); }
.alert-danger  { background: var(--danger-soft);  border-color: #f7d4d4; color: #7f1d1d; }
.alert-danger .alert-icon { color: var(--danger-color); }
.alert-warning { background: var(--warning-soft); border-color: #f2e0bd; color: #78350f; }
.alert-warning .alert-icon { color: var(--warning-color); }
.alert-info    { background: var(--info-soft);    border-color: #cceaf2; color: #164e63; }
.alert-info .alert-icon { color: var(--info-color); }
.alert ul { padding-left: 1.1rem; margin-bottom: 0; }
.alert .btn-close { padding: .9rem .85rem; }

/* ------------------------------------------------------------------ */
/* 15. Modals                                                           */
/* ------------------------------------------------------------------ */
.modal-content {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    align-items: flex-start;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-subtitle { font-size: .78rem; color: var(--muted-color); margin: .1rem 0 0; }
.modal-body { padding: 1.25rem; }
.modal-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-muted);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    gap: .5rem;
}
.modal-footer > * { margin: 0; }
.modal-backdrop.show { opacity: .5; }
.btn-close:focus { box-shadow: 0 0 0 3px var(--bs-focus-ring-color); }

@media (max-width: 575.98px) {
    .modal-dialog { margin: .625rem; }
    .modal-body { padding: 1rem; }
    .modal-header, .modal-footer { padding: .875rem 1rem; }
    .modal-footer .btn { flex: 1 1 auto; }
}

/* ------------------------------------------------------------------ */
/* 16. Pagination                                                       */
/* ------------------------------------------------------------------ */
.pagination { --bs-pagination-border-radius: var(--radius-sm); gap: .2rem; margin-bottom: 0; }
.page-link {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .8rem;
    padding: .32rem .6rem;
    min-width: 32px;
    text-align: center;
    background: var(--card-color);
}
.page-link:hover { background: var(--surface-muted); color: var(--text-color); border-color: var(--border-strong); }
.page-link:focus { box-shadow: 0 0 0 3px var(--bs-focus-ring-color); }
.page-item.active .page-link { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.page-item.disabled .page-link { background: var(--surface-muted); color: #a5adba; border-color: var(--border-color); }

/* Laravel's default paginator markup */
nav[role="navigation"] .flex { align-items: center; }

/* ------------------------------------------------------------------ */
/* 17. Toasts                                                           */
/* ------------------------------------------------------------------ */
.toast-container { z-index: 1090; }
.app-toast {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    min-width: 290px;
    max-width: 380px;
    padding: .75rem .875rem;
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--secondary-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: .845rem;
    color: var(--text-color);
    animation: toast-in .22s ease;
}
.app-toast.is-hiding { animation: toast-out .18s ease forwards; }
.app-toast .toast-icon { font-size: 1rem; line-height: 1.3; flex: 0 0 auto; }
.app-toast .toast-message { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.app-toast .toast-close {
    border: 0; background: transparent; color: var(--muted-color);
    padding: 0 .1rem; line-height: 1; font-size: 1rem; flex: 0 0 auto;
}
.app-toast .toast-close:hover { color: var(--text-color); }
.app-toast.toast-success { border-left-color: #16a34a; }
.app-toast.toast-success .toast-icon { color: var(--success-color); }
.app-toast.toast-danger  { border-left-color: var(--danger-color); }
.app-toast.toast-danger .toast-icon { color: var(--danger-color); }
.app-toast.toast-warning { border-left-color: #f59e0b; }
.app-toast.toast-warning .toast-icon { color: var(--warning-color); }
.app-toast.toast-info,
.app-toast.toast-primary { border-left-color: var(--primary-color); }
.app-toast.toast-info .toast-icon,
.app-toast.toast-primary .toast-icon { color: var(--primary-color); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------------ */
/* 18. Empty states                                                     */
/* ------------------------------------------------------------------ */
.empty-state { text-align: center; padding: 2.75rem 1.25rem; }
.empty-state .empty-icon {
    width: 52px; height: 52px;
    margin: 0 auto .875rem;
    border-radius: 14px;
    display: grid; place-items: center;
    background: var(--neutral-soft);
    color: var(--muted-color);
    font-size: 1.4rem;
}
.empty-state .empty-title { font-size: .95rem; font-weight: 600; margin-bottom: .25rem; }
.empty-state .empty-text { font-size: .82rem; color: var(--muted-color); max-width: 380px; margin: 0 auto; }
.empty-state .empty-actions { margin-top: 1.125rem; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
td .empty-state { padding: 2.25rem 1rem; }

/* ------------------------------------------------------------------ */
/* 19. Loading / skeletons                                              */
/* ------------------------------------------------------------------ */
.skeleton {
    display: block;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 50%, #eef0f3 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite linear;
    height: .85rem;
}
.skeleton-text { height: .7rem; margin: .25rem 0; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.loading-row td { padding: .8rem .875rem !important; }

.spinner-inline {
    display: inline-block;
    width: 15px; height: 15px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: -2px;
}

/* Route-change progress bar */
#appProgress {
    position: fixed; top: 0; left: 0;
    height: 2px; width: 0;
    background: var(--primary-color);
    z-index: 2000;
    transition: width .2s ease, opacity .3s ease;
    opacity: 0;
}
#appProgress.active { opacity: 1; }

/* ------------------------------------------------------------------ */
/* 20. Timeline                                                         */
/* ------------------------------------------------------------------ */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: .3rem; top: .4rem; bottom: .4rem;
    width: 2px;
    background: var(--border-color);
}
.timeline-item { position: relative; padding-bottom: 1.15rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
    position: absolute;
    left: -1.5rem; top: .3rem;
    width: .7rem; height: .7rem;
    border-radius: 50%;
    border: 2px solid var(--card-color);
    box-shadow: 0 0 0 2px var(--border-color);
}
.timeline-dot.bg-primary   { background: var(--primary-color) !important; }
.timeline-dot.bg-success   { background: #16a34a !important; }
.timeline-dot.bg-danger    { background: var(--danger-color) !important; }
.timeline-dot.bg-warning   { background: #f59e0b !important; }
.timeline-dot.bg-info      { background: #0891b2 !important; }
.timeline-dot.bg-secondary { background: #94a3b8 !important; }
.timeline-dot.bg-dark      { background: #334155 !important; }
.timeline-time { font-size: .74rem; color: var(--muted-color); }
.timeline-title { font-size: .865rem; font-weight: 550; color: var(--text-color); }
.timeline-body { font-size: .82rem; color: var(--text-secondary); }

/* ------------------------------------------------------------------ */
/* 21. Definition lists (detail panels)                                 */
/* ------------------------------------------------------------------ */
.detail-list { margin: 0; }
.detail-list .detail-row {
    display: flex;
    gap: 1rem;
    padding: .48rem 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: .835rem;
}
.detail-list .detail-row:last-child { border-bottom: 0; }
.detail-list dt { flex: 0 0 42%; color: var(--muted-color); font-weight: 500; }
.detail-list dd { flex: 1 1 auto; margin: 0; color: var(--text-color); font-weight: 500; text-align: right; word-break: break-word; }

/* ------------------------------------------------------------------ */
/* 22. Calling console                                                  */
/* ------------------------------------------------------------------ */
.call-card .call-lead-name { font-size: 1.15rem; font-weight: 650; letter-spacing: -.015em; }
.call-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .625rem .875rem;
    padding: .875rem 0;
    margin: .875rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.call-meta-item .call-meta-label { font-size: .7rem; color: var(--muted-color); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.call-meta-item .call-meta-value { font-size: .855rem; color: var(--text-color); font-weight: 500; margin-top: .1rem; }
.call-now-btn {
    font-size: 1rem;
    font-weight: 600;
    padding: .8rem;
    letter-spacing: .03em;
    border-radius: var(--radius);
}
.call-now-btn:active { transform: translateY(1px); }
@media (max-width: 575.98px) { .call-meta-grid { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ */
/* 23. Auth pages                                                       */
/* ------------------------------------------------------------------ */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    background: var(--background-color);
}
@media (min-width: 992px) { .auth-page { grid-template-columns: 1fr 1fr; } }

.auth-aside {
    display: none;
    position: relative;
    padding: 3rem;
    background: var(--sidebar-color);
    color: #fff;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}
@media (min-width: 992px) { .auth-aside { display: flex; } }
.auth-aside::after {
    content: "";
    position: absolute;
    width: 520px; height: 520px;
    right: -180px; bottom: -220px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(79, 70, 229, .55), rgba(79, 70, 229, 0) 68%);
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside .auth-headline { font-size: 1.75rem; font-weight: 650; line-height: 1.25; letter-spacing: -.02em; max-width: 22ch; }
.auth-aside .auth-sub { color: #94a3b8; font-size: .9rem; max-width: 40ch; margin-top: .75rem; }
.auth-feature { display: flex; gap: .75rem; align-items: flex-start; margin-top: 1rem; }
.auth-feature .bi { color: #818cf8; font-size: 1rem; margin-top: .1rem; }
.auth-feature-title { font-size: .875rem; font-weight: 550; color: #e2e8f0; }
.auth-feature-text { font-size: .8rem; color: #94a3b8; }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--primary-color);
    color: #fff;
    font-size: 1.3rem;
    margin-bottom: 1.125rem;
}

/* Demo account shortcuts (debug builds only) */
.demo-account {
    display: flex;
    align-items: center;
    gap: .625rem;
    width: 100%;
    text-align: left;
    padding: .5rem .55rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-color);
    transition: background-color .13s ease, border-color .13s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 52px;
}
.demo-account:hover:not(:disabled) { background: var(--card-color); border-color: var(--border-color); }
.demo-account:focus-visible { outline: 2px solid rgba(79, 70, 229, .55); outline-offset: 2px; }
.demo-account:active:not(:disabled) { transform: scale(.995); }
.demo-account:disabled { opacity: .45; }

.demo-account .stat-icon { width: 32px; height: 32px; flex-basis: 32px; font-size: .9rem; }
.demo-account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; flex: 1 1 auto; }
.demo-account-role { font-size: .82rem; font-weight: 600; }
.demo-account-mail { font-size: .72rem; color: var(--muted-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-account-desc { font-size: .7rem; color: var(--muted-color); display: none; }
.demo-account-go { color: var(--muted-color); font-size: 1.15rem; flex: 0 0 auto; }
.demo-account:hover:not(:disabled) .demo-account-go { color: var(--primary-color); }

@media (min-width: 400px) { .demo-account-desc { display: block; } }

/* The row being used to sign in */
.demo-account.is-signing-in {
    opacity: 1;
    background: var(--primary-soft);
    border-color: var(--primary-soft-border);
}
.demo-account.is-signing-in .demo-account-go { display: none; }
.demo-account.is-signing-in::after {
    content: "";
    width: 15px; height: 15px;
    border: 2px solid var(--primary-soft-border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    flex: 0 0 auto;
}

/* ------------------------------------------------------------------ */
/* 24. Error pages                                                      */
/* ------------------------------------------------------------------ */
.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1.25rem;
    background: var(--background-color);
    text-align: center;
}
.error-code {
    font-size: 4.25rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.04em;
    color: var(--primary-color);
}
.error-title { font-size: 1.3rem; font-weight: 650; margin: .75rem 0 .35rem; }
.error-text { color: var(--muted-color); font-size: .9rem; max-width: 46ch; margin: 0 auto; }
.error-actions { margin-top: 1.5rem; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ */
/* 25. Charts                                                           */
/* ------------------------------------------------------------------ */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { max-width: 100%; }

/* ------------------------------------------------------------------ */
/* 26. Utilities                                                        */
/* ------------------------------------------------------------------ */
.min-w-0 { min-width: 0; }
.hstack-gap { display: flex; align-items: center; gap: .5rem; }
.divider-y { border-top: 1px solid var(--border-color); }
.soft-panel { background: var(--surface-muted); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1rem; }
.truncate-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fs-tiny { font-size: .72rem; }

/* Comfortable touch targets on coarse pointers */
@media (pointer: coarse) {
    .btn, .form-control, .form-select { min-height: 42px; }
    .btn-sm, .form-control-sm, .form-select-sm { min-height: 38px; }
    .btn-icon { width: 38px; height: 38px; flex-basis: 38px; }
    .dropdown-item { padding: .6rem .65rem; }
}

/* Small screens */
@media (max-width: 575.98px) {
    .page-title { font-size: 1.15rem; }
    .page-header .page-header-actions { width: 100%; }
    .page-header .page-header-actions > .btn { flex: 1 1 auto; }
    .stat-value { font-size: 1.25rem; }
    .card-body { padding: 1rem; }
    .table-footer { padding: .75rem 1rem; }
    .table-card .table > thead > tr > th:first-child,
    .table-card .table > tbody > tr > td:first-child { padding-left: 1rem; }
    .table-card .table > thead > tr > th:last-child,
    .table-card .table > tbody > tr > td:last-child { padding-right: 1rem; }
}

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

/* ================================================================== */
/* 27. MOBILE APPLICATION LAYER                                        */
/*     Below 992px the product behaves like a native phone app:        */
/*     compact top bar, fixed bottom navigation, sheets and cards.     */
/* ================================================================== */

:root {
    --mobilebar-h: 56px;
    --bottomnav-h: 60px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* Mobile chrome is hidden on desktop and vice versa. */
.app-mobilebar,
.app-bottomnav { display: none; }

.brand-mark-sm { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; font-size: .85rem; }

@media (max-width: 991.98px) {
    /* --- The desktop chrome steps aside entirely ------------------- */
    .app-sidebar,
    .sidebar-backdrop,
    .app-topbar { display: none !important; }

    .app-main { margin-left: 0; }

    /* --- Compact application bar ---------------------------------- */
    .app-mobilebar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        position: sticky;
        top: 0;
        z-index: 1035;
        height: calc(var(--mobilebar-h) + var(--safe-top));
        padding: var(--safe-top) calc(.75rem + var(--safe-right)) 0 calc(.75rem + var(--safe-left));
        background: rgba(255, 255, 255, .92);
        backdrop-filter: saturate(180%) blur(10px);
        border-bottom: 1px solid var(--border-color);
    }
    .mobilebar-title {
        font-size: .95rem;
        font-weight: 650;
        letter-spacing: -.012em;
        color: var(--text-color);
    }

    /* --- Content gets room for the bottom bar ---------------------- */
    .app-content {
        padding: 1rem .875rem calc(var(--bottomnav-h) + var(--safe-bottom) + 1.75rem);
        padding-left: calc(.875rem + var(--safe-left));
        padding-right: calc(.875rem + var(--safe-right));
    }

    /* --- Fixed bottom navigation ---------------------------------- */
    .app-bottomnav {
        display: flex;
        position: fixed;
        inset: auto 0 0 0;
        z-index: 1040;
        height: calc(var(--bottomnav-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: rgba(255, 255, 255, .96);
        backdrop-filter: saturate(180%) blur(12px);
        border-top: 1px solid var(--border-color);
    }
    .bottomnav-item {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        border: 0;
        background: transparent;
        color: var(--muted-color);
        font-size: .65rem;
        font-weight: 550;
        padding: .3rem .15rem;
        -webkit-tap-highlight-color: transparent;
        transition: color .13s ease;
    }
    .bottomnav-icon {
        position: relative;
        font-size: 1.2rem;
        line-height: 1;
        display: grid;
        place-items: center;
        width: 30px;
        height: 26px;
        border-radius: var(--radius-pill);
        transition: background-color .15s ease, color .15s ease;
    }
    .bottomnav-icon .nav-count {
        position: absolute;
        top: -3px; right: -1px;
        height: 15px; min-width: 15px;
        font-size: .58rem;
        border: 2px solid #fff;
        padding: 0 .2rem;
    }
    .bottomnav-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .bottomnav-item.active { color: var(--primary-color); }
    .bottomnav-item.active .bottomnav-icon { background: var(--primary-soft); }
    .bottomnav-item:active .bottomnav-icon { transform: scale(.92); }

    /* The calling action is the agent's main job — give it weight. */
    .bottomnav-item.is-primary .bottomnav-icon {
        background: var(--primary-color);
        color: #fff;
        width: 40px; height: 28px;
    }
    .bottomnav-item.is-primary.active .bottomnav-icon { background: var(--primary-active); }

    /* --- Page header compacts ------------------------------------- */
    .page-header { margin-bottom: .875rem; }
    .page-header .breadcrumb { display: none; }
    .page-title { font-size: 1.1rem; }
    .page-subtitle { font-size: .78rem; }

    /* Cards go edge-to-edge-ish and lose some chrome */
    .card { border-radius: var(--radius); }
    .card-body { padding: .9rem; }
    .card-head { padding: .8rem .9rem; min-height: 46px; }
    .table-card .table > thead > tr > th:first-child,
    .table-card .table > tbody > tr > td:first-child { padding-left: .9rem; }
    .table-card .table > thead > tr > th:last-child,
    .table-card .table > tbody > tr > td:last-child { padding-right: .9rem; }
    .table-footer { padding: .75rem .9rem; }

    /* Nav pills scroll instead of wrapping */
    .nav-pills { flex-wrap: nowrap; width: max-content; min-width: 100%; }
}

/* iOS zooms the viewport when a focused input is under 16px. Keep every
   text control at 16px on touch layouts — the visual size is tuned with
   padding instead. */
@media (max-width: 991.98px) {
    .form-control,
    .form-select,
    .form-control-sm,
    .form-select-sm,
    textarea.form-control {
        font-size: 16px;
        min-height: 44px;
        padding: .55rem .75rem;
    }
    .form-select, .form-select-sm { padding-right: 2.1rem; }
    .form-label { font-size: .8rem; }
    .btn { min-height: 44px; padding: .6rem 1rem; }
    .btn-sm { min-height: 38px; padding: .45rem .75rem; font-size: .82rem; }
    .btn-icon { min-height: 40px; width: 40px; height: 40px; flex-basis: 40px; padding: 0; }
}

/* ------------------------------------------------------------------ */
/* 28. Bottom sheets (offcanvas)                                        */
/* ------------------------------------------------------------------ */
.offcanvas.sheet {
    border: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, .18);
    max-height: 88vh;
    height: auto;
    padding-bottom: var(--safe-bottom);
}
.offcanvas.sheet .offcanvas-header {
    padding: .5rem 1rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.offcanvas.sheet .offcanvas-body { padding: 1rem; }

/* Responsive sheets (offcanvas-lg) — sheet on phones, plain content from
   lg upwards. These rules must stay below the breakpoint, otherwise they
   fight Bootstrap's own "unwrap at lg" styles. */
@media (max-width: 991.98px) {
    .offcanvas-lg.offcanvas-bottom {
        border: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -8px 32px rgba(15, 23, 42, .18);
        max-height: 88vh;
        height: auto;
        padding-bottom: var(--safe-bottom);
    }
    .offcanvas-lg.offcanvas-bottom .offcanvas-header {
        padding: .5rem 1rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    .offcanvas-lg.offcanvas-bottom .offcanvas-body { padding: 1rem; }

    /* The card inside a sheet drops its own chrome. */
    .offcanvas-lg .card.filter-bar {
        border: 0;
        box-shadow: none;
        margin: 0;
        background: transparent;
    }
    .offcanvas-lg .card.filter-bar > .card-body { padding: 0; }
}

@media (min-width: 992px) {
    .offcanvas-lg .card.filter-bar { width: 100%; }
}

.sheet-grabber {
    width: 38px; height: 4px;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
    margin: .5rem auto .1rem;
    flex: 0 0 auto;
}

.sheet-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .625rem;
}
@media (max-width: 359.98px) { .sheet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.sheet-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    text-align: center;
    padding: .9rem .4rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--card-color);
    color: var(--text-secondary);
    font-size: .75rem;
    font-weight: 550;
    line-height: 1.25;
    min-height: 92px;
}
.sheet-tile:active { background: var(--surface-muted); }
.sheet-tile .stat-icon { width: 36px; height: 36px; flex-basis: 36px; font-size: .95rem; }

.offcanvas-backdrop.show { opacity: .45; }

/* ------------------------------------------------------------------ */
/* 29. PWA surfaces: install, update, offline                           */
/* ------------------------------------------------------------------ */
.pwa-install-banner {
    position: fixed;
    left: calc(.75rem + var(--safe-left));
    right: calc(.75rem + var(--safe-right));
    bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + .75rem);
    z-index: 1085;
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .875rem;
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .2s ease, transform .2s ease;
}
.pwa-install-banner.is-visible { opacity: 1; transform: none; }
.pwa-install-icon { border-radius: 10px; flex: 0 0 auto; }
.pwa-install-text { flex: 1 1 150px; min-width: 0; line-height: 1.3; }
.pwa-install-text strong { display: block; font-size: .875rem; }
.pwa-install-text span { font-size: .78rem; color: var(--muted-color); }
.pwa-install-actions { display: flex; gap: .5rem; flex: 1 1 100%; }
.pwa-install-actions .btn { flex: 1 1 auto; }

@media (min-width: 992px) {
    .pwa-install-banner {
        left: auto;
        right: 1.25rem;
        bottom: 1.25rem;
        width: 380px;
    }
    .pwa-install-actions { flex: 0 0 auto; }
    .pwa-install-actions .btn { flex: 0 0 auto; }
}

.pwa-update-bar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: calc(.75rem + var(--safe-top));
    z-index: 1090;
    display: flex;
    align-items: center;
    gap: .65rem;
    max-width: calc(100vw - 1.5rem);
    padding: .6rem .7rem .6rem .875rem;
    background: var(--text-color);
    color: #fff;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
    font-size: .82rem;
}
.pwa-update-bar .bi { font-size: 1rem; }
.pwa-update-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pwa-update-text strong { font-size: .82rem; }
.pwa-update-text span { font-size: .74rem; color: #cbd5e1; }
.pwa-update-bar .btn-close {
    filter: invert(1) grayscale(1);
    opacity: .6;
    padding: .4rem;
    background-size: .65em;
}

.offline-bar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1095;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .55rem .875rem calc(.55rem + var(--safe-bottom));
    background: #78350f;
    color: #fde68a;
    font-size: .8rem;
    font-weight: 500;
    /* Hidden with opacity + visibility rather than a transform: the bar is
       offset above the bottom nav on phones, so translateY(100%) would not
       move it clear of the viewport. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}
.offline-bar.is-visible { opacity: 1; visibility: visible; transform: none; }
@media (max-width: 991.98px) {
    .offline-bar { bottom: calc(var(--bottomnav-h) + var(--safe-bottom)); padding-bottom: .55rem; }
}

/* Toasts must clear the bottom navigation / action bar on phones. */
@media (max-width: 991.98px) {
    .toast-container {
        bottom: calc(var(--bottomnav-h) + var(--safe-bottom)) !important;
        left: 0;
        right: 0;
        padding: .625rem .75rem !important;
        align-items: stretch;
    }
    .app-toast { min-width: 0; max-width: none; width: 100%; }
    body.has-actionbar .toast-container { bottom: calc(64px + var(--safe-bottom)) !important; }
    body.is-offline .toast-container { bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 38px) !important; }
}

.pwa-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .875rem; }
.pwa-steps li { display: flex; align-items: flex-start; gap: .7rem; font-size: .85rem; color: var(--text-secondary); }
.pwa-step-n {
    flex: 0 0 24px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-hover);
    display: grid; place-items: center;
    font-size: .75rem; font-weight: 650;
}

/* ------------------------------------------------------------------ */
/* 30. Mobile record cards (leads, follow-ups)                          */
/* ------------------------------------------------------------------ */
.record-list { display: flex; flex-direction: column; gap: .625rem; }

.record-card {
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: .8rem .875rem;
    box-shadow: var(--shadow-xs);
    position: relative;
}
.record-card.is-overdue { border-left: 3px solid var(--danger-color); }
.record-card.is-today { border-left: 3px solid var(--primary-color); }
.record-card.is-done { opacity: .72; }

.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .625rem; }
.record-name {
    font-size: .925rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.3;
    display: block;
}
.record-sub { font-size: .765rem; color: var(--muted-color); margin-top: .1rem; }

.record-phone {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .85rem;
    font-weight: 550;
    color: var(--text-secondary);
    margin-top: .5rem;
    font-variant-numeric: tabular-nums;
}
.record-phone .bi { color: var(--muted-color); font-size: .85rem; }

.record-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem .75rem;
    margin-top: .625rem;
    padding-top: .625rem;
    border-top: 1px dashed var(--border-color);
}
.record-meta-label {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    color: var(--muted-color);
}
.record-meta-value { font-size: .8rem; color: var(--text-color); font-weight: 500; margin-top: .05rem; }

.record-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.record-actions .btn { flex: 1 1 0; }
.record-actions .btn-call { flex: 1.4 1 0; }

.record-extra { display: none; }
.record-card.is-open .record-extra { display: block; }
.record-toggle {
    background: transparent;
    border: 0;
    color: var(--primary-color);
    font-size: .78rem;
    font-weight: 550;
    padding: .4rem 0 0;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.record-card.is-open .record-toggle .bi { transform: rotate(180deg); }
.record-toggle .bi { transition: transform .15s ease; font-size: .8rem; }

/* Day group heading in the follow-up list */
.record-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin: 1.125rem 0 .5rem;
}
.record-group:first-child { margin-top: 0; }
.record-group-title {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted-color);
}
.record-group-title.is-overdue { color: var(--danger-color); }

/* Desktop table ⇄ mobile cards */
.mobile-only { display: none; }
@media (max-width: 991.98px) {
    .mobile-only { display: block; }
    .desktop-only { display: none !important; }
}

/* ------------------------------------------------------------------ */
/* 31. Quick-select chips (call disposition)                            */
/* ------------------------------------------------------------------ */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .25rem;
}
.chip {
    border: 1px solid var(--border-strong);
    background: var(--card-color);
    color: var(--text-secondary);
    border-radius: var(--radius-pill);
    padding: .45rem .75rem;
    font-size: .8rem;
    font-weight: 550;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 38px;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.chip:active { transform: scale(.97); }
.chip.is-selected,
.btn-check:checked + .chip {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.chip.is-selected .bi,
.btn-check:checked + .chip .bi { color: #fff; }
.btn-check:focus-visible + .chip { box-shadow: 0 0 0 3px var(--bs-focus-ring-color); }
.chip-group.is-invalid .chip { border-color: #f0b4b4; }
.chip-error { font-size: .765rem; color: var(--danger-color); display: none; margin-top: .3rem; }
.chip-group.is-invalid ~ .chip-error { display: flex; align-items: center; gap: .3rem; }

/* ------------------------------------------------------------------ */
/* 32. Sticky mobile action bar (lead detail, calling)                  */
/* ------------------------------------------------------------------ */
.mobile-actionbar { display: none; }

@media (max-width: 991.98px) {
    .mobile-actionbar {
        display: flex;
        gap: .5rem;
        position: fixed;
        inset: auto 0 0 0;
        z-index: 1041;
        padding: .625rem calc(.875rem + var(--safe-right)) calc(.625rem + var(--safe-bottom)) calc(.875rem + var(--safe-left));
        background: rgba(255, 255, 255, .97);
        backdrop-filter: saturate(180%) blur(12px);
        border-top: 1px solid var(--border-color);
    }
    .mobile-actionbar .btn { flex: 1 1 0; }
    /* When an action bar is present it replaces the bottom nav. */
    body.has-actionbar .app-bottomnav { display: none; }
    body.has-actionbar .app-content { padding-bottom: calc(64px + var(--safe-bottom) + 1.25rem); }
}

/* Big primary call button */
.call-now-btn { min-height: 54px; }
@media (max-width: 991.98px) {
    .call-now-btn { min-height: 58px; font-size: 1.05rem; }
}

/* ------------------------------------------------------------------ */
/* 33. Mobile dashboard                                                 */
/* ------------------------------------------------------------------ */
.greeting-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    border: 0;
    border-radius: var(--radius-lg);
    padding: 1.125rem;
    margin-bottom: 1rem;
}
.greeting-hello { font-size: .78rem; color: #94a3b8; }
.greeting-name { font-size: 1.15rem; font-weight: 650; letter-spacing: -.015em; }
.greeting-meta { font-size: .76rem; color: #94a3b8; margin-top: .15rem; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .625rem;
}
.kpi-tile {
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: .8rem .875rem;
    box-shadow: var(--shadow-xs);
}
.kpi-tile .stat-icon { width: 30px; height: 30px; flex-basis: 30px; font-size: .85rem; margin-bottom: .5rem; }
.kpi-tile .stat-value { font-size: 1.5rem; }
.kpi-tile .stat-label { font-size: .72rem; }

.upnext-card {
    border: 1px solid var(--primary-soft-border);
    background: linear-gradient(180deg, var(--primary-soft) 0%, var(--card-color) 62%);
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .625rem;
}
.quick-tile {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--card-color);
    color: var(--text-color);
    font-size: .82rem;
    font-weight: 600;
    box-shadow: var(--shadow-xs);
    min-height: 62px;
}
.quick-tile:active { background: var(--surface-muted); }
.quick-tile .stat-icon { width: 34px; height: 34px; flex-basis: 34px; font-size: .95rem; }

/* ------------------------------------------------------------------ */
/* 34. Mobile filter trigger                                            */
/* ------------------------------------------------------------------ */
.mobile-searchbar {
    display: none;
    gap: .5rem;
    align-items: center;
    margin-bottom: .875rem;
}
@media (max-width: 991.98px) {
    .mobile-searchbar { display: flex; }
    .mobile-searchbar .search-field { flex: 1 1 auto; }
    .mobile-searchbar .btn { flex: 0 0 auto; white-space: nowrap; }
}

/* Standalone (installed) tweaks: no browser chrome, so tighten the top. */
body.is-standalone .app-mobilebar { padding-top: calc(var(--safe-top) + 2px); }

/* ------------------------------------------------------------------ */
/* 35. Print                                                            */
/* ------------------------------------------------------------------ */
@media print {
    .app-sidebar, .app-topbar, .app-mobilebar, .app-bottomnav,
    .sidebar-backdrop, .mobile-actionbar, .mobile-searchbar,
    .btn, .nav-pills, .filter-bar, .page-header-actions,
    .toast-container, .pwa-install-banner, .pwa-update-bar,
    .offline-bar, #appProgress { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0 !important; max-width: none; }
    body { background: #fff; }
    .card { border: 1px solid #d0d5dd !important; box-shadow: none !important; break-inside: avoid; }
    .mobile-only { display: none !important; }
    .desktop-only { display: block !important; }
}
