/* ==========================================================================
   Asmacs CRM - Contact Leads Management
   Global stylesheet
   --------------------------------------------------------------------------
   Sections
     1.  Design tokens (light + dark themes)
     2.  Base / typography
     3.  App shell (sidebar, topbar, content, footer)
     4.  Cards + statistics tiles
     5.  Charts
     6.  Tables + pagination
     7.  Forms + filters
     8.  Badges, empty state, loader, toasts
     9.  Auth (login) screen
     10. Utilities + responsive rules
   ========================================================================== */

/* ==========================================================================
   1. Design tokens
   ========================================================================== */
:root {
    /* Brand palette - white / blue / light grey */
    --brand-500: #2563eb;
    --brand-600: #1d4ed8;
    --brand-700: #1e40af;
    --brand-100: #dbeafe;
    --brand-050: #eff6ff;

    /* Surfaces */
    --bg-body: #f4f6fb;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-topbar: rgba(255, 255, 255, .88);

    /* Text */
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #7c8798;
    --text-inverse: #ffffff;

    /* Lines + shadows */
    --border-color: #e5e9f0;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, .07);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

    /* Status colours */
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #0ea5e9;
    --purple: #7c3aed;

    /* Geometry */
    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 14px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all .22s ease;
}

/* Dark mode - toggled by data-bs-theme="dark" on <html> */
[data-bs-theme="dark"] {
    --bg-body: #0f172a;
    --bg-surface: #16213a;
    --bg-surface-alt: #1c2743;
    --bg-sidebar: #131c31;
    --bg-topbar: rgba(19, 28, 49, .9);

    --text-primary: #e8edf7;
    --text-secondary: #c2cbdb;
    --text-muted: #93a0b8;

    --border-color: #26324c;
    --brand-100: #1e3a8a;
    --brand-050: #172554;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

/* ==========================================================================
   2. Base / typography
   ========================================================================== */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 20px;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: .92rem;
    letter-spacing: .1px;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
}

a {
    text-decoration: none;
    color: var(--brand-500);
}

a:hover {
    color: var(--brand-600);
}

.text-muted-soft {
    color: var(--text-muted) !important;
}

/* Visible focus ring for keyboard users (accessibility) */
:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

/* Skip link - first tab stop on every page */
.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    z-index: 2000;
    background: var(--brand-500);
    color: #fff;
    padding: .6rem 1rem;
    border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
    left: 0;
    color: #fff;
}

/* ==========================================================================
   3. App shell
   ========================================================================== */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: transform .28s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 0 1.15rem;
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.sidebar-brand img {
    height: 34px;
    width: auto;
}

.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 1.02rem;
    line-height: 1.1;
    color: var(--text-primary);
}

.sidebar-brand .brand-text small {
    display: block;
    font-size: .68rem;
    font-weight: 500;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-nav {
    padding: 1rem .75rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

.sidebar-heading {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: .75rem .75rem .4rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .8rem;
    margin-bottom: .2rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-nav .nav-link:hover {
    background: var(--brand-050);
    color: var(--brand-600);
    transform: translateX(3px);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: var(--text-inverse);
    box-shadow: var(--shadow-md);
}

.sidebar-footer {
    padding: .9rem 1rem;
    border-top: 1px solid var(--border-color);
    font-size: .74rem;
    color: var(--text-muted);
    flex: 0 0 auto;
}

/* Dim overlay behind the off-canvas sidebar on small screens */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin .28s ease;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;
    background: var(--bg-topbar);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.app-topbar .page-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.app-topbar .page-title small {
    display: block;
    font-size: .72rem;
    font-weight: 400;
    color: var(--text-muted);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
}

.icon-btn:hover {
    background: var(--brand-050);
    color: var(--brand-600);
    border-color: var(--brand-100);
}

.icon-btn .notif-dot {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--bg-surface);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .3rem .65rem .3rem .3rem;
    border-radius: 40px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: var(--transition);
}

.user-chip:hover {
    border-color: var(--brand-100);
    background: var(--brand-050);
    color: var(--text-primary);
}

.avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .82rem;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
}

.app-content {
    padding: 1.4rem 1.25rem 1rem;
    flex: 1 1 auto;
}

.app-footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    padding: .95rem 1.25rem;
    font-size: .8rem;
    color: var(--text-muted);
}

/* Breadcrumbs */
.breadcrumb {
    --bs-breadcrumb-divider-color: var(--text-muted);
    font-size: .8rem;
    margin-bottom: 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "\203A";
    font-size: 1rem;
    line-height: 1;
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* ==========================================================================
   4. Cards + statistic tiles
   ========================================================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: .9rem 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.1rem;
}

.hoverable:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 1.15rem;
    height: 100%;
}

