/* ============================================================
   SRINIOUTREACH — Violet Terminal
   srini.ee identity × Linear restraint × financial-terminal precision
   ============================================================ */

:root {
  /* Paper / ink */
  --paper: #FFFFFF;
  --paper-tint: #FBFAFD;
  --paper-elev: #F7F5FC;

  --ink: #0B0B12;
  --ink-1: #2A2933;
  --ink-2: #5C5B65;
  --ink-3: #8E8D97;
  --ink-4: #B6B5BD;

  --line: #ECEAF1;
  --line-strong: #D8D6DF;
  --line-soft: #F4F2F8;

  /* Signature violet ramp (srini.ee) */
  --v50:  #F5F2FF;
  --v100: #EAE6FF;
  --v200: #CFC5FF;
  --v300: #AE9BFF;
  --v400: #8C73FA;
  --v500: #6D4EF7;
  --v600: #573CE0;
  --v700: #452EC0;
  --v800: #32218F;
  --v900: #241866;

  --grad:        linear-gradient(135deg, #6D4EF7 0%, #8C73FA 100%);
  --grad-hover:  linear-gradient(135deg, #573CE0 0%, #6D4EF7 100%);
  --grad-soft:   linear-gradient(135deg, #EAE6FF 0%, #F5F2FF 100%);

  /* Status — desaturated to coexist with violet */
  --good: #16A34A; --good-bg: #ECFDF3; --good-ink: #166534;
  --warn: #B45309; --warn-bg: #FEF3C7; --warn-ink: #92400E;
  --bad:  #DC2626; --bad-bg:  #FEE2E2; --bad-ink:  #991B1B;
  --info: #2563EB; --info-bg: #EFF6FF; --info-ink: #1E40AF;

  /* Typography */
  --sans: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --fs-11: 0.6875rem;
  --fs-12: 0.75rem;
  --fs-13: 0.8125rem;
  --fs-14: 0.875rem;
  --fs-15: 0.9375rem;
  --fs-16: 1rem;
  --fs-18: 1.125rem;
  --fs-20: 1.25rem;
  --fs-24: 1.5rem;
  --fs-28: 1.75rem;
  --fs-32: 2rem;
  --fs-40: 2.5rem;
  --fs-56: 3.5rem;
  --fs-72: 4.5rem;

  /* Spacing — 4px base */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 28px; --sp-8: 32px;
  --sp-10: 40px; --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --shadow-sm:  0 1px 2px rgba(11, 11, 18, 0.04);
  --shadow:     0 2px 8px rgba(11, 11, 18, 0.05);
  --shadow-md:  0 8px 24px rgba(11, 11, 18, 0.08);
  --shadow-lg:  0 16px 48px rgba(109, 78, 247, 0.18);
  --glow-violet: 0 0 0 4px rgba(109, 78, 247, 0.15);

  --t-fast:  120ms ease-out;
  --t-base:  180ms cubic-bezier(0.2, 0.6, 0.2, 1);
  --t-spring: 320ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── Aliased & skaalad (varem koodis vabalt kasutatud; kaardistatud
        põhipaletile, et viited resolvuksid ja renderdus oleks järjepidev) ── */
  --ff-sans: var(--sans);
  --ff-mono: var(--mono);
  --bg-subtle: var(--paper-elev);
  --line-light: var(--line);
  --r-card: var(--r-md);
  --accent: var(--v500);
  --ink-1a: var(--line-strong);

  --fs-9:  0.5625rem;
  --fs-10: 0.625rem;

  /* Status-värviskaalad (Tailwind-laadsed astmed) */
  --red-50:   #FEF2F2; --red-200:   #FECACA; --red-500:   #EF4444; --red-600:   #DC2626;
  --green-50: #F0FDF4; --green-200: #BBF7D0; --green-500: #22C55E; --green-600: #16A34A;
  --blue-50:  #EFF6FF; --blue-200:  #BFDBFE; --blue-400:  #60A5FA;
  --blue-500: #3B82F6; --blue-600:  #2563EB; --blue-700:  #1D4ED8;
  --amber-400: #FBBF24; --amber-600: #D97706;
  --orange-500: #F97316; --orange-600: #EA580C;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: var(--sans), sans-serif;
  font-size: var(--fs-15);
  font-weight: 500;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  font-feature-settings: 'ss01' 1;
  background-image:
    radial-gradient(circle at 18% -10%, rgba(109,78,247,0.035) 0%, transparent 40%),
    radial-gradient(circle at 82% 100%, rgba(140,115,250,0.022) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Tabular numerals on number-bearing classes */
.tnum, .num, .compact-stat,
.col-money, .col-employees, .col-margin, .col-year,
.metric-tile .value, .stat-tile .num, .stat-tile .value,
.bar-line, .ratio-grid .value, .trend-row {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color var(--t-fast), text-decoration-color var(--t-fast);
}
a:hover { color: var(--v500); text-decoration-color: var(--v500); }

h1, h2, h3, h4, h5 {
  font-family: var(--sans), sans-serif;
  font-weight: 800;
  letter-spacing: -0.022em;
  line-height: 1.1;
  margin: 0 0 var(--sp-3);
  color: var(--ink);
}
h1 { font-size: var(--fs-40); font-weight: 900; letter-spacing: -0.034em; }
h2 { font-size: var(--fs-24); }
h3 { font-size: var(--fs-18); font-weight: 700; }
h4 { font-size: var(--fs-13); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; color: var(--ink-2); }

p { margin: 0 0 var(--sp-3); color: var(--ink-1); font-weight: 500; }
strong, b { font-weight: 700; color: var(--ink); }
hr { border: none; border-top: 1px solid var(--line); margin: var(--sp-8) 0; }
small { font-size: var(--fs-13); }

::selection { background: var(--v100); color: var(--v900); }

/* ============================================================
   SHELL — sidebar + main
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: var(--sp-6) var(--sp-5);
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  z-index: 10;
}

.brand {
  font-family: var(--sans), sans-serif;
  font-size: var(--fs-20);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--sp-1);
}
.brand::before {
  content: '';
  display: inline-block;
  width: 22px; height: 22px;
  background: var(--grad);
  border-radius: 6px;
  box-shadow:
    inset 0 -6px 12px rgba(255,255,255,0.18),
    0 4px 12px rgba(109,78,247,0.35);
}
.brand:hover { color: var(--v500); text-decoration: none; }

.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-transform: uppercase;
  line-height: 1.4;
  margin-bottom: var(--sp-4);
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--sp-2);
  flex: 1;
}
.main-nav a {
  position: relative;
  display: block;
  padding: 9px var(--sp-3) 9px var(--sp-4);
  text-decoration: none;
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink-1);
  border-radius: var(--r);
  transition: background var(--t-fast), color var(--t-fast);
}
.main-nav a:hover { background: var(--paper-tint); color: var(--ink); }
.main-nav a.active,
.main-nav a[aria-current="page"] {
  background: var(--v50);
  color: var(--v700);
  font-weight: 700;
}
.main-nav a.active::before,
.main-nav a[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: 0; top: 7px; bottom: 7px; width: 2px;
  background: var(--v500);
  border-radius: 2px;
}

/* Nav group (dropdown accordion) */
.nav-group { position: relative; }
.nav-group-btn {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px var(--sp-3) 9px var(--sp-4);
  font-size: var(--fs-14);
  font-weight: 600;
  font-family: var(--sans), sans-serif;
  color: var(--ink-1);
  border-radius: var(--r);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-group-btn:hover { background: var(--paper-tint); color: var(--ink); }
.nav-group[data-open] .nav-group-btn { color: var(--v600); }
.nav-group-chevron { margin-left: auto; flex-shrink: 0; transition: transform var(--t-base); }
.nav-group[data-open] .nav-group-chevron { transform: rotate(180deg); }
.nav-group-items {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding-left: var(--sp-3);
  margin-top: 2px;
}
.nav-group[data-open] .nav-group-items { display: flex; }
.nav-group-items a {
  display: block;
  padding: 7px var(--sp-3);
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-group-items a:hover { background: var(--paper-tint); color: var(--ink); }
.nav-group-items a.active { background: var(--v50); color: var(--v700); font-weight: 700; }

.sidebar-user {
  margin-top: auto;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--paper-tint);
}
.sidebar-user-name {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-logout {
  font-size: var(--fs-12);
  color: var(--ink-3);
  text-decoration: none;
}
.sidebar-user-logout:hover { color: var(--v500); text-decoration: underline; }

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

.container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--sp-12) var(--sp-12);
  flex: 1;
  animation: page-enter 380ms cubic-bezier(0.2, 0.6, 0.2, 1) both;
}
.container-wide { max-width: none; padding-left: var(--sp-8); padding-right: var(--sp-8); }

@keyframes page-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   HEAD / HERO / CRUMBS
   ============================================================ */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--sp-8);
}
.page-head h1 { margin: 0 0 6px; }
.page-head .crumbs { margin-bottom: var(--sp-2); }
.page-head .lead { margin: 0; }
.page-head .button-row { margin: 0; }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: var(--sp-3);
}
.crumbs a { text-decoration: none; color: var(--ink-3); }
.crumbs a:hover { color: var(--v500); }
.crumbs span { color: var(--ink-3); }

.hero {
  padding: var(--sp-16) 0 var(--sp-12);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  max-width: 720px;
}
.hero h1 {
  font-size: var(--fs-72);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.lead {
  font-size: var(--fs-18);
  color: var(--ink-1);
  line-height: 1.5;
  max-width: 65ch;
  font-weight: 500;
}
.muted { color: var(--ink-3); }
.ml-half { margin-left: 0.5rem; }
.small { font-size: var(--fs-13); }
.hint { color: var(--ink-3); font-size: var(--fs-13); margin-top: var(--sp-3); }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-7);
  margin-bottom: var(--sp-6);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.card > :last-child { margin-bottom: 0; }
.card h2 {
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-18);
  font-weight: 700;
  letter-spacing: -0.018em;
}
.card h3 {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-14);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-1);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.button {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans), sans-serif;
  font-size: var(--fs-14);
  font-weight: 700;
  letter-spacing: -0.005em;
  padding: 9px var(--sp-5);
  border-radius: var(--r-pill);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.2;
  transition:
    transform var(--t-base),
    filter var(--t-base),
    box-shadow var(--t-base),
    background var(--t-base),
    color var(--t-base),
    border-color var(--t-base);
  white-space: nowrap;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: var(--shadow-md); }
.button:active { transform: translateY(0); filter: brightness(0.96); }
.button:focus-visible { outline: none; box-shadow: var(--glow-violet); }

/* Primary — violet signature gradient */
.button:not(.secondary):not(.tertiary):not(.danger) {
  background: var(--grad);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 14px rgba(109,78,247,0.28);
}
.button:not(.secondary):not(.tertiary):not(.danger):hover {
  background: var(--grad-hover);
  box-shadow: 0 8px 22px rgba(109,78,247,0.36);
}

/* Secondary — ghost; transparent with hover-to-violet */
.button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}
.button.secondary:hover {
  background: var(--v50);
  color: var(--v700);
  border-color: var(--v300);
  box-shadow: none;
}
.button.secondary.danger {
  color: var(--bad);
  border-color: var(--line-strong);
}
.button.secondary.danger:hover {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad-ink);
}
.button.danger {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}
.button.danger:hover {
  background: var(--bad-ink);
  border-color: var(--bad-ink);
}
.button.danger:disabled {
  opacity: .6;
}

/* Tertiary — text-link styled button */
.button.tertiary {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
  box-shadow: none;
  padding: 6px var(--sp-3);
}
.button.tertiary:hover { background: var(--v50); color: var(--v500); }

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-top: var(--sp-4);
}

.inline-form { display: inline-flex; margin: 0; }

/* ============================================================
   FORMS
   ============================================================ */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--ink-1);
}

input[type=text],
input[type=search],
input[type=email],
input[type=number],
input[type=password],
input[type=url],
input[type=tel],
input:not([type]),
select,
textarea {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans), sans-serif;
  font-size: var(--fs-14);
  font-weight: 500;
  padding: 10px var(--sp-3);
  border-radius: var(--r);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  width: 100%;
  line-height: 1.4;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--v500);
  box-shadow: 0 0 0 3px var(--v100);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.6; font-family: var(--sans), sans-serif; }
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%235C5B65' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-8);
  cursor: pointer;
}

input[type=checkbox], input[type=radio] {
  width: 16px; height: 16px;
  margin: 0;
  accent-color: var(--v500);
  cursor: pointer;
}

input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }

.stacked-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
  align-items: end;
}
.form-actions { display: flex; gap: var(--sp-2); align-items: center; }
.fieldset-hint { margin-top: 4px; }

/* ============================================================
   CHIPS / PILLS / NOTICES
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink-1);
  background: var(--paper-tint);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  line-height: 1.5;
  text-decoration: none;
}
.chip:hover { background: var(--v50); border-color: var(--v200); color: var(--v700); }
.chip-active,
.chip.chip-active {
  background: var(--v500);
  color: white;
  border-color: var(--v500);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  background: var(--paper-tint);
  color: var(--ink-2);
  border: 1px solid var(--line);
  line-height: 1.5;
  white-space: nowrap;
}
.status-pill::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--ink-3);
}

.status-pill.good,
.status-pill.recipient-sent, .status-pill.recipient-delivered,
.status-pill.event-delivery, .status-pill.event-opened,
.status-pill.status-active, .status-pill.status-completed {
  background: var(--good-bg); color: var(--good-ink);
  border-color: rgba(22,163,74,0.22);
}
.status-pill.good::before,
.status-pill.recipient-sent::before, .status-pill.recipient-delivered::before,
.status-pill.event-delivery::before, .status-pill.event-opened::before,
.status-pill.status-active::before, .status-pill.status-completed::before { background: var(--good); }

.status-pill.warn,
.status-pill.event-bounce, .status-pill.recipient-bounced,
.status-pill.status-paused, .status-pill.event-soft_bounce {
  background: var(--warn-bg); color: var(--warn-ink);
  border-color: rgba(180,83,9,0.22);
}
.status-pill.warn::before,
.status-pill.event-bounce::before, .status-pill.recipient-bounced::before,
.status-pill.status-paused::before, .status-pill.event-soft_bounce::before { background: var(--warn); }

.status-pill.bad,
.status-pill.recipient-failed, .status-pill.event-failure,
.status-pill.event-error, .status-pill.event-hard_bounce {
  background: var(--bad-bg); color: var(--bad-ink);
  border-color: rgba(220,38,38,0.22);
}
.status-pill.bad::before,
.status-pill.recipient-failed::before, .status-pill.event-failure::before,
.status-pill.event-error::before, .status-pill.event-hard_bounce::before { background: var(--bad); }

.status-pill.info,
.status-pill.recipient-queued, .status-pill.recipient-pending,
.status-pill.event-queued, .status-pill.status-draft {
  background: var(--info-bg); color: var(--info-ink);
  border-color: rgba(37,99,235,0.22);
}
.status-pill.info::before,
.status-pill.recipient-queued::before, .status-pill.recipient-pending::before,
.status-pill.event-queued::before, .status-pill.status-draft::before { background: var(--info); }

.status-pill.event-clicked, .status-pill.event-reply,
.status-pill.recipient-replied {
  background: var(--v50); color: var(--v700);
  border-color: var(--v200);
}
.status-pill.event-clicked::before, .status-pill.event-reply::before,
.status-pill.recipient-replied::before { background: var(--v500); }

.notice {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-5);
  font-size: var(--fs-14);
  margin: 0 0 var(--sp-4);
  background: var(--paper-tint);
  color: var(--ink-1);
  position: relative;
  overflow: hidden;
}
.notice::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--ink-3);
}
.notice.good     { background: rgba(240,253,244,0.7); color: var(--good-ink); border-color: rgba(22,163,74,0.15); backdrop-filter: blur(4px); }
.notice.good::before { background: var(--good); }
.notice.bad      { background: var(--bad-bg);  color: var(--bad-ink);  border-color: rgba(220,38,38,0.22); }
.notice.bad::before  { background: var(--bad); }
.notice.neutral  { background: var(--paper-tint); color: var(--ink-1); }
.notice.neutral::before { background: var(--ink-3); }
.notice.violet, .notice.info { background: var(--v50); color: var(--v800); border-color: var(--v200); }
.notice.violet::before, .notice.info::before { background: var(--v500); }
.notice strong { color: inherit; }

.delivery-state {
  border-radius: var(--r-pill);
  padding: 4px 10px;
  font-weight: 600;
  font-size: var(--fs-12);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.delivery-state.good    { background: var(--good-bg); color: var(--good-ink); }
.delivery-state.neutral { background: var(--paper-tint); color: var(--ink-2); border: 1px solid var(--line); }

/* ============================================================
   HOMEPAGE SEARCH (index.html)
   ============================================================ */

