/* ============================================================
   Sales Watchtower - Professional Design System
   Light is the default; [data-theme="dark"] on <html> swaps the
   palette (set before first paint by the inline script in the
   layouts, from the user's saved preference).
   ============================================================ */

:root {
    --sidebar-w: 255px;
    --topbar-h: 60px;
    color-scheme: light;

    /* Type - Geist: neutral, modern, excellent figures */
    --font-body: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Geist', var(--font-body);
    --font-mono: 'Geist Mono', ui-monospace, 'Cascadia Mono', 'Menlo', monospace;

    /* Sidebar - deep observatory navy (dark in both themes) */
    --sb-bg: #081120;
    --sb-border: #16243a;
    --sb-text: #8da3bd;
    --sb-text-hover: #f2f7fc;
    --sb-active-bg: rgba(34,211,238,.10);
    --sb-active-text: #67e8f9;
    --sb-active-bar: #22d3ee;
    --sb-section: #4a6585;

    /* Page */
    --page-bg: #f4f6f9;
    --topbar-bg: rgba(255,255,255,.82);
    --topbar-border: #e3e9ef;
    --grid-dot: rgba(18,32,50,.05);
    --page-wash: rgba(14,116,144,.055);

    /* Surfaces */
    --card-bg: #ffffff;
    --card-border: #e3e9ef;
    --card-shadow: 0 1px 2px rgba(8,23,42,.05), 0 4px 16px rgba(8,23,42,.04);
    --card-radius: 12px;
    --surface-2: #f8fafc;           /* table heads, subtle fills   */
    --surface-3: #f1f5f9;           /* chips, neutral badges       */
    --row-hover: #f3fbfd;
    --input-bg: #ffffff;
    --panel-hdr-bg: linear-gradient(180deg, #fbfdfe, #ffffff);
    --glass: rgba(255,255,255,.94);
    --popover-shadow: 0 12px 40px rgba(8,23,42,.14);
    --overlay: rgba(8,23,42,.45);

    /* Lines */
    --border: #e3e9ef;
    --border-subtle: #f1f5f9;
    --line-strong: #cbd5e1;
    --track: #e2e8f0;

    /* Brand colours - aqua-led. NOTE: --indigo keeps its legacy name because
       dozens of views reference it inline, but it carries the brand aqua. */
    --indigo: #0e7490;
    --indigo-light: #22d3ee;
    --indigo-pale: #e6fafd;
    --indigo-line: #a5f3fc;
    --accent-solid: #0e7490;        /* filled buttons / chips with white text */
    --emerald: #10b981;
    --emerald-pale: #d1fae5;
    --emerald-ink: #047857;
    --emerald-line: #a7f3d0;
    --amber: #f59e0b;
    --amber-pale: #fef3c7;
    --amber-ink: #b45309;
    --amber-line: #fde68a;
    --rose: #ef4444;
    --rose-pale: #fee2e2;
    --rose-ink: #b91c1c;
    --rose-line: #fecaca;
    --rose-wash: #fffbfb;
    --sky: #0ea5e9;
    --sky-pale: #e0f2fe;
    --sky-ink: #0369a1;
    --sky-line: #bae6fd;
    --orange: #f97316;
    --orange-pale: #ffedd5;
    --orange-ink: #c2410c;
    --orange-line: #fed7aa;

    /* Text */
    --text-primary: #122032;
    --text-secondary: #43586e;
    --text-muted: #7a8ea3;

    /* Charts (read by js/theme.js) */
    --chart-grid: #eef2f6;
    --chart-text: #7a8ea3;
}

/* ── Dark theme ─────────────────────────────────────────────
   Deep navy, not pure black: keeps the sidebar and content in
   one family and makes the aqua accents glow rather than shout. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --sb-bg: #060c17;
    --sb-border: #142034;

    --page-bg: #0a1220;
    --topbar-bg: rgba(10,18,32,.78);
    --topbar-border: #1a2638;
    --grid-dot: rgba(148,178,212,.06);
    --page-wash: rgba(34,211,238,.07);

    --card-bg: #0f1a2b;
    --card-border: #1c293d;
    --card-shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 20px rgba(0,0,0,.25);
    --surface-2: #132033;
    --surface-3: #18263b;
    --row-hover: #142337;
    --input-bg: #0b1524;
    --panel-hdr-bg: linear-gradient(180deg, #112036, #0f1a2b);
    --glass: rgba(15,26,43,.92);
    --popover-shadow: 0 16px 48px rgba(0,0,0,.55);
    --overlay: rgba(2,6,14,.62);

    --border: #1f2d42;
    --border-subtle: #172438;
    --line-strong: #33445c;
    --track: #1d2b40;

    --indigo: #22b8d6;
    --indigo-light: #67e8f9;
    --indigo-pale: rgba(34,211,238,.12);
    --indigo-line: rgba(34,211,238,.32);
    --accent-solid: #0e8aa8;
    --emerald: #34d399;
    --emerald-pale: rgba(52,211,153,.13);
    --emerald-ink: #6ee7b7;
    --emerald-line: rgba(52,211,153,.32);
    --amber: #fbbf24;
    --amber-pale: rgba(251,191,36,.13);
    --amber-ink: #fcd34d;
    --amber-line: rgba(251,191,36,.32);
    --rose: #f87171;
    --rose-pale: rgba(248,113,113,.13);
    --rose-ink: #fca5a5;
    --rose-line: rgba(248,113,113,.32);
    --rose-wash: rgba(248,113,113,.05);
    --sky: #38bdf8;
    --sky-pale: rgba(56,189,248,.13);
    --sky-ink: #7dd3fc;
    --sky-line: rgba(56,189,248,.32);
    --orange: #fb923c;
    --orange-pale: rgba(251,146,60,.13);
    --orange-ink: #fdba74;
    --orange-line: rgba(251,146,60,.32);

    --text-primary: #e6edf5;
    --text-secondary: #a9b8ca;
    --text-muted: #73879f;

    --chart-grid: #1a2739;
    --chart-text: #7d90a8;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--page-bg);
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--indigo-line); color: #083344; }

/* ── Shell ──────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    border-right: 1px solid var(--sb-border);
}

.sb-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--sb-border);
    text-decoration: none;
}

.sb-brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(14,116,144,.4);
}

.sb-brand-name {
    font-size: 14px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.2px;
    line-height: 1.1;
}

.sb-brand-tagline {
    font-size: 10px;
    color: var(--sb-section);
    letter-spacing: .5px;
    font-weight: 500;
    margin-top: 1px;
}

.sb-nav { flex: 1; padding: 10px 10px; overflow-y: auto; }

.sb-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sb-section);
    padding: 14px 10px 5px;
}

.sb-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 1px;
    transition: background .12s, color .12s;
    position: relative;
}

.sb-link i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; opacity: .8; }
.sb-link:hover { background: rgba(255,255,255,.05); color: var(--sb-text-hover); text-decoration: none; }

.sb-link.active {
    background: var(--sb-active-bg);
    color: var(--sb-active-text);
}

.sb-link.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%; transform: translateY(-50%);
    width: 3px; height: 55%;
    background: var(--sb-active-bar);
    border-radius: 0 3px 3px 0;
}

.sb-link.active i { opacity: 1; }
.sb-link .sb-badge { margin-left: auto; font-size: 10px; font-weight: 700; background: rgba(255,255,255,.1); color: var(--sb-text); padding: 1px 7px; border-radius: 99px; }

.sb-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--sb-border);
}

/* ── Main area ──────────────────────────────────────────── */
#main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar ─────────────────────────────────────────────── */
#topbar {
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky; top: 0; z-index: 50;
    gap: 12px;
}

.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-primary); flex: 1; }
.topbar-meta { font-size: 12px; color: var(--text-muted); }
.topbar-divider { width: 1px; height: 24px; background: var(--border); }

/* ── Content ─────────────────────────────────────────────── */
/* Fills the width beside the sidebar (or the whole window when it is collapsed) */
#content { flex: 1; padding: 28px; min-width: 0; }

/* ── Page header ────────────────────────────────────────── */
.page-hdr {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-hdr-left h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.4px;
    margin: 0 0 2px;
}

.page-hdr-left p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ── KPI Cards ──────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.kpi-icon {
    width: 44px; height: 44px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}

.kpi-icon.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.kpi-icon.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.kpi-icon.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.kpi-icon.rose    { background: var(--rose-pale);    color: var(--rose-ink); }
.kpi-icon.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.kpi-icon.orange  { background: var(--orange-pale);  color: var(--orange-ink); }

.kpi-body { flex: 1; }
.kpi-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 3px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1; letter-spacing: -0.8px; }
.kpi-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Panels ─────────────────────────────────────────────── */
.panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.panel-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-hdr-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-hdr-title .count {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 99px;
    background: var(--indigo-pale);
    color: var(--indigo);
}

.panel-link { font-size: 12.5px; color: var(--indigo); text-decoration: none; font-weight: 500; }
.panel-link:hover { text-decoration: underline; color: var(--indigo); }

.panel-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.panel-empty i { font-size: 32px; display: block; margin-bottom: 10px; opacity: .3; }
.panel-empty p { font-size: 13px; margin: 0; }

/* ── Tables ─────────────────────────────────────────────── */
.wt-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.wt-table thead th {
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.wt-table tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.wt-table tbody tr:last-child td { border-bottom: none; }
.wt-table tbody tr:hover td { background: var(--surface-2); }
.wt-table .td-primary { font-weight: 600; }
.wt-table .td-muted { color: var(--text-muted); font-size: 12px; }
.wt-table .td-right { text-align: right; }
.wt-table .td-center { text-align: center; }

/* ── Badges ─────────────────────────────────────────────── */
.badge-wt {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-wt.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.badge-wt.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.badge-wt.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.badge-wt.rose    { background: var(--rose-pale);    color: var(--rose-ink); }
.badge-wt.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.badge-wt.slate   { background: var(--surface-3);             color: var(--text-secondary); }
.badge-wt.orange  { background: var(--orange-pale);  color: var(--orange-ink); }

/* ── Score bar ──────────────────────────────────────────── */
.score-wrap { display: flex; align-items: center; gap: 8px; min-width: 100px; }

.score-bar { flex: 1; height: 5px; background: var(--track); border-radius: 99px; overflow: hidden; }

.score-fill { height: 100%; border-radius: 99px; }
.score-fill.rose    { background: var(--rose); }
.score-fill.amber   { background: var(--amber); }
.score-fill.sky     { background: var(--sky); }
.score-fill.slate   { background: var(--line-strong); }
.score-fill.emerald { background: var(--emerald); }

.score-num { font-size: 12px; font-weight: 700; color: var(--text-secondary); min-width: 24px; text-align: right; }

/* ── Source pills ───────────────────────────────────────── */
.src-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    margin-right: 3px;
    letter-spacing: .2px;
}

.src-pill.ll { background: var(--orange-pale); color: var(--orange-ink); }
.src-pill.hs { background: var(--orange-pale); color: var(--orange-ink); }

/* ── Signal icon ────────────────────────────────────────── */
.sig-icon { font-size: 14px; }
.sig-icon.on { color: var(--emerald); }
.sig-icon.off { color: var(--line-strong); }

/* ── Stat pills (campaign detail) ───────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 24px; }

.stat-pill {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 9px;
    box-shadow: var(--card-shadow);
    padding: 14px 16px;
    text-align: center;
}

.stat-pill-val { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-primary); line-height: 1; }
.stat-pill-lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-top: 5px; }

/* ── Breadcrumb ─────────────────────────────────────────── */
.wt-crumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 18px; }
.wt-crumb a { color: var(--text-muted); text-decoration: none; }
.wt-crumb a:hover { color: var(--indigo); }
.wt-crumb .sep { color: var(--line-strong); font-size: 11px; }
.wt-crumb .cur { color: var(--text-primary); font-weight: 600; }

