/* ============================================================
   Solar CRM — app.css v3 (Modern, Inter font, Lucide icons)
   ============================================================ */

/* ── 1. Variables ──────────────────────────────────────────── */
:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --primary-light: #fef3c7;
    --primary-glow: rgba(245, 158, 11, .2);
    --secondary: #0f172a;
    --secondary-mid: #1e293b;
    --secondary-light: #334155;
    --bg: #f8fafc;
    --bg-2: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-2: #cbd5e1;
    --text: #0f172a;
    --text-2: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --info: #3b82f6;
    --info-bg: #eff6ff;

    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-full: 999px;

    --sh-xs: 0 1px 2px rgba(0, 0, 0, .04);
    --sh-sm: 0 1px 6px rgba(0, 0, 0, .07);
    --sh-md: 0 4px 16px rgba(0, 0, 0, .09);
    --sh-lg: 0 8px 32px rgba(0, 0, 0, .12);
    --sh-xl: 0 20px 60px rgba(0, 0, 0, .15);

    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --t: .18s ease;
    --t-spring: .25s cubic-bezier(.34, 1.56, .64, 1);
}

/* ── 2. Reset ──────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color var(--t);
}

a:hover {
    color: var(--primary);
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

svg.lucide {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    flex-shrink: 0;
}

/* ── 3. Typography ─────────────────────────────────────────── */
h1 {
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.2;
}

h2 {
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 700;
    letter-spacing: -.02em;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
}

.text-sm {
    font-size: .82rem;
}