.stat-card::after {
    /* Soft colour wash in the corner of each tile */
    content: "";
    position: absolute;
    right: -30px;
    top: -30px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    opacity: .09;
    background: var(--stat-color, var(--brand-500));
}

.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--stat-color, var(--brand-500));
    background: color-mix(in srgb, var(--stat-color, var(--brand-500)) 14%, transparent);
}

.stat-card .stat-label {
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .15rem;
}

.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-card .stat-note {
    font-size: .76rem;
    color: var(--text-muted);
}

/* ==========================================================================
   5. Charts
   ========================================================================== */
.chart-card .card-body {
    position: relative;
}

.chart-holder {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-holder.tall {
    height: 320px;
}

.chart-title {
    font-size: .95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.chart-title i {
    color: var(--brand-500);
}

/* ==========================================================================
   6. Tables + pagination
   ========================================================================== */
.table-wrap {
    max-height: 62vh;
    overflow: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.table {
    --bs-table-bg: var(--bg-surface);
    --bs-table-color: var(--text-primary);
    margin-bottom: 0;
    font-size: .85rem;
    white-space: nowrap;
}

/* Sticky header keeps column names visible while scrolling */
.table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-surface-alt);
    color: var(--text-secondary);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color) !important;
    padding: .75rem .8rem;
}

.table tbody td {
    padding: .7rem .8rem;
    vertical-align: middle;
    border-color: var(--border-color);
}

.table tbody tr {
    transition: background-color .16s ease;
}

.table tbody tr:hover {
    background: var(--brand-050);
}

.table .col-action {
    position: sticky;
    right: 0;
    background: var(--bg-surface);
    box-shadow: -6px 0 8px -8px rgba(16, 24, 40, .35);
}

.table thead .col-action {
    background: var(--bg-surface-alt);
    z-index: 6;
}

.table tbody tr:hover .col-action {
    background: var(--brand-050);
}

.btn-icon-sm {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    font-size: .8rem;
}

/* Search term highlighting */
mark.hl {
    background: #fde68a;
    color: #713f12;
    padding: 0 2px;
    border-radius: 3px;
}

[data-bs-theme="dark"] mark.hl {
    background: #a16207;
    color: #fef3c7;
}

.page-link {
    color: var(--brand-600);
    border-color: var(--border-color);
    background: var(--bg-surface);
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    min-width: 36px;
    text-align: center;
}

.page-item.active .page-link {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: #fff;
}

.page-item.disabled .page-link {
    background: var(--bg-surface-alt);
    color: var(--text-muted);
}

/* ==========================================================================
   7. Forms + filters
   ========================================================================== */
.form-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .3rem;
}

.form-control,
.form-select {
    background: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    font-size: .87rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--brand-500);
    box-shadow: 0 0 0 .18rem rgba(37, 99, 235, .16);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.input-group-text {
    background: var(--bg-surface-alt);
    border-color: var(--border-color);
    color: var(--text-muted);
}

.filter-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

/* Searchable dropdown - see UI.enhanceSearchableSelect() in js/app.js */
.searchable-select {
    position: relative;
}

.searchable-select .searchable-select-clear {
    border-color: var(--border-color);
    color: var(--text-muted);
}

.searchable-select-menu {
    display: none;
    position: absolute;
    z-index: 1055;
    top: calc(100% + .25rem);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
}

.searchable-select.open .searchable-select-menu {
    display: block;
}

.searchable-select-option {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    color: var(--text-primary);
    font-size: .87rem;
    padding: .45rem .6rem;
    border-radius: 6px;
}

.searchable-select-option:hover,
.searchable-select-option.active {
    background: var(--brand-050);
    color: var(--brand-600);
}

.searchable-select-option mark.hl {
    background: rgba(37, 99, 235, .25);
    color: inherit;
    padding: 0;
}

.searchable-select-empty {
    padding: .5rem .6rem;
    font-size: .85rem;
    color: var(--text-muted);
}

.btn {
    border-radius: var(--radius-sm);
    font-size: .86rem;
    font-weight: 500;
    padding: .5rem .95rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--brand-500);
    border-color: var(--brand-500);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--brand-600);
    border-color: var(--brand-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline-secondary:hover {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-soft {
    background: var(--brand-050);
    color: var(--brand-600);
    border: 1px solid var(--brand-100);
}

.btn-soft:hover {
    background: var(--brand-100);
    color: var(--brand-700);
}

/* Modal + dropdown surfaces follow the theme */
.modal-content,
.dropdown-menu,
.offcanvas {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-color);
    border-radius: var(--radius);
}

.modal-header,
.modal-footer {
    border-color: var(--border-color);
}

.dropdown-item {
    color: var(--text-secondary);
    border-radius: 6px;
    padding: .5rem .75rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--brand-050);
    color: var(--brand-600);
}