/* ── Admin ──────────────────────────────────────────────── */
.setting-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.setting-card-hdr {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-2);
}

.setting-card-hdr .title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.setting-card-body { padding: 20px; }

.wt-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: 'Menlo', 'Courier New', monospace;
    color: var(--text-primary);
    background: var(--card-bg);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.wt-input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(14,116,144,.1); }

/* ── Buttons ────────────────────────────────────────────── */
.btn-wt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 15px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity .12s;
}

.btn-wt:hover { opacity: .85; text-decoration: none; }
.btn-wt.primary { background: var(--accent-solid); color: #fff; }
.btn-wt.outline { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-wt.outline:hover { background: var(--surface-2); opacity: 1; }
.btn-wt.danger  { background: var(--rose); color: #fff; }
.btn-wt.sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }

/* ── Filter tabs ────────────────────────────────────────── */
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }

.filter-tab {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: all .12s;
}

.filter-tab:hover, .filter-tab.active {
    border-color: var(--indigo);
    color: var(--indigo);
    background: var(--indigo-pale);
    text-decoration: none;
}

/* ── Alerts ─────────────────────────────────────────────── */
.wt-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.wt-alert i { font-size: 16px; margin-top: 1px; flex-shrink: 0; }
.wt-alert.info    { background: var(--sky-pale);     color: var(--sky-ink); border-color: var(--sky-line); }
.wt-alert.success { background: var(--emerald-pale); color: var(--emerald-ink); border-color: var(--emerald-line); }
.wt-alert.warning { background: var(--amber-pale);   color: var(--amber-ink); border-color: var(--amber-line); }
.wt-alert.danger  { background: var(--rose-pale);    color: var(--rose-ink); border-color: var(--rose-line); }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

/* ── Settings cog flyout ────────────────────────────────── */
.sb-settings-trigger { position: relative; }

.sb-settings-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0; right: 0;
    background: #1a2744;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 6px;
    display: none;
    z-index: 200;
    box-shadow: 0 -8px 24px rgba(0,0,0,.3);
}

.sb-settings-panel.open { display: block; }

.sb-settings-group {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    padding: 8px 10px 4px;
}

.sb-settings-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 7px;
    color: #94a3b8;
    font-size: 13px;
    text-decoration: none;
    transition: background .1s, color .1s;
}

.sb-settings-link:hover {
    background: rgba(255,255,255,.07);
    color: #f1f5f9;
    text-decoration: none;
}

.sb-settings-link i { font-size: 14px; width: 16px; text-align: center; opacity: .8; }

.sb-cog-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 12px;
    background: transparent;
    border: 1px solid var(--sb-border);
    border-radius: 8px;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
    text-align: left;
}

.sb-cog-btn:hover { background: rgba(255,255,255,.05); color: #f1f5f9; border-color: #334155; }

.sb-cog-btn.active {
    background: rgba(14,116,144,.12);
    color: var(--sb-active-text);
    border-color: rgba(14,116,144,.3);
}

.sb-cog-btn .cog-chevron { margin-left: auto; font-size: 10px; transition: transform .2s; }
.sb-cog-btn.active .cog-chevron { transform: rotate(180deg); }

/* ── Topbar user area ───────────────────────────────────── */
.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    position: relative;
    padding: 5px 8px;
    border-radius: 8px;
    transition: background .12s;
}

.topbar-user:hover { background: var(--page-bg); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 230px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    z-index: 300;
    overflow: hidden;
    display: none;
}

.user-dropdown.open { display: block; }

.user-dropdown-hdr {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--page-bg);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    transition: background .1s;
}

.user-dropdown-item:hover { background: var(--page-bg); color: var(--text-primary); text-decoration: none; }
.user-dropdown-item.danger:hover { color: var(--rose); background: var(--rose-pale); }

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--indigo), #8b5cf6);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.user-name { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.topbar-signout {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 16px;
    padding: 4px;
    border-radius: 6px;
    transition: background .12s, color .12s;
}

.topbar-signout:hover { background: var(--rose-pale); color: var(--rose); text-decoration: none; }

/* ── Activity feed ──────────────────────────────────────── */
.activity-feed { list-style: none; margin: 0; padding: 0; }

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.activity-dot.indigo  { background: var(--indigo); }
.activity-dot.emerald { background: var(--emerald); }
.activity-dot.amber   { background: var(--amber); }
.activity-dot.sky     { background: var(--sky); }

.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.activity-meta  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Territory grid ─────────────────────────────────────── */
.territory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

.territory-tile {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 18px;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s, transform .1s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.territory-tile:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    border-color: var(--indigo);
    transform: translateY(-1px);
}

.territory-tile.watched::after {
    content: '\f590';
    font-family: 'Bootstrap Icons';
    position: absolute;
    top: 10px; right: 12px;
    font-size: 12px;
    color: var(--amber);
}

.tile-logo {
    width: 40px; height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    object-fit: contain;
    background: var(--card-bg);
    padding: 3px;
}

.tile-logo-fallback {
    width: 40px; height: 40px;
    border-radius: 8px;
    background: var(--indigo-pale);
    color: var(--indigo);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700;
}

.tile-name { font-size: 14px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.tile-domain { font-size: 11.5px; color: var(--text-muted); }
.tile-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.tile-score { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.tile-score-bar { flex: 1; height: 4px; background: var(--track); border-radius: 99px; overflow: hidden; }
.tile-score-fill { height: 100%; border-radius: 99px; background: var(--indigo); }
.tile-score-num { font-size: 11px; font-weight: 700; color: var(--text-muted); }

/* ── Drawer ─────────────────────────────────────────────── */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.35);
    z-index: 200;
    backdrop-filter: blur(2px);
}

.drawer-overlay.open { display: block; }

.drawer-panel {
    position: fixed;
    top: 0; right: -520px;
    bottom: 0;
    width: 500px;
    max-width: 95vw;
    background: var(--card-bg);
    box-shadow: -4px 0 32px rgba(0,0,0,.12);
    z-index: 201;
    display: flex;
    flex-direction: column;
    transition: right .25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}

.drawer-panel.open { right: 0; }

.drawer-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.drawer-close {
    width: 30px; height: 30px;
    border: none; background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
    transition: background .12s;
}

.drawer-close:hover { background: var(--rose-pale); color: var(--rose); }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }

.drawer-section { margin-bottom: 22px; }

.drawer-section-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ── Signal cards ───────────────────────────────────────── */
.signal-list { display: flex; flex-direction: column; gap: 12px; }

.signal-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-left: 4px solid transparent;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.signal-card.red    { border-left-color: var(--rose); }
.signal-card.amber  { border-left-color: var(--amber); }
.signal-card.green  { border-left-color: var(--emerald); }

.signal-priority-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.signal-priority-dot.red    { background: var(--rose); }
.signal-priority-dot.amber  { background: var(--amber); }
.signal-priority-dot.green  { background: var(--emerald); }

.signal-body { flex: 1; min-width: 0; }
.signal-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.signal-text  { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }
.signal-meta  { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }

.signal-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Visitor table ──────────────────────────────────────── */
.suggested-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all .12s;
}

.suggested-action.add-hs { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-pale); }
.suggested-action.log-activity { border-color: var(--emerald); color: var(--emerald-ink); background: var(--emerald-pale); }
.suggested-action.route { border-color: var(--amber); color: var(--amber-ink); background: var(--amber-pale); }

/* ── Form group ─────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-group .hint  { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--card-bg);
    outline: none;
    transition: border-color .15s;
    appearance: auto;
}
.form-select:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(14,116,144,.1); }

/* ── Grid helpers ───────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col, .three-col { grid-template-columns: 1fr; } }

/* ── d-none / d-md-inline helpers (Bootstrap-free) ─────── */
.d-none { display: none !important; }
@media (min-width: 768px) { .d-md-inline { display: inline !important; } }
.me-1 { margin-right: 4px; }

/* ── Modal ──────────────────────────────────────────────── */
.wt-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
}
.wt-modal {
    background: var(--card-bg);
    border-radius: 14px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.wt-modal-hdr {
    background: var(--sb-bg);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--sb-border);
}
.modal-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: white; flex-shrink: 0;
}
.modal-title { font-size: 14px; font-weight: 700; color: #f8fafc; }
.modal-sub   { font-size: 11.5px; color: var(--sb-section); margin-top: 1px; }
.modal-close {
    background: transparent; border: none;
    color: var(--sb-text); font-size: 22px; cursor: pointer;
    padding: 2px 6px; border-radius: 6px; line-height: 1;
    transition: color .15s;
}
.modal-close:hover { color: white; }
.wt-modal-body { padding: 22px; }
.wt-modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding-top: 16px; margin-top: 4px;
    border-top: 1px solid var(--border);
}

/* ── Form label (lighter weight helper) ─────────────────── */
.form-label {
    display: block; font-size: 12.5px; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 5px;
}

/* ── Widget Dashboard (Gridstack) ───────────────────────── */

/* Gridstack container */
.grid-stack {
    background: transparent;
}

/* Each cell fills its grid slot fully */
/* No height here: Gridstack positions the content with top/bottom insets (its
   margin option), and a height would override the bottom inset, leaving no
   vertical gap between widgets. */
.grid-stack-item-content {
    overflow: hidden;
    border-radius: 10px;
}

/* Widget card */
.widget-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.widget-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    flex-shrink: 0;
    gap: 8px;
}

