/* ==========================================================================
   Outreach — design system
   Tokens, layout, and components. Light and dark themes.
   ========================================================================== */

/* --- Tokens ------------------------------------------------------------- */
:root {
    --bg:            #f6f7f9;
    --surface:       #ffffff;
    --surface-2:     #fafbfc;
    --surface-3:     #f1f3f5;
    --border:        #e4e7ec;
    --border-strong: #d0d5dd;

    --text:          #101828;
    --text-muted:    #667085;
    --text-subtle:   #98a2b3;

    --primary:       #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft:  #eef2ff;
    --primary-text:  #3730a3;

    --success:       #059669;
    --success-soft:  #ecfdf5;
    --success-text:  #047857;

    --warning:       #d97706;
    --warning-soft:  #fffbeb;
    --warning-text:  #b45309;

    --danger:        #dc2626;
    --danger-soft:   #fef2f2;
    --danger-text:   #b91c1c;

    --info:          #0891b2;
    --info-soft:     #ecfeff;
    --info-text:     #0e7490;

    --radius-sm: 5px;
    --radius:    8px;
    --radius-lg: 12px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 4px 8px rgba(16, 24, 40, .06);

    /* Categorical ramp for charts, legends and heat scales */
    --c1: #8b5cf6;  /* violet */
    --c2: #06b6d4;  /* cyan   */
    --c3: #22c55e;  /* green  */
    --c4: #f59e0b;  /* amber  */
    --c5: #ef4444;  /* red    */
    --c6: #ec4899;  /* pink   */
    --c7: #3b82f6;  /* blue   */
    --c8: #14b8a6;  /* teal   */

    --sidebar-w: 212px;
    --header-h:  54px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
    --bg:            #09090b;
    --surface:       #101012;
    --surface-2:     #151518;
    --surface-3:     #1c1c20;
    --border:        #232327;
    --border-strong: #2f2f35;

    --text:          #ededf0;
    --text-muted:    #8b8b93;
    --text-subtle:   #62626b;

    --primary:       #7c73f0;
    --primary-hover: #8f87f5;
    --primary-soft:  #1e1b4b;
    --primary-text:  #c7d2fe;

    --success:       #3fb950;
    --success-soft:  #0d2818;
    --success-text:  #7ee2a8;

    --warning:       #d29922;
    --warning-soft:  #2b1f0a;
    --warning-text:  #f0c674;

    --danger:        #f85149;
    --danger-soft:   #2d1315;
    --danger-text:   #ff9b95;

    --info:          #39c0d6;
    --info-soft:     #0a2429;
    --info-text:     #7fdbe8;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
}

/* --- Reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute only sets display:none at the UA level, so any
   component that declares its own display would otherwise ignore it —
   which would leave modals and drawers visible on page load. */
[hidden] { display: none !important; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
p  { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

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

img, svg { vertical-align: middle; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

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

/* --- Scrollbars --------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: content-box; }

/* ==========================================================================
   Layout
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

/* --- Sidebar ------------------------------------------------------------ */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 40;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 9px;
    height: var(--header-h);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar__logo {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}

.sidebar__name { font-weight: 650; font-size: 14.5px; letter-spacing: -.02em; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.sidebar__label {
    padding: 14px 8px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-subtle);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 8px;
    margin-bottom: 1px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12.5px;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav-item.is-active .nav-item__icon { color: var(--primary); }

.nav-item__icon { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-subtle); }
.nav-item__badge {
    margin-left: auto;
    min-width: 19px; height: 19px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--primary);
    color: #fff;
    font-size: 11px; font-weight: 600;
    display: grid; place-items: center;
}

.sidebar__footer { border-top: 1px solid var(--border); padding: 10px; flex-shrink: 0; }

.user-chip {
    display: flex; align-items: center; gap: 9px;
    width: 100%;
    padding: 7px 8px;
    border: 0; border-radius: var(--radius);
    background: none; cursor: pointer;
    text-align: left;
}
.user-chip:hover { background: var(--surface-3); }

.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-size: 11px; font-weight: 600;
    flex-shrink: 0;
}
.avatar--lg { width: 40px; height: 40px; font-size: 14px; }

.user-chip__meta { min-width: 0; flex: 1; }
.user-chip__name { font-size: 13px; font-weight: 600; }
.user-chip__role { font-size: 11.5px; color: var(--text-subtle); }

/* --- Main --------------------------------------------------------------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;            /* lets children shrink instead of overflowing */
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--header-h);
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}