.search-wrap { position: relative; max-width: 640px; margin-top: var(--sp-6); }
.search-wrap input[type=search] {
  font-size: var(--fs-18);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  background: var(--paper);
}
.search-wrap input[type=search]:focus {
  border-color: var(--v500);
  box-shadow: 0 0 0 4px var(--v100), var(--shadow-sm);
}
.results {
  margin-top: var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  max-width: 640px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.results > a {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  text-decoration: none;
  color: var(--ink-1);
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast), padding-left var(--t-fast);
}
.results > a:last-child { border-bottom: none; }
.results > a:hover { background: var(--v50); color: var(--v700); padding-left: var(--sp-5); }
.r-name { display: block; font-weight: 600; }
.r-meta {
  display: block;
  font-size: var(--fs-12);
  color: var(--ink-3);
  margin-top: 2px;
  font-family: var(--mono), monospace;
  letter-spacing: 0;
}
.status { margin-top: var(--sp-2); color: var(--ink-3); font-size: var(--fs-13); min-height: 1.2em; }

/* ============================================================
   DISCOVERY (filter + table)
   ============================================================ */

.discovery-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-tint);
  margin-bottom: var(--sp-6);
}
.discovery-stats > div { display: flex; flex-direction: column; gap: 4px; }
.discovery-stats > div > span:first-child {
  font-size: var(--fs-11);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.compact-stat {
  font-family: var(--sans), sans-serif;
  font-size: var(--fs-20);
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--ink);
}

.discovery-filter-card { padding: var(--sp-5); }
.discovery-form { gap: var(--sp-4); }
.discovery-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
  align-items: end;
}

.discovery-results-card { padding: 0; overflow: hidden; }
.results-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.results-head h2 { margin: 0; font-size: var(--fs-16); font-weight: 700; letter-spacing: -0.012em; }
.results-head p { margin: 4px 0 0; color: var(--ink-3); font-size: var(--fs-13); }
.results-head .button-row,
.results-head .table-actions { margin: 0; }
.discovery-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.discovery-scroll::-webkit-scrollbar { height: 8px; }
.discovery-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.discovery-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

.discovery-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.discovery-table thead th {
  background: var(--paper);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: var(--fs-11);
  font-weight: 600;
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.discovery-table thead th a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.discovery-table thead th a:hover { color: var(--v500); }
.sort-arrow { font-size: 10px; color: var(--v500); }
.discovery-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.discovery-table tbody tr:hover { background: var(--paper-tint); }
.discovery-table tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--v500); }
.discovery-table tbody tr:last-child { border-bottom: none; }
.discovery-table td {
  padding: var(--sp-3) var(--sp-4);
  vertical-align: top;
  color: var(--ink-1);
}
.discovery-table .col-company { min-width: 220px; }
.discovery-table .col-company strong { font-weight: 600; }
.discovery-table .col-money,
.discovery-table .col-employees,
.discovery-table .col-margin,
.discovery-table .col-year,
.discovery-table td.num,
.discovery-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  font-family: var(--mono), monospace;
  font-size: var(--fs-12);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.discovery-table .code {
  font-family: var(--mono), monospace;
  font-size: var(--fs-11);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.discovery-table .col-emtak {
  font-family: var(--mono), monospace;
  font-size: var(--fs-11);
  color: var(--ink-2);
}
.emtak-cell { line-height: 1.5; }
.emtak-desc {
  color: var(--ink-3);
  font-size: var(--fs-11);
  display: block;
  font-family: var(--sans), sans-serif;
  letter-spacing: 0;
}
.col-select { width: 30px; }
.col-action { text-align: right; white-space: nowrap; }
.table-actions { gap: 4px; }
.button.table-button {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
  padding: 4px var(--sp-2);
  font-size: var(--fs-11);
  font-weight: 600;
  box-shadow: none;
}
.button.table-button:hover {
  background: var(--v50);
  color: var(--v700);
  border-color: var(--v300);
  box-shadow: none;
}

/* EMTAK combo */
.emtak-field { display: flex; flex-direction: column; gap: 6px; }
.emtak-field-title { font-size: var(--fs-13); font-weight: 500; color: var(--ink-1); }
.emtak-combo { position: relative; }
/* Picker-trigger: näeb välja nagu input, aga on tegelikult nupp. */
.emtak-display {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans), sans-serif;
  font-size: var(--fs-14);
  font-weight: 500;
  padding: 10px var(--sp-3);
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  line-height: 1.4;
}
.emtak-display:hover { border-color: var(--ink-3); }
.emtak-display:focus { outline: none; border-color: var(--v500); box-shadow: 0 0 0 2px var(--v100); }
.emtak-combo.open .emtak-display { border-color: var(--v500); }
.emtak-display-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emtak-display-label.is-placeholder { color: var(--ink-3); font-weight: 400; }
.emtak-chevron { color: var(--ink-3); font-size: var(--fs-12); }
.emtak-combo.open .emtak-chevron { transform: rotate(180deg); color: var(--v500); }
.emtak-panel {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  z-index: 12;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-3);
  max-height: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.emtak-search { border-radius: var(--r-sm); }
.emtak-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
}
.emtak-confirm,
.emtak-clear {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  font-size: var(--fs-12);
  cursor: pointer;
  padding: 6px 12px;
  font-weight: 600;
  border-radius: var(--r-sm);
}
.emtak-confirm {
  background: var(--v500);
  color: var(--paper);
  border-color: var(--v500);
}
.emtak-confirm:hover { background: var(--v700); border-color: var(--v700); }
.emtak-clear { color: var(--v500); }
.emtak-clear:hover { text-decoration: underline; }
.emtak-options {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.emtak-option {
  display: grid;
  grid-template-columns: auto 36px 1fr;
  gap: var(--sp-2);
  align-items: center;
  padding: 6px var(--sp-2);
  font-size: var(--fs-12);
  cursor: pointer;
  border-radius: var(--r-sm);
}
.emtak-option:hover { background: var(--v50); }
.emtak-option .code { font-family: var(--mono), monospace; font-weight: 600; color: var(--ink-1); }
.emtak-option .desc { color: var(--ink-2); line-height: 1.4; }

/* ============================================================
   COMPANY DETAIL
   ============================================================ */

.company-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--sp-8);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.company-head h1 {
  font-size: var(--fs-40);
  font-weight: 800;
  letter-spacing: -0.034em;
  margin: 0 0 6px;
}
.company-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  align-items: center;
  font-size: var(--fs-13);
  color: var(--ink-3);
  font-family: var(--mono), monospace;
  letter-spacing: 0.01em;
}
.company-head .button-row { margin: 0; }

.company-head-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  width: 100%;
}
.company-head-title h1 { margin-bottom: 0; }

.company-campaign-banner {
  width: 100%;
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--v50, #f5f3ff);
  border: 1px solid var(--v200, #e2dfff);
  border-left: 3px solid var(--v500, #6d28d9);
  border-radius: var(--r);
}
.company-campaign-banner-title {
  display: block;
  font-weight: 600;
  font-size: var(--fs-13);
  margin-bottom: 4px;
}
.company-campaign-banner-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-13);
}
.company-campaign-banner-list a { font-weight: 600; }

.row-campaigns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.row-campaigns .chip {
  font-size: var(--fs-11);
  text-decoration: none;
}

.preview-item {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3);
  margin-top: var(--sp-3);
  background: var(--paper);
}
.preview-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: 6px;
}
.preview-item-to code {
  background: var(--paper-tint);
  padding: 2px 6px;
  border-radius: 4px;
}
.preview-item-subject { margin: 4px 0 8px; }
.preview-item-body {
  white-space: pre-wrap;
  font-family: var(--mono), monospace;
  font-size: var(--fs-12);
  background: var(--paper-tint);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3);
  margin: 0;
  max-height: 280px;
  overflow: auto;
}
.preview-confirm { border-top: 2px solid var(--v500, #6d28d9); }

.add-step-details { margin-top: var(--sp-4); }
.add-step-form { margin-top: var(--sp-3); }
.add-step-template-pick,
.add-step-template-new {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3) var(--sp-4);
  margin-top: var(--sp-3);
}
.add-step-template-pick legend,
.add-step-template-new legend {
  font-weight: 600;
  padding: 0 6px;
}
.add-step-form textarea {
  width: 100%;
  font-family: var(--mono), monospace;
  font-size: var(--fs-13);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* ============================================================
   STATISTIKA + AUDIT
   ============================================================ */

.stat-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
@media (max-width: 900px) { .stat-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .stat-grid-4 { grid-template-columns: 1fr; } }

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: var(--sp-3);
  font-family: var(--mono), monospace;
  font-size: var(--fs-12);
}
.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 40px;
  align-items: center;
  gap: 8px;
}
.bar-label { color: var(--ink-3); }
.bar-track {
  background: var(--paper-tint);
  border-radius: 4px;
  height: 14px;
  position: relative;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--v500, #6d28d9), var(--v300, #a78bfa));
  border-radius: 4px;
}
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }

.sidebar-user-role {
  display: block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 2px;
}

.audit-detail {
  font-family: var(--mono), monospace;
  font-size: 11px;
  color: var(--ink-3);
  max-width: 460px;
  word-break: break-all;
}

/* ============================================================
   GUIDE PAGE (/juhend) — prose typography for rendered markdown
   ============================================================ */

.prose {
  max-width: 760px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
}
.prose h1 {
  font-size: var(--fs-32);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 var(--sp-4);
}
.prose h2 {
  font-size: var(--fs-24);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: var(--sp-8) 0 var(--sp-3);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.prose h3 {
  font-size: var(--fs-18);
  font-weight: 700;
  margin: var(--sp-6) 0 var(--sp-2);
}
.prose h4 {
  font-size: var(--fs-15);
  font-weight: 700;
  margin: var(--sp-5) 0 var(--sp-2);
}
.prose p { margin: 0 0 var(--sp-3); }
.prose ul, .prose ol {
  margin: 0 0 var(--sp-3);
  padding-left: var(--sp-6);
}
.prose li { margin-bottom: 4px; }
.prose li > p { margin-bottom: 0; }
.prose strong, .prose b { font-weight: 700; }
.prose code {
  font-family: var(--mono), monospace;
  font-size: 0.9em;
  background: var(--paper-tint);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.prose pre {
  background: var(--paper-tint);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--sp-3);
  overflow-x: auto;
  font-size: var(--fs-13);
  line-height: 1.5;
}
.prose pre code {
  background: transparent;
  border: 0;
  padding: 0;
}
.prose blockquote {
  margin: var(--sp-4) 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--v50, #f5f3ff);
  border-left: 3px solid var(--v500, #6d28d9);
  border-radius: 6px;
  font-size: var(--fs-14);
}
.prose blockquote p { margin-bottom: 0; }
.prose blockquote p + p { margin-top: var(--sp-2); }
.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--sp-6) 0;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-3) 0;
  font-size: var(--fs-13);
}
.prose th, .prose td {
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.prose th {
  background: var(--paper-tint);
  font-weight: 700;
}
.prose a {
  color: var(--v500, #6d28d9);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.prose a:hover { text-decoration-thickness: 2px; }
.prose .toc {
  background: var(--paper-tint);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--sp-3) var(--sp-4);
}

.button.disabled, a.button[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-14);
  margin: 0;
}
.kv dt {
  color: var(--ink-3);
  font-weight: 600;
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.kv dd { margin: 0; color: var(--ink); font-weight: 500; }
.kv-contacts dt { letter-spacing: 0.06em; }

.links { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* Finance dashboard */
.finance-dashboard { padding: var(--sp-7); }
.finance-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.finance-head h2 {
  margin: 0;
  font-size: var(--fs-20);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--sp-3);
  background: var(--v50);
  border: 1px solid var(--v200);
  color: var(--v700);
  border-radius: var(--r);
  font-size: var(--fs-12);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-5) 0;
}
.metric-tile {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.metric-tile:hover { border-color: var(--v300); background: var(--v50); }
.metric-tile .label {
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-weight: 600;
}
.metric-tile .value {
  font-size: var(--fs-28);
  font-weight: 700;
  letter-spacing: -0.028em;
  color: var(--ink);
  line-height: 1.05;
}
.metric-change {
  font-size: var(--fs-12);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.metric-change.up   { color: var(--good); }
.metric-change.down { color: var(--bad); }
.metric-change.flat { color: var(--ink-3); }

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.ratio-grid > div {
  border: 1px solid var(--line);
  padding: var(--sp-3);
  border-radius: var(--r);
  background: var(--paper);
}
.ratio-grid .label {
  color: var(--ink-3);
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.ratio-grid .value {
  font-size: var(--fs-18);
  font-weight: 600;
  letter-spacing: -0.018em;
}

.finance-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
  margin-top: var(--sp-6);
}
.signal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.signal-list li {
  padding: 8px var(--sp-3);
  font-size: var(--fs-13);
  border-left: 2px solid var(--line-strong);
  background: var(--paper-tint);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.signal-list li.good { border-color: var(--good); }
.signal-list li.warn { border-color: var(--warn); }
.signal-list li.bad  { border-color: var(--bad); }
.signal-list li.info { border-color: var(--v500); }

.trend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.trend-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: var(--sp-3);
}
.trend-row .label {
  font-family: var(--mono), monospace;
  font-weight: 600;
  font-size: var(--fs-12);
  color: var(--ink-2);
}
.trend-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.bar-line {
  display: grid;
  grid-template-columns: 60px 1fr 100px;
  gap: var(--sp-2);
  align-items: center;
  font-size: var(--fs-11);
}
.bar-line .label {
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.bar-line .value {
  text-align: right;
  font-family: var(--mono), monospace;
  color: var(--ink);
}
.bar {
  height: 10px;
  border-radius: 3px;
  background: var(--v100);
}
.bar.revenue       { background: linear-gradient(90deg, var(--v400), var(--v500)); }
.bar.profit        { background: linear-gradient(90deg, #16A34A, #34D399); }
.bar.profit.good   { background: linear-gradient(90deg, #16A34A, #34D399); }
.bar.profit.warn   { background: linear-gradient(90deg, #B45309, #F59E0B); }
.bar.profit.bad    { background: linear-gradient(90deg, #DC2626, #F87171); }

/* Report tables (bilanss / kasumiaruanne) */
.report-details .grid { gap: var(--sp-6); }
.report-details h3 {
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-bottom: var(--sp-3);
  font-weight: 600;
}
.report-details table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.report-details table th,
.report-details table td {
  padding: 8px var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.report-details table th {
  font-weight: 600;
  color: var(--ink-2);
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.report-details table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono), monospace;
  font-size: var(--fs-12);
}

/* Conversation thread */
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.conversation-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper);
  border-left: 2px solid var(--ink-4);
}
.conversation-item.event-clicked,
.conversation-item.event-opened { border-left-color: var(--v500); }
.conversation-item.event-reply  { border-left-color: var(--good); background: var(--good-bg); }
.conversation-item.event-bounce,
.conversation-item.event-soft_bounce { border-left-color: var(--warn); }
.conversation-item.event-failure,
.conversation-item.event-hard_bounce,
.conversation-item.event-error  { border-left-color: var(--bad); }
.conversation-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  color: var(--ink-3);
}
.conversation-subject { font-weight: 600; color: var(--ink); }
.conversation-body {
  font-size: var(--fs-13);
  color: var(--ink-1);
  white-space: pre-wrap;
  line-height: 1.55;
}
.conversation-error {
  font-size: var(--fs-12);
  color: var(--bad-ink);
  background: var(--bad-bg);
  padding: 6px 8px;
  border-radius: var(--r-sm);
}

/* ============================================================
   GENERIC GRID/TABLE (.grid, .scroll-x)
   ============================================================ */

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.grid th, .grid td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.grid th {
  font-weight: 600;
  color: var(--ink-3);
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--paper);
}
.grid tbody tr:hover { background: var(--paper-tint); }
.grid tbody tr:last-child td { border-bottom: none; }
.grid .num,
.grid td.num,
.grid th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono), monospace;
  font-size: var(--fs-12);
}
.grid .num.small { font-size: var(--fs-11); }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { height: 8px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.scroll-x::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

.grid-financials th,
.grid-financials td {
  font-size: var(--fs-12);
  padding: 8px var(--sp-3);
}

/* ============================================================
   STAT TILES (outreach / leads)
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}
.stat-tile {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-fast);
}
.stat-tile:hover { border-color: var(--v300); }
.stat-tile::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--grad);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.stat-tile:hover::after { opacity: 1; }
.stat-tile > span:first-child {
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-weight: 600;
}
.stat-tile > b,
.stat-tile strong,
.stat-tile .num {
  font-size: var(--fs-28);
  font-weight: 700;
  letter-spacing: -0.028em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

/* ============================================================
   KANBAN (leads.html)
   ============================================================ */

.kanban-section { margin-top: var(--sp-6); }
.kanban-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.kanban-section-head h2 {
  margin: 0;
  font-size: var(--fs-16);
  font-weight: 700;
  letter-spacing: -0.012em;
}
.kanban-section-head .count,
.count {
  font-family: var(--mono), monospace;
  font-size: var(--fs-12);
  color: var(--ink-3);
  background: var(--paper-tint);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 1fr);
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-3);
}

/* Desktop: widen each Kanban column so 3 lead cards fit side-by-side. */
@media (min-width: 1280px) {
  .kanban { grid-auto-columns: minmax(820px, 1fr); }
  .kanban-col-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2);
  }
}
/* Mid-width: 2 cards per row inside each column. */
@media (min-width: 980px) and (max-width: 1279px) {
  .kanban { grid-auto-columns: minmax(560px, 1fr); }
  .kanban-col-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-2);
  }
}
.kanban::-webkit-scrollbar { height: 8px; }
.kanban::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.kanban-col {
  background: var(--paper-tint);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-height: 200px;
}
.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 4px var(--sp-2);
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.kanban-col-head .count {
  font-size: var(--fs-11);
  font-weight: 600;
  background: var(--paper);
  letter-spacing: 0;
}

.kanban-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}
.kanban-card::before {
  content: '';
  position: absolute;
  left: -1px; top: 8px; bottom: 8px; width: 2px;
  background: transparent;
  border-radius: 2px;
  transition: background var(--t-fast);
}
.kanban-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kanban-card:hover::before { background: var(--v500); }