.dropdown-menu {
    padding: .4rem;
    box-shadow: var(--shadow-lg);
}

/* Read-only key/value rows inside the details modal */
.detail-row {
    display: flex;
    gap: .75rem;
    padding: .6rem 0;
    border-bottom: 1px dashed var(--border-color);
}

.detail-row:last-child {
    border-bottom: 0;
}

/* ==========================================================================
   Comments modal - see js/leads.js (openComments / renderComments / submitComment)
   ========================================================================== */
.comments-header-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    color: var(--brand-500);
    background: var(--brand-050);
}

.comments-list {
    max-height: 280px;
    overflow-y: auto;
    padding-right: .25rem;
    margin: -.15rem -.25rem 0 0;
}

.comment-item {
    display: flex;
    gap: .65rem;
    margin-bottom: 1.1rem;
}

.comment-item:last-child {
    margin-bottom: 0;
}

.comment-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .72rem;
    color: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .15);
}

.comment-content {
    flex: 1 1 auto;
    min-width: 0;
}

.comment-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .3rem;
}

.comment-author {
    font-weight: 600;
    font-size: .83rem;
    color: var(--text-primary);
}

.comment-time {
    font-size: .72rem;
    color: var(--text-muted);
}

.comment-bubble {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    border-top-left-radius: 4px;
    padding: .6rem .8rem;
    font-size: .85rem;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

.comments-empty {
    text-align: center;
    padding: 2rem 1rem;
}

.comments-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto .6rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: var(--brand-500);
    background: var(--brand-050);
    border: 1px dashed var(--brand-100);
}

.comments-empty .fa-triangle-exclamation {
    font-size: 1.4rem;
    color: var(--danger, #dc2626);
}

.comment-composer {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.comment-composer .form-label {
    font-size: .78rem;
}

.comment-composer .input-group-text {
    background: var(--bg-surface);
}

.comment-composer #commenterName {
    font-size: .95rem;
    padding-top: .55rem;
    padding-bottom: .55rem;
}

.comments-list-heading {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    margin-bottom: .85rem;
}

.detail-row .detail-label {
    flex: 0 0 42%;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
}

.detail-row .detail-value {
    flex: 1 1 auto;
    font-size: .88rem;
    color: var(--text-primary);
    word-break: break-word;
    white-space: normal;
}

/* ==========================================================================
   7b. Channel cards (Generate Lead Link)
   ========================================================================== */
.channel-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .9rem .5rem;
    height: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    transition: var(--transition);
    text-align: center;
}

.channel-card:hover {
    border-color: var(--channel-color, var(--brand-500));
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.channel-card .channel-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.15rem;
    color: var(--channel-color, var(--brand-500));
    background: color-mix(in srgb, var(--channel-color, var(--brand-500)) 13%, transparent);
    transition: var(--transition);
}

.channel-card .channel-name {
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.2;
}

/* Selected channel */
.channel-card.active {
    border-color: var(--channel-color, var(--brand-500));
    background: color-mix(in srgb, var(--channel-color, var(--brand-500)) 8%, var(--bg-surface));
    color: var(--text-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--channel-color, var(--brand-500)) 22%, transparent);
}

.channel-card.active .channel-icon {
    color: #fff;
    background: var(--channel-color, var(--brand-500));
}

/* Small round icon used in the "recently generated" list */
.channel-dot {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .85rem;
}

.min-w-0 { min-width: 0; }

/* Locked Lead Source on the public form */
.locked-field {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-surface-alt);
    color: var(--text-primary);
    font-weight: 600;
    font-size: .87rem;
}

.locked-field .locked-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .82rem;
}

.locked-field .locked-badge {
    margin-left: auto;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
}

/* ==========================================================================
   8. Badges, empty state, loader, toasts
   ========================================================================== */
