/* ============================================================
   LeadScaner Components — built on tokens.css
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

/* ===== Type ===== */
.t-display { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: -0.02em; line-height: var(--lh-tight); }
.t-h1 { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: -0.015em; line-height: var(--lh-tight); }
.t-h2 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: -0.01em; line-height: var(--lh-snug); }
.t-h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
.t-body { font-size: var(--fs-base); line-height: var(--lh-normal); }
.t-sm { font-size: var(--fs-sm); }
.t-xs { font-size: var(--fs-xs); }
.t-mono { font-family: var(--font-mono); font-feature-settings: 'liga' 0; }
.t-muted { color: var(--text-secondary); }
.t-tert { color: var(--text-tertiary); }
.t-num { font-variant-numeric: tabular-nums; }

/* ===== Page chrome ===== */
.app-shell { min-height: 100vh; background: var(--bg-app); display: flex; flex-direction: column; }

.topnav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  height: var(--topnav-h);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 32px;
  color: var(--nav-text);
  font-size: var(--fs-sm);
}
.topnav__brand {
  font-weight: var(--fw-semibold);
  color: var(--nav-text-active);
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
}
.topnav__brand .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  background: var(--accent-500); margin-right: 8px; vertical-align: 1px;
}
.topnav__links { display: flex; align-items: center; gap: 4px; flex: 1; }
.topnav__link {
  color: var(--nav-text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: var(--fw-medium);
  display: inline-flex; align-items: center; gap: 8px;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.topnav__link:hover { color: var(--nav-text-active); background: rgba(255,255,255,0.04); }
.topnav__link.is-active { color: var(--nav-text-active); background: rgba(255,255,255,0.08); }
.topnav__link .badge-count { background: var(--accent-500); color: white; font-size: 11px; padding: 1px 6px; border-radius: 999px; font-weight: 600; }
.topnav__right { display: flex; align-items: center; gap: 12px; }
.topnav__user {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-500); color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.topnav__chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.06);
  color: var(--nav-text);
  font-size: var(--fs-xs);
}
.topnav__chip .pulse {
  width: 6px; height: 6px; border-radius: 50%; background: var(--success-500);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--success-500) 50%, transparent);
}

.page {
  padding: 28px 32px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}
.page__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; }
.page__title { margin: 0 0 4px; }
.page__sub { color: var(--text-secondary); font-size: var(--fs-sm); }
.page__actions { display: flex; gap: 8px; align-items: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: var(--control-h, 34px);
  padding: 0 14px;
  border-radius: var(--r-control, var(--radius-md));
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn--primary { background: var(--accent-500); color: white; }
.btn--primary:hover { background: var(--accent-600); }
.btn--secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-default); }
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--danger { background: var(--danger-500); color: white; }
.btn--danger:hover { background: var(--danger-700); }
.btn--danger-outline { background: transparent; border-color: var(--danger-200); color: var(--danger-700); }
.btn--danger-outline:hover { background: var(--danger-50); }
.btn--sm { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
.btn--lg { height: 40px; padding: 0 18px; font-size: var(--fs-base); }
.btn--icon { width: var(--control-h, 34px); padding: 0; }
.btn--block { width: 100%; }
.btn .ic { width: 14px; height: 14px; }
.btn--lg .ic { width: 16px; height: 16px; }

.btn-group { display: inline-flex; }
.btn-group .btn {
  border-radius: 0;
  border-right-width: 0;
}
.btn-group .btn:first-child { border-top-left-radius: var(--r-control, var(--radius-md)); border-bottom-left-radius: var(--r-control, var(--radius-md)); }
.btn-group .btn:last-child { border-top-right-radius: var(--r-control, var(--radius-md)); border-bottom-right-radius: var(--r-control, var(--radius-md)); border-right-width: 1px; }
.btn-group .btn.is-active { background: var(--bg-active); color: var(--text-primary); border-color: var(--border-strong); z-index: 1; }

/* Kbd */
.kbd {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 6px; min-width: 18px;
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ===== Inputs ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-primary); }
.field__hint { font-size: var(--fs-xs); color: var(--text-secondary); line-height: 1.5; }
.field__hint--error { color: var(--danger-700); }

.input, .select, .textarea {
  font-family: inherit; font-size: var(--fs-sm); color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-control, var(--radius-md));
  padding: 0 12px;
  height: var(--control-h, 34px);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-500); box-shadow: var(--ring-focus); }