.kanban-card-title {
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.kanban-card-meta {
  font-size: var(--fs-11);
  font-family: var(--mono), monospace;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.kanban-chips, .kanban-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.kanban-status {
  font-size: var(--fs-11);
  font-weight: 600;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kanban-card-actions { display: flex; gap: 4px; margin-top: 4px; }

.kanban-card-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.kanban-card:hover .kanban-card-delete,
.kanban-card-delete:focus-within { opacity: 1; }
.kanban-card-delete-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-3, #888);
  width: 22px;
  height: 22px;
  line-height: 18px;
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.kanban-card-delete-btn:hover,
.kanban-card-delete-btn:focus {
  color: #c0392b;
  background: rgba(192, 57, 43, 0.08);
  border-color: rgba(192, 57, 43, 0.3);
  outline: none;
}

.kanban-card-detail {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kanban-card-address {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--ink-3);
  line-height: 1.4;
}
.kanban-card-financials {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: var(--fs-12);
}
.kanban-card-financials > div { display: contents; }
.kanban-card-financials dt {
  color: var(--ink-3);
  font-weight: 400;
  white-space: nowrap;
}
.kanban-card-financials dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.kanban-card-financials dd.neg { color: #c0392b; }
.kanban-card-emtak {
  font-weight: 400;
  font-size: var(--fs-12);
  text-decoration: none;
  color: var(--ink-2, #555);
  border-bottom: 1px dotted var(--line-strong, #ccc);
}
.kanban-card-emtak:hover { color: var(--v500); border-bottom-color: var(--v500); }

.kanban-card-campaigns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.kanban-card-campaign {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: var(--fs-12);
  padding: 2px 8px;
}
.kanban-card-campaign-name { font-weight: 600; }
.kanban-card-campaign-step {
  opacity: 0.75;
  font-size: var(--fs-11);
  padding-left: 6px;
  border-left: 1px solid currentColor;
}

/* Hide the detail block on narrow viewports — user asked for "desktop" only. */
@media (max-width: 900px) {
  .kanban-card-detail { display: none; }
}
.kanban-empty {
  padding: var(--sp-4);
  text-align: center;
  color: var(--ink-3);
  font-size: var(--fs-12);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
}

.kanban-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

/* Grupid /leads lehel — kasutab Kanbani tokeneid, aga ruudustikuna. */
.groups-section { margin-top: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
.group-create-form {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.group-create-form input[type="text"] {
  flex: 1 1 280px;
  max-width: 360px;
}
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-3);
}
.group-card {
  background: var(--paper-tint);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-height: 140px;
  transition: border-color var(--t-fast), background var(--t-fast);
  position: relative;
}
.group-card.drop-target {
  border-color: var(--v500);
  background: var(--v50);
}
.group-card-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.group-card-head h3 {
  margin: 0;
  flex: 1;
  font-size: var(--fs-14);
  font-weight: 600;
}
.group-card-head .count {
  font-size: var(--fs-11);
  font-weight: 600;
  background: var(--paper);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.group-card-delete { margin: 0; }
.group-card-delete .kanban-card-delete-btn { opacity: 1; }
.group-card-members {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.group-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 6px var(--sp-2);
}
.group-member-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.group-member-name {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-member-name:hover { color: var(--v700); }

/* Discovery rea action-cell: kaks nuppu kõrvuti + grupivalija dropdown. */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.group-picker { position: relative; }
.group-picker > summary {
  list-style: none;
  cursor: pointer;
}
.group-picker > summary::-webkit-details-marker { display: none; }
.group-picker[open] > summary { border-color: var(--v500); }
.group-picker-panel {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 4px);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.group-pick-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 6px var(--sp-2);
  font-size: var(--fs-13);
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}
.group-pick-btn:hover {
  background: var(--paper-tint);
  border-color: var(--line);
}
.group-pick-btn:disabled { opacity: 0.5; cursor: progress; }

.stage-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--v50);
  color: var(--v700);
  border: 1px solid var(--v200);
}
.stage-picker, .inline-stage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.inline-stage select {
  padding: 4px var(--sp-6) 4px var(--sp-2);
  font-size: var(--fs-11);
  width: auto;
  min-width: 120px;
  background-position: right 6px center;
  background-size: 10px;
}

/* ============================================================
   OUTREACH (campaigns / templates / steps)
   ============================================================ */

.subnav {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.subnav a {
  text-decoration: none;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink-2);
  padding: 8px var(--sp-3);
  border-radius: var(--r-sm);
  position: relative;
}
.subnav a:hover { color: var(--ink); background: var(--paper-tint); }
.subnav a.active {
  color: var(--v700);
  background: var(--v50);
}
.subnav a.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -9px; height: 2px;
  background: var(--v500);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: stepc;
}
.step-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.step-item::before {
  content: counter(stepc);
  counter-increment: stepc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: var(--v50);
  color: var(--v700);
  border: 1px solid var(--v200);
  border-radius: 999px;
  font-family: var(--mono), monospace;
  font-size: var(--fs-12);
  font-weight: 700;
  flex-shrink: 0;
}
.step-meta {
  font-size: var(--fs-12);
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line);
}

.outreach-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 2fr);
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}
@media (max-width: 980px) {
  .outreach-grid { grid-template-columns: 1fr; }
}

.outreach-grid-left, .outreach-grid-right {
  align-self: start;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.card-head h2 { margin: 0; }
.button.small { font-size: var(--fs-12); padding: 4px 10px; }

.campaign-list {
  list-style: none;
  margin: var(--sp-3) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.campaign-list-item { margin: 0; }
.campaign-list-link {
  display: block;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.campaign-list-link:hover {
  border-color: var(--v500);
  box-shadow: var(--shadow-md);
}
.campaign-list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: 6px;
}
.campaign-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: var(--fs-12);
}
.campaign-list-sub {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.group-select-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.group-select-label {
  white-space: nowrap;
}
.btn-group-pick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  font: inherit;
  font-size: var(--fs-13);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn-group-pick:hover {
  border-color: var(--v400);
  background: var(--v50);
}
.btn-group-pick-active {
  background: var(--v500);
  color: #fff;
  border-color: var(--v500);
}
.btn-group-pick-active:hover {
  background: var(--v600);
  border-color: var(--v600);
}
.group-pick-count {
  font-size: 11px;
  background: rgba(0,0,0,.1);
  border-radius: 10px;
  padding: 0 5px;
  line-height: 1.6;
}
.btn-group-pick-active .group-pick-count {
  background: rgba(255,255,255,.25);
}

.picker-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-3) 0;
  flex-wrap: wrap;
}
.picker-search {
  flex: 1 1 200px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.picker-select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-13);
  white-space: nowrap;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-2);
  max-height: 460px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper-tint);
}
.picker-grid-compact { max-height: 360px; }
.picker-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.picker-card:hover { border-color: var(--v500); }
.picker-card input[type=checkbox] { margin-top: 3px; }
.picker-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.picker-card-camps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: var(--fs-12);
  color: var(--ink-3);
}
.picker-card:has(input:checked) {
  background: var(--v50, #f5f3ff);
  border-color: var(--v500);
}
.picker-card-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--paper-tint, #f7f7fa);
}
.picker-card-disabled:hover { border-color: var(--line); }

/* Rollipilt + segment-control rollivalijaks /seaded Kasutajad sektsioonis. */
.role-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-2) 0 var(--sp-3);
}
.role-legend-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px 10px;
  border-radius: var(--r);
  flex: 1 1 220px;
  border: 1px solid var(--line);
}
.role-legend-item b { font-size: var(--fs-13); text-transform: lowercase; }

.role-pill,
.role-pill-admin,
.role-pill-sales,
.role-pill-viewer {
  /* Iga roll oma värviga. Värvid on Vibrant-skaala alusel kooskõlas
     ülejäänud UI-ga. */
}
.role-pill-admin { background: var(--v50); border-color: var(--v300); color: var(--v700); }
.role-pill-sales { background: #eaf7ed; border-color: #5fb16f; color: #21643d; }
.role-pill-viewer { background: var(--paper-tint); border-color: var(--line-strong); color: var(--ink-2); }

.role-picker {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--paper);
}
.role-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  padding: 6px 12px;
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.role-btn:last-child { border-right: none; }
.role-btn:hover:not(:disabled):not(.active) { background: var(--paper-tint); color: var(--ink); }
.role-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.role-btn.is-saving { opacity: 0.55; }

/* Aktiivne nupp võtab rolli enda värvi. */
.role-picker .role-btn.role-pill-admin.active  { background: var(--v500); color: var(--paper); }
.role-picker .role-btn.role-pill-sales.active  { background: #2f9e51; color: var(--paper); }
.role-picker .role-btn.role-pill-viewer.active { background: var(--ink-3); color: var(--paper); }

.role-locked-tag {
  margin-left: 8px;
  font-size: var(--fs-11);
  color: var(--ink-3);
  white-space: nowrap;
}

.users-table td { vertical-align: middle; }

.inline-form { display: inline; margin: 0; }
.button-x {
  appearance: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink-3, #888);
  width: 24px;
  height: 24px;
  line-height: 18px;
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  transition: color var(--t-fast);
}
.button-x:hover { color: #c0392b; }
.button-x:focus,
.button-x:focus-visible { outline: none; }

.campaign-form { margin-bottom: var(--sp-4); }

.wizard-step { position: relative; padding-left: var(--sp-4); }
.wizard-step + .wizard-step { margin-top: var(--sp-4); }
.wizard-step > legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: var(--fs-15);
  letter-spacing: -0.01em;
}
.wizard-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--v500, #6d28d9);
  color: #fff;
  font-size: var(--fs-12);
  font-weight: 700;
}
#picker-count-label { font-variant-numeric: tabular-nums; }
.campaign-table th,
.campaign-table td { font-size: var(--fs-13); }
.campaign-table th:not(:first-child),
.campaign-table td:not(:first-child) { text-align: center; }

.lead-checks {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  background: var(--paper-tint);
}
.lead-checks label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: var(--fs-13);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--r-sm);
}
.lead-checks label:hover { background: var(--v50); }

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
}
.mini-details {
  padding: var(--sp-4);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.mini-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-14);
  padding: 4px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mini-details > summary::-webkit-details-marker { display: none; }
.mini-details > summary::before {
  content: '+';
  font-family: var(--mono), monospace;
  color: var(--v500);
  font-weight: 700;
  font-size: var(--fs-16);
  width: 14px;
  display: inline-block;
}
.mini-details[open] > summary::before { content: '–'; }
.template-edit-form { margin-top: var(--sp-3); }
.template-actions { align-items: center; }

.outreach-email-block {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-4);
  background: var(--paper-tint);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.outreach-email-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--sp-3);
  align-items: baseline;
  font-size: var(--fs-13);
}
.outreach-email-row > strong {
  font-size: var(--fs-11);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

/* Käsitsi lisatud kontaktid ettevõtte kaardil. */
.contacts-block {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-4);
  background: var(--paper-tint);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.contacts-title { margin: 0; font-size: var(--fs-14); font-weight: 600; }
.contacts-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.contact-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 6px var(--sp-2);
}
.contact-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  cursor: pointer;
}
.contact-toggle input[type="checkbox"] { margin: 0; }
.contact-info { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.contacts-help { margin-bottom: 4px; }
.contact-row .kanban-card-delete-btn { opacity: 1; }
.contact-add-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
@media (max-width: 720px) {
  .contact-add-form { grid-template-columns: 1fr; }
}

/* ============================================================
   FOOTER
   ============================================================ */

.footer {
  padding: var(--sp-6) var(--sp-12);
  border-top: 1px solid var(--line);
  font-size: var(--fs-12);
  color: var(--ink-3);
  letter-spacing: 0.01em;
  background: var(--paper);
}
.footer a { color: var(--ink-2); text-decoration-color: var(--line-strong); }
.footer a:hover { color: var(--v500); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet & below: kogu nav koondub täisekraani hamburger-drawer'isse
   (vt .mobile-topbar / .sidebar drawer reegleid allpool). */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }

  .container { padding: var(--sp-6) var(--sp-4); }
  .footer { padding: var(--sp-4); }

  .finance-split, .two-col { grid-template-columns: 1fr; }
  .hero h1 { font-size: var(--fs-56); letter-spacing: -0.04em; }
  .page-head { gap: var(--sp-3); }
  .page-head .button-row { width: 100%; }
}