.badge-soft {
    display: inline-block;
    padding: .28rem .55rem;
    border-radius: 30px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
    background: var(--bg-surface-alt);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.badge-soft.blue   { background: rgba(37, 99, 235, .12);  color: #2563eb; border-color: rgba(37, 99, 235, .22); }
.badge-soft.green  { background: rgba(22, 163, 74, .12);  color: #16a34a; border-color: rgba(22, 163, 74, .22); }
.badge-soft.amber  { background: rgba(245, 158, 11, .14); color: #b45309; border-color: rgba(245, 158, 11, .25); }
.badge-soft.red    { background: rgba(220, 38, 38, .12);  color: #dc2626; border-color: rgba(220, 38, 38, .22); }
.badge-soft.purple { background: rgba(124, 58, 237, .12); color: #7c3aed; border-color: rgba(124, 58, 237, .22); }
.badge-soft.sky    { background: rgba(14, 165, 233, .12); color: #0284c7; border-color: rgba(14, 165, 233, .22); }

[data-bs-theme="dark"] .badge-soft.amber { color: #fbbf24; }

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state .empty-illustration {
    width: 96px;
    height: 96px;
    margin: 0 auto 1.1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    color: var(--brand-500);
    background: var(--brand-050);
    border: 1px dashed var(--brand-100);
}

.empty-state h5 {
    font-weight: 600;
    margin-bottom: .4rem;
}

.empty-state p {
    color: var(--text-muted);
    max-width: 420px;
    margin: 0 auto 1.1rem;
    font-size: .87rem;
}

/* Full page loading spinner */
.app-loader {
    position: fixed;
    inset: 0;
    z-index: 2050;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: .9rem;
    background: rgba(244, 246, 251, .72);
    backdrop-filter: blur(3px);
}

[data-bs-theme="dark"] .app-loader {
    background: rgba(15, 23, 42, .72);
}

.app-loader.show {
    display: flex;
}

.app-loader .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--brand-500);
}

.app-loader .loader-text {
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Inline skeleton shimmer used while charts/cards load */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface-alt) 25%, var(--border-color) 37%, var(--bg-surface-alt) 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.3s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.toast-container {
    z-index: 2100;
}

.app-toast {
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--brand-500);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    min-width: 290px;
}

.app-toast.success { border-left-color: var(--success); }
.app-toast.error   { border-left-color: var(--danger); }
.app-toast.warning { border-left-color: var(--warning); }
.app-toast.info    { border-left-color: var(--info); }

.app-toast .toast-icon { font-size: 1.05rem; }
.app-toast.success .toast-icon { color: var(--success); }
.app-toast.error   .toast-icon { color: var(--danger); }
.app-toast.warning .toast-icon { color: var(--warning); }
.app-toast.info    .toast-icon { color: var(--info); }

/* Small banner shown when the API is unreachable and demo data is used */
.demo-banner {
    display: none;
    align-items: center;
    gap: .6rem;
    font-size: .8rem;
    padding: .6rem .9rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .3);
    color: #b45309;
}

.demo-banner.show {
    display: flex;
}

[data-bs-theme="dark"] .demo-banner {
    color: #fbbf24;
}

/* ==========================================================================
   9. Auth (login) screen
   ========================================================================== */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--bg-body);
}

.auth-hero {
    position: relative;
    overflow: hidden;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
}

.auth-hero::before,
.auth-hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}

.auth-hero::before {
    width: 380px;
    height: 380px;
    top: -120px;
    right: -110px;
}

.auth-hero::after {
    width: 260px;
    height: 260px;
    bottom: -90px;
    left: -70px;
}

.auth-hero .hero-inner {
    position: relative;
    z-index: 2;
    max-width: 460px;
}

.auth-hero h1 {
    color: #fff;
    font-size: 2.15rem;
    font-weight: 700;
    line-height: 1.2;
}

.auth-hero p {
    color: rgba(255, 255, 255, .86);
    font-size: .95rem;
}

.auth-hero .hero-list li {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem 0;
    color: rgba(255, 255, 255, .92);
    font-size: .9rem;
}

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.75rem;
}

.auth-card .auth-logo {
    height: 46px;
    margin-bottom: 1.1rem;
}

/* ==========================================================================
   10. Utilities + responsive
   ========================================================================== */
.section-title {
    font-size: 1.02rem;
    font-weight: 600;
    margin: 0;
}

.divider-y {
    width: 1px;
    height: 26px;
    background: var(--border-color);
}

.cursor-pointer { cursor: pointer; }

/* Public mode - anonymous visitors on add-lead.html get the form without
   the admin sidebar, so the shell collapses to a single centred column. */
body.public-mode .app-sidebar {
    display: none;
}

body.public-mode .app-main {
    margin-left: 0;
}

body.public-mode .app-topbar img {
    display: inline-block !important;
}

.fade-in {
    animation: fadeIn .35s ease both;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* Tablet and below - sidebar becomes an off-canvas drawer */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

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

    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .app-content {
        padding: 1rem .85rem;
    }

    .app-topbar {
        padding: 0 .85rem;
    }

    .app-topbar .page-title {
        font-size: .95rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .chart-holder {
        height: 240px;
    }

    .table-wrap {
        max-height: 58vh;
    }
}

/* Print - hide the chrome, keep the data */
@media print {
    .app-sidebar,
    .app-topbar,
    .app-footer,
    .filter-bar,
    .no-print {
        display: none !important;
    }

    .app-main { margin-left: 0; }
    .table-wrap { max-height: none; border: 0; }
}