.widget-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.widget-body {
    padding: 16px;
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Stat widget */
.widget-stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 4px;
}

.widget-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.widget-stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Color accents for stat values */
.widget-stat-block.color-indigo  .widget-stat-value { color: var(--indigo); }
.widget-stat-block.color-emerald .widget-stat-value { color: var(--emerald); }
.widget-stat-block.color-amber   .widget-stat-value { color: var(--amber); }
.widget-stat-block.color-rose    .widget-stat-value { color: var(--rose); }
.widget-stat-block.color-sky     .widget-stat-value { color: var(--sky); }

/* Table widget */
.widget-table-wrap {
    overflow: auto;
    max-height: 100%;
    width: 100%;
}

/* Feed widget */
.widget-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    max-height: 100%;
}

.widget-feed-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.widget-feed-item:last-child { border-bottom: none; }

/* Empty state */
.widget-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 8px;
    font-size: 13px;
}

.widget-empty i { font-size: 28px; opacity: .3; }

/* Edit mode - drag handle cursor */
.grid-stack.edit-mode .grid-stack-item > .grid-stack-item-content {
    cursor: grab;
}

/* Gridstack resize handle colour */
.grid-stack > .grid-stack-item > .ui-resizable-se {
    color: var(--indigo);
}

/* Dashboard top bar */
.dashboard-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-bar-left h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.4px;
    margin: 0 0 2px;
}

.dashboard-bar-left p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.dashboard-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Add Widget button - hidden until edit mode */
#btn-add-widget { display: none; }

/* Widget catalog modal */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.catalog-card {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--card-bg);
}

.catalog-card:hover {
    border-color: var(--indigo);
    box-shadow: 0 2px 12px rgba(14,116,144,.15);
    transform: translateY(-1px);
}

.catalog-card-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}

.catalog-card-icon.color-indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.catalog-card-icon.color-sky     { background: var(--sky-pale);     color: var(--sky); }
.catalog-card-icon.color-emerald { background: var(--emerald-pale); color: var(--emerald); }
.catalog-card-icon.color-amber   { background: var(--amber-pale);   color: var(--amber); }
.catalog-card-icon.color-rose    { background: var(--rose-pale);    color: var(--rose); }

.catalog-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.catalog-card-desc  { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.catalog-section-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    margin: 18px 0 8px;
}

/* Custom query builder */
.query-builder-step { display: none; }
.query-builder-step.active { display: block; }

.source-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.source-card {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.source-card:hover { border-color: var(--indigo); color: var(--indigo); }
.source-card.selected { border-color: var(--indigo); background: var(--indigo-pale); color: var(--indigo); }
.source-card i { display: block; font-size: 20px; margin-bottom: 5px; }

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.color-swatches {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.color-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: border-color .12s, transform .1s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text-primary); }
.color-swatch.indigo  { background: var(--indigo); }
.color-swatch.emerald { background: var(--emerald); }
.color-swatch.amber   { background: var(--amber); }
.color-swatch.rose    { background: var(--rose); }
.color-swatch.sky     { background: var(--sky); }

/* Step nav buttons */
.step-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* wt-input (shared input style) */
.wt-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--card-bg);
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}

.wt-input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(14,116,144,.1); }

/* btn-wt sm modifier */
.btn-wt.sm { padding: 5px 11px; font-size: 12px; }

/* ── AI Builder ─────────────────────────────────────────────────────────── */

.ai-builder-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wt-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--card-bg);
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
    resize: vertical;
    line-height: 1.55;
}

.wt-textarea:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(14,116,144,.1);
}

.ai-examples { }

.ai-example-label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.ai-example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.ai-chip {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    user-select: none;
}

.ai-chip:hover {
    border-color: var(--indigo);
    color: var(--indigo);
    background: var(--indigo-pale);
}

.ai-builder-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* ── Chart widget ────────────────────────────────────────────────────────── */

.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 180px;
}

/* Make sure grid-stack item content fills the card body for charts */
.widget-card .widget-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* wt-alert success variant */
.wt-alert.success {
    background: rgba(52,211,153,.1);
    border:     1px solid rgba(52,211,153,.3);
    color: var(--emerald-ink);
}

/* ============================================================
   Bootstrap-free shims - some views use Bootstrap class names
   (form-check, dropdown, collapse, .btn, spacing utilities) but
   Bootstrap is NOT loaded. These provide the styling/behaviour
   hooks instead (behaviour lives in js/site.js).
   ============================================================ */

/* Spacing & layout utilities */
.d-flex  { display: flex; }
.d-block { display: block; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.opacity-60     { opacity: .6; }

/* Checkboxes */
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input {
    width: 16px; height: 16px;
    margin: 0;
    accent-color: var(--indigo);
    cursor: pointer;
    flex-shrink: 0;
}
.form-check-label { font-size: 13px; color: var(--text-primary); cursor: pointer; }

/* Dropdown menus (toggled by js/site.js) */
.btn-group { position: relative; display: inline-flex; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px); left: 0;
    min-width: 190px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    padding: 5px;
    margin: 0;
    list-style: none;
    z-index: 300;
}
.dropdown-menu.show { display: block; }
.dropdown-menu-end { left: auto; right: 0; }
.dropdown-item {
    display: block;
    width: 100%;
    padding: 7px 12px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background .1s;
}
.dropdown-item:hover { background: var(--page-bg); color: var(--text-primary); }
.dropdown-item.active { background: var(--indigo-pale); color: var(--indigo); font-weight: 600; }

/* Collapse (toggled by js/site.js) */
.collapse:not(.show) { display: none; }

/* Generic .btn fallback so any Bootstrap-class button still looks right */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 15px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-sm, .btn-group-sm > .btn { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-outline-primary { border-color: var(--indigo); color: var(--indigo); }
.btn-outline-primary:hover { background: var(--indigo-pale); color: var(--indigo); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   Button polish - consistent hover/press/focus/disabled states
   ============================================================ */
.btn-wt {
    line-height: 1.4;
    white-space: nowrap;
    user-select: none;
    transition: background .12s, border-color .12s, opacity .12s, transform .05s;
}
.btn-wt:hover { opacity: 1; }
.btn-wt.danger:hover  { background: #dc2626; }
.btn-wt:active:not(:disabled) { transform: translateY(1px); }
.btn-wt:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.btn-wt:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ============================================================
   Responsive layer
   ============================================================ */

/* Wide tables scroll inside their panel instead of breaking the page */
.panel { overflow-x: auto; }
.wt-table { min-width: 560px; }

/* Mobile nav toggle (hamburger) - hidden on desktop */
#nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 17px;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    z-index: 99;
}

/* Tablet & below - sidebar becomes an off-canvas drawer */
@media (max-width: 1024px) {
    #sidebar {
        left: calc(-1 * var(--sidebar-w) - 12px);
        transition: left .25s cubic-bezier(.4,0,.2,1);
    }
    #sidebar.open { left: 0; box-shadow: 4px 0 32px rgba(0,0,0,.3); }
    #main { margin-left: 0; }
    #nav-toggle { display: flex; }
    .sidebar-backdrop.open { display: block; }
}

/* Phones */
@media (max-width: 768px) {
    #content { padding: 16px; }
    #topbar  { padding: 0 14px; gap: 8px; }
    .topbar-meta, .user-name { display: none; }
    .page-hdr-left h1 { font-size: 18px; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
    .kpi-card { padding: 14px 16px; }
    .kpi-value { font-size: 22px; }
    .territory-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
    .panel-hdr { flex-wrap: wrap; gap: 8px; }
    .panel-hdr .wt-input { width: 100% !important; }
    .filter-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .filter-tab { flex-shrink: 0; }
}

/* Small phones - drawer takes the full screen */
@media (max-width: 600px) {
    .drawer-panel { width: 100vw; max-width: 100vw; right: -100vw; }
    .drawer-panel.open { right: 0; }
}

/* ============================================================
   Filter toolbar - single card holding all list filters
   ============================================================ */
.filter-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 12px 16px;
    margin-bottom: 20px;
}

.toolbar-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.toolbar-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-muted);
}

.toolbar-divider { width: 1px; height: 26px; background: var(--border); }
@media (max-width: 900px) { .toolbar-divider { display: none; } }

.toolbar-date {
    width: 140px;
    padding: 5px 8px;
    font-size: 12.5px;
    font-family: inherit;
}

.toolbar-select {
    width: auto;
    min-width: 170px;
    max-width: 240px;
    padding: 5px 28px 5px 10px;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
}

/* Filter tab refinements */
.filter-tab { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.filter-tab .count {
    font-size: 10.5px;
    font-weight: 700;
    padding: 0 6px;
    border-radius: 99px;
    background: var(--indigo-pale);
    color: var(--indigo);
}
.filter-tab.clear { color: var(--text-muted); }
.filter-tab.clear:hover { color: var(--rose); border-color: var(--rose); background: var(--rose-pale); }

/* ── Territory country picker (checkbox chips) ──────────── */
.territory-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding: 2px;
}

.territory-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.territory-chip span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: border-color .12s, background .12s, color .12s;
}

.territory-chip span i { display: none; font-size: 12px; }

.territory-chip:hover span { border-color: var(--indigo); color: var(--indigo); }

.territory-chip input:checked + span {
    border-color: var(--indigo);
    background: var(--indigo-pale);
    color: var(--indigo);
}

.territory-chip input:checked + span i { display: inline; }

.territory-chip input:focus-visible + span {
    outline: 2px solid var(--indigo);
    outline-offset: 2px;
}

/* Table cell helpers */
.td-clip {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-nowrap { white-space: nowrap; }

/* ============================================================
   AQUA WATCHTOWER - observatory design layer
   Deep-navy instrument sidebar, blueprint content area, aqua
   signal accents, mono data readouts. Loaded last so it
   refines the base component styles above.
   ============================================================ */

/* ── Display type ───────────────────────────────────────── */
.page-hdr-left h1,
.dashboard-bar-left h1,
.topbar-title,
.modal-title,
.sb-brand-name,
.tile-name,
.drawer-hdr {
    font-family: var(--font-display);
}

.page-hdr-left h1, .dashboard-bar-left h1 { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }

/* Data readouts in tabular mono - numbers line up like instruments */
.kpi-value, .stat-pill-val, .widget-stat-value, .score-num, .tile-score-num {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.kpi-value { letter-spacing: -1.2px; }

/* ── Content area - faint blueprint dot grid + aqua wash ──── */
#content {
    background:
        radial-gradient(1100px 360px at 50% -180px, var(--page-wash), transparent 65%),
        radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: auto, 26px 26px;
}

/* ── Topbar - frosted glass ─────────────────────────────── */
#topbar {
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ── Sidebar - observatory texture, aqua identity ──────── */
#sidebar {
    background:
        radial-gradient(680px 300px at -15% -8%, rgba(34,211,238,.08), transparent 60%),
        radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 24px 24px,
        var(--sb-bg);
}