.text-xs {
    font-size: .72rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-light {
    color: var(--text-light);
}

.text-center {
    text-align: center;
}

.fw-500 {
    font-weight: 500;
}

.fw-600 {
    font-weight: 600;
}

.fw-700 {
    font-weight: 700;
}

/* ── 4. Layout ─────────────────────────────────────────────── */
.main-content {
    padding: 1.25rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 5rem;
}

@media (min-width: 768px) {
    .main-content {
        padding: 2rem 2.5rem 3rem;
    }
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-1 {
    gap: .5rem;
}

.gap-2 {
    gap: 1rem;
}

.mt-1 {
    margin-top: .5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: .5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

.hidden-xs {
    display: none;
}

@media (min-width: 480px) {
    .hidden-xs {
        display: inline;
    }
}

/* ── 5. Navbar ─────────────────────────────────────────────── */
.navbar {
    background: var(--secondary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .05), var(--sh-md);
    gap: .75rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.navbar-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.navbar-logo svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.navbar-brand a {
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.02em;
    white-space: nowrap;
}

.navbar-links {
    display: flex;
    gap: .25rem;
    flex: 1;
    justify-content: center;
}

.navbar-links a {
    color: #94a3b8;
    padding: .45rem .85rem;
    border-radius: var(--r-sm);
    font-size: .82rem;
    font-weight: 500;
    transition: background var(--t), color var(--t);
    display: flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
}

.navbar-links a svg {
    width: 15px;
    height: 15px;
}

.navbar-links a:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.navbar-links a.active {
    background: rgba(245, 158, 11, .15);
    color: var(--primary);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.user-name {
    font-size: .78rem;
    font-weight: 500;
    color: #94a3b8;
    display: none;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 540px) {
    .user-name {
        display: inline;
    }
}

/* ── 6. Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.2rem;
    border: none;
    border-radius: var(--r-sm);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t);
    min-height: 44px;
    min-width: 44px;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
    letter-spacing: -.01em;
}

.btn svg {
    width: 15px;
    height: 15px;
}

.btn:active {
    transform: scale(.96);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(245, 158, 11, .35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-danger {
    background: var(--error);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, .25);
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-2);
    color: var(--text);
}

.btn-sm {
    padding: .4rem .85rem;
    font-size: .78rem;
    min-height: 36px;
}

.btn-xs {
    padding: .25rem .6rem;
    font-size: .72rem;
    min-height: 30px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: .5rem;
    border-radius: var(--r-sm);
    min-width: 36px;
    min-height: 36px;
}

/* ── 7. Forms ──────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    margin-bottom: .4rem;
    color: var(--text-2);
    letter-spacing: .02em;
    /* text-transform: uppercase; */
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: .7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: .9rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--t), box-shadow var(--t);
    min-height: 44px;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input.input-error,
.form-select.input-error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .1);
}

.form-textarea {
    resize: vertical;
    min-height: 88px;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .9rem center;
    padding-right: 2.5rem;
    cursor: pointer;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.field-error {
    display: block;
    font-size: .74rem;
    color: var(--error);
    margin-top: .3rem;
    font-weight: 500;
    min-height: 1.1em;
}

.input-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: .6rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-xs);
    transition: color var(--t);
}

.toggle-password:hover {
    color: var(--text);
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

/* ── 8. Alerts ─────────────────────────────────────────────── */
.alert {
    padding: .85rem 1rem;
    border-radius: var(--r-sm);
    font-size: .85rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--error-bg);
    color: #b91c1c;
    border-color: var(--error);
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
    border-color: var(--success);
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400e;
    border-color: var(--warning);
}

.alert-info {
    background: var(--info-bg);
    color: #1d4ed8;
    border-color: var(--info);
}

/* ── 9. Cards ──────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--r-md);
    box-shadow: var(--sh-sm);
    border: 1px solid var(--border);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow var(--t), transform var(--t);
}

.card:hover {
    box-shadow: var(--sh-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .85rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--border);
    gap: .5rem;
}

.card-title {
    font-size: .95rem;
    font-weight: 700;
}

/* ── 10. Badges ────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .22rem .7rem;
    border-radius: var(--r-full);
    font-size: .68rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* Lead status */
.badge-new-lead {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-follow-up {
    background: #fef9c3;
    color: #854d0e;
}

.badge-interested {
    background: #fce7f3;
    color: #9d174d;
}

.badge-deal-confirmed {
    background: #d1fae5;
    color: #065f46;
}

.badge-material-pending {
    background: #ffedd5;
    color: #9a3412;
}

.badge-structure-in-progress {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-structure-completed {
    background: #cffafe;
    color: #155e75;
}

.badge-panel-installed {
    background: #dcfce7;
    color: #14532d;
}

.badge-electrical-meter {
    background: #f3e8ff;
    color: #6b21a8;
}

.badge-project-completed {
    background: #d1fae5;
    color: #064e3b;
}

.badge-default {
    background: #f1f5f9;
    color: #475569;
}

/* Role */
.badge-admin {
    background: #fee2e2;
    color: #991b1b;
}

.badge-state-head {
    background: #fef3c7;
    color: #92400e;
}

.badge-zonal-head {
    background: #dbeafe;
    color: #1e40af;
}

.badge-branch-head {
    background: #d1fae5;
    color: #065f46;
}

.badge-bdo {
    background: #fef3c7;
    color: #92400e;
}

.badge-advisory {
    background: #f3e8ff;
    color: #6b21a8;
}

.badge-advisor {
    background: #f3e8ff;
    color: #6b21a8;
}

/* Status */
.badge-active {
    background: #d1fae5;
    color: #065f46;
}

.badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* ── 11. Spinner ───────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .65s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── 12. Toast ─────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
    max-width: calc(100vw - 2.5rem);
}

.toast {
    background: var(--secondary-mid);
    color: #fff;
    padding: .85rem 1.1rem;
    border-radius: var(--r-md);
    font-size: .84rem;
    font-weight: 500;
    box-shadow: var(--sh-lg);
    display: flex;
    align-items: center;
    gap: .6rem;
    pointer-events: auto;
    animation: toastIn .25s var(--t-spring) forwards;
    max-width: 340px;
    border-left: 4px solid transparent;
}

.toast svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.toast-success {
    border-color: var(--success);
}

.toast-error {
    border-color: var(--error);
}

.toast-warning {
    border-color: var(--warning);
}

.toast-info {
    border-color: var(--info);
}

.toast.removing {
    animation: toastOut .2s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* ── 13. Modal ─────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .6);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.open {
    display: flex;
}

@media (min-width: 480px) {
    .modal-overlay {
        align-items: center;
    }
}

.modal {
    background: var(--surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    width: 100%;
    max-width: 540px;
    max-height: 92vh;
    overflow-y: auto;
    padding: 1.75rem;
    animation: modalUp .28s var(--t-spring);
    box-shadow: var(--sh-xl);
}

@media (min-width: 480px) {
    .modal {
        border-radius: var(--r-xl);
    }
}

@keyframes modalUp {
    from {
        transform: translateY(28px) scale(.96);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    background: var(--bg-2);
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    min-height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    transition: background var(--t), color var(--t);
}

.modal-close:hover {
    background: var(--border);
    color: var(--text);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

/* ── 14. Login Page ────────────────────────────────────────── */
.login-page {
    background: radial-gradient(ellipse at 60% 0%, #1e3a5f 0%, #0f172a 60%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: rgba(255, 255, 255, .97);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-xl);
    padding: 2.5rem 2.25rem;
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(20px);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto .85rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--r-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px var(--primary-glow);
    animation: logoPulse 3s ease-in-out infinite;
}

.login-logo svg {
    width: 32px;
    height: 32px;
    color: #fff;
}

@keyframes logoPulse {

    0%,
    100% {
        box-shadow: 0 8px 24px rgba(245, 158, 11, .3);
    }

    50% {
        box-shadow: 0 8px 32px rgba(245, 158, 11, .55);
    }
}

.login-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--secondary);
    letter-spacing: -.03em;
}

.login-subtitle {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: .3rem;
    font-weight: 500;
}

/* ── 15. Metric Cards ──────────────────────────────────────── */
.metrics-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .metrics-row {
        grid-template-columns: repeat(4, 1fr);
    }
}

.metric-card {
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 1.25rem;
    box-shadow: var(--sh-sm);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--t), transform var(--t);
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    opacity: 0;
    transition: opacity var(--t);
}

.metric-card:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
}

.metric-card:hover::after {
    opacity: 1;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .75rem;
}

.metric-icon svg {
    width: 20px;
    height: 20px;
}

.metric-label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .3rem;
}

.metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.03em;
    line-height: 1.1;
}

/* ── 16. Lead Cards ────────────────────────────────────────── */
.lead-card {
    background: var(--surface);
    border-radius: var(--r-md);
    box-shadow: var(--sh-xs);
    border: 1px solid var(--border);
    padding: 1.1rem;
    margin-bottom: .75rem;
    transition: box-shadow var(--t), transform var(--t);
}

.lead-card:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-1px);
}

.lead-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}

.lead-name {
    font-weight: 700;
    font-size: .95rem;
    color: var(--text);
}

.lead-mobile {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .1rem;
    display: flex;
    align-items: center;
    gap: .25rem;
}

.lead-mobile svg {
    width: 12px;
    height: 12px;
}

.lead-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .75rem;
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: .5rem;
}

.lead-card-meta span {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.lead-card-meta svg {
    width: 12px;
    height: 12px;
}

.lead-card-actions {
    display: flex;
    gap: .4rem;
    margin-top: .85rem;
    flex-wrap: wrap;
}

/* ── 17. User Cards ────────────────────────────────────────── */
.user-card {
    background: var(--surface);
    border-radius: var(--r-md);
    box-shadow: var(--sh-xs);
    border: 1px solid var(--border);
    padding: 1.1rem;
    margin-bottom: .75rem;
    transition: box-shadow var(--t);
}

.user-card:hover {
    box-shadow: var(--sh-md);
}

/* ── 18. Filter Bar ────────────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.25rem;
    align-items: flex-end;
    background: var(--surface);
    padding: .85rem 1rem;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    box-shadow: var(--sh-xs);
}

.filter-bar .form-select,
.filter-bar .form-input {
    flex: 1;
    min-width: 110px;
    max-width: 180px;
    min-height: 40px;
    font-size: .82rem;
    padding: .5rem .85rem;
}

/* ── 19. Sticky Action Bar ─────────────────────────────────── */
.sticky-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: .85rem 1.25rem;
    display: flex;
    gap: .5rem;
    z-index: 50;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .08);
}

