/* ============================================================
   Leadi: design tokens
   Warm paper, near-black ink, one oxblood accent, tight 4px corners.
   ============================================================ */
:root {
  --paper: #F2EEE6;
  --paper-2: #E9E3D8;
  --surface: #FBF9F5;
  --ink: #1C1916;
  --ink-2: #3B352F;
  --muted: #847C71;
  --line: #E1D9CC;
  --line-strong: #C8BEAE;

  --accent: #8C1D24;
  --accent-hover: #73171D;
  --accent-soft: #F2E1DE;
  --accent-bright: #E0565F;   /* accent on dark backgrounds */

  --ok: #2B6648;
  --ok-soft: #DDEBE2;
  --warn: #85570C;
  --warn-soft: #F3E7CF;

  --side-bg: #1C1916;
  --side-ink: #EDE7DC;
  --side-muted: #9C9387;

  --radius: 4px;
  --font-display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --side-w: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-display); font-optical-sizing: auto; margin: 0; }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.boot {
  min-height: 100vh; display: grid; place-items: center;
  font: 600 13px var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}

/* ============================================================
   Shell
   ============================================================ */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.side {
  background: var(--side-bg); color: var(--side-ink);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 26px 0 20px;
}
.brand {
  display: inline-flex; align-items: flex-end; gap: 3px;
  font: 800 27px/1 var(--font-display); letter-spacing: -0.03em;
  text-decoration: none; padding: 0 24px 26px;
}
.brand-dot { width: 7px; height: 7px; background: var(--accent-bright); border-radius: 1px; margin-bottom: 4px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 24px; color: var(--side-muted); text-decoration: none;
  font-weight: 500; font-size: 14.5px;
  border-left: 3px solid transparent;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--side-ink); background: rgba(255,255,255,.03); }
.nav a.active { color: #fff; background: rgba(255,255,255,.06); border-left-color: var(--accent-bright); }
.nav-count { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--side-muted); }
.nav-label {
  margin: 22px 24px 6px; font-size: 10.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: #6E665C;
}
.side-foot { margin-top: auto; padding: 18px 24px 0; border-top: 1px solid rgba(255,255,255,.08); }
.me-name { font-weight: 600; font-size: 14px; }
.me-role { font-size: 12px; color: var(--side-muted); margin-bottom: 10px; }
.link {
  display: block; background: none; border: 0; padding: 3px 0; cursor: pointer;
  color: var(--side-muted); font-size: 13px; text-align: left;
}
.link:hover { color: var(--side-ink); text-decoration: underline; text-underline-offset: 3px; }

.main { padding: 40px 48px 64px; min-width: 0; }
.view { max-width: 1240px; }

/* ============================================================
   Page header, toolbar, sections
   ============================================================ */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 26px; flex-wrap: wrap;
}
.page-head h1 { font-size: 38px; line-height: 1.02; font-weight: 700; letter-spacing: -0.03em; }
.page-head .meta { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; max-width: 62ch; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { max-width: 380px; }
.toolbar select { width: auto; min-width: 180px; }
.toolbar-under { margin-top: 14px; }

.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 14px; }
.section-title .muted { font-family: var(--font-body); font-size: 14px; font-weight: 500; letter-spacing: 0; }
.sub-title { font: 700 15px var(--font-display); margin: 22px 0 10px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* ============================================================
   Controls
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid transparent; font: 600 14px/1 var(--font-body);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: #000; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn-line { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-line:hover:not(:disabled) { border-color: var(--ink); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }

.input, textarea, select {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 14px/1.4 var(--font-body);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%231C1916' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(140, 29, 36, .14);
}
.input::placeholder, textarea::placeholder { color: #A39A8E; }
textarea:disabled, .input:disabled { opacity: .6; }

.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input-row { display: flex; gap: 8px; }
.stack { display: grid; gap: 14px; }
.form-error { color: var(--accent); font-size: 13.5px; margin: 0; min-height: 1em; }

.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.check input:disabled + span { opacity: .5; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 0 14px; height: 34px;
  font: 600 13px var(--font-body); color: var(--ink-2); cursor: pointer;
  border-left: 1px solid var(--line-strong);
}
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--ink); color: var(--paper); }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line-strong); overflow-x: auto; }
.tab {
  background: none; border: 0; padding: 10px 0 12px; cursor: pointer; white-space: nowrap;
  font: 600 14px var(--font-body); color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink-2); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab .c { margin-left: 5px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; border-top: 2px solid var(--ink); }