.textarea { padding: 10px 12px; height: auto; min-height: 80px; line-height: var(--lh-normal); resize: vertical; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2365656F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.input--with-icon { padding-left: 32px; }
.input-wrap { position: relative; }
.input-wrap .ic-leading {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-tertiary); pointer-events: none;
}

/* Checkbox / Radio */
.check {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg-surface);
  display: inline-grid; place-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.check:checked { background: var(--accent-500); border-color: var(--accent-500); }
.check:checked::before {
  content: ''; width: 10px; height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/contain no-repeat;
}

.toggle {
  appearance: none; -webkit-appearance: none;
  width: 32px; height: 18px; border-radius: 999px;
  background: var(--gray-200);
  position: relative; cursor: pointer;
  transition: background var(--transition-fast);
}
[data-theme="dark"] .toggle { background: var(--gray-700); }
.toggle::before {
  content: ''; position: absolute;
  top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: white;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-xs);
}
.toggle:checked { background: var(--accent-500); }
.toggle:checked::before { transform: translateX(14px); }

/* ===== Card / Surface ===== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-card, var(--radius-lg));
  box-shadow: var(--shadow-xs);
}
.card__header { padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.card__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); margin: 0; }
.card__sub { font-size: var(--fs-xs); color: var(--text-secondary); margin: 2px 0 0; }
.card__body { padding: var(--pad-card, 20px); }
.card__footer { padding: 12px 20px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bg-app); border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }

/* ===== Badge / Status pill ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill, var(--radius-pill));
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge--neutral  { background: var(--gray-100);   color: var(--gray-700); }
.badge--accent   { background: var(--accent-50);  color: var(--accent-700); }
.badge--success  { background: var(--success-50); color: var(--success-700); }
.badge--warning  { background: var(--warning-50); color: var(--warning-700); }
.badge--danger   { background: var(--danger-50);  color: var(--danger-700); }
.badge--info     { background: var(--info-50);    color: var(--info-700); }
[data-theme="dark"] .badge--neutral { background: #22222B; color: #D4D4DC; }

.badge--outline { background: transparent; border-color: var(--border-default); color: var(--text-secondary); }

/* ===== Banner / Alert ===== */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-card, var(--radius-md));
  border: 1px solid;
  font-size: var(--fs-sm);
}
.banner__title { font-weight: var(--fw-semibold); margin-bottom: 2px; }
.banner__body { color: inherit; opacity: 0.9; }
.banner__icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.banner__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.banner--warning { background: var(--warning-50); border-color: var(--warning-200); color: var(--warning-700); }
.banner--danger  { background: var(--danger-50);  border-color: var(--danger-200);  color: var(--danger-700); }
.banner--success { background: var(--success-50); border-color: var(--success-200); color: var(--success-700); }
.banner--info    { background: var(--info-50);    border-color: var(--info-200);    color: var(--info-700); }
[data-theme="dark"] .banner__body { color: var(--text-secondary); }
[data-theme="dark"] .banner--warning .banner__body { color: #E8D9A6; }
[data-theme="dark"] .banner--danger  .banner__body { color: #F5C6C6; }
[data-theme="dark"] .banner--success .banner__body { color: #B5E8CD; }
[data-theme="dark"] .banner--info    .banner__body { color: #BBD4F5; }

/* ===== KPI card ===== */
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-card, var(--radius-lg));
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
  transition: border-color var(--transition-fast);
}
.kpi:hover { border-color: var(--border-default); }
.kpi__label { font-size: var(--fs-xs); color: var(--text-secondary); font-weight: var(--fw-medium); display: flex; align-items: center; gap: 6px; }
.kpi__value { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi__delta { font-size: var(--fs-xs); display: inline-flex; align-items: center; gap: 4px; }
.kpi__delta--up   { color: var(--success-700); }
.kpi__delta--down { color: var(--danger-700); }
[data-theme="dark"] .kpi__delta--up   { color: #6EE7B7; }
[data-theme="dark"] .kpi__delta--down { color: #FCA5A5; }
.kpi__sparkline { position: absolute; right: 14px; bottom: 14px; opacity: 0.6; }
.kpi--accent { border-color: var(--accent-200); background: linear-gradient(180deg, var(--accent-50), var(--bg-surface) 60%); }

/* ===== Table ===== */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-card, var(--radius-lg));
  /* Phase 999.13-02 (B): allow horizontal scrolling on narrow viewports
     instead of pushing the entire grid track wider. Combined with
     `.layout-sidebar > * { min-width: 0; }` below this prevents the
     7-column /settings/niches table from overflowing past the viewport. */
  overflow-x: auto;
  overflow-y: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td {
  padding: var(--pad-cell-y, 12px) var(--pad-cell-x, 16px);
  text-align: left;
  vertical-align: middle;
}
.table th {
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  text-transform: none;
  letter-spacing: 0;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  user-select: none;
}
.table th .sort-icon { display: inline-block; margin-left: 4px; opacity: 0.4; vertical-align: -1px; }
.table th.is-sorted { color: var(--text-primary); }
.table th.is-sorted .sort-icon { opacity: 1; }
.table tr + tr td { border-top: 1px solid var(--border-subtle); }
.table tbody tr { transition: background var(--transition-fast); cursor: pointer; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr.is-selected { background: var(--accent-50); }

.table .num { font-variant-numeric: tabular-nums; text-align: right; }

/* ===== Filter bar ===== */
.filterbar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-card, var(--radius-lg));
}
.filterbar .field { flex: 0 0 auto; gap: 0; }
.filterbar .field__label { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: var(--r-control, var(--radius-md));
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  font-size: var(--fs-xs); color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
/* Both class names used across templates (legacy is-active + BEM chip--active). */
.chip.is-active,
.chip--active {
  background: var(--accent-50);
  border-color: var(--accent-500);
  color: var(--accent-700);
  font-weight: var(--fw-semibold);
  box-shadow: inset 0 0 0 1px var(--accent-500);
}

/* Phase 999.23-02 D-03 — preset-chip row above filterbar on /leads. */
.chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}


/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 48px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty__icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-sunken);
  color: var(--text-tertiary);
  display: inline-flex; align-items: center; justify-content: center;
}
.empty__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-primary); }
.empty__body { font-size: var(--fs-sm); color: var(--text-secondary); max-width: 380px; line-height: 1.55; }
.empty__actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }

/* ===== Sidebar (settings) ===== */
.layout-sidebar { display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 24px; align-items: start; }
/* Phase 999.13-02 (B): grid items default to min-width: auto (= min-content)
   which makes wide tables push the grid track past the viewport. Forcing
   min-width: 0 lets each child shrink and surfaces overflow on the inner
   .table-wrap (which has overflow-x: auto). */
.layout-sidebar > * { min-width: 0; }
.sidebar-nav {
  position: sticky; top: 80px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-card, var(--radius-lg));
  padding: 8px;
}
.sidebar-nav__group { padding: 12px 12px 6px; font-size: var(--fs-xs); color: var(--text-tertiary); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar-nav__link {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-control, var(--radius-md));
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-nav__link:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav__link.is-active { background: var(--accent-50); color: var(--accent-700); }

.sidebar-nav__link .ic { width: 15px; height: 15px; flex-shrink: 0; }

/* ===== Settings rows ===== */
.setting-row {
  display: grid; grid-template-columns: 1fr 380px; gap: 24px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-row:last-child { border-bottom: none; }
.setting-row__label { font-weight: var(--fw-medium); margin-bottom: 4px; font-size: var(--fs-sm); }
.setting-row__hint { color: var(--text-secondary); font-size: var(--fs-xs); line-height: 1.55; max-width: 480px; }

/* ===== Stepper ===== */
.stepper { display: flex; align-items: center; gap: 0; }
.stepper__item { display: flex; align-items: center; gap: 8px; flex: 1; }
.stepper__num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-sunken); color: var(--text-tertiary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  border: 1px solid var(--border-default);
}
.stepper__label { font-size: var(--fs-sm); color: var(--text-secondary); }
.stepper__line { flex: 1; height: 1px; background: var(--border-subtle); margin: 0 8px; }
.stepper__item.is-active .stepper__num { background: var(--accent-500); color: white; border-color: var(--accent-500); }
.stepper__item.is-active .stepper__label { color: var(--text-primary); font-weight: var(--fw-medium); }
.stepper__item.is-done .stepper__num { background: var(--success-500); color: white; border-color: var(--success-500); }
.stepper__item.is-done .stepper__label { color: var(--text-secondary); }

/* ===== Toast ===== */
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--gray-900);
  color: white;
  border-radius: var(--r-card, var(--radius-md));
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
}
[data-theme="dark"] .toast { background: var(--gray-800); border: 1px solid var(--border-default); }
.toast .ic--success { color: var(--success-500); }
.toast__action { color: var(--accent-200); margin-left: auto; cursor: pointer; font-weight: 500; }