.sticky-actions .btn {
    flex: 1;
}

@media (min-width: 768px) {
    .sticky-actions {
        position: static;
        border-top: none;
        box-shadow: none;
        padding: 0;
        margin-top: 1rem;
        background: transparent;
    }

    .sticky-actions .btn {
        flex: none;
    }
}

/* ── 20. Timeline ──────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: .45rem;
    top: .5rem;
    bottom: .5rem;
    width: 2px;
    background: linear-gradient(to bottom, var(--primary), var(--border));
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.25rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.1rem;
    top: .4rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-date {
    font-size: .72rem;
    color: var(--text-muted);
    margin-bottom: .3rem;
    font-weight: 500;
}

.timeline-content {
    background: var(--bg);
    border-radius: var(--r-sm);
    padding: .7rem .9rem;
    font-size: .85rem;
    border: 1px solid var(--border);
}

/* ── 21. Table ─────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

th,
td {
    padding: .7rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-2);
    font-weight: 700;
    color: var(--text-muted);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f8fafc;
}

/* ── 22. Dashboard Grid ────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── 23. Status Bars ───────────────────────────────────────── */
.status-bar-row {
    margin-bottom: .65rem;
}

.status-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .25rem;
}

.status-bar-count {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 2rem;
    text-align: right;
}

.status-bar-track {
    height: 5px;
    background: var(--border);
    border-radius: var(--r-full);
    overflow: hidden;
}

.status-bar-fill {
    height: 100%;
    border-radius: var(--r-full);
    transition: width .5s var(--t-spring);
    min-width: 2px;
}

/* ── 24. Page header ───────────────────────────────────────── */
.page-header {
    margin-bottom: 1.25rem;
}

/* ── 25. Empty state ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin: 0 auto .75rem;
    opacity: .3;
}

.empty-state-text {
    font-size: .9rem;
}

/* ── 26. Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── 27. Focus ─────────────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ── Responsive Navbar ─────────────────────────────────────── */
.navbar-icon-btn {
    color: #94a3b8;
    min-width: 38px;
    min-height: 38px;
    padding: .4rem;
}

.navbar-icon-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.navbar-icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Show role badge on desktop */
@media (min-width: 640px) {
    #role-badge-desktop {
        display: inline-flex !important;
    }
}

/* Mobile: hide desktop nav links, show hamburger */
@media (max-width: 639px) {
    .navbar-links {
        display: none !important;
    }

    #mobile-menu-btn {
        display: flex !important;
    }

    .user-name {
        display: none !important;
    }

    #logout-btn .hidden-xs {
        display: none;
    }
}

/* Mobile dropdown nav */
.mobile-nav {
    background: var(--secondary-mid);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    padding: .5rem 1rem .75rem;
    position: sticky;
    top: 60px;
    z-index: 99;
    box-shadow: var(--sh-md);
}

.mobile-nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #94a3b8;
    padding: .65rem .75rem;
    border-radius: var(--r-sm);
    font-size: .88rem;
    font-weight: 500;
    transition: background var(--t), color var(--t);
    text-decoration: none;
}

.mobile-nav a svg {
    width: 16px;
    height: 16px;
}

.mobile-nav a:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.mobile-nav-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem .75rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    margin-top: .25rem;
    color: #94a3b8;
    font-size: .82rem;
}

/* Tablet: compact nav */
@media (min-width: 640px) and (max-width: 900px) {
    .navbar-links a span {
        display: none;
    }

    .navbar-links a {
        padding: .45rem .6rem;
    }

    .user-name {
        max-width: 80px;
    }
}

/* ═══════════════════════════════════════════════════════════
   NAVBAR v2 — Mobile-first, no overflow
   ═══════════════════════════════════════════════════════════ */

