/* Archiwright · Prospectare — one stylesheet, mobile first (390), laptop (1440). */

@font-face {
  font-family: "Jost Fallback";
  src: local("Avenir Next"), local("Helvetica Neue"), local("Arial");
  size-adjust: 97%;
  ascent-override: 103%;
  descent-override: 32%;
}

:root {
  --bg: #f4f1ec;
  --surface: #fbfaf7;
  --surface-2: #efebe4;
  --ink: #151515;
  --ink-2: #3a3632;
  --muted: #7a746e;
  --muted-text: #645e58;      /* #7a746e is 4.0:1 on the cream; text uses this 5.2:1 shade */
  --line: #dcd5cb;
  --line-strong: #c9c0b4;
  --accent: #0a6ebd;
  --accent-hover: #085a9b;
  --accent-soft: #e3eef8;
  --danger: #b42318;
  --danger-soft: #fbe5e2;
  --warn: #8a5a00;
  --warn-soft: #fbefd5;
  --ok: #1e6b35;
  --ok-soft: #e2f2e6;
  --focus: #0a6ebd;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r1: 6px; --r2: 10px; --r3: 14px;
  --tap: 44px;
  --font: "Jost", "Jost Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(21, 21, 21, .05), 0 6px 24px rgba(21, 21, 21, .07);
  --shadow-lg: 0 10px 40px rgba(21, 21, 21, .18);
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --sidebar-w: 232px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font); letter-spacing: .005em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.2; letter-spacing: -.005em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted-text); }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.danger-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.skip-link { position: absolute; left: var(--s4); top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: var(--s2) var(--s4); border-radius: var(--r1); }
.skip-link:focus { top: var(--s2); }

/* ---------- boot / login */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
body:not(.is-booting) .boot { display: none; }
.boot__mark { width: 40px; height: 40px; border-radius: 10px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 600; animation: pulse 1.2s var(--ease) infinite alternate; }
@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }

.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s5) var(--s4); }
.login__card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s6) var(--s5); box-shadow: var(--shadow); display: grid; gap: var(--s4); }
.login__title { font-size: 22px; margin-top: var(--s2); }
.login__error { color: var(--danger); background: var(--danger-soft); border-radius: var(--r1); padding: var(--s2) var(--s3); font-size: 15px; }

