/* ButteRE app styles. Shared by every page under site/.
   Tokens follow buttere.ai/css/tokens.css: butter, cream, deep teal, ink.
   Layout: 8px grid, 12px radius, dark teal chrome, cream content cards. */

:root {
  --butter: #F5C941;
  --butter-light: #FBE08A;
  --butter-deep: #C9941F;
  --butter-bronze: #B8782A;
  --butter-glow: rgba(245, 201, 65, 0.35);

  --cream: #FFF6D7;
  --card: #FFFBEC;
  --card-2: #FFF3CF;
  --sand: #F3ECD6;
  --sand-2: #EADFC0;

  --teal: #15363B;
  --teal-2: #1A3F45;
  --teal-3: #234E55;
  --teal-4: #2D5F66;
  --teal-ink: #0E2529;

  --ink: #1A1612;
  --ink-soft: #4A453E;
  --muted: #7A6D52;
  --faint: #B5A98A;
  --on-teal: #F0EBDA;
  --on-teal-soft: rgba(240, 235, 218, 0.72);
  --on-teal-muted: rgba(240, 235, 218, 0.48);

  --line: rgba(26, 22, 18, 0.14);
  --line-soft: rgba(26, 22, 18, 0.08);
  --line-strong: rgba(26, 22, 18, 0.28);
  --line-butter: rgba(201, 148, 31, 0.55);
  --line-teal: rgba(240, 235, 218, 0.14);

  --green: #2F6A42;
  --green-soft: #DCF1E2;
  --green-line: #8FC9A3;
  --amber: #8A5A10;
  --amber-soft: #FBE7C2;
  --amber-line: #E6BE6E;
  --red: #A83232;
  --red-soft: #F8DADA;
  --red-line: #E09A9A;
  --blue: #2B5F8C;
  --blue-soft: #DCE9F5;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --fs-micro: 11px;
  --fs-small: 12px;
  --fs-mono: 13px;
  --fs-body: 14px;
  --fs-lg: 16px;
  --fs-h3: 18px;
  --fs-h2: 22px;
  --fs-h1: 28px;

  --r-1: 6px;
  --r-2: 8px;
  --r-3: 12px;
  --r-4: 16px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(26, 22, 18, 0.06), 0 1px 1px rgba(26, 22, 18, 0.04);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 2px 10px rgba(120, 90, 20, 0.08);
  --shadow-lg: 0 18px 50px rgba(26, 22, 18, 0.22), 0 4px 12px rgba(26, 22, 18, 0.10);
  --focus: 0 0 0 3px rgba(245, 201, 65, 0.55), 0 0 0 1px var(--ink);

  --nav-h: 56px;
  --gutter: 24px;
  --shell-max: 1440px;

  --z-nav: 100;
  --z-drawer: 900;
  --z-toast: 1000;
}

@media (max-width: 720px) {
  :root { --gutter: 16px; }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sand);
  color: var(--ink);
  font: var(--fs-body)/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-width: 320px;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-body); }
p { margin: 0; }
a { color: var(--butter-bronze); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
code, .mono { font-family: var(--font-mono); font-size: var(--fs-mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--font-mono); font-size: var(--fs-mono); font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }
.micro { font-size: var(--fs-micro); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-1); }
::selection { background: var(--butter-light); color: var(--ink); }

