/* ==========================================================================
   Outreach CRM — design system
   ========================================================================== */

:root {
    /* palette */
    --brand:        #4f46e5;
    --brand-dark:   #4338ca;
    --brand-light:  #eef2ff;
    --brand-ring:   rgba(79, 70, 229, .22);

    --ink:          #0f172a;
    --ink-2:        #334155;
    --muted:        #64748b;
    --faint:        #94a3b8;

    --bg:           #f6f7fb;
    --surface:      #ffffff;
    --surface-2:    #f8fafc;
    --line:         #e2e8f0;
    --line-strong:  #cbd5e1;

    --green:        #16a34a;
    --green-bg:     #f0fdf4;
    --amber:        #d97706;
    --amber-bg:     #fffbeb;
    --red:          #dc2626;
    --red-bg:       #fef2f2;
    --blue:         #2563eb;
    --blue-bg:      #eff6ff;

    /* shape */
    --r-sm: 6px;
    --r:    10px;
    --r-lg: 14px;
    --r-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow:    0 4px 14px rgba(15, 23, 42, .08);
    --shadow-lg: 0 18px 48px rgba(15, 23, 42, .16);

    --sidebar: 244px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }

/* ---------- layout ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex: 0 0 var(--sidebar);
    background: #0d1220;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid rgba(255,255,255,.06);
}

.sidebar__brand {
    display: flex; align-items: center; gap: 11px;
    padding: 18px 16px;
    color: #fff; font-weight: 700; font-size: 15.5px;
    letter-spacing: -0.01em;
}
.sidebar__logo {
    width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: grid; place-items: center; overflow: hidden;
    box-shadow: 0 3px 10px rgba(99, 102, 241, .38);
}
.sidebar__logo img { width: 100%; height: 100%; }

.sidebar__nav { padding: 6px 10px 14px; overflow-y: auto; flex: 1; }
.sidebar__nav::-webkit-scrollbar { width: 5px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

.sidebar__label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
    color: #4b5773; padding: 16px 10px 7px; font-weight: 700;
}

.sidebar__link {
    position: relative;
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; border-radius: 9px;
    color: #a8b3c7; font-size: 13.8px; font-weight: 500;
    margin-bottom: 1px;
    transition: background .13s ease, color .13s ease;
}
.sidebar__link:hover { background: rgba(255,255,255,.055); color: #fff; text-decoration: none; }
.sidebar__link svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .8; }
.sidebar__link:hover svg { opacity: 1; }

.sidebar__link.is-active {
    background: linear-gradient(90deg, rgba(99,102,241,.20), rgba(99,102,241,.06));
    color: #fff; font-weight: 600;
}
.sidebar__link.is-active svg { opacity: 1; color: #a5b4fc; }
/* Left rail marker instead of a solid block — reads cleaner at a glance. */
.sidebar__link.is-active::before {
    content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: #818cf8;
}
.sidebar__badge {
    margin-left: auto; font-size: 10.5px; font-weight: 700;
    padding: 2px 7px; border-radius: 999px;
    background: rgba(255,255,255,.1); color: #cbd5e1;
}
.sidebar__link.is-active .sidebar__badge { background: rgba(255,255,255,.2); color: #fff; }
.sidebar__badge--alert { background: rgba(220,38,38,.9); color: #fff; }

.sidebar__foot { padding: 10px 12px 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar__user {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    border-radius: 10px; transition: background .13s ease;
}
.sidebar__user:hover { background: rgba(255,255,255,.05); }
.sidebar__user .avatar { background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; }
.sidebar__user small { display: block; color: #5b6884; font-size: 11.5px; }
.sidebar__logout { color: #5b6884; padding: 6px; border-radius: 8px; line-height: 0; }
.sidebar__logout:hover { color: #fca5a5; background: rgba(255,255,255,.06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 14px 26px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 30;
}
.topbar__title { flex: 1; min-width: 0; }
.topbar__title p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.topbar__actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

.content { padding: 24px 26px 60px; flex: 1; }
.content--narrow { max-width: 1180px; }

/* ---------- cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}
.card__head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card__head h2, .card__head h3 { flex: 1; min-width: 0; }
.card__head p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
/* A description placed directly beside the title would otherwise sit on the
   same flex row and squash it — give it its own line. */
.card__head > p { flex: 1 0 100%; margin-top: 0; }
.card__head > div { flex: 1; min-width: 0; }
.card__body { padding: 20px; }
.card__foot {
    padding: 14px 20px; border-top: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    display: flex; gap: 10px; align-items: center;
}

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat__label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat__value { font-size: 27px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: 12.5px; color: var(--faint); margin-top: 3px; }
.stat--brand .stat__value { color: var(--brand); }
.stat--green .stat__value { color: var(--green); }
.stat--amber .stat__value { color: var(--amber); }
.stat--red   .stat__value { color: var(--red); }

/* ---------- buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 15px; border-radius: var(--r);
    border: 1px solid var(--line-strong); background: var(--surface);
    color: var(--ink); font-size: 14px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: background .13s ease, border-color .13s ease, transform .05s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger:hover { background: #b91c1c; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--lg { padding: 12px 22px; font-size: 15px; }
.btn--block { width: 100%; }

/* ---------- forms ---------- */

.field { margin-bottom: 15px; }
.field label, .label {
    display: block; font-size: 13px; font-weight: 600;
    margin-bottom: 6px; color: var(--ink-2);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.req { color: var(--red); }

.input, .select, .textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--line-strong); border-radius: var(--r);
    background: var(--surface); color: var(--ink);
    font-size: 14px; font-family: inherit;
    transition: border-color .13s ease, box-shadow .13s ease;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 8l3-3.5' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
    padding-right: 30px;
}
.input.is-error, .select.is-error { border-color: var(--red); }
.input.is-ok { border-color: var(--green); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; cursor: pointer; margin-bottom: 9px; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; flex: 0 0 16px; }
.check span small { display: block; color: var(--muted); font-size: 12.5px; }

/* ---------- fieldset sections ---------- */

.section { border-top: 1px solid var(--line); padding: 20px; }
.section:first-child { border-top: 0; }
.section__title {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted); margin-bottom: 14px;
}
.section__title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left; padding: 10px 14px;
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); background: var(--surface-2);
    border-bottom: 1px solid var(--line); white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.is-selected { background: var(--brand-light); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .col-check { width: 40px; }
table.data input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

.cell-primary { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.cell-muted { color: var(--muted); }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Long scraped business names must never blow up the row height. */
.clamp-1, .clamp-2 {
    display: -webkit-box; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere;
}
.clamp-1 { -webkit-line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; }

table.data tbody tr { height: 58px; }
table.data td { max-width: 320px; }

.lead-cell { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.lead-cell .avatar { margin-top: 1px; }
.lead-cell__body { min-width: 0; flex: 1; }
.lead-cell__name {
    font-weight: 600; line-height: 1.35;
    max-width: 290px;
}
.lead-cell__name a { color: var(--ink); }
.lead-cell__name a:hover { color: var(--brand); }
.lead-cell__meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; max-width: 290px; }
.lead-cell__tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.lead-cell__tags .badge { padding: 1px 7px; font-size: 11px; }

.contact-cell { min-width: 0; max-width: 230px; }
.contact-cell a { display: block; }

.rating-cell { display: inline-flex; align-items: baseline; gap: 4px; }
.rating-cell strong { font-size: 14.5px; }
.rating-cell .star { color: #f59e0b; }
.rating-cell small { color: var(--muted); font-size: 12px; }

.row-actions { display: inline-flex; gap: 2px; opacity: .55; transition: opacity .12s ease; }
table.data tbody tr:hover .row-actions { opacity: 1; }

/* ---------- badges ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.badge--green { background: var(--green-bg); color: #15803d; border-color: #bbf7d0; }
.badge--amber { background: var(--amber-bg); color: #b45309; border-color: #fde68a; }
.badge--red   { background: var(--red-bg);   color: #b91c1c; border-color: #fecaca; }
.badge--blue  { background: var(--blue-bg);  color: #1d4ed8; border-color: #bfdbfe; }
.badge--brand { background: var(--brand-light); color: var(--brand-dark); border-color: #c7d2fe; }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--brand-light); color: var(--brand-dark);
    font-size: 12px; font-weight: 700; flex: 0 0 30px;
}
.avatar--sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 10px; }

/* ---------- alerts ---------- */

.alert {
    padding: 12px 15px; border-radius: var(--r);
    font-size: 14px; margin-bottom: 16px;
    border: 1px solid var(--line); background: var(--surface-2);
    display: flex; gap: 10px; align-items: flex-start;
}
.alert--success { background: var(--green-bg); border-color: #bbf7d0; color: #14532d; }
.alert--error   { background: var(--red-bg);   border-color: #fecaca; color: #7f1d1d; }
.alert--warn    { background: var(--amber-bg); border-color: #fde68a; color: #78350f; }
.alert--info    { background: var(--blue-bg);  border-color: #bfdbfe; color: #1e3a8a; }
.alert strong { font-weight: 700; }

/* ---------- empty state ---------- */

.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .35; margin-bottom: 12px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 auto 18px; max-width: 380px; font-size: 14px; }

/* ---------- wizard ---------- */

.wizard-steps {
    display: flex; align-items: center; gap: 6px;
    padding: 18px 22px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    margin-bottom: 22px; overflow-x: auto; box-shadow: var(--shadow-sm);
}
.wstep { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.wstep__dot {
    width: 27px; height: 27px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 12.5px; font-weight: 700;
    background: var(--surface-2); color: var(--faint);
    border: 1.5px solid var(--line-strong);
    transition: all .2s ease;
}
.wstep__text { font-size: 13.5px; font-weight: 600; color: var(--faint); white-space: nowrap; }
.wstep__line { width: 30px; height: 2px; background: var(--line); flex: 0 0 auto; border-radius: 2px; }
.wstep.is-active .wstep__dot { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 0 0 4px var(--brand-ring); }
.wstep.is-active .wstep__text { color: var(--brand); }
.wstep.is-done .wstep__dot { background: var(--green); border-color: var(--green); color: #fff; }
.wstep.is-done .wstep__text { color: var(--ink-2); }

.wizard-pane { display: none; }
.wizard-pane.is-active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- dropzone ---------- */

.dropzone {
    border: 2px dashed var(--line-strong); border-radius: var(--r-xl);
    padding: 54px 28px; text-align: center;
    background: var(--surface); cursor: pointer;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-light); }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-light); transform: scale(1.006); }
.dropzone__icon {
    width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 16px;
    background: var(--brand-light); color: var(--brand);
    display: grid; place-items: center;
}
.dropzone__icon svg { width: 28px; height: 28px; }
.dropzone h3 { font-size: 17px; margin-bottom: 6px; }
.dropzone p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.dropzone__or { display: flex; align-items: center; gap: 12px; max-width: 220px; margin: 0 auto 18px; color: var(--faint); font-size: 12px; }
.dropzone__or::before, .dropzone__or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.dropzone__types { margin-top: 18px; font-size: 12.5px; color: var(--faint); }

.file-card {
    display: flex; align-items: center; gap: 15px;
    padding: 17px 19px; border: 1px solid var(--line);
    border-radius: var(--r-lg); background: var(--surface);
}
.file-card__icon {
    width: 44px; height: 44px; border-radius: 11px; flex: 0 0 44px;
    background: var(--green-bg); color: var(--green);
    display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.file-card__meta { flex: 1; min-width: 0; }
.file-card__meta strong { display: block; font-size: 15px; }
.file-card__meta span { font-size: 13px; color: var(--muted); }
.file-facts { display: flex; gap: 26px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.file-fact__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.file-fact__value { font-size: 19px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ---------- mapping ---------- */

.map-toolbar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    padding: 13px 18px; background: var(--surface-2);
    border: 1px solid var(--line); border-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.map-toolbar__count { font-size: 13px; color: var(--muted); margin-left: auto; }

table.mapping { width: 100%; border-collapse: collapse; }
table.mapping th {
    text-align: left; padding: 10px 16px; background: var(--surface-2);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line);
}
table.mapping td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.mapping tr.is-skipped { background: repeating-linear-gradient(45deg, transparent, transparent 9px, rgba(148,163,184,.05) 9px, rgba(148,163,184,.05) 18px); }
table.mapping tr.is-skipped .map-source strong { color: var(--faint); text-decoration: line-through; }

.map-source strong { display: block; font-size: 14px; font-weight: 650; }
.map-samples { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.map-samples code {
    background: var(--surface-2); border: 1px solid var(--line);
    padding: 1px 5px; border-radius: 4px; font-size: 11.5px;
    max-width: 210px; display: inline-block; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
.map-arrow { color: var(--line-strong); text-align: center; width: 34px; }
.map-target { min-width: 250px; }
.map-confidence { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.conf-bar { width: 46px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; flex: 0 0 46px; }
.conf-bar span { display: block; height: 100%; border-radius: 2px; background: var(--green); }
.conf-bar.is-mid span { background: var(--amber); }
.conf-bar.is-low span { background: var(--line-strong); }

/* ---------- preview ---------- */

.preview-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.preview-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--green { background: var(--green); }
.dot--amber { background: var(--amber); }
.dot--red { background: var(--red); }

table.preview td.status-cell { white-space: nowrap; }
table.preview tr.row-duplicate { background: var(--amber-bg); }
table.preview tr.row-invalid { background: var(--red-bg); }

/* ---------- progress ---------- */

.progress { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress__bar {
    height: 100%; border-radius: 999px; width: 0;
    background: linear-gradient(90deg, var(--brand), #8b5cf6);
    transition: width .28s ease;
}
.progress--lg { height: 13px; }

.run-status { text-align: center; padding: 34px 20px; }
.run-status__num { font-size: 40px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.run-status__label { color: var(--muted); font-size: 14px; margin-top: 4px; }

.spinner {
    width: 17px; height: 17px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
    animation: spin .7s linear infinite; display: inline-block;
}
.spinner--dark { border-color: var(--line-strong); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- summary ---------- */

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.summary-cell { background: var(--surface); padding: 16px 18px; }
.summary-cell__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.summary-cell__value { font-size: 25px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }

/* ---------- filters ---------- */

.filter-bar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    padding: 13px 16px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    margin-bottom: 14px;
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 132px; }
.filter-bar .search { flex: 1; min-width: 210px; }
.filter-panel { padding: 16px; border-top: 1px solid var(--line); display: none; }
.filter-panel.is-open { display: block; }
.filter-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 9px; border-radius: 999px;
    background: var(--brand-light); color: var(--brand-dark);
    font-size: 12.5px; font-weight: 600; border: 1px solid #c7d2fe;
}
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; opacity: .7; }
.chip button:hover { opacity: 1; }

/* ---------- bulk bar ---------- */

.bulk-bar {
    position: sticky; bottom: 18px; z-index: 25;
    display: none; align-items: center; gap: 12px; flex-wrap: wrap;
    margin: 14px auto 0; padding: 12px 16px; width: fit-content; max-width: 100%;
    background: #111827; color: #fff;
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.bulk-bar.is-visible { display: flex; }
.bulk-bar__count { font-weight: 650; font-size: 14px; }
.bulk-bar .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.16); color: #fff; }
.bulk-bar .btn:hover { background: rgba(255,255,255,.22); }
.bulk-bar .btn--danger { background: var(--red); border-color: var(--red); }
.bulk-bar__sep { width: 1px; height: 22px; background: rgba(255,255,255,.18); }

.select-all-note {
    padding: 9px 14px; background: var(--brand-light); border: 1px solid #c7d2fe;
    border-radius: var(--r); font-size: 13.5px; text-align: center; margin-bottom: 12px;
}
.select-all-note button { background: none; border: 0; color: var(--brand-dark); font-weight: 700; cursor: pointer; text-decoration: underline; font-size: 13.5px; }

/* ---------- pagination ---------- */

.pagination { display: flex; align-items: center; gap: 7px; padding: 14px 18px; flex-wrap: wrap; }
.pagination__info { color: var(--muted); font-size: 13.5px; margin-right: auto; }
.pagination a, .pagination span.page {
    min-width: 33px; height: 33px; padding: 0 9px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    font-size: 13.5px; font-weight: 600; color: var(--ink-2); background: var(--surface);
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .is-disabled { opacity: .4; pointer-events: none; }

/* ---------- modal ---------- */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 23, 42, .55);
    display: none; align-items: flex-start; justify-content: center;
    padding: 44px 18px; overflow-y: auto;
    backdrop-filter: blur(2px);
}
.modal-backdrop.is-open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--r-xl);
    width: min(620px, 100%); box-shadow: var(--shadow-lg);
    animation: pop .18s ease;
}
.modal--wide { width: min(940px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal__head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal__head h2 { flex: 1; }
.modal__close { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal__close:hover { color: var(--ink); }
.modal__body { padding: 22px; }
.modal__foot { padding: 15px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }

/* ---------- toast ---------- */

.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
    padding: 12px 16px; border-radius: var(--r); background: var(--ink); color: #fff;
    font-size: 14px; box-shadow: var(--shadow-lg); min-width: 240px; max-width: 380px;
    animation: slide .22s ease; display: flex; gap: 9px; align-items: flex-start;
}
.toast--success { background: #15803d; }
.toast--error { background: #b91c1c; }
.toast--warn { background: #b45309; }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------- detail view ---------- */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 22px; }
.detail-item__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.detail-item__value { font-size: 14.5px; word-break: break-word; }
.detail-item__value.is-empty { color: var(--faint); }

.lead-hero { display: flex; gap: 16px; align-items: flex-start; }
.lead-hero .avatar { width: 54px; height: 54px; flex-basis: 54px; font-size: 19px; }
.lead-hero h1 { font-size: 21px; }
.lead-hero__meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }

.raw-json {
    background: #0f172a; color: #cbd5e1; padding: 15px; border-radius: var(--r);
    font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-x: auto; max-height: 380px; margin: 0;
}

/* ---------- misc ---------- */

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.ml-auto { margin-left: auto; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ==========================================================================
   Auth screen
   ========================================================================== */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

.auth__brand {
    position: relative; overflow: hidden;
    background: linear-gradient(150deg, #312e81 0%, #4f46e5 45%, #7c3aed 100%);
    color: #fff; padding: 56px 60px;
    display: flex; flex-direction: column;
}
/* Soft light blooms so the panel is not a flat rectangle of colour. */
.auth__brand::before,
.auth__brand::after {
    content: ""; position: absolute; border-radius: 50%; pointer-events: none;
}
.auth__brand::before {
    width: 520px; height: 520px; right: -190px; top: -160px;
    background: radial-gradient(circle, rgba(255,255,255,.16), transparent 68%);
}
.auth__brand::after {
    width: 420px; height: 420px; left: -140px; bottom: -160px;
    background: radial-gradient(circle, rgba(168,85,247,.34), transparent 70%);
}
.auth__brand > * { position: relative; z-index: 1; }

.auth__logo { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 700; }
.auth__logo img { width: 40px; height: 40px; border-radius: 12px; }

.auth__pitch { margin: auto 0; max-width: 460px; }
.auth__pitch h1 { font-size: 38px; line-height: 1.15; letter-spacing: -0.028em; margin-bottom: 16px; }
.auth__pitch p { font-size: 16px; line-height: 1.65; color: rgba(255,255,255,.82); margin: 0 0 30px; }

.auth__features { display: grid; gap: 14px; }
.auth__feature { display: flex; gap: 13px; align-items: flex-start; }
.auth__feature-icon {
    width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
    background: rgba(255,255,255,.14); display: grid; place-items: center;
    backdrop-filter: blur(4px);
}
.auth__feature-icon svg { width: 17px; height: 17px; }
.auth__feature strong { display: block; font-size: 14.5px; font-weight: 650; }
.auth__feature span { font-size: 13.5px; color: rgba(255,255,255,.72); line-height: 1.5; }

.auth__metrics {
    display: flex; gap: 34px; margin-top: 40px; padding-top: 26px;
    border-top: 1px solid rgba(255,255,255,.16);
}
.auth__metric b { display: block; font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.auth__metric span { font-size: 12.5px; color: rgba(255,255,255,.68); }

.auth__form {
    display: flex; align-items: center; justify-content: center;
    padding: 48px 40px; background: var(--surface);
}
.auth__card { width: min(400px, 100%); }
.auth__card h2 { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth__card > p { color: var(--muted); margin: 0 0 28px; font-size: 14.5px; }

.auth__field { margin-bottom: 17px; position: relative; }
.auth__field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--ink-2); }
.auth__field .input { padding: 12px 14px; font-size: 15px; }
.auth__field .input:focus { box-shadow: 0 0 0 4px var(--brand-ring); }

.auth__toggle {
    position: absolute; right: 10px; top: 33px;
    border: 0; background: none; color: var(--faint);
    cursor: pointer; padding: 5px; border-radius: 6px; line-height: 0;
}
.auth__toggle:hover { color: var(--ink-2); background: var(--surface-2); }

.auth__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.auth__foot { margin-top: 26px; text-align: center; font-size: 13px; color: var(--faint); }

@media (max-width: 980px) {
    .auth { grid-template-columns: 1fr; }
    .auth__brand { padding: 34px 26px; }
    .auth__pitch h1 { font-size: 27px; }
    .auth__pitch p { margin-bottom: 20px; }
    .auth__features, .auth__metrics { display: none; }
    .auth__form { padding: 34px 22px 54px; }
}

/* ==========================================================================
   Dashboard hero
   ========================================================================== */

.hero { margin-bottom: 22px; }
.hero__greeting {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    font-size: 27px; font-weight: 700; letter-spacing: -0.025em;
}
.hero__wave { font-size: 25px; }
.hero__meta { color: var(--muted); font-size: 14px; margin-top: 6px; }

.attention {
    display: inline-flex; align-items: center; gap: 9px; flex-wrap: wrap;
    margin-top: 12px; padding: 8px 14px; border-radius: 999px;
    background: var(--amber-bg); border: 1px solid #fde68a;
    color: #92400e; font-size: 13.5px; font-weight: 600;
}
.attention--info { background: var(--blue-bg); border-color: #bfdbfe; color: #1e40af; }
.attention--good { background: var(--green-bg); border-color: #bbf7d0; color: #15803d; }
.attention a { color: inherit; text-decoration: underline; font-weight: 700; }

/* ---------- metric cards ---------- */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 16px; margin-bottom: 22px; }

.metric {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 18px 20px;
    display: flex; flex-direction: column; gap: 14px;
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.metric:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--line-strong); }
.metric__top { display: flex; align-items: flex-start; gap: 13px; }
.metric__icon {
    width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
    display: grid; place-items: center;
}
.metric__icon svg { width: 20px; height: 20px; }
.metric__icon--brand { background: var(--brand-light); color: var(--brand); }
.metric__icon--green { background: var(--green-bg); color: var(--green); }
.metric__icon--amber { background: var(--amber-bg); color: var(--amber); }
.metric__icon--red   { background: var(--red-bg);   color: var(--red); }
.metric__icon--blue  { background: var(--blue-bg);  color: var(--blue); }

.metric__value { font-size: 29px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric__label { font-size: 13px; color: var(--muted); margin-top: 3px; font-weight: 500; }
.metric__foot {
    margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line);
    display: flex; align-items: center; font-size: 13px; font-weight: 600;
}
.metric__foot a { display: inline-flex; align-items: center; gap: 5px; }
.metric__foot a:hover { text-decoration: none; gap: 8px; }
.metric__trend { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.metric__trend.is-up { color: var(--green); }
.metric__trend.is-down { color: var(--red); }

/* ---------- panel with range chips ---------- */

.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { flex: 1; min-width: 0; font-size: 16px; }
.range-chips { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.range-chip {
    padding: 5px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
    color: var(--muted); border: 0; background: none; cursor: pointer;
}
.range-chip:hover { color: var(--ink); }
.range-chip.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.panel-link { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }

/* ---------- quick actions rail ---------- */

.quick-action {
    display: flex; align-items: center; gap: 13px;
    padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r);
    margin-bottom: 9px; background: var(--surface); transition: all .14s ease;
}
.quick-action:hover {
    text-decoration: none; border-color: var(--brand);
    background: var(--brand-light); transform: translateX(2px);
}
.quick-action__icon {
    width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
    background: var(--brand-light); color: var(--brand);
    display: grid; place-items: center;
}
.quick-action__icon svg { width: 17px; height: 17px; }
.quick-action strong { display: block; font-size: 14px; color: var(--ink); }
.quick-action span { font-size: 12.5px; color: var(--muted); }
.quick-action__arrow { margin-left: auto; color: var(--faint); }

/* ---------- setup checklist ---------- */

.checklist-item { display: flex; align-items: flex-start; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist-item:last-child { border-bottom: 0; }
.checklist-tick {
    width: 21px; height: 21px; border-radius: 50%; flex: 0 0 21px;
    display: grid; place-items: center; font-size: 11px; font-weight: 700;
    border: 1.5px solid var(--line-strong); color: var(--faint);
}
.checklist-item.is-done .checklist-tick { background: var(--green); border-color: var(--green); color: #fff; }
.checklist-item.is-done strong { color: var(--muted); text-decoration: line-through; }
.checklist-item strong { display: block; font-size: 13.5px; }
.checklist-item span { font-size: 12.5px; color: var(--muted); }

/* ---------- lead form ---------- */

.lead-form { max-width: 680px; }
.lead-form .card__body { padding: 24px; }
.input--lg { padding: 12px 14px; font-size: 16px; }

.more-fields {
    max-width: 680px;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface); margin-top: 18px;
}
.more-fields[open] { background: transparent; border-color: transparent; }
.more-fields > summary {
    display: flex; align-items: center; gap: 10px;
    padding: 15px 20px; cursor: pointer; list-style: none;
    border-radius: var(--r-lg);
}
.more-fields > summary::-webkit-details-marker { display: none; }
.more-fields[open] > summary {
    background: var(--surface); border: 1px solid var(--line);
    margin: -1px;                      /* keep the outline aligned when open */
}
.more-fields > summary:hover { background: var(--surface-2); }
.more-fields__title { font-weight: 650; font-size: 14.5px; }
.more-fields__hint { font-size: 13px; color: var(--muted); }
.more-fields__chevron { margin-left: auto; color: var(--faint); transition: transform .18s ease; }
.more-fields[open] .more-fields__chevron { transform: rotate(180deg); }
.more-fields .card { max-width: 680px; }

.form-footnote {
    max-width: 680px; margin-top: 18px;
    font-size: 13.5px; color: var(--muted); text-align: center;
}

/* ---------- tabs (page level) ---------- */

.page-tabs {
    display: flex; gap: 4px; margin-bottom: 20px; overflow-x: auto;
    border-bottom: 1px solid var(--line);
}
.page-tab {
    display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
    padding: 11px 16px; border: 0; background: none; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.page-tab:hover { color: var(--ink); }
.page-tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.page-tab svg { width: 16px; height: 16px; }
.page-tab__badge {
    font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted);
}
.page-tab.is-active .page-tab__badge { background: var(--brand-light); color: var(--brand-dark); }

.tab-pane { display: none; }
.tab-pane.is-active { display: block; animation: fade .18s ease; }

/* ---------- status strip ---------- */

.status-strip {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 14px 18px; border-radius: var(--r-lg);
    border: 1px solid var(--line); background: var(--surface);
    margin-bottom: 20px;
}
.status-strip__dot {
    width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px;
    background: var(--green); box-shadow: 0 0 0 4px rgba(22,163,74,.14);
}
.status-strip__dot--off { background: var(--faint); box-shadow: 0 0 0 4px rgba(148,163,184,.16); }
.status-strip strong { font-size: 14.5px; }
.status-strip__meta { font-size: 13px; color: var(--muted); }
.status-strip code {
    background: var(--surface-2); border: 1px solid var(--line);
    padding: 2px 8px; border-radius: 6px; font-size: 12.5px;
}

/* ---------- compose ---------- */

.compose-lead {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: var(--r);
    background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 16px;
}
.compose-lead__body { min-width: 0; flex: 1; }
.compose-lead strong { display: block; font-size: 14px; }
.compose-lead span { font-size: 13px; color: var(--muted); }
.compose-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.compose-tracking {
    display: flex; align-items: center; gap: 8px; font-size: 12.5px;
    color: var(--muted); margin-top: 10px;
}
.compose-tracking svg { width: 14px; height: 14px; color: var(--green); }

/* ---------- charts ---------- */

.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.chart-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 18px; }
.chart-host { width: 100%; min-height: 60px; }
.chart-svg { display: block; overflow: visible; }
.chart-grid-line, .chart-grid { }
.chart-svg .chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { font-size: 11px; fill: var(--faint); font-family: inherit; }
.chart-bar { transition: opacity .12s ease; }
.chart-bar:hover, .chart-arc:hover { opacity: .82; cursor: pointer; }
.chart-hover { cursor: crosshair; }
.chart-empty { padding: 34px 12px; text-align: center; color: var(--faint); font-size: 13.5px; }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.chart-legend b { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }
.chart-legend--stack { flex-direction: column; gap: 8px; margin-top: 0; }

.chart-donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.chart-donut__value { font-size: 21px; font-weight: 700; fill: var(--ink); }
.chart-donut__label { font-size: 11px; fill: var(--muted); }

.chart-tooltip {
    position: fixed; z-index: 300; display: none; pointer-events: none;
    background: #111827; color: #fff; border-radius: 8px; padding: 9px 11px;
    font-size: 12.5px; box-shadow: var(--shadow-lg); min-width: 130px;
}
.chart-tooltip__row { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.chart-tooltip__row i { width: 8px; height: 8px; border-radius: 2px; }
.chart-tooltip__row b { margin-left: auto; font-variant-numeric: tabular-nums; }

.sparkline { display: block; margin-top: 6px; }

/* ---------- funnel ---------- */

.funnel-step { margin-bottom: 18px; }
.funnel-step:last-child { margin-bottom: 0; }
.funnel-step__head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.funnel-step__label { font-size: 13.5px; font-weight: 600; }
.funnel-step__value { margin-left: auto; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.funnel-step__bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.funnel-step__bar div { height: 100%; border-radius: 999px; transition: width .5s ease; }
.funnel-step__meta { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- AI insights ---------- */

.insight-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; }
.insight-headline { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.5; }
.insight-section { margin-bottom: 20px; }
.insight-section h4 {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); margin: 0 0 10px; font-weight: 700;
}
.insight-item {
    padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r);
    margin-bottom: 8px; background: var(--surface-2);
}
.insight-item__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.insight-item__meta { font-size: 13px; color: var(--muted); margin-top: 4px; display: block; }
.insight-actions { margin: 0; padding-left: 20px; }
.insight-actions li { margin-bottom: 10px; }
.insight-wins { margin: 0; padding-left: 20px; color: var(--ink-2); }
.insight-wins li { margin-bottom: 6px; }

/* ---------- tabs ---------- */

.tab-filters {
    display: flex; gap: 4px; overflow-x: auto; padding: 4px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.tab {
    display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
    padding: 8px 14px; border-radius: var(--r); font-size: 13.5px; font-weight: 600;
    color: var(--ink-2);
}
.tab:hover { background: var(--surface-2); text-decoration: none; }
.tab.is-active { background: var(--brand); color: #fff; }
.tab__count {
    font-size: 11.5px; padding: 1px 7px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.tab.is-active .tab__count { background: rgba(255,255,255,.22); color: #fff; }

tr.row-error td { background: var(--red-bg); color: #7f1d1d; padding-top: 4px; padding-bottom: 8px; }
td.cell-danger { color: var(--red); font-weight: 600; }

/* ---------- model failover chain ---------- */

.chain-list { list-style: none; margin: 0; padding: 0; }
.chain-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface-2); margin-bottom: 6px; cursor: grab; font-size: 13.5px;
}
.chain-item:active { cursor: grabbing; }
.chain-item.is-dragging { opacity: .45; }
.chain-item__order {
    width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px;
    display: grid; place-items: center; background: var(--brand-light);
    color: var(--brand-dark); font-size: 11.5px; font-weight: 700;
}
.chain-item__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain-item__remove {
    border: 0; background: none; color: var(--muted); font-size: 18px;
    line-height: 1; cursor: pointer; padding: 0 4px;
}
.chain-item__remove:hover { color: var(--red); }
.chain-empty {
    padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--r);
    color: var(--muted); font-size: 13px; text-align: center;
}

/* ---------- PWA chrome ---------- */

.offline-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    background: var(--amber); color: #fff; text-align: center;
    padding: 9px 14px; font-size: 13.5px; font-weight: 600;
}
.pwa-banner {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 160;
    display: flex; align-items: center; gap: 12px;
    background: #111827; color: #fff; padding: 11px 15px;
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg); font-size: 14px;
}
body.is-offline .btn--primary { opacity: .65; }

.mobile-nav { display: none; }

/* ---------- responsive ---------- */

@media (max-width: 1200px) {
    .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1080px) {
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar {
        position: fixed; left: 0; top: 0; transform: translateX(-100%);
        z-index: 60; transition: transform .22s ease; box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: none; }
    .content, .topbar { padding-left: 14px; padding-right: 14px; }
    .content { padding-bottom: 84px; }          /* clear the bottom bar */
    .menu-toggle { display: inline-flex !important; }

    .topbar { flex-wrap: wrap; gap: 10px; }
    .topbar__title h1 { font-size: 19px; }
    .topbar__actions { width: 100%; }
    .topbar__actions .btn { flex: 1; justify-content: center; }

    .wizard-steps { padding: 12px; }
    .wstep__text { display: none; }
    .wstep__line { width: 14px; }

    .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat { padding: 13px 14px; }
    .stat__value { font-size: 22px; }

    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }

    /* Wide tables become stacked cards, so nothing is cut off. */
    table.data.stack-on-mobile thead { display: none; }
    table.data.stack-on-mobile tbody tr {
        display: block; height: auto; padding: 12px 14px;
        border-bottom: 1px solid var(--line);
    }
    table.data.stack-on-mobile td {
        display: flex; align-items: flex-start; gap: 12px;
        padding: 4px 0; border: 0; max-width: none;
    }
    table.data.stack-on-mobile td::before {
        content: attr(data-label); flex: 0 0 96px;
        font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
        color: var(--muted); font-weight: 700; padding-top: 2px;
    }
    table.data.stack-on-mobile td:empty { display: none; }
    table.data.stack-on-mobile .col-check { position: absolute; right: 18px; }
    table.data.stack-on-mobile .truncate,
    table.data.stack-on-mobile .lead-cell__name,
    table.data.stack-on-mobile .lead-cell__meta { max-width: none !important; }

    .bulk-bar { bottom: 76px; width: calc(100% - 24px); justify-content: center; }
    .modal-backdrop { padding: 16px; align-items: flex-end; }
    .modal { border-radius: var(--r-xl) var(--r-xl) 0 0; }

    .mobile-nav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
        display: flex; background: var(--surface);
        border-top: 1px solid var(--line);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 12px rgba(15,23,42,.06);
    }
    .mobile-nav__item {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
        padding: 7px 2px; border-radius: var(--r); color: var(--muted);
        font-size: 10.5px; font-weight: 600;
    }
    .mobile-nav__item svg { width: 20px; height: 20px; }
    .mobile-nav__item.is-active { color: var(--brand); background: var(--brand-light); }
    .mobile-nav__item:hover { text-decoration: none; }

    .chart-donut { justify-content: center; }
    .filter-bar { padding: 10px; }
    .filter-bar .input, .filter-bar .select { width: 100%; min-width: 0; }
    .filter-bar .search { min-width: 0; }
}

@media (max-width: 520px) {
    .stats { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: 1fr; }
    .pagination { justify-content: center; }
    .pagination__info { width: 100%; text-align: center; margin-bottom: 6px; }
}

@media print {
    .sidebar, .topbar__actions, .bulk-bar, .filter-bar, .mobile-nav { display: none !important; }
}