.sb-brand-icon {
    background: linear-gradient(135deg, #06b6d4, #0e7490);
    box-shadow: 0 2px 14px rgba(34,211,238,.35);
}

.sb-brand-tagline {
    text-transform: uppercase;
    letter-spacing: 1.6px;
    font-size: 9px;
}

.sb-link.active::before { box-shadow: 0 0 10px rgba(34,211,238,.75); }

.user-avatar { background: linear-gradient(135deg, #06b6d4, #0e7490); }

/* ── KPI cards - signal strip on hover ──────────────────── */
.kpi-card { position: relative; overflow: hidden; }
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--indigo-light), var(--indigo));
    opacity: 0;
    transition: opacity .18s;
}
.kpi-card:hover::before { opacity: 1; }

/* ── Panels - micro-label headers ───────────────────────── */
.panel-hdr { background: var(--panel-hdr-bg); }
.panel-hdr-title {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .9px;
    color: var(--text-secondary);
}

/* ── Tables - aqua scan-line hover ──────────────────────── */
.wt-table thead th { background: var(--surface-2); }
.wt-table tbody tr:hover td { background: var(--row-hover); }
.wt-table tbody tr:hover td:first-child { box-shadow: inset 2.5px 0 0 var(--indigo-light); }

/* ── Buttons - depth + aqua interaction ─────────────────── */
.btn-wt.primary {
    background: linear-gradient(180deg, #0d8aa9, #0e7490);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(8,23,42,.18);
}
.btn-wt.primary:hover { background: linear-gradient(180deg, #0fa0c2, #0c8298); }
.btn-wt.danger { box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 1px 2px rgba(8,23,42,.15); }
.btn-wt.outline:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-pale); }

/* ── Filter chips - squared instrument toggles ──────────── */
.filter-tab {
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 5px 12px;
}

.toolbar-label { color: var(--text-muted); }

/* ── Territory tiles - lift with aqua glow ──────────────── */
.territory-tile:hover {
    border-color: var(--indigo-light);
    box-shadow: 0 6px 24px rgba(14,116,144,.16);
    transform: translateY(-2px);
}
.tile-score-fill { background: linear-gradient(90deg, var(--indigo-light), var(--indigo)); }

/* ── Drawer - deeper presence ───────────────────────────── */
.drawer-panel { border-left: 1px solid var(--border); box-shadow: -12px 0 48px rgba(8,23,42,.25); }
.drawer-hdr { background: var(--panel-hdr-bg); }
.drawer-section-title { letter-spacing: 1px; }

/* ── Inputs - aqua focus ring ───────────────────────────── */
.wt-input:focus, .form-select:focus, .wt-textarea:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(14,116,144,.13);
}

/* ── Entrance - staggered rise on page load ─────────────── */
@keyframes wt-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
    .kpi-card, .panel, .filter-toolbar, .stat-pill {
        animation: wt-rise .45s cubic-bezier(.22,.8,.3,1) both;
    }
    .kpi-card:nth-child(2), .stat-pill:nth-child(2) { animation-delay: .05s; }
    .kpi-card:nth-child(3), .stat-pill:nth-child(3) { animation-delay: .10s; }
    .kpi-card:nth-child(4), .stat-pill:nth-child(4) { animation-delay: .15s; }
    .kpi-card:nth-child(5), .stat-pill:nth-child(5) { animation-delay: .20s; }
    .panel { animation-delay: .12s; }

    /* Stagger only the first tiles - grids can hold 1000+ */
    .territory-tile:nth-child(-n+8) { animation: wt-rise .4s cubic-bezier(.22,.8,.3,1) both; }
    .territory-tile:nth-child(2) { animation-delay: .04s; }
    .territory-tile:nth-child(3) { animation-delay: .08s; }
    .territory-tile:nth-child(4) { animation-delay: .12s; }
    .territory-tile:nth-child(5) { animation-delay: .16s; }
    .territory-tile:nth-child(6) { animation-delay: .20s; }
    .territory-tile:nth-child(7) { animation-delay: .24s; }
    .territory-tile:nth-child(8) { animation-delay: .28s; }
}


/* ============================================================
   Workflow automation
   ============================================================ */

/* â”€â”€ Status dot â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.wf-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0; display: inline-block;
}
.wf-dot.emerald { background: var(--emerald); }
.wf-dot.slate   { background: var(--line-strong); }
.wf-dot.rose    { background: var(--rose); }

/* â”€â”€ Integration readiness chips â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.int-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.int-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600;
    padding: 4px 10px; border-radius: 99px;
    border: 1px solid var(--border);
}
.int-chip.ok      { background: var(--emerald-pale); color: var(--emerald-ink); border-color: var(--emerald-line); }
.int-chip.missing { background: var(--surface-2);             color: var(--text-muted); }
.int-chip i       { font-size: 12px; }

.int-row {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 0; border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}
.int-row:last-of-type { border-bottom: none; }
.int-row i         { width: 16px; text-align: center; color: var(--text-muted); }
.int-row .int-name { flex: 1; font-weight: 500; color: var(--text-secondary); }

/* â”€â”€ Workflow list â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.wf-list { display: flex; flex-direction: column; }

.wf-card {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
}
.wf-card:last-child { border-bottom: none; }
.wf-card:hover      { background: var(--surface-2); }
.wf-card.live       { border-left-color: var(--emerald); }

.wf-icon {
    width: 36px; height: 36px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.wf-icon.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.wf-icon.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.wf-icon.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.wf-icon.rose    { background: var(--rose-pale);    color: var(--rose-ink); }
.wf-icon.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.wf-icon.orange  { background: var(--orange-pale);  color: var(--orange-ink); }
.wf-icon.slate   { background: var(--surface-3);             color: var(--text-secondary); }

.wf-body { flex: 1; min-width: 0; }

.wf-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.wf-name {
    font-size: 14.5px; font-weight: 700; color: var(--text-primary);
    text-decoration: none; letter-spacing: -0.2px;
}
.wf-name:hover { color: var(--indigo); text-decoration: none; }

.wf-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

.wf-chips {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap; margin-top: 9px;
}

.wf-chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 600;
    padding: 3px 8px; border-radius: 6px;
    background: var(--surface-3); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.wf-chip i { font-size: 11px; }
.wf-chip.trigger { background: var(--card-bg); border-color: var(--line-strong); color: var(--text-primary); }
.wf-chip.missing { background: var(--amber-pale);   color: var(--amber-ink);               border-color: var(--amber-line); }
.wf-chip.indigo  { background: var(--indigo-pale);  color: var(--indigo);         border-color: var(--indigo-line); }
.wf-chip.emerald { background: var(--emerald-pale); color: var(--emerald-ink);               border-color: var(--emerald-line); }
.wf-chip.amber   { background: var(--amber-pale);   color: var(--amber-ink);               border-color: var(--amber-line); }
.wf-chip.rose    { background: var(--rose-pale);    color: var(--rose-ink);               border-color: var(--rose-line); }
.wf-chip.sky     { background: var(--sky-pale);     color: var(--sky-ink);               border-color: var(--sky-line); }
.wf-chip.orange  { background: var(--orange-pale);  color: var(--orange-ink);               border-color: var(--orange-line); }
.wf-chip.slate   { background: var(--surface-3);             color: var(--text-secondary); }

.wf-arrow { font-size: 11px; color: var(--line-strong); margin: 0 1px; }

.wf-meta {
    display: flex; align-items: center; gap: 14px;
    flex-wrap: wrap; margin-top: 10px;
    font-size: 11.5px; color: var(--text-muted);
}
.wf-meta i { margin-right: 3px; opacity: .8; }

.wf-actions {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap; flex-shrink: 0; justify-content: flex-end;
    max-width: 260px;
}

/* â”€â”€ Template gallery â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.tpl-grid {
    display: grid; gap: 14px; padding: 18px 20px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.tpl-card {
    display: flex; flex-direction: column;
    border: 1px solid var(--border); border-radius: 10px;
    padding: 16px; background: var(--card-bg);
    transition: border-color .15s, box-shadow .15s;
}
.tpl-card:hover { border-color: var(--indigo-light); box-shadow: var(--card-shadow); }

.tpl-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.tpl-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
}
.tpl-icon.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.tpl-icon.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.tpl-icon.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.tpl-icon.rose    { background: var(--rose-pale);    color: var(--rose-ink); }
.tpl-icon.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.tpl-icon.orange  { background: var(--orange-pale);  color: var(--orange-ink); }
.tpl-icon.slate   { background: var(--surface-3);             color: var(--text-secondary); }

.tpl-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); line-height: 1.25; }
.tpl-desc { font-size: 12.5px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }

.tpl-steps {
    margin: 0 0 14px; padding-left: 18px;
    font-size: 12px; color: var(--text-secondary); line-height: 1.7;
}
.tpl-steps li::marker { color: var(--indigo); font-weight: 700; }

/* â”€â”€ Builder layout â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.wf-builder { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.wf-builder-main { min-width: 0; }
.wf-builder-side { position: sticky; top: 76px; }

.wf-step { margin-bottom: 18px; }

.wf-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent-solid); color: #fff;
    font-size: 11px; font-weight: 700; margin-right: 8px;
    font-family: var(--font-body);
}

.wf-lead { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.55; }
.wf-lead code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

.wf-hint-line {
    font-size: 12.5px; color: var(--text-muted); margin: 0;
    padding: 14px 16px; border: 1px dashed var(--border); border-radius: 8px;
    background: var(--surface-2);
}
.wf-hint-line i { margin-right: 6px; }

/* â”€â”€ Trigger picker â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.trg-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.trg-card {
    display: flex; align-items: flex-start; gap: 10px;
    text-align: left; padding: 12px; cursor: pointer;
    background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 10px;
    font-family: inherit; position: relative;
    transition: border-color .15s, background .15s;
}
.trg-card:hover    { border-color: var(--indigo-light); }
.trg-card.selected { border-color: var(--indigo); background: var(--indigo-pale); }

.trg-icon {
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.trg-icon.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.trg-icon.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.trg-icon.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.trg-icon.rose    { background: var(--rose-pale);    color: var(--rose-ink); }
.trg-icon.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.trg-icon.orange  { background: var(--orange-pale);  color: var(--orange-ink); }
.trg-card.selected .trg-icon { background: var(--card-bg); }

.trg-body { min-width: 0; }
.trg-name { font-size: 13px; font-weight: 700; color: var(--text-primary); line-height: 1.25; }
.trg-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.45; }

.trg-tick { position: absolute; top: 9px; right: 9px; font-size: 14px; color: var(--indigo); display: none; }
.trg-card.selected .trg-tick { display: block; }

/* â”€â”€ Config grids â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cfg-grid { display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cfg-grid .form-group { margin-bottom: 16px; }

/* Long-form inputs get the full row */
.cfg-grid .form-group:has(textarea) { grid-column: 1 / -1; }