/* ---------- nav (dark teal chrome) ---------- */
.nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  background: var(--teal);
  color: var(--on-teal);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.nav-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: var(--nav-h);
  display: flex; align-items: center; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--on-teal); text-decoration: none; flex-shrink: 0;
  font-weight: 700; letter-spacing: -0.02em; font-size: 17px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(160deg, var(--butter-light), var(--butter) 55%, var(--butter-deep));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 8px var(--butter-glow);
  display: grid; place-items: center;
  color: var(--teal-ink); font-family: var(--font-mono); font-size: 12px; font-weight: 700;
}
.brand-re { color: var(--butter); }
.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  display: inline-flex; align-items: center; height: 34px; padding: 0 12px;
  border-radius: var(--r-2); color: var(--on-teal-soft); font-size: 13px; font-weight: 500;
  white-space: nowrap; text-decoration: none; position: relative;
}
.nav-link:hover { color: var(--on-teal); background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav-link[aria-current="page"] { color: var(--on-teal); background: rgba(255, 255, 255, 0.08); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -11px; height: 2px;
  background: var(--butter); border-radius: 2px;
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.identity {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 4px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-teal);
  color: var(--on-teal); font-size: 12px; max-width: 280px;
}
.identity-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--butter); color: var(--teal-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 11px; flex-shrink: 0;
}
.identity-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-plan {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--butter); padding: 2px 6px; border-radius: 4px; background: rgba(245, 201, 65, 0.12);
  flex-shrink: 0;
}
.identity-out { color: var(--on-teal-muted); font-size: 12px; white-space: nowrap; }
.identity-out:hover { color: var(--on-teal); }
.nav-toggle {
  display: none; margin-left: auto; width: 36px; height: 36px; border-radius: var(--r-2);
  border: 1px solid var(--line-teal); background: transparent; color: var(--on-teal); cursor: pointer;
}
@media (max-width: 920px) {
  .identity-email { display: none; }
}
@media (max-width: 720px) {
  .nav-inner { flex-wrap: wrap; height: auto; min-height: var(--nav-h); padding-top: 10px; padding-bottom: 10px; row-gap: 8px; }
  .nav-links { order: 3; width: 100%; margin-left: -4px; flex-wrap: wrap; overflow: visible; row-gap: 2px; }
  .nav-link { height: 30px; padding: 0 10px; font-size: 12px; }
  .nav-link[aria-current="page"]::after { display: none; }
  .nav-right { margin-left: auto; }
  .identity { max-width: 160px; }
}

/* ---------- page shell ---------- */
.shell { max-width: var(--shell-max); margin: 0 auto; padding: 24px var(--gutter) 64px; }
.shell-narrow { max-width: 960px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eyebrow { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.12em; text-transform: uppercase; color: var(--butter-bronze); font-weight: 600; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 920px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 16px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 20px; }
.card-teal { background: var(--teal); color: var(--on-teal); border-color: rgba(0, 0, 0, 0.3); }
.card-teal .muted { color: var(--on-teal-muted); }
@media (max-width: 720px) {
  .card-pad, .card-body { padding: 14px 16px; }
  .card-head { padding: 12px 16px; }
}

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (max-width: 920px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3);
  padding: 14px 16px; box-shadow: var(--shadow-card); position: relative; overflow: hidden; min-width: 0;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--butter); border-radius: 3px 0 0 3px; }
.tile.tile-teal::before { background: var(--teal-3); }
.tile.tile-green::before { background: var(--green); }
.tile.tile-amber::before { background: var(--amber); }
.tile-label { font-size: var(--fs-small); color: var(--muted); font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: var(--fs-micro); color: var(--muted); margin-top: 6px; }
.tile-sub b { color: var(--ink-soft); font-weight: 600; }
@media (max-width: 720px) { .tile-value { font-size: 20px; } .tile { padding: 12px 14px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--r-2);
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.btn:hover { background: var(--cream); border-color: var(--ink-soft); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--butter); border-color: var(--butter-deep); color: var(--ink); font-weight: 600; }
.btn-primary:hover { background: var(--butter-light); border-color: var(--butter-deep); }
.btn-teal { background: var(--teal); border-color: var(--teal-ink); color: var(--on-teal); }
.btn-teal:hover { background: var(--teal-2); color: var(--on-teal); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: rgba(26, 22, 18, 0.06); border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red-line); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: var(--r-1); }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-block { width: 100%; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r-2);
  background: #FFFDF5; color: var(--ink); font: inherit; font-size: 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input.mono, .input[type="number"] { font-family: var(--font-mono); font-size: var(--fs-mono); }
.textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234A453E' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-soft); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--butter-deep); box-shadow: 0 0 0 3px rgba(245, 201, 65, 0.4); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input-sm, .select-sm { height: 30px; font-size: 12px; }
.input-group { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.help { font-size: var(--fs-micro); color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--butter-deep); }

/* filter bar */
.filters {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3);
  box-shadow: var(--shadow-card); padding: 12px 16px; margin-bottom: 16px;
  display: grid; gap: 12px;
}
.filters-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters-row .field { flex: 1 1 120px; }
.filters-row .field.wide { flex: 2 1 220px; }
.filters-row .field.narrow { flex: 0 1 100px; }
.filters-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.filters-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filters-chips .label { margin-right: 4px; }
@media (max-width: 720px) {
  .filters { padding: 12px; }
  .filters-row .field, .filters-row .field.wide, .filters-row .field.narrow { flex: 1 1 calc(50% - 5px); }
  .filters-actions { margin-left: 0; width: 100%; }
  .filters-actions .btn { flex: 1 1 auto; }
}

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px;
  border-radius: var(--r-pill); border: 1px solid var(--line-strong);
  background: #FFFDF5; color: var(--ink-soft); font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; user-select: none;
}
.chip:hover { border-color: var(--ink-soft); background: var(--cream); }
.chip[aria-pressed="true"], .chip.active { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.chip-hot[aria-pressed="true"] { background: var(--red); border-color: var(--red); }
.chip-static { cursor: default; }
.chip-static:hover { border-color: var(--line-strong); background: #FFFDF5; }

.grade {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: var(--r-1);
  font-family: var(--font-mono); font-weight: 700; font-size: 13px; border: 1px solid transparent;
}
.grade-A { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.grade-B { background: var(--butter); color: #3F2E05; border-color: var(--butter-deep); }
.grade-C { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.grade-D, .grade-none { background: var(--sand-2); color: var(--muted); border-color: transparent; }
.grade-lg { width: 44px; height: 44px; font-size: 22px; border-radius: var(--r-2); }

.score {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 24px; padding: 0 7px;
  border-radius: var(--r-1); font-family: var(--font-mono); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
.score-fire { background: var(--teal); color: var(--butter); }
.score-hot { background: var(--butter); color: #3F2E05; }
.score-warm { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.score-low { background: var(--sand-2); color: var(--muted); }

.flag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--sand-2); color: var(--ink-soft); white-space: nowrap; border: 1px solid transparent;
}
.flag-pre_foreclosure, .flag-trustee_sale, .flag-lis_pendens, .flag-tax_delinquent, .flag-probate { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.flag-absentee_owner, .flag-out_of_state_owner { background: var(--blue-soft); color: var(--blue); }
.flag-entity_owner { background: var(--butter-light); color: #5A4208; }
.flag-long_held, .flag-very_long_held { background: var(--green-soft); color: var(--green); }
.flag-value_add_price, .flag-cheap_ppsf { background: var(--amber-soft); color: var(--amber); }
.flags { display: flex; gap: 4px; flex-wrap: wrap; }

/* score button + popover (why this score) */
.score-btn { cursor: pointer; border-color: transparent; }
.score-btn:hover { box-shadow: 0 0 0 2px var(--butter-glow); }
.score-btn[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--butter-deep); }
.score-pop {
  position: absolute; z-index: calc(var(--z-drawer) + 5);
  background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-3);
  box-shadow: var(--shadow-lg); padding: 10px 12px 8px; font-size: 13px; outline: none;
}
.score-pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.score-pop-head b { font-size: 14px; }
.score-pop-close { margin-left: auto; width: 26px; height: 26px; border-radius: var(--r-1); border: 1px solid var(--line); background: var(--cream); cursor: pointer; font-size: 16px; line-height: 1; padding: 0; color: var(--ink-soft); }
.score-pop-close:hover { background: var(--sand-2); }
.score-pop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 50vh; overflow: auto; }
.score-pop-list li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--line-soft); }
.score-pop-list li:first-child { border-top: 0; }
.score-pop-list li .mono { font-weight: 600; color: var(--green); }
.score-pop-list li .mono.neg { color: var(--red); }
.score-pop-foot { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-soft); }

/* why now cell */
.why { display: grid; gap: 1px; min-width: 0; }
.why-main { font-weight: 500; color: var(--ink); }
.why-hot .why-main { color: var(--red); }
.why-pts { font-size: 11px; color: var(--muted); font-weight: 600; margin-left: 6px; white-space: nowrap; }
.why-sub { font-size: 12px; color: var(--muted); }

/* score breakdown list (drawer, parcel page, memo) */
.reason-list { list-style: none; margin: 0; padding: 0; display: grid; }
.reason-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.reason-list li:last-child { border-bottom: 0; }
.reason-list .mono { font-weight: 600; color: var(--green); }
.reason-list .mono.neg { color: var(--red); }

/* comps panel */
.comps-hero { display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; align-items: center; padding: 12px 14px; border-radius: var(--r-2); background: var(--cream); border: 1px solid var(--line-soft); }
.comps-hero .fact-value { font-size: 22px; font-weight: 600; white-space: normal; }
.comps-src { font-size: 12px; color: var(--ink-soft); }
.comps-src b { color: var(--ink); }
.comps-band { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r-2); overflow: hidden; }
.comps-band .fact { padding: 8px 10px; }
.sales { width: 100%; border-collapse: collapse; font-size: 12px; }
.sales th { text-align: left; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sales td { padding: 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.sales tr:last-child td { border-bottom: 0; }
.sales .num { font-size: 12px; }
.sales .addr { font-weight: 500; color: var(--ink); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sales-wrap { overflow-x: auto; }
.comps-band .fact-value { white-space: normal; }
@media (max-width: 480px) { .comps-hero { grid-template-columns: 1fr; } .comps-band { grid-template-columns: 1fr 1fr; } .comps-band .fact:last-child { grid-column: 1 / -1; } .sales .col-sm { display: none; } }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: middle; }
.status-new { background: var(--blue); }
.status-dialing, .status-left_vm, .status-contacted { background: var(--amber-line); }
.status-appt_set, .status-claimed, .status-synced, .status-offer, .status-under_contract { background: var(--green); }
.status-closed { background: var(--teal); }
.status-dead, .status-dnc { background: var(--red); }

.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; background: var(--sand-2); color: var(--ink-soft);
}
.pill-ok { background: var(--green-soft); color: var(--green); }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-bad { background: var(--red-soft); color: var(--red); }
.pill-teal { background: var(--teal); color: var(--on-teal); }

.delta { font-family: var(--font-mono); font-size: 12px; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.delta-flat { color: var(--muted); }

/* ---------- tables ---------- */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--card-2); color: var(--muted);
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap; border-bottom: 1px solid var(--line);
}
.table thead th.num, .table td.num { text-align: right; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--ink); }
.table th[data-sort][aria-sort]::after { content: ""; display: inline-block; width: 0; height: 0; margin-left: 6px; vertical-align: middle; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.table th[aria-sort="descending"]::after { border-top: 5px solid var(--butter-deep); }
.table th[aria-sort="ascending"]::after { border-bottom: 5px solid var(--butter-deep); }
.table tbody tr { transition: background 100ms ease; }
.table tbody tr.row-link { cursor: pointer; }
.table tbody tr.row-link:hover { background: var(--cream); }
.table tbody tr:focus-within { background: var(--cream); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num { font-family: var(--font-mono); font-size: var(--fs-mono); font-variant-numeric: tabular-nums; }
.table .cell-primary { font-weight: 500; color: var(--ink); }
.table .cell-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.table .cell-ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-bar { display: none; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); background: var(--card-2); }
.sort-bar .label { margin: 0; white-space: nowrap; }
.sort-bar .select { flex: 1; }
@media (max-width: 720px) { .sort-bar { display: flex; } }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager .mono { color: var(--ink-soft); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* phone: table rows collapse to cards */
@media (max-width: 720px) {
  .table-cards thead { display: none; }
  .table-cards tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
  .table-cards tbody td, .table-cards tbody td:first-child, .table-cards tbody td:last-child { display: block; padding: 0; border: 0; text-align: left; }
  .table-cards tbody td[data-label=""]::before { display: none; }
  .table-cards tbody td.num { text-align: left; }
  .table-cards tbody td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 1px; }
  .table-cards tbody td.cell-span { grid-column: 1 / -1; }
  .table-cards tbody td.cell-hide-phone { display: none; }
  .table-cards .cell-ellipsis { max-width: none; white-space: normal; }
}

/* ---------- skeleton ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--sand-2); border-radius: var(--r-1); color: transparent !important; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton-row td > span { display: inline-block; height: 14px; width: 70%; }

/* ---------- drawer ---------- */
.drawer-veil {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  background: rgba(14, 37, 41, 0.55); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 180ms ease;
}
.drawer-veil.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-drawer) + 1);
  width: min(680px, 100vw); background: var(--sand);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; outline: none;
}
.drawer.open { transform: translateX(0); }
.drawer-narrow { width: min(440px, 100vw); }
.drawer-head {
  background: var(--teal); color: var(--on-teal);
  padding: 16px 20px; display: flex; align-items: flex-start; gap: 12px; flex-shrink: 0;
}
.drawer-head .drawer-title { font-size: 17px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.drawer-head .drawer-sub { font-size: 12px; color: var(--on-teal-soft); margin-top: 3px; font-family: var(--font-mono); }
.drawer-close {
  margin-left: auto; flex-shrink: 0; width: 34px; height: 34px; border-radius: var(--r-2);
  border: 1px solid var(--line-teal); background: rgba(255, 255, 255, 0.06); color: var(--on-teal); cursor: pointer;
  display: grid; place-items: center;
}
.drawer-close:hover { background: rgba(255, 255, 255, 0.12); }
.drawer-close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 32px; display: grid; gap: 14px; align-content: start; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
@media (max-width: 720px) {
  .drawer-head { padding: 14px 16px; }
  .drawer-body { padding: 14px 16px 28px; }
  .drawer-foot { padding: 10px 16px; }
}

/* sections inside drawers and detail pages */
.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--shadow-card); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.section-head h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.section-head .state { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.section-body { padding: 14px 16px; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line-soft); border-radius: var(--r-2); overflow: hidden; border: 1px solid var(--line-soft); }
.fact { background: var(--card); padding: 10px 12px; min-width: 0; }
.fact-label { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.fact-value { font-family: var(--font-mono); font-size: var(--fs-mono); font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fact-value.big { font-size: 17px; font-weight: 600; }
.fact-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.facts-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facts-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .facts, .facts-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.uw-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.uw-main { padding: 14px 16px; border-radius: var(--r-2); background: var(--teal); color: var(--on-teal); }
.uw-main .fact-label { color: var(--on-teal-muted); }
.uw-main .fact-value { color: var(--butter); font-size: 24px; font-weight: 600; white-space: normal; }
.uw-main .fact-sub { color: var(--on-teal-soft); }
.uw-alt { padding: 14px 16px; border-radius: var(--r-2); background: var(--cream); border: 1px solid var(--line-soft); }
.uw-alt .fact-value { font-size: 24px; font-weight: 600; white-space: normal; }
@media (max-width: 480px) { .uw-hero { grid-template-columns: 1fr; } }

.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.tl-item:last-child { border-bottom: 0; }
.tl-date { font-family: var(--font-mono); font-size: 12px; color: var(--muted); padding-top: 2px; white-space: nowrap; }
.tl-type { font-weight: 600; font-size: 13px; }
.tl-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }

.flag-rows { display: grid; gap: 6px; }
.flag-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 8px 10px; background: var(--cream); border-radius: var(--r-2); border: 1px solid var(--line-soft); }
.flag-row .flag { margin-top: 1px; }
.flag-row p { font-size: 12px; color: var(--ink-soft); line-height: 1.45; }