/* Phone landscape / large phone */
@media (max-width: 720px) {
  .container { padding: var(--sp-5) var(--sp-4); }
  h1 { font-size: var(--fs-32); }
  h2 { font-size: var(--fs-20); }
  .hero { padding: var(--sp-8) 0 var(--sp-6); }
  .hero h1 { font-size: var(--fs-40); letter-spacing: -0.038em; }
  .lead { font-size: var(--fs-16); }
  .card { padding: var(--sp-5); }
  .finance-dashboard { padding: var(--sp-5); }

  .company-head { gap: var(--sp-4); padding-bottom: var(--sp-5); margin-bottom: var(--sp-6); }
  .company-head h1 { font-size: var(--fs-32); }

  /* Filter form: 2-up grid */
  .discovery-row,
  .form-row { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  .discovery-row > label,
  .form-row > label { min-width: 0; }
  .discovery-row .form-actions,
  .form-row .form-actions { grid-column: 1 / -1; gap: var(--sp-2); }
  .discovery-row .form-actions .button,
  .form-row .form-actions .button { flex: 1; }

  /* Results head wraps cleanly */
  .results-head {
    flex-direction: column;
    align-items: stretch;
    padding: var(--sp-4) var(--sp-5);
    gap: var(--sp-3);
  }
  .results-head .button-row { width: 100%; justify-content: flex-start; }

  /* Discovery table: compact + scroll hint */
  .discovery-table { font-size: var(--fs-12); }
  .discovery-table thead th,
  .discovery-table td { padding: 8px var(--sp-3); }
  .discovery-table .col-emtak,
  .discovery-table .col-margin { display: none; }
  .discovery-scroll {
    background:
      linear-gradient(to right, var(--paper) 0%, var(--paper) 6%, transparent 12%, transparent 88%, var(--paper) 94%, var(--paper) 100%) 0 0 / 100% 100% no-repeat local,
      linear-gradient(to right, transparent 0%, rgba(109,78,247,0.12) 6%, transparent 18%, transparent 82%, rgba(109,78,247,0.12) 94%, transparent 100%) 100% 0 / 60px 100% no-repeat scroll;
  }

  /* KPI/stat grids: 2-up */
  .stat-grid,
  .metric-grid,
  .discovery-stats { grid-template-columns: repeat(2, 1fr); }

  /* KV: collapse to single column */
  .kv { grid-template-columns: 1fr; gap: 2px var(--sp-2); }
  .kv dt { margin-top: var(--sp-2); }
  .kv dt:first-child { margin-top: 0; }

  /* Kanban: stack vertically, no horizontal scroll */
  .kanban {
    display: flex;
    flex-direction: column;
    grid-auto-flow: initial;
    grid-auto-columns: initial;
    overflow-x: visible;
    gap: var(--sp-3);
  }
  .kanban-col { min-height: 120px; }
  .kanban-card { padding: var(--sp-3); }

  /* Conversation thread: trim padding */
  .conversation-item { padding: var(--sp-3); }
  .outreach-email-row { grid-template-columns: 1fr; gap: 2px; }
  .outreach-email-row > strong { font-size: 10px; }

  /* Buttons in rows: better wrap */
  .button-row .button { flex: 1 0 auto; }
  .button { padding: 9px var(--sp-4); }
  .button.table-button { flex: 0 0 auto; }

  /* Trend bars: smaller label column */
  .trend-row { grid-template-columns: 60px 1fr; }
  .bar-line { grid-template-columns: 50px 1fr 80px; }

  /* Sub-navigation: scrollable horizontally */
  .subnav { overflow-x: auto; flex-wrap: nowrap; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav a { white-space: nowrap; }
}

/* Phone portrait */
@media (max-width: 480px) {
  .container { padding: var(--sp-4) var(--sp-3); }
  .card { padding: var(--sp-4); }
  .finance-dashboard { padding: var(--sp-4); }
  h1 { font-size: var(--fs-28); letter-spacing: -0.028em; }
  .hero h1 { font-size: var(--fs-32); letter-spacing: -0.034em; }
  .company-head h1 { font-size: var(--fs-24); letter-spacing: -0.028em; }

  /* Filter form: one column on tiny screens */
  .discovery-row,
  .form-row { grid-template-columns: 1fr; }
  .discovery-row .form-actions,
  .form-row .form-actions { flex-direction: column; }
  .discovery-row .form-actions .button,
  .form-row .form-actions .button { width: 100%; }

  /* Stat tiles: scrollable horizontal strip for KPIs */
  .stat-grid,
  .metric-grid,
  .discovery-stats { grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
  .stat-tile, .metric-tile { padding: var(--sp-3); }
  .stat-tile > b,
  .stat-tile strong,
  .stat-tile .num,
  .metric-tile .value { font-size: var(--fs-20); }
  .compact-stat { font-size: var(--fs-16); }

  /* Tables: ultra-compact */
  .discovery-table { font-size: var(--fs-11); }
  .discovery-table thead th,
  .discovery-table td { padding: 6px var(--sp-2); }
  .grid th, .grid td { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-12); }

  /* Page head buttons stack */
  .page-head { align-items: flex-start; }
  .page-head .button-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .page-head .button-row .button { width: 100%; }

  /* Status pills: smaller */
  .status-pill { font-size: 10px; padding: 2px 8px; }

  /* Inline forms full width */
  .inline-form, .inline-form .button { width: 100%; }

  /* Subnav: pill-style on phones */
  .subnav { gap: 4px; padding-bottom: var(--sp-3); }
  .subnav a { padding: 6px 10px; font-size: var(--fs-12); }
  .subnav a.active::after { display: none; }
  .subnav a.active { background: var(--v500); color: white; }

  /* Footer: just one tight line */
  .footer { padding: var(--sp-3); font-size: 10px; line-height: 1.5; }
}

/* Very narrow phones (iPhone SE etc.) */
@media (max-width: 360px) {
  .sidebar { padding: 8px var(--sp-3); gap: var(--sp-3); }
  .main-nav a { padding: 5px 10px; font-size: var(--fs-13); }
  .container { padding: var(--sp-3) var(--sp-3); }
  .hero h1 { font-size: var(--fs-28); }
  .company-head h1 { font-size: var(--fs-20); }
  .stat-grid, .metric-grid, .discovery-stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   SETTINGS PAGE
   ============================================================ */

.container-narrow { max-width: 880px; }

.active-mode-banner {
  margin-top: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  border-radius: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-3);
}
.active-mode-banner.mode-good {
  background: rgba(34, 139, 34, 0.06);
  border-color: rgba(34, 139, 34, 0.25);
  border-left-color: #228b22;
}
.active-mode-banner.mode-partial {
  background: rgba(217, 119, 6, 0.06);
  border-color: rgba(217, 119, 6, 0.3);
  border-left-color: #d97706;
}
.active-mode-banner.mode-off {
  background: rgba(192, 57, 43, 0.05);
  border-color: rgba(192, 57, 43, 0.25);
  border-left-color: #c0392b;
}
.active-mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-3);
}
.active-mode-label {
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3, #666);
}
.active-mode-value {
  font-size: var(--fs-18);
  font-weight: 700;
}
.active-mode-pill {
  font-size: var(--fs-12);
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
}
.active-mode-pill.mode-good    { background: rgba(34, 139, 34, 0.15);  color: #1a6a1a; }
.active-mode-pill.mode-partial { background: rgba(217, 119, 6, 0.15);  color: #92590a; }
.active-mode-pill.mode-off     { background: rgba(192, 57, 43, 0.12);  color: #a52a18; }
.active-mode-detail {
  margin: 6px 0 0;
  font-size: var(--fs-13);
  color: var(--ink-2, #555);
}
.active-mode-detail code {
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: var(--fs-12);
}

.settings-section {
  margin-top: var(--sp-8);
  padding: var(--sp-6) var(--sp-7);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.settings-section h2 { margin-top: 0; }

.settings-form { display: flex; flex-direction: column; gap: var(--sp-5); }
.settings-form-test {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-4);
}
.settings-form-test label { flex: 1 1 240px; }

.settings-fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.settings-fieldset legend {
  padding: 0 6px;
  font-weight: 600;
}
.settings-fieldset > label,
.settings-form > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-fieldset label > span,
.settings-form > label > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.settings-fieldset input,
.settings-fieldset select,
.settings-form input,
.settings-form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
@media (max-width: 640px) {
  .settings-row { grid-template-columns: 1fr; }
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

.settings-test-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  align-items: flex-end;
}
.settings-test-row > .settings-form-test {
  margin: 0;
}

.settings-subgroup {
  border-left: 2px solid var(--line);
  padding-left: var(--sp-4);
  margin-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.settings-subhead {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.settings-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3, #888);
}

.settings-quickstart { background: linear-gradient(180deg, var(--v50) 0%, var(--paper) 100%); }
.settings-steps {
  margin: var(--sp-4) 0 0;
  padding-left: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.settings-steps li { line-height: 1.55; }
.settings-steps b { font-weight: 700; }

/* ── Prospeo ──────────────────────────────────────────────────────── */
.prospeo-tabs {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.prospeo-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  font-size: var(--fs-14);
  color: var(--ink-2);
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.prospeo-tab:hover { color: var(--ink-1); }
.prospeo-tab.active { color: var(--v600); border-bottom-color: var(--v500); font-weight: 600; }

.prospeo-company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}
.prospeo-company-card .card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
}
.prospeo-card-info {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  min-width: 0;
  flex: 1 1 160px;
}
.prospeo-card-text { min-width: 0; }
.prospeo-card-text h3 { margin: 0 0 2px; }
.prospeo-card-text p { margin: 0; }
.prospeo-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  flex-shrink: 1;
  margin-top: 0;
  align-self: flex-start;
  min-width: 0;
  max-width: 100%;
  justify-content: center;
}
.prospeo-card-actions .button {
  flex: 1 1 auto;
  min-width: 120px;
}
.prospeo-card-actions .button {
  justify-content: center;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .prospeo-card-actions {
    min-width: 0;
    width: 100%;
  }
}
.prospeo-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.prospeo-company-card h3 { margin: 0 0 2px; font-size: var(--fs-15); }
.prospeo-desc { margin-top: var(--sp-2); }

.prospeo-person-table { margin-top: var(--sp-4); }

.prospeo-modal {
  border: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 0;
  width: min(640px, 95vw);
  max-height: 85vh;
  overflow-y: auto;
  outline: none;
}
.prospeo-modal::backdrop { background: rgba(0,0,0,.4); }
.prospeo-modal-inner { padding: var(--sp-6); }
.prospeo-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.prospeo-modal-head h2 { margin: 0; }

.prospeo-contact-list { display: flex; flex-direction: column; gap: var(--sp-3); margin: var(--sp-4) 0; }
.prospeo-contact-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
}
.prospeo-contact-row:hover { background: var(--paper-tint); }
.prospeo-contact-info { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* ── CSV Import ─────────────────────────────────────────────────────── */
.csv-drop {
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-base), background var(--t-base);
  outline: none;
}
.csv-drop:hover,
.csv-drop.drag-over,
.csv-drop:focus-visible {
  border-color: var(--v500);
  background: var(--v50);
}
.csv-drop p { margin: var(--sp-2) 0; }
.csv-drop-icon { font-size: 2rem; line-height: 1; display: block; margin-bottom: var(--sp-2); color: var(--ink-3); }

.csv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-14);
}
.csv-table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
  background: var(--paper-tint);
  white-space: nowrap;
}
.csv-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.csv-table tr:last-child td { border-bottom: none; }
.csv-table tr:hover td { background: var(--paper-tint); }
.csv-table td:last-child { width: 32px; text-align: center; }

.csv-rm {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-4);
  padding: 3px var(--sp-2);
  border-radius: var(--r-xs);
  font-size: var(--fs-14);
  line-height: 1;
  transition: color var(--t-fast), background var(--t-fast);
}
.csv-rm:hover { color: var(--bad); background: var(--bad-bg); }

.csv-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.csv-footer label { display: flex; gap: var(--sp-3); align-items: center; font-size: var(--fs-14); }
.csv-footer select { width: auto; min-width: 160px; }

.csv-progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: var(--sp-4);
}
#csv-progress-fill {
  height: 100%;
  background: var(--grad);
  border-radius: var(--r-pill);
  transition: width .25s ease;
  width: 0;
}
.email-st { display: inline-block; padding: 2px 8px; border-radius: var(--r-pill); font-size: var(--fs-11); font-weight: 600; white-space: nowrap; }
.email-st-valid   { background: var(--good-bg); color: var(--good-ink); }
.email-st-catchall{ background: var(--warn-bg); color: var(--warn-ink); }
.email-st-risky   { background: var(--warn-bg); color: var(--warn-ink); }
.email-st-invalid { background: var(--bad-bg);  color: var(--bad-ink);  }

/* ── Dual range slider (Prospeo headcount) ────────────────────────── */
.hc-box {
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 10px var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--paper);
  transition: border-color var(--t-fast);
}
.hc-box:focus-within { border-color: var(--ink-3); }
.hc-box-lbl {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.hc-box input[type=number] {
  border: none !important;
  outline: none !important;
  padding: 0 !important;
  font-size: var(--fs-13) !important;
  font-weight: 600 !important;
  color: var(--ink) !important;
  background: transparent !important;
  width: 100%;
  box-shadow: none !important;
  -moz-appearance: textfield;
}
.hc-box input[type=number]::-webkit-inner-spin-button,
.hc-box input[type=number]::-webkit-outer-spin-button { display: none; }

.hc-slider { width: 100%; }
.hc-track {
  position: relative;
  height: 26px;
  width: 100%;
}
.hc-track-bg {
  position: absolute;
  width: 100%;
  height: 4px;
  top: 50%; transform: translateY(-50%);
  background: var(--line);
  border-radius: 2px;
  z-index: 0;
}
.hc-fill {
  position: absolute;
  height: 4px;
  top: 50%; transform: translateY(-50%);
  background: var(--v500);
  border-radius: 2px;
  pointer-events: none;
  z-index: 0;
}
.hc-fill.snapping {
  transition: left .25s ease, width .25s ease;
}
.hc-track input[type=range] {
  position: absolute;
  width: 100%;
  height: 26px;
  top: 50%;
  transform: translateY(-88%);
  background: transparent;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  outline: none !important;
  margin: 0;
  padding: 0;
}
.hc-track input[type=range]:focus,
.hc-track input[type=range]:focus-visible,
.hc-track input[type=range]:focus-within {
  outline: none !important;
  box-shadow: none !important;
}
.hc-track input[type=range]:focus::-webkit-slider-thumb,
.hc-track input[type=range]:focus-visible::-webkit-slider-thumb {
  outline: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.2) !important;
}
.hc-track input[type=range]:focus::-moz-range-thumb,
.hc-track input[type=range]:focus-visible::-moz-range-thumb { outline: none !important; }
.hc-track input[type=range]::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.hc-track input[type=range]::-moz-range-track { height: 4px; background: transparent; }
.hc-track input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff center/10px no-repeat;
  border: 1px solid var(--line-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  pointer-events: all;
  cursor: grab;
  position: relative;
  z-index: 3;
  outline: none;
  transition: box-shadow .15s ease, transform .1s ease;
}
#hc-min::-webkit-slider-thumb {
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'%3E%3Cpath d='M6.5 2 2 7l4.5 5' stroke='%23717171' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat;
}
#hc-max::-webkit-slider-thumb {
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'%3E%3Cpath d='M3.5 2 8 7l-4.5 5' stroke='%23717171' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat;
}
.hc-track input[type=range]:hover::-webkit-slider-thumb {
  box-shadow: 0 3px 12px rgba(0,0,0,.22);
}
.hc-track input[type=range]:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.hc-track input[type=range]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  pointer-events: all;
  cursor: grab;
  outline: none;
}