/* The title yields space to the search bar rather than crowding it out */
.topbar__lead { flex: 0 1 auto; min-width: 0; max-width: 42%; }
.topbar__title { font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.topbar__sub { font-size: 12.5px; color: var(--text-muted); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { flex: 1; padding: 16px; min-width: 0; }
.content--flush { padding: 0; }

.container { max-width: 1480px; margin: 0 auto; min-width: 0; }
.container--narrow { max-width: 780px; }
.container--form   { max-width: 980px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13.5px; font-weight: 550;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--primary-hover); color: #fff; }

.btn--default { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn--default:hover { background: var(--surface-3); }

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-text); color: #fff; }

.btn--danger-soft { background: var(--danger-soft); color: var(--danger-text); border-color: transparent; }
.btn--danger-soft:hover { background: var(--danger); color: #fff; }

.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: var(--success-text); color: #fff; }

.btn--sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn--sm svg { width: 13px; height: 13px; }
.btn--lg { height: 40px; padding: 0 18px; font-size: 14.5px; }
.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 28px; }
.btn--block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}

.card__header {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
}
.card__title { font-size: 13px; font-weight: 620; letter-spacing: -.01em; }
.card__sub { font-size: 11px; color: var(--text-subtle); margin-top: 1px; }
.card__actions { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.card__body { padding: 14px; }
.card__body--flush { padding: 0; }
.card__footer {
    padding: 11px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   Stats
   ========================================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 15px 17px;
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
.stat__label {
    font-size: 12px; font-weight: 550;
    color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
}
.stat__value {
    font-size: 25px; font-weight: 670;
    letter-spacing: -.03em;
    margin-top: 5px;
    font-variant-numeric: tabular-nums;
}
.stat__meta { font-size: 12px; color: var(--text-subtle); margin-top: 3px; }
.stat__delta { font-size: 12px; font-weight: 600; }
.stat__delta--up { color: var(--success); }
.stat__delta--down { color: var(--danger); }

/* ==========================================================================
   Tables — fixed layout, truncating cells, never horizontally scrolling
   ========================================================================== */
.table-wrap { width: 100%; min-width: 0; }

.table {
    width: 100%;
    table-layout: fixed;          /* the key to predictable, non-scrolling columns */
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

.table th, .table td {
    padding: 7px 10px;
    text-align: left;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;          /* every cell is one line */
    border-bottom: 1px solid var(--border);
}

.table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface-2);
    font-size: 10px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-subtle);
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--primary-soft); }
.table tbody tr:last-child td { border-bottom: 0; }

.table--clickable tbody tr { cursor: pointer; }

/* Column sizing helpers — widths are declared per table in <colgroup> */
.col-check   { width: 38px; }
.col-actions { width: 44px; }
.col-num     { width: 74px; text-align: right; }
.table .num  { text-align: right; font-variant-numeric: tabular-nums; padding-left: 8px; padding-right: 10px; }
.table .center { text-align: center; }

/* Sortable headers */
.th-sort {
    display: inline-flex; align-items: center; gap: 4px;
    color: inherit; text-decoration: none;
}
.th-sort:hover { color: var(--text); text-decoration: none; }
.th-sort__arrow { opacity: .35; width: 11px; height: 11px; }
.th-sort.is-active { color: var(--text); }
.th-sort.is-active .th-sort__arrow { opacity: 1; color: var(--primary); }

/* A two-line identity cell that still respects the fixed layout */
.cell-stack { min-width: 0; }
.cell-stack__top {
    font-weight: 560;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-stack__sub {
    font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cell-person { display: flex; align-items: center; gap: 9px; min-width: 0; }

.empty-cell { color: var(--text-subtle); }

/* ==========================================================================
   Badges, pills, dots
   ========================================================================== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 21px; padding: 0 7px;
    border-radius: 5px;
    font-size: 11.5px; font-weight: 580;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden; text-overflow: ellipsis;
}
.badge--muted   { background: var(--surface-3); color: var(--text-muted); }
.badge--primary { background: var(--primary-soft); color: var(--primary-text); }
.badge--success { background: var(--success-soft); color: var(--success-text); }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge--info    { background: var(--info-soft);    color: var(--info-text); }
.badge--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }
.badge__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: currentColor; }
.dot--pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ==========================================================================
   Filter bar
   ========================================================================== */
.toolbar {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}
.toolbar__spacer { margin-left: auto; }

.search {
    position: relative;
    flex: 1 1 220px;
    max-width: 340px;
    min-width: 160px;
}
.search__icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--text-subtle); pointer-events: none;
}
.search input { padding-left: 31px; }

.chip-row { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    height: 28px; padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12.5px; font-weight: 530;
    cursor: pointer;
    white-space: nowrap;
    transition: all .12s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip__count {
    font-size: 11px;
    padding: 0 5px; height: 16px;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--text-muted);
    display: grid; place-items: center;
    font-variant-numeric: tabular-nums;
}
.chip.is-active .chip__count { background: rgba(255,255,255,.25); color: #fff; }

/* Bulk-action bar that slides in when rows are selected */
.bulkbar {
    display: none;
    align-items: center; gap: 10px;
    padding: 9px 16px;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    flex-wrap: wrap;
}
.bulkbar.is-visible { display: flex; }
.bulkbar__count { font-weight: 600; color: var(--primary-text); }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { margin-bottom: 15px; min-width: 0; }
.field:last-child { margin-bottom: 0; }

.label {
    display: block;
    font-size: 13px; font-weight: 550;
    margin-bottom: 5px;
}
.label__hint { font-weight: 400; color: var(--text-subtle); font-size: 12px; }

.input, .select, .textarea {
    width: 100%;
    height: 36px;
    padding: 0 11px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13.5px;
    color: var(--text);
    transition: border-color .12s, box-shadow .12s;
    box-shadow: var(--shadow-xs);
}
.textarea { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.6; }

.input:hover, .select:hover, .textarea:hover { border-color: var(--text-subtle); }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }

.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent); }

.select {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23667085' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 15px;
}
[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239198a1' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}

.input--sm, .select--sm { height: 30px; font-size: 12.5px; padding: 0 9px; }
.select--sm { padding-right: 26px; background-size: 13px; }

.field__error { color: var(--danger); font-size: 12.5px; margin-top: 4px; }
.field__help  { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 15px;
}
.field-row--2 { grid-template-columns: 1fr 1fr; }
.field-row--3 { grid-template-columns: repeat(3, 1fr); }

/* Checkbox / radio */
.check {
    display: flex; align-items: flex-start; gap: 9px;
    cursor: pointer;
    min-width: 0;
}
.check input[type="checkbox"], .check input[type="radio"] {
    appearance: none;
    width: 16px; height: 16px;
    margin: 1px 0 0;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    flex-shrink: 0;
    transition: all .12s;
    position: relative;
}
.check input[type="radio"] { border-radius: 50%; }

.check input:checked {
    background: var(--primary);
    border-color: var(--primary);
}
.check input[type="checkbox"]:checked::after {
    content: "";
    position: absolute; left: 4.5px; top: 1.5px;
    width: 4px; height: 8px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(43deg);
}
.check input[type="radio"]:checked::after {
    content: "";
    position: absolute; inset: 3.5px;
    border-radius: 50%; background: #fff;
}
.check input:indeterminate { background: var(--primary); border-color: var(--primary); }
.check input:indeterminate::after {
    content: "";
    position: absolute; left: 3px; top: 6px;
    width: 8px; height: 2px; background: #fff; border-radius: 1px;
}

.check__text { font-size: 13.5px; min-width: 0; }
.check__title { font-weight: 550; }
.check__desc { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

/* Toggle switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    width: 36px; height: 20px;
    border-radius: 99px;
    background: var(--border-strong);
    position: relative;
    transition: background .15s;
    flex-shrink: 0;
}
.switch__track::after {
    content: "";
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px;
    border-radius: 50%; background: #fff;
    transition: transform .15s;
    box-shadow: var(--shadow-xs);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Segmented control */
.segmented {
    display: inline-flex;
    padding: 2px;
    background: var(--surface-3);
    border-radius: var(--radius);
}
.segmented__item {
    padding: 5px 11px;
    border: 0; border-radius: var(--radius-sm);
    background: none;
    font-size: 12.5px; font-weight: 550;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* Fieldset-style grouping inside forms */
.form-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: 0; padding-bottom: 0; }
.form-section__title { font-size: 14px; font-weight: 620; margin-bottom: 3px; }
.form-section__desc { font-size: 12.5px; color: var(--text-muted); margin-bottom: 15px; }

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
    display: flex; gap: 2px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 10px 13px;
    font-size: 13.5px; font-weight: 550;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab__count {
    margin-left: 5px;
    font-size: 11.5px;
    padding: 1px 5px;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--text-muted);
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.pagination__pages { margin-left: auto; display: flex; align-items: center; gap: 3px; }
.page-link {
    min-width: 30px; height: 30px;
    padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px; font-weight: 530;
}
.page-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.page-link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.is-disabled { opacity: .4; pointer-events: none; }

/* ==========================================================================
   Empty states
   ========================================================================== */
.empty {
    padding: 52px 24px;
    text-align: center;
    max-width: 420px;
    margin: 0 auto;
}
.empty__icon {
    width: 44px; height: 44px;
    margin: 0 auto 14px;
    border-radius: var(--radius-lg);
    background: var(--surface-3);
    display: grid; place-items: center;
    color: var(--text-subtle);
}
.empty__icon svg { width: 21px; height: 21px; }
.empty__title { font-size: 15px; font-weight: 620; margin-bottom: 5px; }
.empty__text { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.6; }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toasts {
    position: fixed; top: 16px; right: 16px; z-index: 100;
    display: flex; flex-direction: column; gap: 8px;
    max-width: min(400px, calc(100vw - 32px));
}
.toast {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    animation: toast-in .22s cubic-bezier(.2, .9, .3, 1);
}
.toast--success { border-left-color: var(--success); }
.toast--error   { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast--info    { border-left-color: var(--info); }
.toast__icon { flex-shrink: 0; width: 17px; height: 17px; margin-top: 1px; }
.toast--success .toast__icon { color: var(--success); }
.toast--error   .toast__icon { color: var(--danger); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info    .toast__icon { color: var(--info); }
.toast__body { flex: 1; min-width: 0; line-height: 1.5; }
.toast__close {
    border: 0; background: none; cursor: pointer;
    color: var(--text-subtle); padding: 0; line-height: 1;
    flex-shrink: 0;
}
.toast__close:hover { color: var(--text); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(16px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(16, 24, 40, .5);
    backdrop-filter: blur(2px);
    display: grid; place-items: center;
    padding: 20px;
    animation: fade-in .14s ease;
}
.modal {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in .18s cubic-bezier(.2, .9, .3, 1);
}
.modal--lg { max-width: 760px; }
.modal--xl { max-width: 1000px; }
.modal__header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 15px; font-weight: 620; }
.modal__close { margin-left: auto; }
.modal__body { padding: 20px; overflow-y: auto; flex: 1; }
.modal__footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Drawer (lead detail slide-over)
   ========================================================================== */
.drawer-backdrop {
    position: fixed; inset: 0; z-index: 70;
    background: rgba(16, 24, 40, .38);
    animation: fade-in .14s ease;
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 71;
    width: min(680px, 100vw);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: drawer-in .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }

.drawer__header {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.drawer__body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer__footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    display: flex; gap: 8px; align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ==========================================================================
   Definition grid (detail panes)
   ========================================================================== */
.dl { display: grid; grid-template-columns: 124px 1fr; gap: 9px 14px; font-size: 13.5px; align-items: start; }
.dl dt { color: var(--text-muted); font-size: 12.5px; padding-top: 1px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ==========================================================================
   Timeline (message history)
   ========================================================================== */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
    content: "";
    position: absolute; left: 8px; top: 6px; bottom: 6px;
    width: 1.5px; background: var(--border);
}

.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item__dot {
    position: absolute; left: -26px; top: 3px;
    width: 17px; height: 17px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
    display: grid; place-items: center;
}
.tl-item__dot svg { width: 9px; height: 9px; }
.tl-item__dot--sent    { border-color: var(--primary); color: var(--primary); }
.tl-item__dot--reply   { border-color: var(--success); color: var(--success); }
.tl-item__dot--open    { border-color: var(--info);    color: var(--info); }
.tl-item__dot--failed  { border-color: var(--danger);  color: var(--danger); }

.tl-item__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tl-item__title { font-weight: 570; font-size: 13.5px; }
.tl-item__time { font-size: 12px; color: var(--text-subtle); margin-left: auto; white-space: nowrap; }
.tl-item__meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.tl-item__body {
    margin-top: 8px;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.tl-item__body--reply { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 22%, transparent); }

/* Rendered email preview */
.email-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 13.5px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}
.email-preview p { margin: 0 0 11px; }
.email-preview p:last-child { margin-bottom: 0; }
.email-preview img { max-width: 100%; height: auto; }

/* ==========================================================================
   Progress + meters
   ========================================================================== */
/* Declared as <span> in the markup, so display must be set explicitly —
   an inline element ignores width and height. */
.progress {
    display: block;
    width: 100%;
    height: 6px;
    background: var(--surface-3);
    border-radius: 99px;
    overflow: hidden;
}
.progress__bar {
    display: block;
    height: 100%;
    min-width: 2px;
    background: var(--primary);
    border-radius: 99px;
    transition: width .3s;
}
.progress__bar--success { background: var(--success); }
.progress__bar--warning { background: var(--warning); }
.progress__bar--danger  { background: var(--danger); }
.progress__bar--info    { background: var(--info); }
.progress__bar--primary { background: var(--primary); }
.progress__bar--muted   { background: var(--text-subtle); }

.meter { display: flex; align-items: center; gap: 8px; min-width: 0; }
.meter .progress { flex: 1; min-width: 40px; }
.meter__value { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ==========================================================================
   Charts (CSS-drawn, no JS library)
   ========================================================================== */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 10px; }
.chart__col {
    flex: 1;
    min-width: 0;
    display: flex; flex-direction: column; justify-content: flex-end;
    gap: 1px;
    height: 100%;
    position: relative;
    border-radius: 3px 3px 0 0;
}
.chart__col:hover { background: var(--surface-3); }
.chart__bar { border-radius: 2px 2px 0 0; min-height: 1px; transition: height .3s; }
.chart__bar--sent    { background: var(--primary); opacity: .85; }
.chart__bar--opened  { background: var(--info); opacity: .85; }
.chart__bar--replies { background: var(--success); }

.chart-axis {
    display: flex; justify-content: space-between;
    font-size: 11px; color: var(--text-subtle);
    padding-top: 7px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.legend__item { display: flex; align-items: center; gap: 5px; }
.legend__swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

/* Horizontal breakdown bars */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 50px; gap: 11px; align-items: center; font-size: 13px; }
.bar-row__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__value { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Sequence builder
   ========================================================================== */
.step-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.step-card.is-disabled { opacity: .62; }

.step-card__head {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.step-card__num {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--primary-text);
    display: grid; place-items: center;
    font-size: 12.5px; font-weight: 650;
    flex-shrink: 0;
}
.step-card__body { padding: 15px 16px; }
.step-card__stats {
    display: flex; gap: 18px; flex-wrap: wrap;
    padding: 11px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 12.5px;
}
.step-stat { display: flex; align-items: baseline; gap: 5px; }
.step-stat__value { font-weight: 620; font-variant-numeric: tabular-nums; }
.step-stat__label { color: var(--text-muted); }

.step-connector {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 0 9px 32px;
    color: var(--text-muted);
    font-size: 12.5px;
    position: relative;
}
.step-connector::before {
    content: "";
    position: absolute; left: 13px; top: 0; bottom: 0;
    width: 1.5px;
    background: var(--border);
}

/* ==========================================================================
   Schedule grid
   ========================================================================== */
.schedule-day {
    display: grid;
    grid-template-columns: 30px 108px 1fr;
    gap: 12px;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.schedule-day:last-child { border-bottom: 0; }
.schedule-day.is-off .schedule-day__name,
.schedule-day.is-off .schedule-day__times { opacity: .45; }
.schedule-day__name { font-weight: 550; font-size: 13.5px; }
.schedule-day__times { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.schedule-day__times .input { width: 118px; }

/* ==========================================================================
   Inbox split view
   ========================================================================== */
.inbox {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    height: calc(100vh - var(--header-h));
    min-width: 0;
}
.inbox__list {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: var(--surface);
    min-width: 0;
}
.inbox__detail { overflow-y: auto; background: var(--bg); min-width: 0; }

.reply-row {
    display: block;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    min-width: 0;
}
.reply-row:hover { background: var(--surface-2); text-decoration: none; }
.reply-row.is-active { background: var(--primary-soft); }
.reply-row__top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.reply-row__name {
    font-weight: 570; font-size: 13.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reply-row__time { margin-left: auto; font-size: 11.5px; color: var(--text-subtle); white-space: nowrap; }
.reply-row__subject {
    font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 3px;
}
.reply-row__snippet {
    font-size: 12.5px; color: var(--text-muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.45;
}

/* ==========================================================================
   Misc utilities
   ========================================================================== */
.stack   { display: flex; flex-direction: column; }
.stack-4 { gap: 4px; } .stack-6 { gap: 6px; } .stack-8  { gap: 8px; }
.stack-12{ gap: 12px; } .stack-14{ gap: 14px; } .stack-16 { gap: 16px; }
.stack-20{ gap: 20px; } .stack-24{ gap: 24px; }

.row { display: flex; align-items: center; }
.row-6 { gap: 6px; } .row-8 { gap: 8px; } .row-10 { gap: 10px; }
.row-12 { gap: 12px; } .row-16 { gap: 16px; }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--start { align-items: flex-start; }
.row--baseline { align-items: baseline; }

.grid { display: grid; gap: 10px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

.text-xs { font-size: 11.5px; } .text-sm { font-size: 12.5px; }
.text-md { font-size: 14px; }   .text-lg { font-size: 16px; }
.text-muted  { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-warning{ color: var(--warning); }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; }
.num-tab { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.min-w-0 { min-width: 0; }
.break-word { overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 12px; }

.mt-4{margin-top:4px}.mt-8{margin-top:8px}.mt-12{margin-top:12px}
.mt-16{margin-top:16px}.mt-20{margin-top:20px}.mt-24{margin-top:24px}
.mb-4{margin-bottom:4px}.mb-8{margin-bottom:8px}.mb-12{margin-bottom:12px}
.mb-16{margin-bottom:16px}.mb-20{margin-bottom:20px}.mb-24{margin-bottom:24px}
.ml-auto{margin-left:auto}

.hidden { display: none !important; }
.w-full { width: 100%; }
.flex-1 { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.relative { position: relative; }

.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13.5px;
    line-height: 1.55;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert--info    { background: var(--info-soft);    color: var(--info-text); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); }
.alert--danger  { background: var(--danger-soft);  color: var(--danger-text); }
.alert--success { background: var(--success-soft); color: var(--success-text); }

.code-block {
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.65;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 220px;
    overflow-y: auto;
    color: var(--text-muted);
}

/* Dropdown menu */
.dropdown { position: relative; }
.dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 5px); z-index: 50;
    min-width: 186px;
    padding: 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    animation: fade-in .1s ease;
}
.dropdown__menu[hidden] { display: none; }
.dropdown__menu--left { right: auto; left: 0; }
.dropdown__item {
    display: flex; align-items: center; gap: 9px;
    width: 100%;
    padding: 7px 9px;
    border: 0; border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}
.dropdown__item:hover { background: var(--surface-3); text-decoration: none; }
.dropdown__item svg { width: 15px; height: 15px; color: var(--text-subtle); flex-shrink: 0; }
.dropdown__item--danger { color: var(--danger); }
.dropdown__item--danger svg { color: var(--danger); }
.dropdown__divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown__label {
    padding: 6px 9px 3px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-subtle);
}

/* Tooltip */
.tip { position: relative; }
.tip::after {
    content: attr(data-tip);
    position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%);
    padding: 5px 8px;
    background: var(--text);
    color: var(--surface);
    font-size: 11.5px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0; pointer-events: none;
    transition: opacity .12s;
    z-index: 60;
}
.tip:hover::after { opacity: 1; }

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent),
        radial-gradient(700px 420px at 90% 110%, color-mix(in srgb, #8b5cf6 10%, transparent), transparent),
        var(--bg);
}
.auth__card { width: 100%; max-width: 396px; }
.auth__brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.auth__title { font-size: 20px; font-weight: 660; text-align: center; letter-spacing: -.02em; }
.auth__sub { font-size: 13.5px; color: var(--text-muted); text-align: center; margin: 5px 0 22px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px) {
    .grid--sidebar, .grid--main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        width: 260px;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: none; }
    .main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex !important; }
    .inbox { grid-template-columns: minmax(0, 1fr); height: auto; }
    .inbox__list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 46vh; }
}

@media (max-width: 720px) {
    .content { padding: 14px; }
    .topbar { padding: 0 14px; }
    .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
    .field-row, .field-row--2, .field-row--3 { grid-template-columns: minmax(0, 1fr); }
    .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
    .dl dt { margin-top: 8px; }
    .schedule-day { grid-template-columns: 26px 1fr; row-gap: 8px; }
    .schedule-day__times { grid-column: 1 / -1; padding-left: 38px; }
    .bar-row { grid-template-columns: 96px 1fr 44px; }
    .drawer { width: 100vw; }
}

.sidebar-toggle { display: none; }

@media print {
    .sidebar, .topbar__actions, .toolbar, .pagination, .toasts { display: none !important; }
    .main { margin-left: 0; }
    body { background: #fff; }
}

/* ==========================================================================
   Reporting board
   Dense analytical components: KPI strip, filter bar, funnel, donut,
   heatmap, scatter, inline micro-bars.
   ========================================================================== */

/* --- Page head ---------------------------------------------------------- */
.board-head {
    display: flex; align-items: flex-start; gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.board-head__title { font-size: 19px; font-weight: 660; letter-spacing: -.025em; }
.board-head__sub { font-size: 11.5px; color: var(--text-subtle); margin-top: 2px; }
.board-head__actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* --- Filter bar --------------------------------------------------------- */
.filterbar {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
}
.filterbar__group { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.filterbar__label {
    font-size: 9.5px; font-weight: 600;
    letter-spacing: .09em; text-transform: uppercase;
    color: var(--text-subtle);
}
.filterbar__group .select,
.filterbar__group .input {
    height: 28px;
    font-size: 12px;
    padding: 0 26px 0 9px;
    background: var(--surface-2);
    border-color: var(--border);
    box-shadow: none;
}
.filterbar__group .input { padding-right: 9px; }
.filterbar__spacer { margin-left: auto; align-self: flex-end; display: flex; gap: 6px; }

/* --- KPI strip ---------------------------------------------------------- */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.kpi {
    position: relative;
    padding: 11px 13px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 0;
}
/* Coloured hairline along the top edge identifies the metric family */
.kpi::before {
    content: "";
    position: absolute; inset: 0 0 auto 0;
    height: 2px;
    background: var(--kpi-color, var(--primary));
    opacity: .85;
}
.kpi__label {
    font-size: 9.5px; font-weight: 650;
    letter-spacing: .09em; text-transform: uppercase;
    color: var(--kpi-color, var(--text-muted));
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi__value {
    font-size: 23px; font-weight: 680;
    letter-spacing: -.035em;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.kpi__meta {
    font-size: 10.5px; color: var(--text-subtle);
    margin-top: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi__delta { font-weight: 600; }
.kpi__delta--up { color: var(--c3); }
.kpi__delta--down { color: var(--c5); }

/* --- Goal / capacity meter ---------------------------------------------- */
.goal { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.goal__ring {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 680;
    flex-shrink: 0;
    background: conic-gradient(var(--c3) calc(var(--pct) * 1%), var(--surface-3) 0);
}
.goal__ring span {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--surface);
    display: grid; place-items: center;
    font-variant-numeric: tabular-nums;
}
.goal__body { flex: 1; min-width: 180px; }
.goal__label {
    font-size: 9.5px; font-weight: 650; letter-spacing: .09em;
    text-transform: uppercase; color: var(--text-subtle);
}
.goal__value { font-size: 19px; font-weight: 670; letter-spacing: -.03em; margin: 3px 0 7px; font-variant-numeric: tabular-nums; }

/* --- Column chart ------------------------------------------------------- */
.cchart { display: flex; align-items: flex-end; gap: 2px; height: 168px; }
.cchart__col {
    flex: 1; min-width: 0;
    height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end;
    gap: 1px;
    border-radius: 2px;
}
.cchart__col:hover { background: var(--surface-2); }
.cchart__seg { display: block; border-radius: 1.5px; min-height: 0; transition: height .25s; }
.cchart__seg--a { background: color-mix(in srgb, var(--c1) 80%, transparent); }
.cchart__seg--b { background: color-mix(in srgb, var(--c2) 80%, transparent); }
.cchart__seg--c { background: var(--c3); }
/* The peak column is called out, as in the reference board */
.cchart__col.is-peak .cchart__seg--a { background: var(--c1); }
.cchart__col.is-peak .cchart__seg--b { background: var(--c2); }

/* --- Funnel ------------------------------------------------------------- */
.funnel { display: flex; flex-direction: column; gap: 3px; }
.funnel__row { display: grid; grid-template-columns: 1fr 74px; gap: 10px; align-items: center; }
.funnel__bar {
    height: 26px;
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10.5px; font-weight: 620;
    color: #0b0b0d;
    white-space: nowrap; overflow: hidden;
    min-width: 42px;
    transition: width .3s;
}
.funnel__num {
    text-align: right;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.funnel__num b { color: var(--text); font-weight: 620; }

/* --- Distribution / reason rows ----------------------------------------- */
.drow {
    display: grid;
    grid-template-columns: 1fr 44px;
    gap: 10px;
    align-items: center;
    padding: 4px 0;
}
.drow__label {
    font-size: 11.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 4px;
}
.drow__count {
    text-align: right; font-size: 11.5px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.drow__track { display: block; height: 4px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.drow__fill  { display: block; height: 100%; border-radius: 99px; min-width: 2px; }

/* --- Leaderboard -------------------------------------------------------- */
.lb { display: flex; flex-direction: column; }
.lb__row {
    display: grid;
    grid-template-columns: 18px 24px 1fr auto;
    gap: 9px;
    align-items: center;
    padding: 6px 2px;
    border-bottom: 1px solid var(--border);
}
.lb__row:last-child { border-bottom: 0; }
.lb__rank {
    font-size: 10.5px; color: var(--text-subtle);
    text-align: right; font-variant-numeric: tabular-nums;
}
.lb__name {
    font-size: 12px; font-weight: 560;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb__sub { font-size: 10px; color: var(--text-subtle); }
.lb__right { text-align: right; min-width: 74px; }
.lb__value { font-size: 12px; font-weight: 620; font-variant-numeric: tabular-nums; }
.lb__bar { height: 3px; border-radius: 99px; margin-top: 4px; background: var(--surface-3); overflow: hidden; }
.lb__bar span { display: block; height: 100%; border-radius: 99px; min-width: 2px; }

/* --- Donut -------------------------------------------------------------- */
.donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.donut {
    width: 104px; height: 104px;
    border-radius: 50%;
    flex-shrink: 0;
    display: grid; place-items: center;
    position: relative;
}
.donut::after {
    content: "";
    position: absolute; inset: 26px;
    border-radius: 50%;
    background: var(--surface);
}
.donut__center {
    position: relative; z-index: 1;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.donut__total { font-size: 15px; font-weight: 680; letter-spacing: -.03em; }
.donut__cap { font-size: 9px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .08em; }
.donut-legend { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 2px; }
.donut-legend__row {
    display: grid;
    grid-template-columns: 8px 1fr auto auto;
    gap: 8px; align-items: center;
    font-size: 11.5px;
    padding: 2px 0;
}
.donut-legend__dot { width: 7px; height: 7px; border-radius: 2px; }
.donut-legend__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend__pct { color: var(--text-subtle); font-variant-numeric: tabular-nums; font-size: 10.5px; }
.donut-legend__val { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }

/* --- Big outcome tiles -------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
    padding: 14px 10px;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid color-mix(in srgb, var(--tile-color, var(--primary)) 28%, transparent);
    background: color-mix(in srgb, var(--tile-color, var(--primary)) 9%, transparent);
}
.tile__label {
    font-size: 9px; font-weight: 650; letter-spacing: .1em;
    text-transform: uppercase; color: var(--text-subtle);
}
.tile__value {
    font-size: 25px; font-weight: 680; letter-spacing: -.035em;
    color: var(--tile-color, var(--text));
    margin-top: 5px; font-variant-numeric: tabular-nums;
}

/* --- Heatmap (GitHub-style contribution grid) --------------------------- */
.heat {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 11px);
    gap: 2.5px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.heat__cell {
    width: 11px; height: 11px;
    border-radius: 2px;
    background: var(--surface-3);
}
.heat__cell--1 { background: color-mix(in srgb, var(--c3) 26%, var(--surface-3)); }
.heat__cell--2 { background: color-mix(in srgb, var(--c3) 48%, var(--surface-3)); }
.heat__cell--3 { background: color-mix(in srgb, var(--c3) 72%, var(--surface-3)); }
.heat__cell--4 { background: var(--c3); }
.heat-legend {
    display: flex; align-items: center; gap: 4px;
    font-size: 10px; color: var(--text-subtle);
    margin-top: 8px;
}
.heat-legend__cell { width: 9px; height: 9px; border-radius: 2px; }

/* --- Scatter ------------------------------------------------------------ */
.scatter {
    position: relative;
    height: 178px;
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-left: 26px;
}
.scatter__dot {
    position: absolute;
    width: 7px; height: 7px;
    border-radius: 50%;
    transform: translate(-50%, 50%);
    opacity: .85;
}
.scatter__dot:hover { opacity: 1; transform: translate(-50%, 50%) scale(1.5); }
.scatter__ylabel {
    position: absolute; left: -26px;
    font-size: 9px; color: var(--text-subtle);
    transform: translateY(50%);
}
.scatter__xaxis {
    display: flex; justify-content: space-between;
    font-size: 9px; color: var(--text-subtle);
    margin: 5px 0 0 26px;
}

/* --- Compact two-column effectiveness list ------------------------------ */
.eff { display: flex; flex-direction: column; }
.eff__row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
}
.eff__row:last-child { border-bottom: 0; }
.eff__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eff__val { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 11px; }
.eff__val b { font-weight: 640; }
.eff__val span { color: var(--text-subtle); }

/* --- Compliance bar ----------------------------------------------------- */
.comply { display: flex; flex-direction: column; gap: 9px; }
.comply__head {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 11.5px;
    margin-bottom: 4px;
}
.comply__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.comply__stat { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.comply__track { display: block; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.comply__fill { display: block; height: 100%; border-radius: 99px; min-width: 2px; }

/* --- Movement pills ----------------------------------------------------- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 9px;
    border-radius: 99px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 11px;
    white-space: nowrap;
}
.pill__n { font-weight: 650; font-variant-numeric: tabular-nums; }

/* --- Section divider ---------------------------------------------------- */
.section-head { margin: 18px 0 10px; }
.section-head__title { font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.section-head__sub { font-size: 11.5px; color: var(--text-subtle); margin-top: 2px; }

/* --- Numeric matrix table ----------------------------------------------- */
.table--matrix { font-size: 11.5px; }
.table--matrix th, .table--matrix td { padding: 5px 8px; }
.table--matrix td.n { text-align: right; font-variant-numeric: tabular-nums; }
.table--matrix .zero { color: var(--text-subtle); }
.table--matrix .hot  { color: var(--c3); font-weight: 620; }
.table--matrix .warm { color: var(--c4); font-weight: 600; }
.table--matrix .cold { color: var(--c5); font-weight: 600; }

@media (max-width: 860px) {
    .tiles { grid-template-columns: 1fr; }
    .kpi-strip { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* ==========================================================================
   Global search — header trigger + command palette
   ========================================================================== */

/* --- Header trigger ----------------------------------------------------- */
.searchbar {
    display: flex; align-items: center; gap: 8px;
    height: 30px;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    padding: 0 8px 0 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-subtle);
    font-size: 12.5px;
    cursor: pointer;
    text-align: left;
    transition: border-color .12s, background .12s;
}
.searchbar:hover { border-color: var(--border-strong); background: var(--surface-3); }
.searchbar svg { width: 14px; height: 14px; flex-shrink: 0; }
.searchbar__text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kbd {
    display: inline-flex; align-items: center; gap: 1px;
    height: 18px; padding: 0 5px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: var(--surface);
    font-family: var(--font);
    font-size: 10.5px; font-weight: 600;
    color: var(--text-subtle);
    white-space: nowrap;
}

/* --- Palette ------------------------------------------------------------ */
.palette-backdrop {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(8, 8, 10, .55);
    backdrop-filter: blur(3px);
    display: flex; justify-content: center;
    padding: 12vh 16px 24px;
    animation: fade-in .1s ease;
}
@media (max-height: 640px) { .palette-backdrop { padding-top: 5vh; } }

.palette {
    width: 100%;
    max-width: 620px;
    max-height: 72vh;
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: palette-in .14s cubic-bezier(.2, .9, .3, 1);
}
@keyframes palette-in {
    from { opacity: 0; transform: translateY(-8px) scale(.985); }
    to   { opacity: 1; transform: none; }
}

.palette__head {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.palette__head > svg { width: 17px; height: 17px; color: var(--text-subtle); flex-shrink: 0; }

.palette__input {
    flex: 1;
    border: 0; outline: 0;
    background: transparent;
    font-size: 14.5px;
    color: var(--text);
    min-width: 0;
    padding: 0;
}
.palette__input::placeholder { color: var(--text-subtle); }

.palette__spinner {
    width: 14px; height: 14px;
    border: 1.5px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.palette__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
}

.palette__group + .palette__group { margin-top: 2px; }
.palette__label {
    padding: 8px 9px 4px;
    font-size: 9.5px; font-weight: 650;
    letter-spacing: .1em; text-transform: uppercase;
    color: var(--text-subtle);
}

.palette__item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 9px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    scroll-margin: 46px;
}
.palette__item:hover { text-decoration: none; }
/* Selection follows the keyboard, so hover alone must not move it */
.palette__item.is-active { background: var(--primary-soft); }
.palette__item.is-active .palette__title { color: var(--primary-text); }

.palette__icon {
    width: 26px; height: 26px;
    border-radius: 6px;
    flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 10px; font-weight: 650;
}
.palette__icon svg { width: 14px; height: 14px; }
.palette__item.is-active .palette__icon { background: var(--primary); color: #fff; }

.palette__text { flex: 1; min-width: 0; }
.palette__title {
    font-size: 13px; font-weight: 550;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.palette__sub {
    font-size: 11.5px; color: var(--text-subtle);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-top: 1px;
}
.palette__title mark {
    background: color-mix(in srgb, var(--c4) 34%, transparent);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
.palette__sub mark { background: color-mix(in srgb, var(--c4) 22%, transparent); color: inherit; }

.palette__meta {
    font-size: 10.5px; color: var(--text-subtle);
    flex-shrink: 0; white-space: nowrap;
}
.palette__enter { flex-shrink: 0; opacity: 0; }
.palette__item.is-active .palette__enter { opacity: 1; }

.palette__more {
    display: block;
    padding: 6px 9px 8px;
    font-size: 11.5px;
    color: var(--primary);
}

.palette__empty { padding: 34px 16px; text-align: center; }
.palette__empty-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.palette__empty-text { font-size: 12px; color: var(--text-subtle); line-height: 1.6; }

.palette__foot {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 10.5px;
    color: var(--text-subtle);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.palette__hint { display: flex; align-items: center; gap: 4px; }

@media (max-width: 720px) {
    .searchbar__text, .searchbar .kbd { display: none; }
    .searchbar { width: 32px; max-width: 32px; padding: 0; justify-content: center; }
    .palette__foot { display: none; }
}