/* ===== Modal ===== */
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-card, var(--radius-lg));
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px;
}
.modal__header { padding: 20px 24px 0; }
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin: 0 0 4px; }
.modal__sub { color: var(--text-secondary); font-size: var(--fs-sm); }
.modal__body { padding: 16px 24px; }
.modal__footer { padding: 12px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border-subtle); }

/* ===== Misc ===== */
.divider { height: 1px; background: var(--border-subtle); margin: 16px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.grow { flex: 1; }

.dot-status { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.dot-status--green { background: var(--success-500); }
.dot-status--yellow { background: var(--warning-500); }
.dot-status--red { background: var(--danger-500); }
.dot-status--gray { background: var(--gray-400); }

.score-bar {
  position: relative; width: 56px; height: 4px;
  background: var(--bg-sunken); border-radius: 999px; overflow: hidden;
  display: inline-block; vertical-align: middle;
}
.score-bar__fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-500); border-radius: 999px; }

/* Niche tag */
.niche-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 8px;
  border-radius: var(--r-pill, 999px);
  font-size: var(--fs-xs);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-weight: 500;
}

/* Mockup phone */
.phone {
  width: 375px;
  border: 1px solid var(--border-default);
  border-radius: 28px;
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
}
.phone__notch {
  height: 30px; background: var(--gray-950); display: flex; justify-content: space-between; align-items: center; padding: 0 18px;
  color: white; font-size: 11px; font-family: var(--font-mono);
}
.phone__notch .pill { background: var(--gray-700); width: 80px; height: 18px; border-radius: 999px; }
.phone__body { background: var(--bg-app); }

/* Lead detail layout */
.lead-detail { display: grid; grid-template-columns: 1fr 360px; gap: 24px; }

/* Inbox layout */
.inbox-layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; border: 1px solid var(--border-subtle); border-radius: var(--r-card, var(--radius-lg)); background: var(--bg-surface); overflow: hidden; min-height: 540px; }
.inbox-list { border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column; }
.inbox-list__header { padding: 12px; border-bottom: 1px solid var(--border-subtle); }
.inbox-item { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background var(--transition-fast); }
.inbox-item:hover { background: var(--bg-hover); }
.inbox-item.is-active { background: var(--accent-50); border-left: 2px solid var(--accent-500); padding-left: 12px; }

.inbox-detail { padding: 18px 22px; }

/* Chat bubble */
.chat-bubble {
  background: var(--bg-sunken);
  border-radius: 12px 12px 12px 2px;
  padding: 10px 12px;
  font-size: var(--fs-sm); line-height: 1.5;
  max-width: 80%;
}
.chat-bubble--out {
  background: var(--accent-50);
  color: var(--accent-700);
  border-radius: 12px 12px 2px 12px;
  align-self: flex-end;
  margin-left: auto;
}


/* Animations */
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--success-500) 40%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.pulse { animation: pulse-dot 2s infinite; }

/* Responsive */
@media (max-width: 768px) {
  .topnav { padding: 0 12px; gap: 12px; }
  .topnav__links { display: none; }
  .page { padding: 16px; }
  .layout-sidebar { grid-template-columns: 1fr; }
  .lead-detail { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; gap: 12px; }
  .inbox-layout { grid-template-columns: 1fr; }
}

/* ============================================================
   Phase 6 — hotkey help modal + J/K row focus indicator (D-02)
   ============================================================ */