/* ── HC mode toggle ───────────────────────────────────────────────── */
.hc-toggle {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--paper);
}
.hc-toggle-btn {
  padding: 3px 10px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-3);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.hc-toggle-btn:first-child { border-right: 1px solid var(--line-strong); }
.hc-toggle-btn.active { background: var(--v50); color: var(--v600); font-weight: 600; }
.hc-toggle-btn:hover:not(.active) { background: var(--paper-tint); color: var(--ink-2); }

/* ── HC range chips ───────────────────────────────────────────────── */
.hc-chip {
  padding: 4px 10px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  align-self: stretch;
}
.hc-chip:hover { border-color: var(--ink-3); color: var(--ink-1); }
.hc-chip.active { background: var(--v50); color: var(--v600); border-color: var(--v300); font-weight: 600; }

/* ── Slider labels mobile (alla) ─────────────────────────────────── */
@media (max-width: 640px) {
  #hc-slider-view {
    flex-wrap: wrap;
    row-gap: var(--sp-1);
  }
  #hc-slider-view .hc-slider { order: 1; width: 100% !important; flex: 0 0 100% !important; min-width: 0 !important; }
  #hc-slider-view #hc-min-num { order: 2; text-align: left; min-width: 0; }
  #hc-slider-view #hc-max-num { order: 3; margin-left: auto; text-align: right; min-width: 0; }
}

/* ── Prospeo kaardid mobile ──────────────────────────────────────── */
@media (max-width: 640px) {
  .prospeo-company-grid {
    grid-template-columns: 1fr;
    gap: var(--sp-3);
  }
  .prospeo-company-card .card-head {
    flex-direction: column;
    gap: var(--sp-3);
  }
  .prospeo-card-info { flex: 1 1 100%; min-width: 0; }
  .prospeo-card-actions {
    width: 100% !important;
    min-width: 0 !important;
    grid-template-columns: 1fr 1fr;
    flex-shrink: 1;
  }
  .prospeo-card-actions .button { font-size: var(--fs-12); padding: 8px var(--sp-2); }
}