.cfg-check {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 12.5px; color: var(--text-secondary); cursor: pointer;
    line-height: 1.5;
}
.cfg-check input { margin-top: 2px; flex-shrink: 0; accent-color: var(--indigo); }

.cfg-vars-hint {
    display: inline-block; margin-left: 5px;
    font-family: var(--font-mono); font-size: 10px; font-weight: 600;
    background: var(--indigo-pale); color: var(--indigo);
    padding: 1px 5px; border-radius: 4px; cursor: help;
}

/* â”€â”€ Conditions â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cond-row {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 0; flex-wrap: wrap;
}
.cond-row + .cond-row { border-top: 1px solid var(--border); }

.cond-join {
    font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
    color: var(--text-muted); min-width: 40px; letter-spacing: .5px;
}

.cond-row .form-select { width: auto; min-width: 150px; flex: 0 1 auto; }
.cond-row .wt-input    { width: auto; min-width: 120px; flex: 1 1 120px; max-width: 240px; }
.cond-novalue          { color: var(--text-muted); flex: 1; font-size: 12px; }

.cond-del {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-muted); padding: 5px 7px; border-radius: 6px;
    font-size: 12px; margin-left: auto;
}
.cond-del:hover { background: var(--rose-pale); color: var(--rose); }

/* â”€â”€ Action cards â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.act-list { display: flex; flex-direction: column; gap: 10px; }

.act-card {
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--card-bg); overflow: hidden;
}
.act-card.disabled { opacity: .6; }

.act-hdr {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 13px; cursor: pointer; background: var(--surface-2);
}
.act-hdr:hover { background: var(--row-hover); }

.act-step {
    font-family: var(--font-mono); font-size: 11px; font-weight: 600;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--track); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.act-icon {
    width: 28px; height: 28px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0;
}
.act-icon.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.act-icon.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.act-icon.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.act-icon.rose    { background: var(--rose-pale);    color: var(--rose-ink); }
.act-icon.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.act-icon.orange  { background: var(--orange-pale);  color: var(--orange-ink); }
.act-icon.slate   { background: var(--surface-3);             color: var(--text-secondary); }

.act-title { flex: 1; min-width: 0; }
.act-name  { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.act-sub   {
    font-size: 11.5px; color: var(--text-muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: var(--font-mono);
}

.act-tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.act-tool {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-muted); padding: 4px 6px; border-radius: 5px; font-size: 12px;
}
.act-tool:hover:not(:disabled) { background: var(--track); color: var(--text-primary); }
.act-tool:disabled             { opacity: .3; cursor: default; }
.act-tool[data-act-del]:hover  { background: var(--rose-pale); color: var(--rose); }

.act-chev { font-size: 11px; color: var(--text-muted); margin-left: 4px; transition: transform .2s; }
.act-card.collapsed .act-chev { transform: rotate(-90deg); }

.act-body { padding: 16px 14px 6px; border-top: 1px solid var(--border); }
.act-card.collapsed .act-body { display: none; }

.act-desc { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.5; }

.act-flags {
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px 0 14px; border-top: 1px solid var(--border);
}

/* â”€â”€ Action picker modal â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.pick-overlay {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(8,23,42,.55); backdrop-filter: blur(2px);
    display: none; align-items: flex-start; justify-content: center;
    padding: 60px 20px; overflow-y: auto;
}
.pick-overlay.open { display: flex; }

.pick-modal {
    background: var(--card-bg); border-radius: 14px; width: 100%; max-width: 780px;
    box-shadow: 0 24px 64px rgba(8,23,42,.35); overflow: hidden;
}

.pick-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 20px; background: var(--sb-bg); color: #f8fafc;
    font-size: 14px; font-weight: 700;
}
.pick-hdr .modal-close { color: var(--sb-text); }

.pick-grid {
    display: grid; gap: 10px; padding: 18px 20px;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}

.pick-card {
    display: flex; align-items: flex-start; gap: 11px;
    text-align: left; padding: 12px; cursor: pointer;
    background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 10px;
    font-family: inherit; transition: border-color .15s, background .15s;
}
.pick-card:hover { border-color: var(--indigo); background: var(--indigo-pale); }

.pick-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.pick-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.45; }

/* â”€â”€ Variable chips â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.var-chips { display: flex; gap: 5px; flex-wrap: wrap; }

.var-chip {
    font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
    background: var(--surface-3); color: var(--text-secondary);
    border: 1px solid var(--border); border-radius: 5px;
    padding: 3px 6px; cursor: pointer;
}
.var-chip:hover { background: var(--indigo-pale); color: var(--indigo); border-color: var(--indigo-light); }

/* â”€â”€ Sticky save bar â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.wf-savebar {
    position: sticky; bottom: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 18px; margin: 4px -4px 0;
    background: var(--glass); backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(8,23,42,.07);
}
.wf-savebar-left  { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.wf-savebar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* â”€â”€ Run audit trail â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.log-groups { display: flex; flex-direction: column; }

.log-group { border-bottom: 1px solid var(--border); }
.log-group:last-child { border-bottom: none; }

.log-group-hdr {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 20px; background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.log-entity { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.log-key    { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }
.log-count  { font-size: 11px; color: var(--text-muted); margin-left: auto; }

.log-line {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 9px 20px; font-size: 12.5px;
    border-bottom: 1px solid var(--border-subtle);
}
.log-line:last-child { border-bottom: none; }
.log-line.bad        { background: var(--rose-wash); }

.log-tick { font-size: 12px; margin-top: 2px; flex-shrink: 0; color: var(--emerald); }
.log-line.bad .log-tick { color: var(--rose); }

.log-step {
    font-weight: 600; color: var(--text-secondary);
    min-width: 175px; flex-shrink: 0;
}
.log-step i { margin-right: 4px; opacity: .8; }

.log-detail { flex: 1; color: var(--text-secondary); min-width: 0; word-break: break-word; }
.log-time   { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* â”€â”€ Narrow screens â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
@media (max-width: 1100px) {
    .wf-builder { grid-template-columns: minmax(0, 1fr); }
    .wf-builder-side { position: static; }
}

@media (max-width: 860px) {
    .wf-card { flex-wrap: wrap; }
    .wf-actions { max-width: none; width: 100%; justify-content: flex-start; }
    .log-step { min-width: 0; }
    .log-line { flex-wrap: wrap; }
}


/* ============================================================
   Chrome - brand mark, topbar controls, avatars, theme switch
   ============================================================ */

/* Brand mark is an SVG now; the old gradient box styling no longer applies */
.sb-brand-icon {
    width: 36px; height: 36px;
    background: none;
    border-radius: 9px;
    box-shadow: 0 4px 16px rgba(34,211,238,.28);
}
.sb-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar-title { font-weight: 600; letter-spacing: -0.2px; }
.topbar-right { gap: 10px; }

kbd {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 5px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    background: var(--surface-2);
    color: var(--text-muted);
    white-space: nowrap;
}

.topbar-search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    min-width: 220px;
    padding: 0 8px 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.topbar-search:hover { border-color: var(--indigo-line); color: var(--text-secondary); background: var(--card-bg); }
.topbar-search-text { flex: 1; text-align: left; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--indigo-line); color: var(--indigo); }

/* Sun shows in dark mode (click = go light), moon in light mode */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle i { position: absolute; transition: transform .35s cubic-bezier(.3,1.4,.5,1), opacity .2s; }
.theme-toggle .bi-sun        { transform: translateY(140%) rotate(-90deg); opacity: 0; }
.theme-toggle .bi-moon-stars { transform: none; opacity: 1; }
[data-theme="dark"] .theme-toggle .bi-sun        { transform: none; opacity: 1; color: var(--amber); }
[data-theme="dark"] .theme-toggle .bi-moon-stars { transform: translateY(-140%) rotate(90deg); opacity: 0; }

/* Mobile hamburger follows the theme */
#nav-toggle { background: var(--card-bg); }

/* ── Avatars - initials underneath, photo on top when we have one ── */
.user-avatar {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #22d3ee, #0e7490);
    box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 3.5px var(--indigo-line);
}
.user-avatar img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.user-avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.topbar-user:hover { background: var(--surface-2); }