/* Override old navbar styles */
.navbar {
    all: unset;
    display: flex;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 200;
}

.navbar {
    background: var(--secondary);
    height: 56px;
    display: flex !important;
    align-items: center;
    padding: 0 1rem;
    gap: .5rem;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 2px 12px rgba(0, 0, 0, .2);
    overflow: hidden;
    /* CRITICAL: prevents overflow */
    width: 100%;
    box-sizing: border-box;
}

/* Brand */
.nav-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
    min-width: 0;
}

.nav-logo {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(245, 158, 11, .3);
}

.nav-logo svg {
    width: 16px;
    height: 16px;
    color: #fff;
}

.nav-brand-name {
    color: #fff;
    font-size: .95rem;
    font-weight: 800;
    letter-spacing: -.02em;
    white-space: nowrap;
    text-decoration: none;
}

/* Desktop nav links — hidden on mobile */
.nav-links {
    display: none;
    list-style: none;
    flex: 1;
    justify-content: center;
    gap: .15rem;
    margin: 0;
    padding: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: #94a3b8;
    padding: .4rem .75rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.nav-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.nav-link.active {
    background: rgba(245, 158, 11, .15);
    color: var(--primary);
}

/* Desktop right side — hidden on mobile */
.nav-right {
    display: none;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.nav-user-name {
    font-size: .78rem;
    font-weight: 500;
    color: #94a3b8;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-role-badge {
    font-size: .62rem !important;
}

.nav-icon-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.nav-icon-btn svg {
    width: 15px;
    height: 15px;
}

.nav-logout-btn {
    display: flex;
    align-items: center;
    gap: .35rem;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px;
    color: #94a3b8;
    font-size: .78rem;
    font-weight: 500;
    padding: .4rem .75rem;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
    font-family: var(--font);
}

.nav-logout-btn:hover {
    background: rgba(239, 68, 68, .15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, .3);
}

.nav-logout-btn svg {
    width: 14px;
    height: 14px;
}

/* Hamburger — visible on mobile only */
.nav-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}

.nav-hamburger:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.nav-hamburger svg {
    width: 18px;
    height: 18px;
}

/* ── Mobile Drawer ──────────────────────────────────────────── */
.nav-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(280px, 85vw);
    height: 100vh;
    background: var(--secondary-mid);
    z-index: 300;
    transition: right .28s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, .3);
    overflow-y: auto;
}

.nav-drawer.open {
    right: 0;
}

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    backdrop-filter: blur(2px);
}

.nav-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.nav-drawer-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.nav-drawer-user {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.nav-drawer-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.nav-drawer-name {
    font-size: .9rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: .2rem;
}

.nav-drawer-links {
    list-style: none;
    padding: .5rem;
    flex: 1;
}

.nav-drawer-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #94a3b8;
    padding: .75rem .85rem;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
    margin-bottom: .15rem;
}

.nav-drawer-link svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.nav-drawer-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.nav-drawer-link.active {
    background: rgba(245, 158, 11, .15);
    color: var(--primary);
}

.nav-drawer-footer {
    padding: .75rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.nav-drawer-logout {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .75rem .85rem;
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .2);
    border-radius: 8px;
    color: #fca5a5;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: background .15s;
}

.nav-drawer-logout:hover {
    background: rgba(239, 68, 68, .2);
}

.nav-drawer-logout svg {
    width: 16px;
    height: 16px;
}

/* ── Desktop breakpoint ─────────────────────────────────────── */
@media (min-width: 768px) {
    .navbar {
        padding: 0 1.5rem;
        height: 60px;
    }

    .nav-links {
        display: flex !important;
    }

    .nav-right {
        display: flex !important;
    }

    .nav-hamburger {
        display: none !important;
    }
}

/* ── User Cards v2 ─────────────────────────────────────────── */
.users-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
}

@media (min-width: 640px) {
    .users-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .users-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.user-card-v2 {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    transition: box-shadow var(--t), transform var(--t);
    box-shadow: var(--sh-xs);
}

.user-card-v2:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
}