.hotkey-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}
.hotkey-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  vertical-align: middle;
}
.hotkey-table tr:last-child td { border-bottom: 0; }
.hotkey-table td:first-child {
  width: 35%;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* J/K row focus indicator (D-02 navigation). */
tr.lead-row.is-focused {
  outline: 2px solid var(--accent-500);
  outline-offset: -2px;
  background: var(--accent-50);
}

/* ============================================================
   Phase 6 toast region (D-03b bulk approve undo countdown)
   ============================================================ */
.toast-region {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  max-width: 420px;
  pointer-events: none;
}
.toast-region .toast { pointer-events: auto; }

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-default, #e5e7eb);
  border-left: 4px solid var(--accent-500, #6366f1);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  font-size: var(--fs-base);
  color: var(--text-primary);
  margin-top: 8px;
}
.toast--undo    { border-left-color: var(--warning-500, #f59e0b); }
.toast--success { border-left-color: var(--success-500, #10b981); }
.toast--error   { border-left-color: var(--danger-500, #ef4444); }
.toast--warn    { border-left-color: var(--warning-500, #f59e0b); }
.toast--info    { border-left-color: var(--accent-500, #6366f1); }

.toast__countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Bulk approve preview modal list. */
.bulk-preview-list {
  margin: 12px 0;
  padding-left: 20px;
}
.bulk-preview-list li {
  padding: 4px 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary, #6b7280);
}

/* ============================================================
   Phase 6 / Plan 06-03: Tag editor + filter (CRM-19, D-04)
   ============================================================ */

/* Tag chip — display tag with × remove button. */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 8px;
  margin: 2px 4px 2px 0;
  border-radius: 12px;
  background: var(--bg-sunken, #f3f4f6);
  border: 1px solid var(--border-subtle, #e5e7eb);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  line-height: 1.2;
  vertical-align: middle;
}
.tag-chip__label {
  font-variant-numeric: tabular-nums;
}
.tag-chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
}
.tag-chip__remove:hover,
.tag-chip__remove:focus-visible {
  background: var(--danger-50, #fef2f2);
  color: var(--danger-500, #ef4444);
  outline: none;
}

/* Container for current tags on lead detail. */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  min-height: 22px;
}

/* Tag filter chip-input on /leads list. */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  margin-bottom: 8px;
}
.tag-filter .chip--active {
  background: var(--accent-50, #f5f3ff);
  color: var(--accent-700, #5b21b6);
  border-color: var(--accent-200, #ddd6fe);
}

/* ============================================================
   Phase 6 D-05 — Score-bar segmented (two-stacked layout)
   ============================================================ */
.score-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}
.score-bar__positive,
.score-bar__negative {
  display: flex;
  gap: 2px;
  min-height: var(--space-5);
  background: var(--bg-sunken);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.score-bar__total {
  align-self: center;
  padding: var(--space-1) var(--space-3);
  font-weight: 600;
  border: 2px solid var(--accent-500);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
}
.score-bar__total-only {
  align-self: flex-start;
  padding: var(--space-2) var(--space-3);
  font-weight: 600;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}
.score-seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-2);
  color: white;
  font-size: var(--fs-xs);
  font-weight: 500;
  min-width: 24px;
  white-space: nowrap;
}
.score-seg--pos { background: var(--success-500); }
.score-seg--neg { background: var(--danger-500); }

/* ===== Phase 6 / 06-05 (D-07) — cost chip 3-state ===== */
/* Anchor variant of .topnav__chip (the cost chip is an <a> link to /costs).
   Hover state nudges background up so click affordance is obvious. */
a.topnav__chip {
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}
a.topnav__chip:hover {
  background: rgba(255,255,255,0.12);
}
.topnav__chip--warn {
  background: var(--warning-50);
  border: 1px solid var(--warning-500);
  color: var(--warning-500);
}
.topnav__chip--alert {
  background: var(--danger-50);
  border: 1px solid var(--danger-500);
  color: var(--danger-500);
  font-weight: 600;
}
a.topnav__chip--warn:hover {
  background: var(--warning-50);
  filter: brightness(0.96);
}
a.topnav__chip--alert:hover {
  background: var(--danger-50);
  filter: brightness(0.96);
}

/* Phase 999.5-01 (D-A2/D-A3): generic in-UI confirm modal styles.
   Owned by modals.js — overlay + centered card with primary/danger CTA.
   Uses native <dialog> for a11y (focus trap, Esc to close). */

.lsc-modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 480px;
  width: 90vw;
}

.lsc-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.lsc-modal__panel {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg, 0 10px 40px rgba(15, 23, 42, 0.18));
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lsc-modal__header {
  padding: 20px 24px 8px;
}

.lsc-modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
}

.lsc-modal__body {
  padding: 8px 24px 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary, #475569);
  white-space: pre-wrap;
}

.lsc-modal__actions {
  padding: 12px 24px 18px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--border-soft, #f1f5f9);
  background: var(--surface-soft, #f8fafc);
}

.lsc-modal__actions .btn {
  min-width: 96px;
}

/* Phase 999.5-04 (D-H1/D-H3): chip count badge — small pill next to chip label. */
.chip__count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 999px;
  background: var(--surface-soft, #f1f5f9);
  color: var(--text-secondary, #475569);
  vertical-align: baseline;
}
.chip.is-active .chip__count,
.chip--active .chip__count {
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
}
.chip__count--zero {
  opacity: 0.5;
}