/* ── User menu ──────────────────────────────────────────── */
.user-dropdown {
    width: 280px;
    background: var(--card-bg);
    box-shadow: var(--popover-shadow);
    transform-origin: top right;
}
.user-dropdown.open { animation: wt-pop .16s cubic-bezier(.2,.9,.3,1.2); }
.user-dropdown-hdr {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface-2);
}
.user-dropdown-name  { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.user-dropdown-email { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown-item:hover { background: var(--surface-2); }

.user-dropdown-theme {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.theme-seg {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}
.theme-seg button {
    width: 30px; height: 26px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
}
.theme-seg button:hover { color: var(--text-primary); }
.theme-seg button[aria-pressed="true"] {
    background: var(--card-bg);
    color: var(--indigo);
    box-shadow: 0 1px 3px rgba(8,23,42,.15);
}

@keyframes wt-pop {
    from { opacity: 0; transform: translateY(-4px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* ============================================================
   Command palette
   ============================================================ */
.cmdk-overlay {
    position: fixed; inset: 0;
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 16px 16px;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.cmdk-overlay.open { display: flex; animation: wt-fade .12s ease-out; }

.cmdk {
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: var(--popover-shadow), 0 0 0 1px rgba(34,211,238,.06);
    overflow: hidden;
    animation: wt-pop .18s cubic-bezier(.2,.9,.3,1.15);
}

.cmdk-search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 16px;
}
.cmdk-input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 15px;
}
.cmdk-input:focus-visible { outline: 0; }
.cmdk-input::placeholder { color: var(--text-muted); }

.cmdk-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 6px; }

.cmdk-group {
    padding: 10px 10px 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cmdk-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--text-secondary);
    cursor: pointer;
}
.cmdk-item i { width: 18px; text-align: center; font-size: 15px; color: var(--text-muted); }
.cmdk-item.active { background: var(--indigo-pale); color: var(--text-primary); }
.cmdk-item.active i { color: var(--indigo); }
.cmdk-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-hint  { font-size: 11.5px; color: var(--text-muted); }

.cmdk-empty { padding: 36px 12px; text-align: center; color: var(--text-muted); font-size: 13px; }
.cmdk-empty i { display: block; font-size: 22px; margin-bottom: 8px; opacity: .5; }

.cmdk-foot {
    display: flex;
    gap: 16px;
    padding: 9px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 11.5px;
    color: var(--text-muted);
}
.cmdk-foot kbd { margin-right: 2px; }

@keyframes wt-fade { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   Theme polish
   ============================================================ */

/* Smooth cross-fade while switching theme (class added briefly by theme.js) */
.theme-switching *, .theme-switching *::before, .theme-switching *::after {
    transition: background-color .3s ease, border-color .3s ease, color .2s ease, fill .3s ease, box-shadow .3s ease !important;
}

/* Visible keyboard focus everywhere, in the brand colour */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--indigo);
    outline-offset: 2px;
}

/* Inputs sit slightly below the card surface in dark mode */
.wt-input, .form-select, .wt-textarea, .sp-custom input, .sp-targets input { background: var(--input-bg); color: var(--text-primary); }
.wt-input::placeholder, .wt-textarea::placeholder { color: var(--text-muted); opacity: .8; }

[data-theme="dark"] ::selection { background: rgba(34,211,238,.35); color: #fff; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2a3a52; }
[data-theme="dark"] .tile-logo { background: #fff; border-color: transparent; }   /* most logos assume white */
[data-theme="dark"] .kpi-card:hover,
[data-theme="dark"] .territory-tile:hover { box-shadow: 0 8px 28px rgba(0,0,0,.45), 0 0 0 1px rgba(34,211,238,.18); }
[data-theme="dark"] .btn-wt.primary {
    background: linear-gradient(180deg, #11a3c4, #0e7f9c);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 0 0 1px rgba(34,211,238,.25), 0 4px 14px rgba(34,211,238,.15);
}
[data-theme="dark"] .btn-wt.primary:hover { background: linear-gradient(180deg, #16b4d6, #0f8eae); }
[data-theme="dark"] .wt-modal,
[data-theme="dark"] .pick-modal { border: 1px solid var(--card-border); }

/* Phones: search collapses to an icon */
@media (max-width: 768px) {
    .topbar-search { min-width: 0; width: 36px; padding: 0; justify-content: center; }
    .topbar-search-text, .topbar-search kbd { display: none; }
    .cmdk-overlay { padding-top: 8vh; }
    .cmdk-foot { display: none; }
}

/* ── Widget catalog: show what's already on the dashboard ── */
.catalog-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.catalog-added {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 700;
    padding: 2px 8px; border-radius: 99px;
    background: var(--emerald-pale); color: var(--emerald-ink);
    white-space: nowrap;
}
.catalog-card.added {
    cursor: default;
    background: var(--surface-2);
    border-style: dashed;
}
.catalog-card.added:hover { border-color: var(--border); box-shadow: none; transform: none; }
.catalog-card.added .catalog-card-icon,
.catalog-card.added .catalog-card-title,
.catalog-card.added .catalog-card-desc { opacity: .55; }

/* ============================================================
   Lists - search, filters, sortable headers, paging
   ============================================================ */

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.list-search {
    position: relative;
    flex: 1 1 220px;
    max-width: 380px;
}
.list-search i {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}
.list-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 32px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--input-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.list-search input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-pale); }
.list-search input::placeholder { color: var(--text-muted); }

.list-filter {
    height: 36px;
    max-width: 180px;
    padding: 0 30px 0 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background-color: var(--input-bg);
    color: var(--text-secondary);
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    text-overflow: ellipsis;
    transition: border-color .15s, background-color .15s, color .15s;
}
.list-filter:hover { border-color: var(--line-strong); }
.list-filter:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-pale); }
/* An active filter stands out so it's obvious why rows are missing */
.list-filter.set { border-color: var(--indigo-line); background-color: var(--indigo-pale); color: var(--indigo); font-weight: 600; }

.list-clear {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    padding: 0 10px;
    border-radius: 9px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
}
.list-clear:hover { color: var(--rose); background: var(--rose-pale); text-decoration: none; }
.list-clear[hidden] { display: none; }

.list-results { transition: opacity .15s; }
.list-results.is-loading { opacity: .55; pointer-events: none; }

/* Sortable headers (server links and client-side) */
.wt-table th.th-sort { cursor: pointer; user-select: none; }
.wt-table th.th-sort a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.wt-table th.th-sort i { font-size: 10px; opacity: .45; margin-left: 2px; transition: opacity .15s; }
.wt-table th.th-sort:hover { color: var(--text-primary); }
.wt-table th.th-sort:hover i { opacity: .8; }
.wt-table th.th-sort.active { color: var(--indigo); }
.wt-table th.th-sort.active i { opacity: 1; font-size: 12px; }
.wt-table th.td-right a { justify-content: flex-end; }
.wt-table .num { font-variant-numeric: tabular-nums; }

/* Entity cell: logo / initials + name + sub-line */
.cell-entity { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.cell-logo {
    width: 30px; height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    object-fit: contain;
    padding: 2px;
}
.cell-logo.fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-color: transparent;
    background: var(--indigo-pale);
    color: var(--indigo);
    font-size: 12px;
    font-weight: 700;
}
.cell-logo.round { border-radius: 50%; }
.cell-title { color: var(--text-primary); text-decoration: none; }
.cell-title:hover { color: var(--indigo); }
.cell-link { color: var(--text-secondary); text-decoration: none; font-weight: 500; }
.cell-link:hover { color: var(--indigo); text-decoration: underline; }
.cell-sub { display: flex; align-items: center; gap: 7px; }
.cell-mail { color: inherit; text-decoration: none; }
.cell-mail:hover { color: var(--indigo); text-decoration: underline; }
.cell-linkedin { color: #0a66c2; font-size: 12.5px; line-height: 1; }
[data-theme="dark"] .cell-linkedin { color: #4ea1f3; }

tr.row-link { cursor: pointer; }

/* Footer: range + page size + pager */
.list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--text-muted);
}
.list-range { display: flex; align-items: center; gap: 16px; }
.list-range b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.list-size { display: inline-flex; align-items: center; gap: 6px; }
.list-size select {
    height: 30px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--input-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 12.5px;
}

.pager { display: flex; align-items: center; gap: 4px; }
.pager-btn {
    min-width: 32px; height: 32px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: border-color .12s, color .12s, background .12s;
}
.pager-btn:hover { border-color: var(--indigo-line); color: var(--indigo); text-decoration: none; }
.pager-btn.on { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.pager-btn.disabled { opacity: .4; pointer-events: none; }
.pager-gap { padding: 0 4px; color: var(--text-muted); }

/* Client-side quick filter above a table */
.table-search { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.table-search-count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.wt-table tr.filtered-out { display: none !important; }
.wt-table tr.table-search-empty td { text-align: center; padding: 28px 16px; color: var(--text-muted); }

@media (max-width: 768px) {
    .list-search { max-width: none; flex-basis: 100%; }
    .list-filter { flex: 1 1 calc(50% - 4px); max-width: none; }
    .list-footer { flex-direction: column; align-items: stretch; }
    .pager { justify-content: center; flex-wrap: wrap; }
}

/* Header cells default to centred in browsers; align with their columns instead */
.wt-table thead th { text-align: left; }
.wt-table thead th.td-right, .wt-table thead th.num { text-align: right; }
.wt-table thead th.td-center { text-align: center; }

/* Live lists swap their results on every keystroke; replaying the entrance animation would flicker */
.list-results .panel { animation: none; }

/* ── Tooltips (tips.js) ───────────────────────────────────────
   Dark bubble in both themes, so it reads as "help" rather than content. */
.wt-tip {
    position: fixed; z-index: 3000; pointer-events: none;
    max-width: 280px; padding: 7px 10px; border-radius: 8px;
    background: #0b1a2c; color: #eef4fa; border: 1px solid #23395a;
    font: 500 12.5px/1.45 var(--font-body); text-align: left; white-space: normal;
    box-shadow: 0 8px 24px rgba(4,12,24,.28);
    opacity: 0; transform: translateY(3px); transition: opacity .12s ease, transform .12s ease;
}
.wt-tip.show { opacity: 1; transform: none; }
.wt-tip.detail { max-width: 360px; white-space: pre-line; }
.wt-tip::after {
    content: ""; position: absolute; left: var(--arrow-x, 50%); bottom: -5px;
    width: 8px; height: 8px; margin-left: -4px; background: inherit;
    border-right: 1px solid #23395a; border-bottom: 1px solid #23395a; transform: rotate(45deg);
}
.wt-tip.below::after { bottom: auto; top: -5px; transform: rotate(225deg); }

/* Small "?" help marker next to labels and headings */
.help-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; margin-left: 4px; border-radius: 50%;
    font-size: 10px; font-weight: 700; line-height: 1; vertical-align: 1px;
    color: var(--text-muted); border: 1px solid var(--line-strong); cursor: help;
}
.help-dot:hover, .help-dot:focus-visible { color: var(--indigo); border-color: var(--indigo); outline: none; }

/* ── Clickable cards / stats ──────────────────────────────────
   Anything that navigates gets the same lift + "open" chevron. */
.wt-clickable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; color: inherit; text-decoration: none; position: relative; }
.wt-clickable:hover { transform: translateY(-1px); box-shadow: var(--popover-shadow); border-color: var(--indigo-line); text-decoration: none; color: inherit; }
.wt-clickable:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: 2px; }
.wt-clickable .go-chev { opacity: 0; transition: opacity .12s ease, transform .12s ease; color: var(--indigo); }
.wt-clickable:hover .go-chev, .wt-clickable:focus-visible .go-chev { opacity: 1; transform: translateX(2px); }
tr.wt-row-link { cursor: pointer; }
tr.wt-row-link:hover td { background: var(--row-hover); }

/* ── Sync status pill (_SyncStatus view component) ──────────── */
.sync-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.sync-status .sync-when { display: inline-flex; align-items: center; gap: 5px; cursor: help; }
.sync-status .sync-when.stale { color: var(--amber-ink); }
.sync-status .sync-when.never { color: var(--rose-ink); }
.sync-status .bi-arrow-clockwise.spin { display: inline-block; animation: wt-spin 1s linear infinite; }
@keyframes wt-spin { to { transform: rotate(360deg); } }

/* ── Toasts (ux.js wtToast) ─────────────────────────────────── */
.wt-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 3100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.wt-toast {
    display: flex; align-items: flex-start; gap: 9px; padding: 11px 14px; border-radius: 10px;
    background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--card-border);
    box-shadow: var(--popover-shadow); font-size: 13px; line-height: 1.45;
    opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
}
.wt-toast.show { opacity: 1; transform: none; }
.wt-toast i { font-size: 15px; margin-top: 1px; flex-shrink: 0; }
.wt-toast.info i    { color: var(--sky); }
.wt-toast.success i { color: var(--emerald); }
.wt-toast.warning i { color: var(--amber); }
.wt-toast.error i   { color: var(--rose); }

/* ── Territory / Visitors / Signals / company drawer: interactivity pass ── */
.territory-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 12px; color: var(--text-muted); margin: -4px 0 14px; }
.territory-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.territory-legend-bar { display: inline-block; flex: none; width: 40px; }
.territory-tile { cursor: pointer; }
.territory-tile:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: 2px; }
.drawer-link-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; margin: 0 -6px; border-bottom: 1px solid var(--border); border-radius: 6px; color: inherit; text-decoration: none; }
.drawer-link-row:hover, .drawer-link-row:focus-visible { background: var(--row-hover); color: inherit; text-decoration: none; }
.drawer-link-row .go-ext { margin-left: auto; font-size: 11px; color: var(--indigo); opacity: 0; transition: opacity .12s ease; flex-shrink: 0; }
.drawer-link-row:hover .go-ext, .drawer-link-row:focus-visible .go-ext { opacity: 1; }
.drawer-link-item .activity-body { border-radius: 6px; }
.drawer-link-item .activity-body:hover .activity-title { color: var(--indigo); text-decoration: underline; }
.drawer-section-title .help-dot { margin-left: 4px; }
#drawer-content .bi.spin { display: inline-block; animation: wt-spin 1s linear infinite; }
.signal-company-link { display: inline-flex; align-items: center; gap: 4px; color: var(--indigo); text-decoration: none; font-weight: 500; cursor: pointer; }
.signal-company-logo { width: 16px; height: 16px; flex-shrink: 0; border-radius: 3px; object-fit: contain; border: 1px solid var(--border); }
.signal-company-initials { align-items: center; justify-content: center; background: var(--accent-solid); color: #fff; font-size: 8px; font-weight: 700; }
.signal-company-link:hover { text-decoration: underline; color: var(--indigo); }
#visitors-table tr.wt-row-link:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { #drawer-content .bi.spin { animation: none; } }

/* ── Control Centre / dashboard UX (Views/Dashboard, _Widget partial) ───────── */
.dashboard-bar-right .sync-status { margin-right: 4px; }
.widget-hdr .go-chev { margin-left: auto; font-size: 12px; }
.widget-title .help-dot { flex-shrink: 0; }
.grid-stack.edit-mode .go-chev { display: none; }
.grid-stack.edit-mode .wt-clickable { cursor: inherit; }
.grid-stack.edit-mode .widget-item-link { pointer-events: none; }  /* no accidental navigation while arranging */
.widget-item-link { display: block; color: inherit; text-decoration: none; border-radius: 6px; }
.widget-item-link:hover .activity-title, .widget-item-link:focus-visible .activity-title { color: var(--indigo); }
.widget-item-link:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: 2px; }
.widget-item-link .ext-ico { font-size: 10px; color: var(--text-muted); margin-left: 3px; }
.widget-feed-item .activity-actions { margin-left: auto; flex-shrink: 0; }
.widget-empty p { max-width: 280px; margin: 0; line-height: 1.45; }
.wt-table tr.wt-row-link:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: -2px; }
.dash-edit-hint { margin-bottom: 14px; align-items: center; gap: 10px; }
.dash-empty { border: 1px dashed var(--line-strong); border-radius: 12px; margin-bottom: 16px; }
.dash-empty i { font-size: 30px; opacity: .4; display: block; margin-bottom: 8px; }
.dash-empty .btn-wt { margin-top: 10px; }
.catalog-card[role="button"]:focus-visible,
.source-card:focus-visible, .color-swatch:focus-visible, .ai-chip:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: 2px; }
#topbar-user:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: 2px; border-radius: 8px; }