/* ---------- brand */
.brand { display: inline-flex; align-items: center; gap: var(--s3); color: var(--ink); min-height: var(--tap); }
.brand:hover { text-decoration: none; }
.brand__mark { width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 600; font-size: 16px; flex: none; }
.brand__text { font-weight: 500; font-size: 17px; line-height: 1.15; display: grid; }
.brand__sub { font-size: 13px; color: var(--muted-text); font-weight: 400; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- shell */
.shell { min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 0 var(--s2) 0 var(--s4); background: rgba(244, 241, 236, .94); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.topbar .brand__text { font-size: 17px; }
.sidebar { display: none; }
.main { padding: var(--s5) var(--s4) calc(var(--tabbar-h) + var(--s6) + env(safe-area-inset-bottom)); min-height: calc(100vh - var(--topbar-h)); }
.main:focus { outline: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(251, 250, 247, .97); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.tabbar__link { display: grid; justify-items: center; align-content: center; gap: 2px; color: var(--muted-text); font-size: 12px; font-weight: 500; background: none; border: 0; padding: 0; cursor: pointer; min-height: var(--tap); }
.tabbar__link svg { width: 24px; height: 24px; }
.tabbar__link:hover { text-decoration: none; color: var(--ink); }
.tabbar__link[aria-current="page"] { color: var(--ink); }
.tabbar__link[aria-current="page"] svg { color: var(--accent); }

.icon-btn { width: var(--tap); height: var(--tap); display: grid; place-items: center; border: 0; background: none; border-radius: var(--r2); color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: var(--s4); position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: var(--s5) var(--s4); border-right: 1px solid var(--line); background: var(--bg);
  }
  .sidebar .brand { padding: 0 var(--s2); }
  .sidebar__foot { margin-top: auto; padding: 0 var(--s2); font-size: 13px; color: var(--muted-text); line-height: 1.4; }
  .main { padding: var(--s6) var(--s6) var(--s7); min-height: 100vh; }
}
@media (min-width: 1280px) { .main { padding: var(--s6) 40px var(--s7); } }

.nav { display: grid; gap: 2px; }
.nav__link { display: flex; align-items: center; min-height: 40px; padding: 0 var(--s3); border-radius: var(--r1); color: var(--ink-2); font-weight: 500; font-size: 15px; }
.nav__link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav__link[aria-current="page"] { background: var(--ink); color: var(--bg); }

.search { position: relative; }
.search__icon { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search__input { padding-left: 38px; padding-right: 36px; }
.search__kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 500 12px/1 var(--mono); color: var(--muted-text); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; background: var(--bg); }
.search__input:focus + .search__kbd { display: none; }

/* ---------- page scaffolding */
.page { max-width: 1200px; margin: 0 auto; display: grid; gap: var(--s5); }
.page--wide { max-width: 1440px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s4); }
.page-head__title { display: grid; gap: var(--s1); min-width: 0; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.eyebrow { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-text); font-weight: 500; }
.crumb { font-size: 14px; color: var(--muted-text); display: inline-flex; align-items: center; min-height: 32px; }
.crumb a { color: var(--muted-text); }
.section { display: grid; gap: var(--s3); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.section__head a { font-size: 15px; }
.grid-2 { display: grid; gap: var(--s5); }
@media (min-width: 1024px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .grid-2--detail { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .grid-2--overview { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
}
.stack { display: grid; gap: var(--s4); align-content: start; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.row--between { justify-content: space-between; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s4); min-width: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.card__head h2 { font-size: 17px; font-weight: 600; }
@media (min-width: 700px) { .card { padding: var(--s5); } .card--flush { padding: 0; } }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--r2);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 15px; line-height: 1.1; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ink { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn--ink:hover { background: #2b2926; }
.btn--danger { color: var(--danger); border-color: #e7b9b3; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-solid:hover { background: #961d13; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { min-height: 36px; padding: 0 var(--s3); font-size: 14px; border-radius: var(--r1); }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn--icon { width: var(--tap); padding: 0; }
.btn--sm.btn--icon { width: 36px; }
@media (pointer: coarse) { .btn--sm { min-height: var(--tap); } .btn--sm.btn--icon { width: var(--tap); } }

/* ---------- forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field__hint { font-size: 13px; color: var(--muted-text); }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r2);
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font-size: 16px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { padding: 10px var(--s3); min-height: 96px; resize: vertical; line-height: 1.45; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("chevron.svg"); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 110, 189, .18); outline: none; }
.input[disabled], .select[disabled], .textarea[disabled] { background: var(--surface-2); color: var(--muted-text); }
.input--sm, .select--sm { min-height: 36px; font-size: 15px; }
@media (pointer: coarse) { .input--sm, .select--sm { min-height: var(--tap); font-size: 16px; } }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.form-grid { display: grid; gap: var(--s4); }
@media (min-width: 700px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid--3 { grid-template-columns: repeat(3, 1fr); } .span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; } }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.check { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--tap); cursor: pointer; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; cursor: pointer; }
.saved-note { font-size: 13px; color: var(--muted-text); min-height: 20px; }

/* chips (toggle buttons) */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s3);
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip__x { font-size: 16px; line-height: 1; color: inherit; opacity: .7; }
@media (pointer: coarse) { .chip { min-height: 40px; } }

/* ---------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap; background: #ebe7e1; color: #4d4843;
}
.badge--lg { height: 28px; padding: 0 12px; font-size: 14px; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-new { background: #ebe7e1; color: #4d4843; }
.s-qualified { background: #e1edf8; color: #0b4f87; }
.s-to_call { background: #fbefd5; color: #7f5300; }
.s-called { background: #f6e3bf; color: #6f4600; }
.s-consented { background: #e0f1e4; color: #1e6b35; }
.s-sent { background: #e6e8f8; color: #33399b; }
.s-followed_up { background: #dcdff5; color: #2b3190; }
.s-replied { background: #d9f0ed; color: #0d625c; }
.s-meeting { background: #efe4f7; color: #66308f; }
.s-won { background: #1e6b35; color: #fff; }
.s-lost { background: #f1e3e0; color: #87463e; }
.s-opted_out { background: #fbdfdb; color: #a61f15; }
.s-excluded { background: #57524d; color: #fff; }
.t-1 { background: #151515; color: #fff; }
.t-2 { background: #fde6d4; color: #8a3b00; }
.t-3 { background: #ebe7e1; color: #4d4843; }
.t-4 { background: #e0f1e4; color: #1e6b35; }
.t-none { background: transparent; color: var(--muted-text); border: 1px dashed var(--line-strong); }
.badge--suppressed { background: var(--danger); color: #fff; }
.badge--live { background: #e0f1e4; color: #1e6b35; }
.badge--building { background: #fbefd5; color: #7f5300; }
.badge--research { background: #e1edf8; color: #0b4f87; }
.badge--paused { background: #ebe7e1; color: #4d4843; }
.badge--done { background: #e0f1e4; color: #1e6b35; }
.badge--running { background: #e1edf8; color: #0b4f87; }
.badge--queued { background: #ebe7e1; color: #4d4843; }
.badge--failed { background: #fbdfdb; color: #a61f15; }
.badge--outline { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2); }

/* ---------- KPI tiles, funnel, bars */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s3) var(--s4); display: grid; gap: 2px; min-height: 88px; align-content: center; color: var(--ink); }
a.kpi:hover { text-decoration: none; border-color: var(--line-strong); background: #fff; }
.kpi__value { font-size: 30px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi__label { font-size: 14px; color: var(--muted-text); line-height: 1.3; }
.kpi--accent .kpi__value { color: var(--accent); }
.kpi--danger .kpi__value { color: var(--danger); }

.funnel { display: grid; gap: 10px; }
.funnel__row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 36px; gap: var(--s3); align-items: center; font-size: 14px; }
.funnel__label { color: var(--ink-2); }
.funnel__track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.funnel__bar { height: 100%; background: var(--ink); border-radius: 999px; min-width: 2px; width: 0; transition: width .5s var(--ease); }
.funnel__row:nth-child(n+4) .funnel__bar { background: var(--accent); }
.funnel__row:last-child .funnel__bar { background: var(--ok); }
.funnel__n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
@media (min-width: 700px) { .funnel__row { grid-template-columns: 120px minmax(0, 1fr) 44px; } }

.stackbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.stackbar span { height: 100%; width: 0; }
.stackbar .b-1 { background: #151515; }
.stackbar .b-2 { background: #e48a4a; }
.stackbar .b-3 { background: #b9b1a6; }
.stackbar .b-4 { background: #4f9a65; }
.stackbar .b-null { background: #dcd5cb; }
.legend { display: flex; flex-wrap: wrap; gap: 4px var(--s3); font-size: 13px; color: var(--muted-text); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__sw { width: 10px; height: 10px; border-radius: 3px; }
.legend__sw.b-1 { background: #151515; } .legend__sw.b-2 { background: #e48a4a; } .legend__sw.b-3 { background: #b9b1a6; } .legend__sw.b-4 { background: #4f9a65; } .legend__sw.b-null { background: #dcd5cb; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress__bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .35s var(--ease); }
.progress--done .progress__bar { background: var(--ok); }
.progress--failed .progress__bar { background: var(--danger); }
.progress--lg { height: 12px; }

/* ---------- lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list__item { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; padding: var(--s3) 0; border-top: 1px solid var(--line); min-height: 56px; }
.list__item:first-child { border-top: 0; padding-top: 0; }
.list__item:last-child { padding-bottom: 0; }
.list__main { min-width: 0; display: grid; gap: 2px; }
.list__title { font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
a.list__title:hover { color: var(--accent); }
.list__meta { font-size: 14px; color: var(--muted-text); }
.list__side { flex: none; text-align: right; font-size: 14px; display: grid; gap: 2px; justify-items: end; }
.list--links .list__item { position: relative; }

.niche-cards { display: grid; gap: var(--s3); }
@media (min-width: 700px) { .niche-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.niche-card { display: grid; gap: var(--s3); }
.niche-card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.niche-card__name { font-size: 18px; font-weight: 500; color: var(--ink); }
.niche-card__stats { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: 14px; color: var(--muted-text); }
.niche-card__stats b { color: var(--ink); font-weight: 500; }

/* ---------- feed / timeline */
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed__item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.feed__item:first-child { border-top: 0; padding-top: 0; }
.feed__icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.feed__icon svg { width: 16px; height: 16px; }
.feed__icon.i-call { background: #fbefd5; color: #7f5300; }
.feed__icon.i-email, .feed__icon.i-followup { background: #e6e8f8; color: #33399b; }
.feed__icon.i-reply { background: #d9f0ed; color: #0d625c; }
.feed__icon.i-meeting { background: #efe4f7; color: #66308f; }
.feed__icon.i-consent { background: #e0f1e4; color: #1e6b35; }
.feed__icon.i-opt_out { background: #fbdfdb; color: #a61f15; }
.feed__body { min-width: 0; display: grid; gap: 2px; }
.feed__summary { overflow-wrap: anywhere; }
.feed__meta { font-size: 13.5px; color: var(--muted-text); display: flex; flex-wrap: wrap; gap: 2px var(--s2); align-items: center; }
.feed__meta .sep::before { content: "·"; margin-right: var(--s2); }
.feed__text { margin-top: var(--s1); font-size: 15px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: var(--r1); padding: var(--s2) var(--s3); }
.feed__item.is-pending { opacity: .6; }

.timeline .feed__item { position: relative; }
.timeline .feed__item:not(:last-child)::after { content: ""; position: absolute; left: 15.5px; top: 44px; bottom: -12px; width: 1px; background: var(--line); }
.timeline .feed__item:first-child:not(:last-child)::after { top: 32px; }
.timeline .feed__item { border-top: 0; }

/* ---------- table → cards */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
.tbl a { color: var(--ink); }
.tbl a:hover { color: var(--accent); }
.tbl a.ext { color: var(--accent); }
.cell-sub { display: block; font-size: 13.5px; color: var(--muted-text); }
.cell-stack { display: grid; gap: 4px; justify-items: start; min-width: 0; }
.cell-title a { font-weight: 500; }
.host { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.tbl tr.is-selected { background: var(--accent-soft); }
.tbl tr.is-pending { opacity: .55; }
@media (max-width: 699.98px) {
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s3) var(--s4); margin-bottom: var(--s3); }
  .tbl tr.is-selected { border-color: var(--accent); }
  .tbl td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: 7px 0; text-align: right; min-width: 0; border-top: 1px solid #ece7df; }
  .tbl td::before { content: attr(data-label); flex: none; color: var(--muted-text); font-size: 14px; text-align: left; }
  .tbl td > * { min-width: 0; }
  .tbl td .cell-stack { justify-items: end; }
  .tbl td.cell-title { display: block; text-align: left; font-size: 17px; padding: 2px 52px var(--s2) 0; border-top: 0; }
  .tbl td.cell-title .cell-sub { font-size: 14px; margin-top: 2px; }
  .tbl td.cell-title::before, .tbl td.cell-check::before, .tbl td.cell-actions::before { content: none; }
  .tbl td.cell-check { position: absolute; top: 4px; right: 4px; width: auto; padding: 0; border: 0; }
  .tbl td.cell-actions { justify-content: flex-start; flex-wrap: wrap; gap: var(--s2); padding-top: var(--s3); text-align: left; }
  .tbl td.cell-actions .btn { flex: 1 1 auto; }
  .tbl td.m-hide-empty:empty, .tbl td.is-empty { display: none; }
  .tbl td.cell-badges { justify-content: flex-start; flex-wrap: wrap; gap: 6px; border-top: 0; padding-top: 0; }
  .tbl td.cell-badges::before { content: none; }
  .tbl td.cell-block { display: block; text-align: left; }
  .tbl td.cell-block::before { display: block; margin-bottom: 4px; }
  .host { max-width: 200px; }
}
@media (min-width: 700px) {
  .tbl th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted-text); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
  .tbl td { padding: 10px 12px; border-bottom: 1px solid #ebe5dc; vertical-align: middle; }
  .tbl tbody tr:last-child td { border-bottom: 0; }
  .tbl tbody tr:hover { background: #f7f4ef; }
  .tbl tbody tr.is-selected:hover { background: var(--accent-soft); }
  .tbl .cell-check { width: 44px; padding-right: 0; }
  .tbl .cell-actions { white-space: nowrap; text-align: right; }
  .tbl .cell-actions .row { justify-content: flex-end; flex-wrap: nowrap; gap: 6px; }
  .tbl .col-num { text-align: right; }
  .tbl th.col-num { text-align: right; }
  .tbl td.cell-badges { display: none; }
}
.cell-check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 12px; cursor: pointer; display: block; }

/* ---------- filters */
.filters { display: grid; gap: var(--s3); }
.filters__bar { display: flex; gap: var(--s2); align-items: center; }
.filters__bar .search { flex: 1 1 auto; min-width: 0; }
.filters__panel { display: none; }
.filters__panel.is-open { display: grid; gap: var(--s4); }
.filters__group { display: grid; gap: var(--s2); }
.filters__group > .field__label { font-size: 13px; color: var(--muted-text); text-transform: uppercase; letter-spacing: .05em; }
.filters__count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; }
.filters__summary { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; font-size: 14px; color: var(--muted-text); }
@media (max-width: 1023.98px) {
  .filters__panel.is-open { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s4); }
}
@media (min-width: 1024px) {
  .filters__toggle { display: none; }
  .filters__panel, .filters__panel.is-open { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); align-items: flex-end; }
  .filters__group { gap: 6px; }
  .filters__panel .select, .filters__panel .input { width: auto; min-width: 150px; }
}
.status-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.status-picker .chip { min-height: 32px; font-size: 13.5px; padding: 0 10px; }
@media (pointer: coarse) { .status-picker .chip { min-height: 40px; } }

.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; font-size: 15px; color: var(--muted-text); }
.pager__btns { display: flex; gap: var(--s2); }

/* ---------- bulk bar */
.bulkbar {
  position: fixed; z-index: 40; left: var(--s3); right: var(--s3); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s3));
  background: var(--ink); color: var(--bg); border-radius: var(--r3); box-shadow: var(--shadow-lg);
  padding: var(--s3); display: grid; gap: var(--s2);
  animation: rise .2s var(--ease);
}
.bulkbar__count { font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding-left: var(--s1); }
.bulkbar__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.bulkbar .select { background-color: #2b2926; color: var(--bg); border-color: #4a4641; background-image: url("chevron-light.svg"); }
.bulkbar .btn { background: #2b2926; color: var(--bg); border-color: #4a4641; }
.bulkbar .btn:hover { background: #3a3632; }
.bulkbar .btn--ghost { background: transparent; border-color: transparent; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) {
  .bulkbar { left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); display: flex; align-items: center; padding: var(--s2) var(--s2) var(--s2) var(--s4); }
  .bulkbar__actions { display: flex; gap: var(--s2); }
  .bulkbar .select { width: auto; }
  @keyframes rise { from { opacity: 0; } to { opacity: 1; } }
}
@media (min-width: 1024px) { .bulkbar { bottom: var(--s5); left: calc(50% + var(--sidebar-w) / 2); } }
.has-bulkbar .main { padding-bottom: calc(var(--tabbar-h) + 200px); }
@media (min-width: 700px) { .has-bulkbar .main { padding-bottom: 120px; } }

/* ---------- empty / skeleton */
.empty { text-align: center; padding: var(--s7) var(--s4); display: grid; gap: var(--s3); justify-items: center; color: var(--muted-text); border: 1px dashed var(--line-strong); border-radius: var(--r3); background: rgba(251, 250, 247, .6); }
.empty__title { color: var(--ink); font-size: 18px; font-weight: 500; }
.empty--sm { padding: var(--s5) var(--s4); }
.skel { display: grid; gap: var(--s3); }
.skel__line { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #ebe6de 0%, #f3efe9 50%, #ebe6de 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel__line--title { height: 28px; width: 40%; }
.skel__block { height: 120px; border-radius: var(--r3); background: #ebe6de; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- key/value */
.kv { display: grid; gap: 0; margin: 0; }
.kv__row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--s3); padding: 10px 0; border-top: 1px solid #ebe5dc; align-items: baseline; }
.kv__row:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--muted-text); font-size: 14px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 700px) { .kv__row { grid-template-columns: 140px minmax(0, 1fr); } }

.signals { width: 100%; border-collapse: collapse; font-size: 14px; }
.signals td { padding: 6px 0; border-top: 1px solid #ebe5dc; vertical-align: top; }
.signals td:last-child { text-align: right; padding-left: var(--s3); overflow-wrap: anywhere; }
.signals tr:first-child td { border-top: 0; }
.signals .bad { color: var(--danger); }
.signals .good { color: var(--ok); }
details.disclosure > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); font-weight: 500; color: var(--ink-2); }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: ""; width: 8px; height: 8px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform .15s var(--ease); margin-right: 2px; }
details.disclosure[open] > summary::before { transform: rotate(45deg); }

/* ---------- prospect detail */
.p-head { display: grid; gap: var(--s3); }
.p-head__name { font-size: 26px; overflow-wrap: anywhere; }
.p-head__badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.p-head__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.p-head__actions .btn--wide { grid-column: span 2; }
@media (min-width: 700px) { .p-head__actions { display: flex; flex-wrap: wrap; } .p-head__name { font-size: 30px; } }
.notice { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r2); font-size: 15px; line-height: 1.45; align-items: flex-start; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.notice--danger { background: var(--danger-soft); color: #7d1a12; }
.notice--warn { background: var(--warn-soft); color: #5e3d00; }
.notice--info { background: var(--accent-soft); color: #0b4372; }
.notice code, .code { font-family: var(--mono); font-size: 13.5px; background: rgba(255, 255, 255, .65); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }

.quality { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: var(--s4); align-items: center; }
.ring { width: 76px; height: 76px; position: relative; }
.ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.ring__track { stroke: var(--surface-2); }
.ring__val { stroke: var(--ink); transition: stroke-dashoffset .6s var(--ease); }
.ring--t2 .ring__val { stroke: #d9742f; }
.ring--t3 .ring__val { stroke: #8f877c; }
.ring--t4 .ring__val { stroke: #3f8a55; }
.ring__n { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.reasons { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.reasons li { display: flex; gap: var(--s2); align-items: baseline; font-size: 15px; }
.reasons li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); flex: none; transform: translateY(-2px); }
.shots { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s3); }
.shots img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r1); background: #fff; }

.next-box { border-color: var(--line-strong); background: #fff; }
.next-box__current { display: grid; gap: 2px; padding: var(--s3) var(--s4); border-radius: var(--r2); background: var(--bg); margin-bottom: var(--s4); }
.next-box__current.is-overdue { background: var(--danger-soft); }
.next-box__current.is-today { background: var(--warn-soft); }
.next-box__what { font-size: 17px; font-weight: 500; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- modal / sheet / menu */
dialog { color: var(--ink); }
.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--r3);
  background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: pop .18s var(--ease); }
.modal--wide { width: min(760px, calc(100vw - 24px)); }
.modal::backdrop, .sheet::backdrop { background: rgba(21, 21, 21, .38); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s5); border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 18px; font-weight: 600; }
.modal__body { padding: var(--s5); overflow-y: auto; display: grid; gap: var(--s4); }
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--bg); }
@media (max-width: 699.98px) {
  .modal { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r3) var(--r3) 0 0; }
  .modal[open] { animation: slideup .22s var(--ease); }
  .modal__body { padding: var(--s4); }
  .modal__head { padding-left: var(--s4); }
  .modal__foot { padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); }
  .modal__foot .btn { flex: 1 1 auto; }
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border: 0; padding: var(--s2) var(--s3) calc(var(--s3) + env(safe-area-inset-bottom)); border-radius: var(--r3) var(--r3) 0 0; background: var(--surface); }
.sheet[open] { animation: slideup .22s var(--ease); }
.sheet__nav { display: grid; }
.sheet__link { display: flex; align-items: center; min-height: 52px; padding: 0 var(--s3); font-size: 17px; font-weight: 500; color: var(--ink); border: 0; background: none; text-align: left; border-bottom: 1px solid var(--line); cursor: pointer; }
.sheet__link:last-child { border-bottom: 0; }
.sheet__link[aria-current="page"] { color: var(--accent); }
.sheet__link--muted { color: var(--muted-text); }

.menu { position: fixed; z-index: 60; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); box-shadow: var(--shadow-lg); padding: var(--s1); display: grid; animation: pop .12s var(--ease); }
.menu__item { display: flex; align-items: center; min-height: 40px; padding: 0 var(--s3); border: 0; background: none; text-align: left; border-radius: var(--r1); font-size: 15px; cursor: pointer; color: var(--ink); }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-2); outline: none; }
.menu__item[disabled] { opacity: .45; cursor: not-allowed; }
.menu__item--danger { color: var(--danger); }
@media (pointer: coarse) { .menu__item { min-height: var(--tap); } }

/* ---------- toasts */
.toasts { position: fixed; z-index: 80; left: var(--s3); right: var(--s3); top: calc(var(--topbar-h) + var(--s2)); display: grid; gap: var(--s2); pointer-events: none; }
@media (min-width: 700px) { .toasts { left: auto; right: var(--s5); top: auto; bottom: var(--s5); width: 380px; } }
.toast { pointer-events: auto; display: flex; gap: var(--s3); align-items: center; justify-content: space-between; background: var(--ink); color: var(--bg); padding: var(--s3) var(--s3) var(--s3) var(--s4); border-radius: var(--r2); box-shadow: var(--shadow-lg); font-size: 15px; animation: pop .18s var(--ease); }
.toast--error { background: #7d1a12; }
.toast--ok { background: #17502a; }
.toast__btn { flex: none; border: 0; background: rgba(255, 255, 255, .14); color: inherit; border-radius: var(--r1); min-height: 32px; padding: 0 var(--s3); font-weight: 500; cursor: pointer; }
.toast.is-leaving { opacity: 0; transition: opacity .2s; }

/* ---------- places modal / jobs */
.estimate { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.estimate__cell { background: var(--bg); border-radius: var(--r2); padding: var(--s3); display: grid; gap: 2px; }
.estimate__n { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.estimate__l { font-size: 13px; color: var(--muted-text); }
.city-picker { max-height: 220px; overflow-y: auto; padding: var(--s1); margin: calc(-1 * var(--s1)); }
.run-log { list-style: none; margin: 0; padding: 0; font-size: 14px; display: grid; gap: 4px; max-height: 180px; overflow-y: auto; }
.run-log li { display: flex; justify-content: space-between; gap: var(--s3); }
.log { margin: 0; font: 13px/1.55 var(--mono); background: #1d1b19; color: #ece6dc; border-radius: var(--r2); padding: var(--s4); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow-y: auto; }

.dirs-table td:first-child { font-weight: 500; }
.research { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
@media (min-width: 700px) { .research { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.city-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.status-line { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.status-line:first-of-type { border-top: 0; }
.status-line__label { flex: 1 1 200px; }
.yes, .no { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.yes { color: var(--ok); } .no { color: var(--danger); }
.yes::before, .no::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

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

/* table helpers for desktop-only cells */
@media (max-width: 699.98px) { .tbl .d-only, .tbl td.d-cell { display: none; } }
.p-status { width: auto; flex: 1 1 180px; }
@media (min-width: 700px) { .p-status { flex: 0 0 auto; min-width: 180px; } }
.filters__status { flex-basis: 100%; }
.search .search__input { padding-left: 38px; padding-right: 36px; }
@media (min-width: 700px) {
  .tbl th.cell-badges, .tbl .m-cell { display: none; }
  .tbl--prospects th, .tbl--prospects td { padding-left: 10px; padding-right: 10px; }
  .tbl--prospects .cell-title { min-width: 190px; }
  .tbl--prospects .cell-actions .btn--sm { width: 36px; padding: 0; }
  .tbl--prospects .btn__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tbl--prospects .host { max-width: 170px; }
}
@media (max-width: 699.98px) { .tbl .d-only { display: none; } }
.p-head__more { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.p-head__more .p-status { grid-column: 1 / -1; width: 100%; }
@media (min-width: 700px) { .p-head__more { display: flex; flex-wrap: wrap; align-items: center; } .p-head__more .p-status { width: auto; } }
@media (min-width: 700px) { .tbl .m-only { display: none; } }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: var(--s2); }
fieldset.filters__group > legend { font-size: 13px; color: var(--muted-text); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
fieldset[disabled] { opacity: .6; }
@media (max-width: 699.98px) { .estimate__n { font-size: 18px; } .estimate__cell { padding: var(--s2) var(--s3); } }
.tbl td.cell-title { font-weight: 500; }
.tbl td.cell-title .cell-sub { font-weight: 400; }
.tbl .progress { width: 140px; }
.tierbar { display: grid; gap: var(--s2); }
@media (max-width: 699.98px) {
  .card--flush:has(> .tbl-wrap) { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  .tbl tbody tr:last-child { margin-bottom: 0; }
}
.notice--slim { padding: var(--s2) var(--s3); align-items: center; }
.notice__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); flex: 1; min-width: 0; }
.notice__row .btn { background: rgba(255, 255, 255, .7); }
.kpi--warn .kpi__value { color: var(--warn); }
@media (max-width: 699.98px) { .kpis .kpi:first-child { grid-column: span 2; } }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.funnel__bar.is-zero { min-width: 0; }