/* AI tool grid */
.tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tool {
  text-align: left; padding: 10px 12px; border-radius: var(--r-2);
  border: 1px solid var(--line); background: #FFFDF5; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  transition: border-color 120ms ease, background 120ms ease;
}
.tool:hover { border-color: var(--butter-deep); background: var(--cream); }
.tool-name { font-weight: 600; font-size: 13px; }
.tool-desc { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.tool-state { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; }
.tool.running { border-color: var(--butter-deep); }
.tool.running .tool-state { color: var(--butter-bronze); }
.tool.done .tool-state { color: var(--green); }
.tool.error .tool-state { color: var(--red); }
.tool.running .tool-state::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--butter-deep); border-right-color: transparent; margin-right: 5px; vertical-align: -1px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 420px) { .tools { grid-template-columns: 1fr; } }

.prose { font-size: 14px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; word-wrap: break-word; }
.prose-box { padding: 12px 14px; border-radius: var(--r-2); background: var(--cream); border: 1px solid var(--line-soft); }
.copy-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.copy-head .label { margin: 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.kv dd { margin: 0; font-family: var(--font-mono); font-size: var(--fs-mono); overflow-wrap: anywhere; }

.actions-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 560px) { .actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- concierge ---------- */
.fab {
  position: fixed; right: 20px; bottom: 20px; z-index: calc(var(--z-drawer) - 1);
  height: 48px; padding: 0 18px 0 14px; border-radius: var(--r-pill);
  background: var(--teal); color: var(--on-teal); border: 1px solid var(--teal-ink);
  box-shadow: 0 10px 30px rgba(14, 37, 41, 0.35), 0 0 0 1px rgba(245, 201, 65, 0.25);
  display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.fab:hover { background: var(--teal-2); }
.fab .fab-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--butter); box-shadow: 0 0 0 4px rgba(245, 201, 65, 0.25); }
@media (max-width: 720px) { .fab { right: 16px; bottom: 16px; height: 44px; font-size: 13px; } }