/* Command palette: one-line description under the highlighted item */
.cmdk-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cmdk-desc { display: none; font-size: 11.5px; color: var(--text-muted); white-space: normal; line-height: 1.35; margin-top: 2px; }
.cmdk-item.active .cmdk-desc { display: block; }

/* ── UX pass: Workflows / Admin / Territory admin / Users ───── */
a.log-entity { text-decoration: none; }
a.log-entity:hover, a.log-entity:focus-visible { color: var(--indigo); text-decoration: underline; }
.wf-meta a { text-decoration: none; }
.wf-meta a:hover { text-decoration: underline; }
.wf-card.wt-clickable .wf-title-row .go-chev { font-size: 12px; }
.act-hdr[role="button"]:focus-visible { outline: 2px solid var(--indigo-light); outline-offset: 2px; border-radius: 8px; }
.cfg-vars-hint[tabindex] { cursor: help; }
/* Larger company logo beside the page title on the company page */
.cell-logo.company-hdr-logo { width: 44px; height: 44px; border-radius: 10px; padding: 3px; }
.cell-logo.fallback.company-hdr-logo { font-size: 18px; padding: 0; }


/* ============================================================
   Collapsible sidebar (desktop) - state saved per device
   html.sb-collapsed is set before first paint by _Head.
   ============================================================ */
/* Toggle icon: hamburger on phones/tablets; on desktop a sidebar-panel icon that
   shows the state - filled panel while the sidebar is showing, outline when hidden. */
#nav-toggle .nav-ico-hide,
#nav-toggle .nav-ico-show { display: none; }
#nav-toggle:hover { color: var(--indigo); border-color: var(--indigo-line); }

@media (min-width: 1025px) {
    #nav-toggle { display: flex; }
    #nav-toggle .nav-ico-menu { display: none; }
    html:not(.sb-collapsed) #nav-toggle .nav-ico-hide { display: inline-block; }
    html.sb-collapsed #nav-toggle .nav-ico-show { display: inline-block; }
    html.sb-collapsed #sidebar { left: calc(-1 * var(--sidebar-w) - 12px); }
    html.sb-collapsed #main    { margin-left: 0; }
    /* Animate only after load, so a saved state doesn't slide on every page */
    html.sb-anim #sidebar { transition: left .22s cubic-bezier(.4,0,.2,1); }
    html.sb-anim #main    { transition: margin-left .22s cubic-bezier(.4,0,.2,1); }
}
@media (prefers-reduced-motion: reduce) {
    html.sb-anim #sidebar, html.sb-anim #main { transition: none; }
}


/* ============================================================
   Company drawer - scrolling + resizable width
   ============================================================ */
/* The AJAX wrapper must be a flex column too, or .drawer-body can't scroll */
#drawer-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.drawer-panel {
    width: min(var(--drawer-w, 500px), 95vw);
    max-width: 95vw;
    right: calc(-1 * min(var(--drawer-w, 500px), 95vw) - 40px);
}
.drawer-panel.open { right: 0; }
.drawer-panel.resizing { transition: none; user-select: none; }
.drawer-body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.drawer-resize {
    position: absolute;
    top: 0; bottom: 0; left: -5px;
    width: 10px;
    cursor: ew-resize;
    z-index: 2;
    touch-action: none;
    background: transparent;
    border: 0;
    padding: 0;
}
.drawer-resize::after {
    content: '';
    position: absolute;
    top: 50%; left: 3px;
    width: 4px; height: 44px;
    transform: translateY(-50%);
    border-radius: 99px;
    background: var(--line-strong);
    opacity: .55;
    transition: opacity .12s, background .12s, height .12s;
}
.drawer-resize:hover::after,
.drawer-resize:focus-visible::after,
.drawer-panel.resizing .drawer-resize::after { opacity: 1; background: var(--indigo); height: 72px; }
.drawer-resize:focus-visible { outline: none; }

@media (max-width: 600px) {
    .drawer-panel { width: 100vw; max-width: 100vw; right: -100vw; }
    .drawer-resize { display: none; }
}


/* ============================================================
   Website activity (LeadForensics) - drawer + visitors table
   ============================================================ */
.web-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.web-stat {
    display: flex; flex-direction: column; gap: 2px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}
.web-stat-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.web-stat-val   { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.web-subtitle {
    display: flex; align-items: center; gap: 6px;
    margin: 16px 0 8px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-secondary);
}

.key-moments { display: flex; flex-direction: column; gap: 6px; }
.key-moment  { display: flex; align-items: center; gap: 8px; font-size: 12.5px; min-width: 0; }
.key-moment .badge-wt { font-size: 10.5px; padding: 2px 7px; flex-shrink: 0; }
.key-moment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); text-decoration: none; }
a.key-moment-name:hover { color: var(--indigo); text-decoration: underline; }
.key-moment-time { flex-shrink: 0; font-size: 11.5px; color: var(--text-muted); }