.table-wrap.flush { border-top: 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  padding: 11px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t th:first-child, .t td:first-child { padding-left: 0; }
.t th:last-child, .t td:last-child { padding-right: 0; }
.t tbody tr { cursor: pointer; transition: background .12s, opacity .3s, transform .3s; }
.t tbody tr:hover { background: var(--surface); }
.t tbody tr.static { cursor: default; }
.t tr.gone { opacity: 0; transform: translateX(14px); }
.t .c-email { font-weight: 600; word-break: break-all; min-width: 200px; }
.t .c-act { text-align: right; width: 1%; white-space: nowrap; }
.t .c-date { white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.t .c-snip { color: var(--ink-2); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.xk { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 8px 5px 7px; border-radius: 2px; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-pool { background: var(--paper-2); color: var(--ink-2); }
.pill-claimed { background: var(--warn-soft); color: var(--warn); }
.pill-sent { background: #E3DED4; color: var(--ink); }
.pill-replied { background: var(--ok-soft); color: var(--ok); }
.pill-dnc { background: var(--accent-soft); color: var(--accent); }
.pill-bad { background: var(--accent-soft); color: var(--accent); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; font-size: 13.5px; flex-wrap: wrap; }
.pager-btns { display: flex; gap: 8px; }

.empty { padding: 52px 0 56px; border-bottom: 1px solid var(--line); }
.empty h3 { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 6px; }
.empty p { margin: 0; color: var(--muted); max-width: 52ch; }

.skel { display: inline-block; height: 1em; width: 4ch; background: var(--paper-2); border-radius: 2px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ============================================================
   KPI strip
   ============================================================ */
.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line-strong);
  margin: 0 0 32px;
}
.kpis.k5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { padding: 16px 20px 18px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi-value {
  font: 700 44px/1 var(--font-display); letter-spacing: -0.035em;
  margin-top: 12px; font-variant-numeric: tabular-nums;
}
.kpi-value.accent { color: var(--accent); }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* ============================================================
   Drawer (lead details)
   ============================================================ */
#drawer-root { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
#drawer-root.open { pointer-events: auto; }
.scrim { position: absolute; inset: 0; background: rgba(28, 25, 22, .34); animation: fade .18s ease-out; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(500px, 100%);
  background: var(--paper); border-left: 1px solid var(--line-strong);
  overflow-y: auto; padding: 26px 30px 40px;
  animation: slide .24s cubic-bezier(.2, .8, .2, 1);
  box-shadow: -24px 0 48px rgba(28, 25, 22, .12);
}
@keyframes slide { from { transform: translateX(28px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.drawer-head { position: relative; padding-right: 40px; margin-bottom: 18px; }
.drawer-eyebrow { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; flex-wrap: wrap; }
.drawer-title { font-size: 26px; line-height: 1.12; font-weight: 700; letter-spacing: -0.025em; word-break: break-all; }
.drawer-sub { color: var(--ink-2); margin-top: 6px; }
.icon-btn {
  position: absolute; top: -4px; right: -6px; width: 36px; height: 36px;
  background: none; border: 0; cursor: pointer; border-radius: var(--radius);
  font-size: 26px; line-height: 1; color: var(--muted);
}
.icon-btn:hover { color: var(--ink); background: var(--paper-2); }
.drawer-tools { display: flex; gap: 8px; margin: 0 0 20px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: 0; margin: 0 0 22px; font-size: 13.5px; border-top: 1px solid var(--line); }
.kv dt, .kv dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); padding-right: 12px; word-break: break-word; }
.kv dd { word-break: break-word; }
.kv a { color: var(--accent); }

.step { display: grid; grid-template-columns: 38px 1fr; gap: 0 10px; padding: 20px 0; border-top: 1px solid var(--line-strong); }
.step-num { font: 700 19px/1.3 var(--font-display); color: var(--accent); font-variant-numeric: tabular-nums; }
.step h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 12px; }
.step .check { margin-bottom: 12px; }
.step-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 12.5px; }
.step.locked .step-body > *:not(.hint):not(h3) { opacity: .5; }

.timeline { display: grid; gap: 0; margin: 0 0 22px; border-top: 1px solid var(--line); font-size: 13.5px; }
.timeline div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline span { color: var(--muted); }
.timeline b { font-weight: 600; text-align: right; }
.block { margin: 0 0 20px; }
.block h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.quote {
  white-space: pre-wrap; word-break: break-word; font-size: 14px;
  background: var(--surface); border-left: 3px solid var(--line-strong);
  padding: 12px 14px; border-radius: 0 var(--radius) var(--radius) 0;
}
.quote.ok { border-left-color: var(--ok); }
.quote.empty-q { color: var(--muted); font-style: italic; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line-strong); flex-wrap: wrap; }

/* ============================================================
   Toasts
   ============================================================ */
#toast-root { position: fixed; left: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--ink); color: var(--paper); padding: 12px 16px;
  border-radius: var(--radius); font-size: 14px; max-width: 380px;
  border-left: 3px solid var(--side-muted); box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
  animation: rise .2s ease-out;
}
.toast.good { border-left-color: #5FB389; }
.toast.bad { border-left-color: var(--accent-bright); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ============================================================
   Login
   ============================================================ */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
.login-art {
  background: var(--side-bg); color: var(--side-ink);
  padding: 44px 52px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.login-art .brand { padding: 0; font-size: 34px; }
.login-quote { font: 700 clamp(40px, 5.4vw, 76px)/0.98 var(--font-display); letter-spacing: -0.04em; max-width: 11ch; margin: 0; }
.login-quote em { font-style: normal; color: var(--accent-bright); }
.login-foot { font-size: 13px; color: var(--side-muted); }
.login-form { align-self: center; justify-self: center; width: min(360px, calc(100% - 32px)); display: grid; gap: 16px; padding: 40px 0; }
.login-form h1 { font-size: 30px; letter-spacing: -0.025em; margin-bottom: 4px; }

.notice { max-width: 460px; margin: 18vh auto 0; padding: 0 16px; }
.notice h1 { font-size: 32px; letter-spacing: -0.025em; margin-bottom: 10px; }
.notice p { color: var(--ink-2); }

/* ============================================================
   Import
   ============================================================ */
.drop {
  display: grid; gap: 6px; place-items: center; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  padding: 44px 20px; cursor: pointer; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #FFFDF9; }
.drop-title { font: 700 19px var(--font-display); letter-spacing: -0.01em; }
.drop-sub { font-size: 13px; color: var(--muted); }
.import-opts { display: flex; gap: 16px; margin: 14px 0 28px; flex-wrap: wrap; }
.import-opts .field { min-width: 260px; }
.map-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.import-foot { display: flex; align-items: center; gap: 18px; margin-top: 22px; flex-wrap: wrap; }
.progress { flex: 1; min-width: 160px; max-width: 360px; height: 6px; background: var(--paper-2); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.result { margin-top: 26px; }

/* ============================================================
   Analytics + team
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 40px; margin-bottom: 36px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--ink); stroke-width: 1.5; }
.chart .bar-sent { fill: #CFC5B5; }
.chart .bar-replied { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(28, 25, 22, .05); }
.chart text { font: 11px var(--font-body); fill: var(--muted); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin: -4px 0 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 1px; }
.now { margin: 0; border-top: 2px solid var(--ink); }
.now div { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
.now dt { color: var(--ink-2); font-size: 14px; }
.now dd { margin: 0; font: 700 24px var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.mini-bar { display: inline-block; width: 90px; height: 6px; background: var(--paper-2); vertical-align: middle; margin-right: 10px; border-radius: 1px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--ink-2); }

.grid-team { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--ink); padding: 20px 20px 22px; }
.toggle { border: 1px solid var(--line-strong); background: transparent; border-radius: 2px; padding: 4px 9px; font: 600 12px var(--font-body); cursor: pointer; }
.toggle.on { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.toggle.off { background: var(--paper-2); color: var(--muted); }
.toggle:disabled { cursor: default; }
.t tr.inactive td { color: var(--muted); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .grid-2, .grid-team { grid-template-columns: 1fr; }
  .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.k5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis.k5 .kpi:nth-child(4) { border-left: 0; padding-left: 0; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; z-index: 30; height: auto;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    padding: 12px 16px; gap: 6px 14px;
  }
  .brand { padding: 0; font-size: 22px; }
  .nav { flex-direction: row; overflow-x: auto; order: 3; width: 100%; gap: 2px; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .nav a { border-left: 0; border-bottom: 2px solid transparent; padding: 8px 10px; white-space: nowrap; font-size: 14px; }
  .nav a.active { border-bottom-color: var(--accent-bright); background: none; }
  .nav-label { display: none; }
  .nav-count { margin-left: 4px; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; gap: 14px; align-items: center; }
  .me { display: none; }
  .main { padding: 24px 16px 48px; }
  .page-head h1 { font-size: 30px; }
  .kpis, .kpis.k5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-left: 0; padding-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .kpi-value { font-size: 34px; }
  .hide-sm { display: none; }
  .toolbar .search, .toolbar select { max-width: none; flex: 1 1 100%; }
  .map-grid { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 20px; gap: 22px; }
  .login-quote { font-size: 38px; }
  .drawer { padding: 22px 18px 36px; }
  #toast-root { left: 16px; right: 16px; bottom: 16px; }
}