.uc-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -.02em;
}

.uc-body {
    flex: 1;
    min-width: 0;
}

.uc-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}

.uc-name {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uc-mobile {
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: .1rem;
}

.uc-badges {
    display: flex;
    gap: .3rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.uc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem .75rem;
    margin-top: .4rem;
}

.uc-meta-item {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .73rem;
    color: var(--text-muted);
}

.uc-meta-item svg {
    flex-shrink: 0;
    opacity: .7;
}

/* ── User Card v2 FIXES (override any conflicting styles) ──── */
.users-grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: .75rem;
    margin-top: .5rem;
}

@media (min-width: 640px) {
    .users-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .users-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

.user-card-v2 {
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
    padding: 1rem !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: .85rem !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .07) !important;
    transition: box-shadow .18s, transform .18s !important;
    margin-bottom: 0 !important;
}

.user-card-v2:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, .1) !important;
    transform: translateY(-2px) !important;
}

.user-card-v2 .uc-avatar {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: .95rem !important;
    font-weight: 800 !important;
    flex-shrink: 0 !important;
    letter-spacing: -.02em !important;
}

.user-card-v2 .uc-body {
    flex: 1 !important;
    min-width: 0 !important;
    display: block !important;
}

.user-card-v2 .uc-top {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: .4rem !important;
    margin-bottom: .4rem !important;
}

.user-card-v2 .uc-name {
    font-size: .9rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 140px !important;
}

.user-card-v2 .uc-mobile {
    font-size: .74rem !important;
    color: #64748b !important;
    margin-top: .1rem !important;
}

.user-card-v2 .uc-badges {
    display: flex !important;
    gap: .25rem !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    flex-shrink: 0 !important;
}

.user-card-v2 .uc-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: .25rem .6rem !important;
    margin-top: .35rem !important;
    padding-top: .35rem !important;
    border-top: 1px solid #f1f5f9 !important;
}

.user-card-v2 .uc-meta-item {
    display: flex !important;
    align-items: center !important;
    gap: .25rem !important;
    font-size: .71rem !important;
    color: #64748b !important;
}

/* ── Lead Card v2 ──────────────────────────────────────────── */
.lc {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1rem 1.1rem;
    margin-bottom: .65rem;
    transition: box-shadow .18s, transform .18s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.lc:hover {
    box-shadow: 0 4px 18px rgba(0, 0, 0, .1);
    transform: translateY(-1px);
}

.lc-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .6rem;
}

.lc-identity {
    min-width: 0;
}

.lc-name {
    font-size: .95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.lc-phone {
    font-size: .76rem;
    color: #64748b;
    margin-top: .1rem;
}

.lc-status {
    flex-shrink: 0;
}

.lc-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem .85rem;
    margin-bottom: .55rem;
    padding: .55rem .7rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}

.lc-stat {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .76rem;
    color: #475569;
    font-weight: 500;
}

.lc-stat svg {
    opacity: .6;
    flex-shrink: 0;
}

.lc-amount {
    color: #059669 !important;
    font-weight: 700 !important;
}

.lc-amount svg {
    opacity: 1 !important;
}

.lc-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .65rem;
    flex-wrap: wrap;
}

.lc-by,
.lc-time {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    color: #94a3b8;
}

.lc-by svg,
.lc-time svg {
    opacity: .5;
}

.lc-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    padding-top: .6rem;
    border-top: 1px solid #f1f5f9;
}

.lc-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .38rem .85rem;
    border-radius: 8px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all .15s;
    text-decoration: none;
    font-family: inherit;
    min-height: 34px;
}

.lc-btn svg {
    flex-shrink: 0;
}

.lc-btn-view {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.lc-btn-view:hover {
    background: #dbeafe;
    color: #1e40af;
}

.lc-btn-edit {
    background: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}

.lc-btn-edit:hover {
    background: #dcfce7;
    color: #166534;
}

.lc-btn-assign {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.lc-btn-assign:hover {
    background: #fde68a;
    color: #78350f;
}