.top-pages { display: flex; flex-direction: column; gap: 4px; }
.top-page  { position: relative; border-radius: 6px; overflow: hidden; }
.top-page-bar { position: absolute; inset: 0 auto 0 0; background: var(--indigo-pale); opacity: .8; border-radius: 6px; }
.top-page-row { position: relative; display: flex; align-items: center; gap: 7px; padding: 5px 8px; font-size: 12.5px; min-width: 0; }
.top-page-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); text-decoration: none; }
a.top-page-name:hover { color: var(--indigo); text-decoration: underline; }
.top-page-meta { flex-shrink: 0; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.visit-timeline { display: flex; flex-direction: column; border-left: 2px solid var(--border); margin-left: 5px; }
.visit-item { position: relative; padding: 0 0 4px 16px; }
.visit-item > summary {
    list-style: none;
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
    padding: 6px 8px; margin-left: -8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
}
.visit-item > summary::-webkit-details-marker { display: none; }
.visit-item > summary:hover { background: var(--row-hover); }
.visit-item > summary:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.visit-dot {
    position: absolute; left: -7px; top: 11px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--card-bg); border: 2px solid var(--line-strong);
}
.visit-dot.hot { border-color: var(--emerald); background: var(--emerald-pale); }
.visit-item[open] .visit-dot { border-color: var(--indigo); }
.visit-item[open] .visit-dot.hot { border-color: var(--emerald); }
.visit-when { font-weight: 600; color: var(--text-primary); }
.visit-meta { color: var(--text-muted); font-size: 12px; }
.visit-body { padding: 2px 0 8px; }
.visit-source { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.visit-page { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12.5px; min-width: 0; border-bottom: 1px dashed var(--border-subtle); }
.visit-page:last-child { border-bottom: 0; }
.visit-page-time { flex-shrink: 0; width: 42px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.visit-page-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); text-decoration: none; }
a.visit-page-name:hover { color: var(--indigo); text-decoration: underline; }
.visit-page-dur { flex-shrink: 0; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Visitors table: activity highlights under the company name */
.visit-highlights { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.visit-highlights .badge-wt { font-size: 10px; padding: 1px 6px; }
.last-seen-rel { font-weight: 600; color: var(--text-primary); }

/* HubSpot activity (company drawer) - expandable, full text inline */
.hs-activity-list { display: flex; flex-direction: column; }
.hs-activity { border-bottom: 1px solid var(--border); }
.hs-activity:last-child { border-bottom: 0; }
.hs-activity > summary {
    list-style: none;
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 6px; margin: 0 -6px;
    border-radius: 6px;
    cursor: pointer;
}
.hs-activity > summary::-webkit-details-marker { display: none; }
.hs-activity > summary:hover { background: var(--row-hover); }
.hs-activity > summary:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.hs-activity-icon {
    flex-shrink: 0;
    width: 26px; height: 26px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    background: var(--surface-2); color: var(--text-muted);
}
.hs-activity-icon.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.hs-activity-icon.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.hs-activity-icon.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.hs-activity-icon.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.hs-activity-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hs-activity-title { font-size: 13px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-activity-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-muted); }
.hs-activity-chevron { flex-shrink: 0; font-size: 11px; color: var(--text-muted); margin-top: 6px; transition: transform .15s; }
.hs-activity[open] .hs-activity-chevron { transform: rotate(180deg); }
.hs-activity-body { padding: 0 0 10px 36px; }
.hs-activity-text {
    font-size: 12.5px; line-height: 1.55; color: var(--text-secondary);
    white-space: pre-wrap; overflow-wrap: anywhere;
    max-height: 320px; overflow-y: auto;
}

/* -- Alerts: plain-English list + sentence builder ---------------------- */
.al-h2 { font-size: 16px; font-weight: 700; color: var(--text-primary); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.al-h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); margin: 18px 0 4px; }
.al-count { font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-3); border-radius: 10px; padding: 1px 8px; }
.al-muted { color: var(--text-muted); font-size: 13.5px; margin: 0; }

.al-ideas { margin-bottom: 28px; }
.al-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.al-tile {
    display: flex; flex-direction: column; gap: 4px; padding: 16px;
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--card-radius);
    text-decoration: none; color: var(--text-primary); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.al-tile:hover { border-color: var(--indigo-light); box-shadow: var(--card-shadow); transform: translateY(-1px); color: var(--text-primary); text-decoration: none; }
.al-tile:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.al-tile-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 19px; margin-bottom: 6px; }
.al-tile-icon.indigo  { background: var(--indigo-pale);  color: var(--indigo); }
.al-tile-icon.emerald { background: var(--emerald-pale); color: var(--emerald-ink); }
.al-tile-icon.amber   { background: var(--amber-pale);   color: var(--amber-ink); }
.al-tile-icon.rose    { background: var(--rose-pale);    color: var(--rose-ink); }
.al-tile-icon.sky     { background: var(--sky-pale);     color: var(--sky-ink); }
.al-tile-title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.al-tile-hint  { font-size: 13px; color: var(--text-muted); line-height: 1.45; }

.al-list { padding: 0; margin-bottom: 24px; }
.al-row { display: flex; align-items: center; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--border); cursor: pointer; }
.al-row:last-child { border-bottom: none; }
.al-row:hover { background: var(--row-hover); }
.al-row-body { flex: 1; min-width: 0; }
.al-row.off .al-sentence { color: var(--text-muted); }
.al-sentence { font-size: 15.5px; line-height: 1.75; color: var(--text-primary); }
.al-pill { display: inline; font-weight: 600; color: var(--indigo); }
.al-row.off .al-pill { color: var(--text-secondary); }
.al-custom { font-size: 10.5px; margin-left: 6px; vertical-align: 2px; }
.al-status { font-size: 13.5px; margin-top: 4px; }
.al-status i { margin-right: 4px; }
.al-status .ok    { color: var(--emerald-ink); }
.al-status .warn  { color: var(--amber-ink); }
.al-status .muted { color: var(--text-muted); }
.al-status a { color: inherit; text-decoration: underline; font-weight: 600; }
.al-status strong { font-weight: 600; }
[data-theme="dark"] .al-status .ok   { color: var(--emerald); }
[data-theme="dark"] .al-status .warn { color: var(--amber); }

.al-toggle-form { display: flex; align-items: center; gap: 8px; margin: 0; flex-shrink: 0; }
.al-switch-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); min-width: 24px; }
.al-switch {
    position: relative; width: 48px; height: 28px; flex-shrink: 0; padding: 0; cursor: pointer;
    border: none; border-radius: 14px; background: var(--line-strong); transition: background .15s;
}
.al-switch.on { background: var(--emerald); }
.al-switch:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.al-switch-knob {
    position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(8,23,42,.25); transition: left .15s;
}
.al-switch.on .al-switch-knob { left: 23px; }

.al-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); margin-bottom: 24px; }
.al-empty i { font-size: 30px; color: var(--indigo); }
.al-empty p { margin: 6px 0 0; font-size: 14px; }
.al-empty strong { color: var(--text-primary); }

.al-advanced, .al-more { margin: 8px 0 24px; }
.al-advanced > summary, .al-more > summary {
    list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    font-size: 14px; font-weight: 600; color: var(--text-secondary); padding: 4px 0;
}
.al-advanced > summary::-webkit-details-marker, .al-more > summary::-webkit-details-marker { display: none; }
.al-advanced > summary i, .al-more > summary i { transition: transform .15s; font-size: 12px; }
.al-advanced[open] > summary i, .al-more[open] > summary i { transform: rotate(90deg); }
.al-advanced-body { padding-top: 10px; }
.al-advanced-body .tpl-grid { padding: 10px 0 0; }
.al-advanced-links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.al-advanced-note { font-size: 13px; color: var(--text-muted); margin: 0 0 6px; }

/* Builder */
.al-builder { padding: 26px 28px; margin-bottom: 26px; }
.al-big-sentence { font-size: 22px; line-height: 2.1; color: var(--text-primary); font-weight: 500; }
.al-pill.big {
    font: inherit; font-weight: 600; color: var(--indigo); background: var(--indigo-pale);
    border: 2px solid transparent; border-radius: 10px; padding: 1px 12px; cursor: pointer; line-height: 1.5;
    transition: border-color .12s, background .12s;
}
.al-pill.big:hover { border-color: var(--indigo-line); }
.al-pill.big.active { border-color: var(--indigo); }
.al-pill.big.empty { color: var(--amber-ink); background: var(--amber-pale); border-style: dashed; border-color: var(--amber-line); }
.al-pill.big:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.al-panel { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.al-panel-hint { margin: 0; color: var(--text-muted); font-size: 14px; }
.al-panel-hint i { margin-right: 6px; }
.al-q { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 14px; }
.al-q-sub { font-size: 13.5px; font-weight: 400; color: var(--text-muted); margin-left: 6px; }
.al-opts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.al-opt {
    display: flex; align-items: flex-start; gap: 12px; text-align: left; padding: 14px 16px; cursor: pointer;
    background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 10px; color: var(--text-primary);
    transition: border-color .12s, background .12s;
}
.al-opt > i { font-size: 20px; color: var(--indigo); margin-top: 1px; }
.al-opt:hover:not([disabled]) { border-color: var(--indigo-light); }
.al-opt.selected { border-color: var(--indigo); background: var(--indigo-pale); }
.al-opt[disabled] { cursor: not-allowed; opacity: .55; }
.al-opt-title { display: block; font-size: 15px; font-weight: 700; line-height: 1.3; }
.al-opt-hint  { display: block; font-size: 13px; color: var(--text-muted); line-height: 1.4; margin-top: 2px; }
.al-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.al-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; cursor: pointer;
    font-size: 14.5px; font-weight: 500; color: var(--text-primary);
    background: var(--card-bg); border: 1.5px solid var(--line-strong); border-radius: 22px;
}
.al-chip:hover { border-color: var(--indigo-light); }
.al-chip.selected { background: var(--indigo-pale); border-color: var(--indigo); color: var(--indigo); font-weight: 600; }
.al-person { margin-top: 14px; max-width: 360px; }
.al-person label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }

.al-example-hdr { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.al-example-count { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.al-example {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--card-radius);
    padding: 20px 22px; transition: opacity .15s;
}
.al-example.loading { opacity: .55; }
.al-ex-head { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.al-ex-head i { margin-right: 4px; }
.al-ex-title { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.al-ex-body { font-size: 14.5px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.al-ex-link { margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--indigo); }
.al-example-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 18px; font-size: 13px; }

.al-linkbtn { background: none; border: none; padding: 4px 0; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--indigo); }
.al-linkbtn:hover:not([disabled]) { text-decoration: underline; }
.al-linkbtn[disabled] { color: var(--text-muted); cursor: default; }
.al-linkbtn.danger { color: var(--rose-ink); }
[data-theme="dark"] .al-linkbtn.danger { color: var(--rose); }
.al-linkbtn i { margin-right: 4px; }

.al-wording { padding: 20px 22px; margin-bottom: 18px; }
.al-wording label { font-weight: 600; }
.al-wording-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.al-more-body { padding: 10px 0 0; font-size: 14.5px; color: var(--text-primary); }
.al-more-body p { margin: 0 0 12px; }

.al-savebar {
    position: sticky; bottom: 0; z-index: 40; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 14px 18px; margin-top: 8px;
    background: var(--glass); backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 -4px 20px rgba(8,23,42,.07);
}
.al-savebar-left  { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; font-size: 14.5px; color: var(--text-secondary); }
.al-savebar-left strong { color: var(--text-primary); }
.al-savebar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.al-save-error { color: var(--rose-ink); font-size: 13.5px; font-weight: 600; }
[data-theme="dark"] .al-save-error { color: var(--rose); }
.al-delete { margin: 18px 0 0; }

@media (max-width: 640px) {
    .al-big-sentence { font-size: 18px; }
    .al-builder { padding: 18px; }
    .al-row { flex-wrap: wrap; }
}

/* Alerts: "how does it decide" detail */
.al-pill.has-tip { border-bottom: 1px dotted currentColor; cursor: help; }
.al-detail { margin-top: 10px; }
.al-detail-text {
    margin-top: 8px; padding: 14px 16px; max-width: 720px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
    font-size: 14px; line-height: 1.6; color: var(--text-secondary); white-space: pre-line;
}