.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.msg { max-width: 92%; padding: 10px 12px; border-radius: var(--r-3); font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-user { justify-self: end; background: var(--butter-light); color: var(--ink); border-bottom-right-radius: 4px; }
.msg-ai { justify-self: start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-ai.thinking { color: var(--muted); font-style: italic; }
.msg-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.msg-tool { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--teal); color: var(--on-teal); font-family: var(--font-mono); font-size: 10px; }
.msg-tool b { color: var(--butter); font-weight: 600; }
.chat-suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--card); align-items: flex-end; }
.chat-form .textarea { min-height: 40px; max-height: 140px; height: 40px; }
.chat-usage { font-family: var(--font-mono); font-size: 10px; color: var(--muted); padding: 0 16px 10px; }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: var(--z-toast); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; padding: 10px 14px; border-radius: var(--r-2);
  background: var(--teal); color: var(--on-teal); font-size: 13px; box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--butter); display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in 180ms ease-out;
}
.toast-error { border-left-color: var(--red-line); }
.toast-ok { border-left-color: var(--green-line); }
.toast b { font-weight: 600; }
.toast-close { margin-left: auto; background: none; border: 0; color: var(--on-teal-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- misc ---------- */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 28px; }
.bars i { display: block; flex: 1; min-width: 3px; background: var(--teal-3); border-radius: 2px 2px 0 0; }
.bars i:last-child { background: var(--butter-deep); }
.spark { width: 100%; height: 36px; overflow: visible; }
.banner { padding: 12px 16px; border-radius: var(--r-2); background: var(--cream); border: 1px solid var(--line-butter); font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner-error { background: var(--red-soft); border-color: var(--red-line); color: var(--red); }
.banner-teal { background: var(--teal); color: var(--on-teal); border-color: var(--teal-ink); }
.divider { height: 1px; background: var(--line-soft); margin: 4px 0; }
footer.foot { max-width: var(--shell-max); margin: 0 auto; padding: 0 var(--gutter) 32px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
footer.foot a { color: var(--muted); }

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