/* ── AI Email ──────────────────────────────────────────────────────── */
.ai-draft-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--sp-5);
  align-items: start;
}
.ai-draft-main textarea {
  font-family: var(--ff-mono), monospace;
  font-size: var(--fs-13);
  line-height: 1.6;
  min-height: 320px;
}
.ai-draft-actions { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }
.ai-draft-actions .full-width { width: 100%; }
.email-body-preview {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--fs-13);
  line-height: 1.6;
  background: var(--bg-subtle, #f8f8f8);
  border: 1px solid var(--line, #e0e0e0);
  border-radius: var(--r-card, 8px);
  padding: var(--sp-4);
  margin: 0;
}
.research-preview {
  white-space: pre-wrap;
  font-size: var(--fs-11);
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-subtle, #f8f8f8);
  padding: var(--sp-3);
  border-radius: var(--r-card, 6px);
  margin-top: var(--sp-2);
}
.company-meta { margin: 0 0 var(--sp-4); }
.company-meta dt { font-size: var(--fs-11); color: var(--ink-3); margin-top: var(--sp-2); }
.company-meta dd { margin: 0; font-size: var(--fs-13); }
.form-field-static { margin-bottom: var(--sp-4); }
.form-field-static .label {
  display: block;
  font-size: var(--fs-11);
  color: var(--ink-3);
  margin-bottom: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.text-error { color: var(--red-600, #dc2626); }
.truncate-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.data-table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-weight: 600;
  font-size: var(--fs-11);
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-light, #f0f0f0);
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
@media (max-width: 768px) {
  .ai-draft-layout { grid-template-columns: 1fr; }
}

/* ── Claude auth status ────────────────────────────────────────────── */
.claude-auth-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-card, 8px);
  border: 1px solid var(--line-light, #e8e8e8);
  background: var(--bg-subtle, #f8faf8);
}
.claude-auth-status.good { border-color: var(--green-200, #bbf7d0); background: var(--green-50, #f0fdf4); }
.auth-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.auth-dot.good { background: var(--green-500, #22c55e); }
.auth-dot.off  { background: var(--ink-3, #999); }

/* ── AI generation jobs ───────────────────────────────────────────── */
.jobs-list { display: flex; flex-direction: column; gap: var(--sp-4); }
.job-row {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line-light, #ebebeb);
  border-radius: var(--r-card, 8px);
  background: var(--bg-subtle, #fafafa);
}
.job-row[data-status="running"] { border-color: var(--blue-200, #bfdbfe); background: var(--blue-50, #eff6ff); }
.job-row[data-status="done"] { border-color: var(--green-200, #bbf7d0); background: var(--green-50, #f0fdf4); }
.job-row[data-status="error"] { border-color: var(--red-200, #fecaca); background: var(--red-50, #fef2f2); }
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.job-head b { display: block; font-size: var(--fs-13); }
.job-head .muted { display: block; font-size: var(--fs-11); }
.job-actions { flex-shrink: 0; }
.job-progress-wrap { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.job-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--ink-1a, #e0e0e0);
  border-radius: 99px;
  overflow: hidden;
}
.job-progress-fill {
  height: 100%;
  background: var(--blue-500, #3b82f6);
  border-radius: 99px;
  transition: width .4s ease;
  animation: job-pulse 1.5s ease-in-out infinite;
}
.job-progress-fill.done { background: var(--green-500, #22c55e); animation: none; }
.job-progress-fill.error { background: var(--red-500, #ef4444); animation: none; }
@keyframes job-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
.job-progress-label { font-size: var(--fs-12); color: var(--ink-2); white-space: nowrap; min-width: 80px; }
.button-x.small { font-size: var(--fs-11); padding: 2px 6px; }

/* ── AI login wall ────────────────────────────────────────────────── */
.ai-login-wall {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 340px;
  padding: var(--sp-8) var(--sp-4);
}
.ai-login-box {
  text-align: center;
  max-width: 380px;
}
.ai-login-icon {
  font-size: 2.5rem;
  margin: 0 0 var(--sp-4);
  line-height: 1;
}
.ai-login-box h2 { margin: 0 0 var(--sp-2); font-size: 1.3rem; }
.ai-login-box .muted { margin: 0 0 var(--sp-5); }
.ai-login-btn { min-width: 200px; }
.ai-login-code {
  display: block;
  background: var(--bg-subtle, #f4f4f4);
  border: 1px solid var(--line, #e0e0e0);
  border-radius: var(--r-card, 8px);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-13);
  margin: var(--sp-4) 0;
  text-align: left;
  word-break: break-all;
}

/* ══════════════════════════════════════════════════════════════════
   LOGIN / LANDING PAGE — split layout: dark feature hero + sign-in panel
   ══════════════════════════════════════════════════════════════════ */
.login-body {
  margin: 0;
  background: var(--paper);
  background-image: none;
  min-height: 100vh;
}
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .login-page { grid-template-columns: 1.05fr 0.95fr; }
}

/* ── Hero (left) ───────────────────────────────────────────────── */
.login-hero {
  display: none;
  position: relative;
  overflow: hidden;
  background: var(--v900);
  color: #fff;
  padding: var(--sp-12) var(--sp-12);
}
@media (min-width: 1024px) {
  .login-hero {
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    overflow-y: auto;
  }
}
.login-hero-blob {
  position: absolute;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.login-hero-blob-1 { top: -8rem; right: -8rem; background: rgba(140, 115, 250, 0.30); }
.login-hero-blob-2 { bottom: -6rem; left: -8rem; background: rgba(109, 78, 247, 0.28); }

.login-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.login-brand {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-10);
}
.login-brand-name {
  font-size: var(--fs-24);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
.login-brand-tag {
  font-size: var(--fs-11);
  letter-spacing: 0.2em;
  color: var(--v300);
  font-weight: 700;
}
.login-hero-body { flex: 1; max-width: 40rem; }
.login-eyebrow {
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--v300);
  font-weight: 700;
}
.login-hero-title {
  margin: 0 0 var(--sp-5);
  font-size: var(--fs-40);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
.login-lead {
  margin: 0 0 var(--sp-6);
  font-size: var(--fs-16);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.78);
}
.login-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  padding-top: var(--sp-5);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.login-stat-value {
  font-size: var(--fs-28);
  font-weight: 800;
  line-height: 1;
}
.login-stat-label {
  margin-top: var(--sp-2);
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.5);
}

.login-features {
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.login-features-eyebrow {
  margin: 0 0 var(--sp-5);
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--v300);
  font-weight: 700;
}
.login-features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-6) var(--sp-7);
}
@media (min-width: 640px)  { .login-features-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1440px) { .login-features-grid { grid-template-columns: repeat(3, 1fr); } }

.login-fgroup-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  /* Reserveeri ruum kahele tiitlireale, et nimekirjad joonduksid
     üle veergude ühele joonele ka siis, kui pealkiri murdub kahele reale. */
  min-height: 44px;
}
.login-fgroup-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  color: var(--v300);
}
.login-fgroup-icon svg { width: 18px; height: 18px; display: block; }
.login-fgroup-title {
  margin: 0;
  font-size: var(--fs-15);
  font-weight: 700;
  line-height: 1.25;
  color: #fff;
}
.login-fgroup-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.login-fgroup-list li {
  position: relative;
  padding-left: var(--sp-4);
  font-size: var(--fs-13);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.82);
}
.login-fgroup-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--v300);
}
.login-features-foot {
  margin: var(--sp-6) 0 0;
  font-size: var(--fs-13);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.7);
}
.login-features-foot-icon { color: var(--v300); margin-right: var(--sp-1); }
.login-features-foot-icon svg { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; }
.login-hero-copyright {
  margin: var(--sp-10) 0 0;
  font-size: var(--fs-11);
  color: rgba(255, 255, 255, 0.4);
}

/* ── Sign-in panel (right) ─────────────────────────────────────── */
.login-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--sp-8) var(--sp-6);
}
@media (min-width: 640px) { .login-panel { padding: var(--sp-8) var(--sp-10); } }
.login-panel-top { display: flex; align-items: center; }
.login-panel-brand {
  font-size: var(--fs-18);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.login-panel-brand-tag {
  font-size: var(--fs-11);
  letter-spacing: 0.18em;
  color: var(--ink-3);
  font-weight: 700;
  margin-left: var(--sp-2);
}
@media (min-width: 1024px) { .login-panel-top { display: none; } }

.login-panel-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card { width: 100%; max-width: 24rem; }
.login-welcome {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-32);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.login-welcome-hint {
  margin: 0 0 var(--sp-6);
  font-size: var(--fs-15);
  line-height: 1.6;
  color: var(--ink-2);
}
.login-ms-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 14px var(--sp-5);
  border-radius: var(--r-md);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-16);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: background var(--t-base), transform var(--t-fast);
}
.login-ms-btn:hover { background: var(--ink-1); color: #fff; transform: translateY(-1px); }
.login-ms-btn:active { transform: translateY(0); }
.login-ms-logo { display: block; flex-shrink: 0; }

.login-alert {
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}
.login-alert-bad  { background: var(--bad-bg);  border: 1px solid #FCA5A5; }
.login-alert-warn { background: var(--warn-bg); border: 1px solid #FCD34D; }
.login-alert-title { margin: 0; font-size: var(--fs-13); font-weight: 700; }
.login-alert-bad  .login-alert-title { color: var(--bad-ink); }
.login-alert-warn .login-alert-title { color: var(--warn-ink); }
.login-alert-text { margin: var(--sp-1) 0 0; font-size: var(--fs-12); line-height: 1.5; }
.login-alert-bad  .login-alert-text { color: var(--bad-ink); }
.login-alert-warn .login-alert-text { color: var(--warn-ink); }

.login-note {
  margin-top: var(--sp-5);
  border: 1px solid var(--line);
  background: var(--paper-tint);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-12);
  line-height: 1.55;
  color: var(--ink-2);
}
.login-terms {
  margin: var(--sp-4) 0 0;
  font-size: var(--fs-11);
  line-height: 1.55;
  color: var(--ink-3);
}
.login-panel-foot {
  margin: 0;
  padding-top: var(--sp-4);
  text-align: center;
  font-size: var(--fs-11);
  color: var(--ink-3);
}
@media (min-width: 1024px) { .login-panel-foot { display: none; } }

/* ── Sera-style contact/company cards in draft sidebar ───────────── */
.ai-draft-sidebar-wrap { display: flex; flex-direction: column; gap: var(--sp-4); }
.ai-draft-actions-card { padding: var(--sp-4); }

.sera-card {
  background: var(--paper);
  border: 1px solid var(--line-light, #ebebeb);
  border-radius: var(--r-card, 10px);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* contact row */
.sera-contact-row { display: flex; align-items: flex-start; gap: var(--sp-3); }
.sera-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: #3b82f6; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-14); font-weight: 600; flex-shrink: 0;
}
.sera-contact-info { min-width: 0; flex: 1; }
.sera-contact-name { font-weight: 600; font-size: var(--fs-14); color: var(--ink-1); }
.sera-contact-title { font-size: var(--fs-12); color: var(--ink-3); margin-top: 2px; }
.sera-contact-links { display: flex; flex-direction: column; gap: var(--sp-1); }
.sera-contact-link {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-13); color: var(--ink-2);
  text-decoration: none; word-break: break-all;
}
.sera-contact-link:hover { color: var(--ink-1); }
.sera-contact-link svg { flex-shrink: 0; color: var(--ink-3); }

/* company card */
.sera-company-row { display: flex; align-items: center; gap: var(--sp-3); }
.sera-company-name { font-weight: 600; font-size: var(--fs-14); color: var(--ink-1); }
.sera-company-name a.link-plain { color: inherit; text-decoration: none; }
.sera-company-name a.link-plain:hover { text-decoration: underline; }

.sera-company-meta { display: flex; flex-direction: column; gap: 4px; }
.sera-meta-row { display: flex; align-items: baseline; gap: var(--sp-2); font-size: var(--fs-13); }
.sera-meta-key { color: var(--ink-3); flex-shrink: 0; min-width: 70px; }
.sera-meta-val { color: var(--ink-2); }

.sera-company-desc {
  background: var(--bg-subtle, #f8f8f8);
  border: 1px solid var(--line-light, #ebebeb);
  border-radius: var(--r-sm, 6px);
  padding: var(--sp-3);
}
.sera-desc-text { font-size: var(--fs-12); color: var(--ink-2); line-height: 1.55; }

.sera-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-1); }
.chip-sm { font-size: var(--fs-11); padding: 3px 8px; }
.chip-group { background: var(--v50, #f3f0ff); color: var(--v600, #6d28d9); }

/* ── Job item (compact) ───────────────────────────────────────────── */
.jobs-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.job-item {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-light, #ebebeb);
  border-radius: var(--r-sm, 7px);
  background: var(--bg-subtle, #fafafa);
  transition: border-color .15s;
}
.job-item[data-status="running"] { border-color: var(--blue-200, #bfdbfe); background: var(--blue-50, #eff6ff); }
.job-item[data-status="done"]    { border-color: var(--green-200, #bbf7d0); background: var(--green-50, #f0fdf4); }
.job-item[data-status="error"]   { border-color: var(--red-200, #fecaca);  background: var(--red-50, #fef2f2); }

.job-item-top {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: 6px;
}
.job-item-name  { font-size: var(--fs-13); font-weight: 600; flex: 1; min-width: 0; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.job-item-count { font-size: var(--fs-12); color: var(--ink-3); white-space: nowrap; }
.job-delete-btn {
  background: none; border: none; cursor: pointer;
  font-size: var(--fs-11); color: var(--ink-3); padding: 0 2px; line-height: 1;
  transition: color .1s;
}
.job-delete-btn:hover { color: var(--ink-1); }

.job-item-bar-wrap { margin-bottom: 5px; }
.job-item-bar {
  height: 4px; background: var(--ink-1a, #e4e4e7);
  border-radius: 99px; overflow: hidden;
}
.job-item-fill {
  height: 100%; border-radius: 99px;
  background: var(--blue-500, #3b82f6);
  transition: width .5s ease;
  animation: job-pulse 1.4s ease-in-out infinite;
}
.job-item-fill.done  { background: var(--green-500, #22c55e); animation: none; }
.job-item-fill.error { background: var(--red-500, #ef4444);   animation: none; }

.job-item-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2);
}
.job-item-time    { font-size: var(--fs-11); color: var(--ink-4, #aaa); }
.job-item-link    { font-size: var(--fs-11); color: var(--accent, #555); text-decoration: none; }
.job-item-link:hover { text-decoration: underline; }
.job-item-running { font-size: var(--fs-11); color: var(--blue-500, #3b82f6); }
.job-item-err     { font-size: var(--fs-11); color: var(--red-500, #ef4444); }

/* ── UI/UX review fixes ────────────────────────────────────────────── */

/* LOW-8: roll-label chip */
.chip-role { font-size: var(--fs-11); padding: 2px 8px; }
.chip-role-admin   { background: var(--v50, #f3f0ff); color: var(--v600, #6d28d9); }
.chip-role-sales   { background: #ecfdf5; color: #065f46; }
.chip-role-viewer  { background: var(--bg-subtle, #f4f4f5); color: var(--ink-3); }

/* LOW-10: tab-dot color ring */
.tv-tab::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--tab-dot, transparent);
  flex-shrink: 0;
  margin-right: 5px;
  vertical-align: middle;
}
.tv-tab[data-group="all"]::before,
.tv-tab[data-group="none"]::before { display: none; }

/* LOW-12: h1 väiksem andmelehtedel */
.leads-page h1,
.outreach-page h1,
.ai-draft-page h1,
.container-wide h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  letter-spacing: -0.018em;
}

/* LOW-13: tv-col-addr peidetud (veerg eemaldati DOM-ist) */
.tv-col-addr { display: none; }

/* LOW-14: email body preview div (mitte pre) */
.email-body-preview {
  white-space: pre-wrap;
  font-family: var(--ff-sans), sans-serif;
  font-size: var(--fs-14);
  line-height: 1.7;
  background: var(--bg-subtle, #f8f8f8);
  border: 1px solid var(--line, #e0e0e0);
  border-radius: var(--r-card, 8px);
  padding: var(--sp-4);
  margin: 0;
}

/* stat-tile link */
.stat-tile-link {
  display: block; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.stat-tile-link:hover { border-color: var(--ink-3); box-shadow: 0 2px 8px rgba(0,0,0,.06); }

/* campaign-list-meta-grid */
.campaign-list-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 8px;
  margin: 6px 0 4px;
}
.camp-metric { display: flex; flex-direction: column; }
.camp-metric-label { font-size: var(--fs-9, 9px); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4, #aaa); }
.camp-metric b { font-size: var(--fs-14); font-weight: 700; color: var(--ink-1); }

/* confirm dialog */
.confirm-dialog {
  border: none; border-radius: var(--r-card, 10px);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 0; min-width: 320px; max-width: 420px;
}
.confirm-dialog::backdrop { background: rgba(0,0,0,.35); }
.confirm-dialog-inner { padding: var(--sp-6) var(--sp-6) var(--sp-5); }
.confirm-dialog-msg { font-size: var(--fs-15); margin: 0 0 var(--sp-5); line-height: 1.5; }
.confirm-dialog-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }

/* empty-state */
.empty-state {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
}
.empty-state-icon { font-size: 2rem; margin: 0; }
.empty-state-title { font-size: var(--fs-16); font-weight: 600; margin: 0; color: var(--ink-1); }
.empty-state-sub { font-size: var(--fs-13); color: var(--ink-3); margin: 0 0 var(--sp-3); max-width: 280px; }

/* tv-grp-empty edit hint */
.tv-grp-empty { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-4, #bbb); }
.tv-grp-empty svg { opacity: .5; }

/* mobile nav */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 300;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  align-items: center; justify-content: space-between;
}
.mobile-brand {
  font-weight: 700; font-size: var(--fs-16); text-decoration: none; color: var(--ink-1);
  display: inline-flex; align-items: center; gap: 8px;
}
.mobile-brand::before {
  content: '';
  width: 20px; height: 20px;
  background: var(--grad);
  border-radius: 5px;
  box-shadow:
    inset 0 -6px 12px rgba(255,255,255,0.18),
    0 4px 12px rgba(109,78,247,0.35);
}
.mobile-hamburger {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; padding: 4px;
}
.mobile-hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--ink-1); border-radius: 2px;
  transform-origin: center;
  transition: transform var(--t-base), opacity var(--t-fast);
}
/* Kolm kriipsu → rist, kui menüü on avatud (juhitakse aria-expanded'iga) */
.mobile-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.mobile-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.mobile-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
/* Väldi drawer'i libisemis-animatsiooni akna suuruse muutmisel / breakpoint'i
   ületamisel (muidu sidebar "hüppab" üle ekraani). JS lisab .resizing klassi. */
.resizing .sidebar { transition: none !important; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-4) 0; }
.sidebar-close { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--ink-3); }
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 149; background: rgba(0,0,0,.35); }
.sidebar-overlay.sidebar-overlay-visible { display: block; }

@media (max-width: 960px) {
  .mobile-topbar { display: flex; }
  .app-main { padding-top: 52px; }
  /* Täisekraani hamburger-drawer. z-index jääb topbar'i (300) ALLA, et ülemine
     header jääks nähtavale; sisu paditakse topbar'i alla. */
  .sidebar {
    position: fixed; inset: 0; z-index: 250;
    height: 100%; width: 100% !important;
    transform: translateX(-100%); transition: transform .25s ease;
    background: var(--paper);
    border-right: none;
    overflow-y: auto;
    padding: calc(52px + var(--sp-4)) var(--sp-5) var(--sp-8);
    gap: var(--sp-2);
  }
  .sidebar.sidebar-open { transform: translateX(0); }
  /* Topbar näitab brändi ja hamburger→X sulgeb — drawer'i oma päist pole vaja. */
  .sidebar-header { display: none; }
  /* Puuteala-sõbralikud nav-elemendid täisekraanil */
  .main-nav a, .nav-group-btn { padding: 12px var(--sp-4); font-size: var(--fs-16); }
  .nav-group-items a { padding: 10px var(--sp-4); font-size: var(--fs-15); }
}

/* ── AI Inbox messenger layout ────────────────────────────────────── */
.ai-inbox-page { max-width: none; }
.inbox-shell {
  display: grid;
  grid-template-columns: 260px 320px 1fr;
  height: 100%;
  overflow: hidden;
  border-top: 1px solid var(--line-light);
}

/* Vasak sidebar */
.inbox-sidebar {
  border-right: 1px solid var(--line-light);
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}
.inbox-sidebar-head { padding: var(--sp-4); border-bottom: 1px solid var(--line-light); flex-shrink: 0; }
.inbox-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.inbox-title { font-size: var(--fs-18); font-weight: 700; margin: 0; }
.inbox-auth-chip { display: flex; align-items: center; gap: 5px; font-size: var(--fs-11); color: var(--ink-3); }
.inbox-logout-btn { background: none; border: none; cursor: pointer; color: var(--ink-3); font-size: var(--fs-12); padding: 0 2px; }
.inbox-logout-btn:hover { color: var(--ink-1); }
.inbox-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.inbox-stat { font-size: var(--fs-11); color: var(--ink-3); }
.inbox-stat b { color: var(--ink-1); }
.inbox-stat-active b { color: var(--blue-600, #2563eb); }
.inbox-stat-reply b  { color: var(--green-600, #16a34a); }
.inbox-stat-followup b { color: var(--amber-600, #d97706); }
.inbox-gen-panel { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-light); flex-shrink: 0; overflow-y: auto; max-height: 320px; }
.inbox-jobs { padding: var(--sp-2) var(--sp-4); flex-shrink: 0; }
.inbox-notice { margin: var(--sp-2) var(--sp-4); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-12); }
.inbox-notice.good    { background: #f0fdf4; color: #065f46; border: 1px solid #bbf7d0; }
.inbox-notice.neutral { background: var(--bg-subtle); color: var(--ink-3); border: 1px solid var(--line-light); }

/* Kontaktide nimekiri */
.inbox-list {
  border-right: 1px solid var(--line-light);
  overflow-y: auto;
  background: var(--bg-subtle, #fafafa);
}
.inbox-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-11); font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-3);
  background: var(--bg-subtle);
  position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--line-light);
}
.inbox-group-count { font-weight: 400; }
.inbox-contact {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-light);
  text-decoration: none; color: inherit;
  background: var(--paper);
  transition: background .1s;
  cursor: pointer;
}
.inbox-contact:hover { background: var(--bg-subtle); }
.inbox-contact-active { background: var(--blue-50, #eff6ff) !important; border-left: 3px solid var(--blue-500, #3b82f6); }
.inbox-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #3b82f6; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-12); font-weight: 600; flex-shrink: 0;
}
.inbox-contact-info { flex: 1; min-width: 0; }
.inbox-contact-name    { font-size: var(--fs-13); font-weight: 600; color: var(--ink-1); text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.inbox-contact-company { font-size: var(--fs-11); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-contact-preview { font-size: var(--fs-11); color: var(--ink-4, #bbb); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.inbox-contact-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.inbox-contact-time { font-size: var(--fs-10); color: var(--ink-4, #bbb); }

/* Status dot */
.inbox-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-pending  .inbox-status-dot, .inbox-status-dot.status-pending  { background: var(--amber-400, #fbbf24); }
.status-sent     .inbox-status-dot, .inbox-status-dot.status-sent     { background: var(--blue-400, #60a5fa); }
.status-replied  .inbox-status-dot, .inbox-status-dot.status-replied  { background: var(--green-500, #22c55e); }
.status-followup .inbox-status-dot, .inbox-status-dot.status-followup { background: var(--orange-500, #f97316); }
.status-rejected .inbox-status-dot, .inbox-status-dot.status-rejected { background: var(--ink-4, #bbb); }
.status-error    .inbox-status-dot, .inbox-status-dot.status-error    { background: var(--red-500, #ef4444); }

/* Detail paneel */
.inbox-detail {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}
.inbox-detail-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--ink-3); gap: var(--sp-2);
}
.inbox-detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line-light);
  flex-shrink: 0;
}
.inbox-detail-who { display: flex; align-items: center; gap: var(--sp-3); }
.inbox-detail-name { font-size: var(--fs-15); font-weight: 600; }
.inbox-detail-sub  { font-size: var(--fs-12); color: var(--ink-3); }
.inbox-detail-sub a { color: inherit; }
.inbox-thread { flex: 1; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }

/* Kirjad threadis */
.inbox-msg {
  border-radius: var(--r-card, 10px);
  overflow: hidden;
  border: 1px solid var(--line-light);
}
.inbox-msg-out { border-color: var(--blue-200, #bfdbfe); background: var(--blue-50, #eff6ff); }
.inbox-msg-in  { border-color: var(--green-200, #bbf7d0); background: var(--green-50, #f0fdf4); }
.inbox-msg-header { padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid rgba(0,0,0,.06); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.inbox-msg-subject { padding: var(--sp-2) var(--sp-4) 0; font-size: var(--fs-13); font-weight: 600; color: var(--ink-1); }
.inbox-msg-body    { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-13); white-space: pre-wrap; line-height: 1.65; color: var(--ink-2); }
.inbox-msg-footer  { padding: var(--sp-2) var(--sp-4); border-top: 1px solid rgba(0,0,0,.06); display: flex; justify-content: space-between; }

/* Status badges */
.inbox-status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  font-size: var(--fs-11); font-weight: 600;
}
.inbox-status-badge.pending  { background: #fef3c7; color: #92400e; }
.inbox-status-badge.sent     { background: var(--blue-50); color: var(--blue-700, #1d4ed8); }
.inbox-status-badge.replied  { background: #f0fdf4; color: #065f46; }
.inbox-status-badge.followup { background: #fff7ed; color: #9a3412; }
.inbox-status-badge.rejected { background: var(--bg-subtle); color: var(--ink-3); }
.inbox-status-badge.error    { background: #fef2f2; color: #991b1b; }

.inbox-followup-cta { padding: var(--sp-4); background: var(--bg-subtle); border: 1px dashed var(--line); border-radius: var(--r-card); }

/* Mobile */
@media (max-width: 900px) {
  .inbox-shell { grid-template-columns: 1fr; }
  .inbox-sidebar { display: none; }
  .inbox-detail { display: none; }
  .inbox-list { display: block; }
}

/* ── Gmail-style AI inbox ─────────────────────────────────────────── */
.ai-inbox-page { max-width: none; }
.gmail-shell { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

.gmail-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--sp-5);
  border-bottom: 1px solid var(--line-light);
  flex-shrink: 0; background: var(--paper);
}
.gmail-toolbar-left  { display: flex; align-items: center; gap: var(--sp-3); }
.gmail-toolbar-right { display: flex; align-items: center; gap: var(--sp-3); }
.gmail-title { font-size: var(--fs-18); font-weight: 700; margin: 0; }

.gmail-jobs-bar {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--sp-2) var(--sp-5);
  background: var(--blue-50, #eff6ff);
  border-bottom: 1px solid var(--blue-200, #bfdbfe);
  flex-shrink: 0;
}
.gmail-job { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-12); }
.gmail-job-name { font-weight: 600; min-width: 120px; }
.gmail-job-count { color: var(--ink-3); min-width: 40px; text-align: right; }

.gmail-body {
  display: flex; flex: 1; overflow: hidden;
}

/* Vasak nimekiri */
.gmail-list {
  width: 420px; min-width: 320px; max-width: 50%;
  border-right: 1px solid var(--line-light);
  overflow-y: auto; flex-shrink: 0;
  background: var(--paper);
}

.gmail-section-header {
  width: 100%;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px var(--sp-4) 8px var(--sp-3);
  background: var(--bg-subtle, #f6f6f6);
  border: none; border-bottom: 1px solid var(--line-light);
  cursor: pointer; font-size: var(--fs-12); font-weight: 600;
  color: var(--ink-2); text-align: left;
  position: sticky; top: 0; z-index: 2;
}
.gmail-section-header:hover { background: var(--line-light); }
.gmail-chevron { transition: transform .2s; flex-shrink: 0; }
.gmail-section-name { flex: 1; }
.gmail-section-count {
  font-size: var(--fs-11); font-weight: 400; color: var(--ink-3);
  background: var(--paper); border-radius: 99px;
  padding: 1px 7px; border: 1px solid var(--line-light);
}

.gmail-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--line-light);
  cursor: pointer; transition: background .1s;
  font-size: var(--fs-13);
}
.gmail-row:hover { background: var(--bg-subtle); }
.gmail-row-active { background: var(--blue-50, #eff6ff) !important; }
.gmail-row-unread .gmail-row-name,
.gmail-row-unread .gmail-row-subject { font-weight: 700; }

.gmail-row-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot-pending  { background: var(--amber-400, #fbbf24); }
.status-dot-sent     { background: var(--blue-400, #60a5fa); }
.status-dot-replied  { background: var(--green-500, #22c55e); }
.status-dot-followup { background: var(--orange-500, #f97316); }
.status-dot-rejected { background: var(--ink-4, #ccc); }
.status-dot-error    { background: var(--red-500, #ef4444); }

.gmail-row-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #3b82f6; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-11); font-weight: 700; flex-shrink: 0;
}
.gmail-row-main { display: flex; flex-direction: column; min-width: 0; flex: 0 0 130px; }
.gmail-row-name    { font-size: var(--fs-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gmail-row-company { font-size: var(--fs-11); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gmail-row-subject { flex: 1; font-size: var(--fs-13); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gmail-row-date    { font-size: var(--fs-11); color: var(--ink-3); flex-shrink: 0; white-space: nowrap; }

/* Parem detail */
.gmail-detail {
  flex: 1; overflow-y: auto; display: flex;
  flex-direction: column; background: var(--paper);
}
.gmail-detail-empty { display: flex; align-items: center; justify-content: center; flex: 1; }
.gmail-detail-inner { display: flex; flex-direction: column; padding: var(--sp-5) var(--sp-6); gap: var(--sp-4); max-width: 720px; }

.gd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.gd-back {
  background: none; border: none; cursor: pointer; padding: 4px 6px;
  color: var(--ink-3); border-radius: var(--r-sm); display: none;
}
.gd-back:hover { background: var(--bg-subtle); color: var(--ink-1); }
.gd-subject { font-size: var(--fs-20); font-weight: 700; margin: 0; line-height: 1.3; }
.gd-head-actions { flex-shrink: 0; }

.gd-meta { display: flex; align-items: flex-start; gap: var(--sp-3); }
.gd-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: #3b82f6; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-14); font-weight: 700; flex-shrink: 0;
}
.gd-meta-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.gd-meta-name    { font-weight: 600; font-size: var(--fs-14); }
.gd-meta-title   { font-size: var(--fs-12); color: var(--ink-3); }
.gd-meta-company { font-size: var(--fs-12); color: var(--ink-2); }
.gd-meta-company a { color: inherit; text-decoration: none; }
.gd-meta-company a:hover { text-decoration: underline; }
.gd-meta-email  { font-size: var(--fs-12); color: var(--ink-3); }
.gd-meta-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

.gd-thread { display: flex; flex-direction: column; gap: var(--sp-3); }
.gd-msg { border-radius: var(--r-card, 10px); border: 1px solid var(--line-light); overflow: hidden; }
.gd-msg-out { border-color: var(--blue-200, #bfdbfe); }
.gd-msg-in  { border-color: var(--green-200, #bbf7d0); }
.gd-msg-body {
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-14); white-space: pre-wrap; line-height: 1.7;
  color: var(--ink-1);
}
.gd-msg-footer {
  display: flex; justify-content: space-between;
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--fs-11); color: var(--ink-3);
  border-top: 1px solid var(--line-light);
  background: var(--bg-subtle);
}
.gd-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding-top: var(--sp-2); }

/* Mobile */
@media (max-width: 900px) {
  .gmail-body { position: relative; }
  .gmail-list { width: 100%; max-width: 100%; border-right: none; }
  .gmail-detail { position: absolute; inset: 0; z-index: 10; display: none; }
  .gd-back { display: flex !important; }
  .gmail-detail-inner { padding: var(--sp-4); }
}

/* ── AI inbox tabel-vaade ─────────────────────────────────────────── */
.aigroup { margin-bottom: var(--sp-4); border: 1px solid var(--line-light); border-radius: var(--r-card, 10px); overflow: hidden; }

.aigroup-header {
  width: 100%; display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-4);
  background: var(--bg-subtle, #f6f6f6);
  border: none; border-bottom: 1px solid var(--line-light);
  cursor: pointer; text-align: left;
  font-size: var(--fs-13); font-weight: 600; color: var(--ink-1);
}
.aigroup-header:hover { background: #eee; }
.aigroup-chevron { transition: transform .2s; flex-shrink: 0; color: var(--ink-3); }
.aigroup-name  { flex: 1; }
.aigroup-count { font-size: var(--fs-11); font-weight: 400; color: var(--ink-3); margin-right: var(--sp-2); }
.aigroup-badge {
  font-size: var(--fs-10); font-weight: 600; padding: 2px 7px;
  border-radius: 99px; white-space: nowrap;
}
.aigroup-badge.pending  { background: #fef3c7; color: #92400e; }
.aigroup-badge.followup { background: #fff7ed; color: #9a3412; }
.aigroup-badge.replied  { background: #f0fdf4; color: #065f46; }

.ai-table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.ai-table thead th {
  padding: 8px var(--sp-3);
  font-size: var(--fs-11); font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-3);
  border-bottom: 1px solid var(--line-light);
  text-align: left; background: var(--paper);
}
.ai-th-check { width: 36px; }
.ai-row { transition: background .1s; }
.ai-row:hover { background: var(--bg-subtle); }
.ai-row-unread .ai-contact-name,
.ai-row-unread .ai-td-subject { font-weight: 700; }
.ai-row td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--line-light); vertical-align: middle; }
.ai-row:last-child td { border-bottom: none; }
.ai-td-check   { width: 36px; }
.ai-td-contact { min-width: 200px; }
.ai-td-subject { color: var(--ink-2); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-td-status  { white-space: nowrap; }
.ai-td-date    { white-space: nowrap; }
.ai-td-action  { white-space: nowrap; text-align: right; }

.ai-contact-row { display: flex; align-items: center; gap: var(--sp-2); }
.ai-avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  background: #3b82f6; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-10); font-weight: 700;
}
.ai-contact-name { font-size: var(--fs-13); font-weight: 500; }
.ai-contact-co   { font-size: var(--fs-11); color: var(--ink-3); }

.bulk-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--blue-50, #eff6ff);
  border: 1px solid var(--blue-200, #bfdbfe);
  border-radius: var(--r-card, 8px);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-13); font-weight: 600;
}
.bulk-bar[hidden] { display: none; }

/* ── Tabelivaade (tv-*) — globaalne, kasutatav kõigil lehtedel ───── */
.table-view-section { margin-top: 0; }

.tv-tabs-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--sp-2); margin-bottom: var(--sp-3);
}
.tv-tabs-row .tv-search-input,
.tv-tab { height: 34px; line-height: 1; font-size: var(--fs-14); font-weight: 500; box-sizing: border-box; }
.tv-tabs-row .tv-search-input {
  width: 140px; flex-shrink: 0; margin-bottom: 0;
  padding: 0 12px 0 30px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center / 13px 13px;
  border-radius: 999px; -webkit-appearance: none; appearance: none;
}
.tv-group-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); flex: 1; }
.tv-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper-tint); cursor: pointer;
}
.tv-tab:not(.tv-tab-active):hover { background: var(--v50); border-color: var(--v300); }
.tv-tab-active { background: var(--v600); color: #fff; border-color: var(--v600); }
.tv-tab-active:hover { background: var(--v700); border-color: var(--v700); }
.tv-all-icon { flex-shrink: 0; }

.tv-tab[data-group]:not([data-group="all"])::before,
.tv-tab[data-aigroup]:not([data-aigroup="all"])::before {
  content: ''; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--tab-dot, var(--ink-3)); flex-shrink: 0;
}
.tv-tab-active[data-group]:not([data-group="all"])::before,
.tv-tab-active[data-aigroup]:not([data-aigroup="all"])::before { background: rgba(255,255,255,0.85); }

.tv-bulk-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--v50); border-radius: var(--r-md);
  padding: 8px 14px 8px 10px; margin-bottom: var(--sp-3); width: 100%;
}
.tv-bulk-clear-btn {
  background: none; border: none; color: var(--ink-2); border-radius: 50%;
  width: 34px; height: 34px; font-size: 14px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; padding: 0; box-sizing: border-box;
}
.tv-bulk-clear-btn:hover { background: var(--v100); }
.tv-bulk-count { font-size: var(--fs-15); font-weight: 600; color: var(--ink-1); white-space: nowrap; flex-shrink: 0; margin-right: var(--sp-1); }
.tv-bulk-sep { width: 1px; height: 22px; background: var(--v200); flex-shrink: 0; margin: 0 var(--sp-2); }
.tv-bulk-bar .button { height: 34px; box-sizing: border-box; padding-top: 0; padding-bottom: 0; font-size: var(--fs-14); }

.tv-section-box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.tv-section-box > .tv-tabs-row { padding: var(--sp-3) var(--sp-3) 0; margin-bottom: var(--sp-3); }
.tv-section-box > .tv-bulk-bar { width: auto; margin: 0 var(--sp-3) var(--sp-2); }
.tv-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.tv-table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); background: var(--paper); }
.tv-table thead { background: var(--paper-tint); border-bottom: 1px solid var(--line); }
.tv-table th { padding: 10px 12px; text-align: left; font-weight: 600; font-size: var(--fs-12); text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); white-space: nowrap; }
.tv-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tv-table tr:last-child td { border-bottom: none; }
.tv-table tr:hover td { background: var(--v50); }

.tv-col-check  { width: 36px; }
.tv-col-name   { min-width: 180px; }
.tv-col-contact{ min-width: 160px; }
.tv-col-status { width: 130px; white-space: nowrap; }
.tv-col-group  { width: 150px; }
.tv-col-action { width: 80px; text-align: center; }
.tv-name-link  { font-weight: 600; color: var(--ink-1); text-decoration: none; }
.tv-name-link:hover { color: var(--v600); text-decoration: underline; }
.tv-addr-sub   { display: block; margin-top: 2px; }
.tv-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }
.tv-dot-new       { background: var(--v400, #6366f1); }
.tv-dot-contacted { background: #3b82f6; }
.tv-dot-replied   { background: #10b981; }
.tv-open-btn { white-space: nowrap; }
.tv-search-input {
  width: 100%; padding: 6px 14px 6px 34px; font-size: var(--fs-13); color: var(--ink-1);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 11px center;
  background-size: 13px 13px; border: 1px solid var(--line); border-radius: var(--r-pill); outline: none;
}
.tv-search-input:focus { border-color: var(--v400); box-shadow: 0 0 0 2px color-mix(in srgb, var(--v400) 20%, transparent); }
.tv-search-input::placeholder { color: var(--ink-3); }
.tv-pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); padding: var(--sp-3); border-top: 1px solid var(--line); }
.ai-row-unread .tv-name-link { font-weight: 700; }

/* ── Claude dropdown menu ─────────────────────────────────────────── */
.claude-menu-wrap { position: relative; }
.claude-menu-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill, 999px);
  border: 1px solid var(--line); background: var(--paper);
  font-size: var(--fs-13); font-weight: 500; color: var(--ink-1);
  cursor: pointer; white-space: nowrap;
  transition: border-color .12s, background .12s;
}
.claude-menu-btn:hover { border-color: var(--ink-3); background: var(--bg-subtle); }
.claude-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 200;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-card, 10px);
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  min-width: 200px; overflow: hidden;
}
.claude-menu-dropdown[hidden] { display: none; }
.claude-menu-info {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px 14px; font-size: var(--fs-13); color: var(--ink-2);
}
.claude-menu-sep { height: 1px; background: var(--line-light); }
.claude-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 14px; font-size: var(--fs-13); color: var(--ink-1);
  background: none; border: none; cursor: pointer;
}
.claude-menu-item:hover { background: var(--bg-subtle); color: var(--ink-1); }

/* ── AI inline job progress ───────────────────────────────────────── */
.ai-jobs-inline { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.ai-job-inline {
  display: flex; align-items: center; gap: var(--sp-3);
  background: transparent;
  padding: 4px 0;
  max-width: 480px;
}
.ai-job-spin {
  flex-shrink: 0; color: var(--blue-500, #3b82f6);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-job-name  { font-size: var(--fs-13); font-weight: 500; min-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-job-bar-wrap { flex: 1; }
.ai-job-bar-track {
  height: 4px; background: var(--line-light, #e8e8e8);
  border-radius: 99px; overflow: hidden;
}
.ai-job-bar-fill {
  height: 100%; background: var(--blue-500, #3b82f6);
  border-radius: 99px; transition: width .4s ease;
}
.ai-job-count { font-size: var(--fs-12); color: var(--ink-3); white-space: nowrap; min-width: 36px; text-align: right; }

/* ── AI row menu (kolm punkti) ────────────────────────────────────── */
.ai-row-menu-wrap { position: relative; display: inline-block; }
.ai-row-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 4px 6px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .1s, color .1s;
}
.ai-row-menu-btn:hover { background: var(--bg-subtle); color: var(--ink-1); }
.ai-row-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 100;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-card, 8px);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 180px; overflow: hidden;
  padding-bottom: 4px;
}
.ai-row-menu-dropdown[hidden] { display: none; }
.ai-row-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 14px; font-size: var(--fs-13);
  background: none; border: none; cursor: pointer; color: var(--ink-1);
  white-space: nowrap;
}
.ai-row-menu-item:hover { background: var(--bg-subtle); }
.ai-row-menu-item-danger { color: var(--red-600, #dc2626); }
.ai-row-menu-item-danger:hover { background: #fef2f2; }

/* Klikkable rida - highlight ilma sinise lingita */
.ai-email-row:hover .tv-name-link { color: var(--v600); text-decoration: underline; }

/* ── AI kirjavahetus ajatelg ──────────────────────────────────────── */
.ai-thread-col { display: flex; flex-direction: column; gap: var(--sp-4); }
.ai-thread-item { display: flex; flex-direction: column; gap: var(--sp-2); }
.ai-thread-meta { display: flex; align-items: center; gap: var(--sp-2); }
.ai-thread-time { font-size: var(--fs-11); }

.ai-thread-bubble {
  border-radius: var(--r-card, 10px);
  border: 1px solid var(--line-light);
  overflow: hidden;
}
.ai-thread-bubble.out { border-color: var(--blue-200, #bfdbfe); background: var(--blue-50, #eff6ff); }
.ai-thread-bubble.in  { border-color: var(--green-200, #bbf7d0); background: var(--green-50, #f0fdf4); }
.ai-thread-subject { padding: var(--sp-3) var(--sp-4) var(--sp-1); font-weight: 600; font-size: var(--fs-14); }
.ai-thread-body { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-14); white-space: pre-wrap; line-height: 1.7; color: var(--ink-1); }
.ai-thread-footer { padding: var(--sp-2) var(--sp-4); font-size: var(--fs-11); color: var(--ink-3); border-top: 1px solid var(--line-light); background: var(--bg-subtle); }

.ai-thread-form { background: var(--paper); border: 1px solid var(--line-light); border-radius: var(--r-card, 10px); padding: var(--sp-4); }

.ai-thread-followup {
  display: flex; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-subtle); border: 1px dashed var(--line);
  border-radius: var(--r-card); margin-top: var(--sp-2);
}

/* ── Draft inline actions ─────────────────────────────────────────── */
.ai-draft-inline-actions {
  display: flex; gap: var(--sp-2); margin-top: var(--sp-1);
}

/* ── Thread individual controls ───────────────────────────────────── */
.ai-thread-delete-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-4, #ccc); padding: 2px 4px; border-radius: var(--r-sm);
  transition: color .1s, background .1s;
}
.ai-thread-delete-btn:hover { color: var(--red-500, #ef4444); background: #fef2f2; }
.ai-thread-bubble-dim { opacity: .55; }
.ai-thread-meta { display: flex; align-items: center; gap: var(--sp-2); }

/* ── AI draft card ────────────────────────────────────────────────── */
.ai-draft-card {
  background: var(--paper);
  border: 1px solid var(--line-light, #e8e8e8);
  border-radius: var(--r-card, 10px);
  overflow: hidden;
}
.ai-draft-card-dim { opacity: .55; }

.ai-draft-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--line-light);
  background: var(--bg-subtle, #fafafa);
}
.ai-draft-subject {
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  font-weight: 600; font-size: var(--fs-14); color: var(--ink-1);
}
.ai-draft-body {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-14); white-space: pre-wrap; line-height: 1.7; color: var(--ink-1);
}
.ai-draft-footer {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-11); color: var(--ink-3);
  border-top: 1px solid var(--line-light);
  background: var(--bg-subtle);
}
.ai-draft-card-actions {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line-light);
  background: var(--bg-subtle);
}

/* ── AI floating chat widget ──────────────────────────────────────── */
.ai-fab-wrap {
  position: fixed; bottom: 28px; right: 28px; z-index: 500;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}

.ai-fab {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--ink-1, #18181b); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.22);
  transition: transform .15s, box-shadow .15s;
}
.ai-fab:hover { transform: scale(1.06); box-shadow: 0 4px 18px rgba(0,0,0,.3); }

/* Panel */
.ai-chat-panel {
  width: 380px; max-width: calc(100vw - 2rem);
  background: var(--paper);
  border: 1px solid var(--line-light, #ebebeb);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  display: flex; flex-direction: column; overflow: hidden;
  max-height: 520px;
}
.ai-chat-panel[hidden] { display: none; }

/* Header */
.ai-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-light, #ebebeb);
  background: var(--paper);
}
.ai-chat-head-left  { display: flex; align-items: center; gap: 10px; }
.ai-chat-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--ink-1, #18181b); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ai-chat-head-title { font-size: var(--fs-14); font-weight: 600; color: var(--ink-1); line-height: 1.2; }
.ai-chat-head-sub   { font-size: var(--fs-11); color: var(--ink-3); margin-top: 1px; }
.ai-chat-close {
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 4px; border-radius: 6px;
  display: flex; align-items: center;
  transition: background .1s, color .1s;
}
.ai-chat-close:hover { background: var(--bg-subtle); color: var(--ink-1); }

/* Messages */
.ai-chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--paper);
}
.ai-chat-msg { display: flex; }
.ai-chat-msg-user { justify-content: flex-end; }
.ai-chat-msg-bot  { justify-content: flex-start; }

.ai-chat-bubble-user {
  background: var(--ink-1, #18181b); color: #fff;
  padding: 10px 14px; border-radius: 14px 14px 3px 14px;
  font-size: var(--fs-13); line-height: 1.55;
  max-width: 82%; white-space: pre-wrap;
}
.ai-chat-bubble-bot {
  background: var(--paper); color: var(--ink-1);
  border: 1px solid var(--line-light, #ebebeb);
  padding: 10px 14px; border-radius: 14px 14px 14px 3px;
  font-size: var(--fs-13); line-height: 1.55;
  max-width: 88%; white-space: pre-wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* Suggestion chips — inside messages */
.ai-chat-chips-row {
  display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px;
}
.ai-chat-chip {
  font-size: var(--fs-11); padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--line, #e4e4e7);
  background: var(--paper); color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
  transition: border-color .1s, background .1s;
}
.ai-chat-chip:hover { border-color: var(--ink-3); background: var(--bg-subtle); }

/* Loader */
.ai-chat-loader {
  display: flex; gap: 4px; align-items: center;
  padding: 8px 14px;
  background: var(--paper); border: 1px solid var(--line-light);
  border-radius: 14px 14px 14px 3px;
}
.ai-chat-loader span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  animation: chat-bounce .9s ease-in-out infinite;
}
.ai-chat-loader span:nth-child(2) { animation-delay: .2s; }
.ai-chat-loader span:nth-child(3) { animation-delay: .4s; }
@keyframes chat-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-5px)} }

/* Input area */
.ai-chat-form {
  padding: 8px 12px 10px;
}
.ai-chat-input-wrap {
  display: flex; align-items: center;
  border: 1px solid var(--line, #e4e4e7);
  border-radius: 999px;
  background: var(--paper);
  padding: 6px 6px 6px 14px;
  transition: border-color .15s;
}
.ai-chat-input-wrap:focus-within { border-color: var(--ink-3); }
.ai-chat-input {
  flex: 1; resize: none; overflow: hidden;
  font-size: var(--fs-13); line-height: 1.5;
  border: none; outline: none; box-shadow: none;
  background: transparent;
  font-family: var(--ff-sans), sans-serif;
  font-weight: 400;
  padding: 2px 6px 2px 0;
  min-height: 22px; max-height: 100px;
  display: block;
}
.ai-chat-input:focus { outline: none; box-shadow: none; }
.ai-chat-input::placeholder { color: var(--ink-4, #bbb); }
.ai-chat-send {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: none; color: var(--ink-3);
  border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color .12s;
}
.ai-chat-send:hover { color: var(--ink-1); }
.ai-chat-send:disabled { opacity: .3; cursor: not-allowed; }

/* ── AI chat apply change block ───────────────────────────────────── */
.ai-chat-apply-wrap {
  margin-top: 8px; padding: 10px 12px;
  background: var(--blue-50, #eff6ff);
  border: 1px solid var(--blue-200, #bfdbfe);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 88%;
}
.ai-chat-apply-preview { font-size: var(--fs-12); color: var(--ink-2); }
.ai-chat-apply-label { margin-bottom: 2px; }
.ai-chat-apply-body {
  color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-chat-apply-wrap .button,
.ai-chat-apply-wrap .button.secondary {
  width: fit-content; font-size: var(--fs-12);
}
.ai-chat-clear-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 3px; border-radius: 5px;
  display: flex; align-items: center;
  transition: color .1s, background .1s;
}
.ai-chat-clear-btn:hover { color: var(--ink-1); background: var(--bg-subtle); }

/* ── AI thread tracking event ─────────────────────────────────────── */
.ai-thread-event {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 4px 0;
  font-size: var(--fs-12);
}
.ai-thread-event-icon { font-size: var(--fs-13); }
.ai-thread-event-label { color: var(--ink-2); font-weight: 500; }
.ai-thread-event-time  { color: var(--ink-4, #bbb); }
.ai-thread-event-link  { color: var(--ink-3); text-decoration: none; }
.ai-thread-event-link:hover { text-decoration: underline; }

/* ── Follow-up banner ─────────────────────────────────────────────── */
.followup-banner {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 16px; margin-bottom: var(--sp-4);
  background: #fff7ed; border: 1px solid #fed7aa;
  border-radius: var(--r-card, 8px);
  font-size: var(--fs-13); color: #9a3412;
}
.followup-banner svg { flex-shrink: 0; color: #f97316; }
.followup-banner-link { margin-left: auto; font-weight: 600; color: #ea580c; text-decoration: none; white-space: nowrap; }
.followup-banner-link:hover { text-decoration: underline; }
.stat-tile-followup { border-color: #fed7aa !important; }
.stat-tile-followup b { color: #f97316; }

/* ── Autopilot toggle ─────────────────────────────────────────────── */
.autopilot-section { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line-light); }
.autopilot-form { display: flex; flex-direction: column; gap: var(--sp-2); }
.autopilot-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); cursor: default; }
.autopilot-label { display: flex; flex-direction: column; gap: 1px; }
.autopilot-label b { font-size: var(--fs-13); }

.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 22px;
  background: var(--ink-4, #ccc); cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; left: 3px; top: 3px;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--v600, #4f46e5); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Follow-up picker ─────────────────────────────────────────────── */
.followup-picker { border: 1px solid var(--line-light); border-radius: var(--r-card,8px); overflow:hidden; max-height:300px; overflow-y:auto; }
.fp-group { }
.fp-group-head { display:flex; align-items:center; justify-content:space-between; gap:var(--sp-2); padding:8px 12px; background:var(--bg-subtle); border-bottom:1px solid var(--line-light); font-size:var(--fs-13); position:sticky;top:0;z-index:1; }
.fp-group-check-label { display:flex;align-items:center;gap:var(--sp-2);cursor:pointer; }
.fp-contact { display:flex;align-items:center;gap:var(--sp-3); padding:8px 12px; border-bottom:1px solid var(--line-light); cursor:pointer; font-size:var(--fs-13); transition:background .1s; }
.fp-contact:last-child { border-bottom:none; }
.fp-contact:hover { background:var(--bg-subtle); }
.fp-contact-due { background:rgba(251,191,36,.06); }
.fp-contact-info { flex:1;min-width:0; }
.fp-contact-name { display:block; font-weight:500; white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.fp-contact-co   { display:block; }
.fp-contact-days { flex-shrink:0; }
.fp-due { color:var(--orange-600,#ea580c); font-weight:600; }

/* Autopilot row */
.autopilot-toggle-row { display:flex;align-items:flex-start;justify-content:space-between;gap:var(--sp-3); }
.autopilot-label { display:flex;flex-direction:column;gap:2px; }
.autopilot-label b { font-size:var(--fs-13); }
.autopilot-label .ap-sub { font-size:var(--fs-12);color:var(--ink-3); }

/* ── Autopilot row layout ─────────────────────────────────────────── */
.autopilot-section { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line-light); }
.ap-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
}
.ap-title { font-size: var(--fs-13); font-weight: 600; color: var(--ink-1); }
.ap-sub   { font-size: var(--fs-12); color: var(--ink-3); }
.ap-days-input {
  width: 40px !important; max-width: 40px !important; min-width: 40px !important;
  height: 22px; font-size: var(--fs-13); text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 0 !important; outline: none; flex-shrink: 0; box-sizing: border-box;
  -webkit-appearance: none; -moz-appearance: textfield; appearance: textfield;
}
.ap-days-input::-webkit-outer-spin-button,
.ap-days-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ap-days-input:focus { border-color: var(--ink-3); }
.toggle-switch { width: 40px; height: 22px; flex-shrink: 0; }

/* ── Chat apply preview full body ─────────────────────────────────── */
.ai-chat-apply-subject { font-size: var(--fs-12); margin-bottom: var(--sp-2); }
.ai-chat-apply-body-full {
  font-size: var(--fs-12); white-space: pre-wrap; color: var(--ink-2);
  max-height: 200px; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line-light);
  border-radius: 6px; padding: var(--sp-2) var(--sp-3);
  line-height: 1.55;
}
.ai-chat-apply-btns { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }

/* ── Chat expand ──────────────────────────────────────────────────── */
.ai-chat-expand-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 4px; border-radius: 6px;
  display: flex; align-items: center;
  transition: color .1s, background .1s;
}
.ai-chat-expand-btn:hover { color: var(--ink-1); background: var(--bg-subtle); }

.ai-chat-panel-expanded {
  position: fixed !important;
  bottom: 80px !important;
  right: 28px !important;
  width: min(720px, calc(100vw - 56px)) !important;
  max-height: calc(100vh - 200px) !important;
  z-index: 600;
  box-shadow: 0 16px 64px rgba(0,0,0,.2) !important;
}
.ai-chat-panel-expanded .ai-chat-messages {
  max-height: calc(100vh - 360px);
}

/* Apply wrap inside bubble */
.ai-chat-bubble-bot .ai-chat-apply-wrap {
  margin-top: var(--sp-3);
  border-top: 1px solid var(--line-light);
  padding-top: var(--sp-3);
  background: none;
  border-left: none; border-right: none; border-bottom: none;
  border-radius: 0;
  padding-left: 0; padding-right: 0;
}

/* ── Thread compose form ──────────────────────────────────────────── */
.ai-thread-compose-wrap { margin-top: var(--sp-2); }
.ai-thread-compose-form {
  margin-top: var(--sp-3);
  background: var(--paper); border: 1px solid var(--line-light);
  border-radius: var(--r-card, 10px); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
}

/* ── AI tracking issue banner ─────────────────────────────────────── */
.tracking-issue {
  border-radius: var(--r-card, 8px); padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3); border: 1px solid;
}
.tracking-issue-error   { background: #fef2f2; border-color: #fecaca; }
.tracking-issue-warning { background: #fffbeb; border-color: #fde68a; }
.tracking-issue-info    { background: #eff6ff; border-color: #bfdbfe; }
.tracking-issue-head {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-13); margin-bottom: 4px;
}
.tracking-issue-fix { margin-left: auto; font-size: var(--fs-12); font-weight: 600; text-decoration: none; }
.tracking-issue-fix:hover { text-decoration: underline; }
.tracking-issue-detail { margin: 0 0 var(--sp-1); }
.tracking-issue-steps  { margin: var(--sp-1) 0 0 var(--sp-4); padding: 0; }
.tracking-issue-steps li { margin-bottom: 2px; }

/* ── Research DDG results ─────────────────────────────────────────── */
.research-ddg-section {
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--line-light);
  display: flex; flex-direction: column; gap: 6px;
}
.research-ddg-header {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--fs-11); font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-3); margin-bottom: 2px;
}
.research-ddg-item {
  padding: 5px 0;
  border-bottom: 1px solid var(--line-light);
}
.research-ddg-item:last-of-type { border-bottom: none; }
.research-ddg-title   { font-size: var(--fs-12); font-weight: 500; color: var(--ink-2); line-height: 1.4; }
.research-ddg-snippet { font-size: var(--fs-11); color: var(--ink-3); line-height: 1.45; margin-top: 2px; }

/* ── Prospeo contact picker ───────────────────────────────────────── */
.prospeo-contact-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.prospeo-contact-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-light); border-radius: var(--r-sm, 7px);
  background: var(--paper);
}
.prospeo-contact-info { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.prospeo-contact-name { font-size: var(--fs-13); font-weight: 500; }

/* ── Intelligence search results ──────────────────────────────────── */
.intel-result {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line-light); border-radius: var(--r-card,8px);
  margin-bottom: var(--sp-3); background: var(--paper);
}
.intel-result-head {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-1); flex-wrap: wrap;
}
.intel-relevance {
  margin-left: auto; font-size: var(--fs-11); color: var(--green-600,#16a34a);
  font-weight: 600;
}
.intel-result-text { font-size: var(--fs-13); color: var(--ink-2); margin: 4px 0; line-height: 1.5; }

/* ── tv-bulk-icon-btn (global) ────────────────────────────────────── */
.tv-bulk-icon-btn {
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  cursor: pointer;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .12s, color .12s;
}
.tv-bulk-icon-btn:hover {
  background: rgba(220, 38, 38, 0.08);
  color: var(--red-600, #dc2626);
}
