/* House Search mockup — shared styles. Tokens on :root, dark mode selected. */
:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #efeeea;
  --border: #dddbd4;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a887f;
  --accent: #2f6b45;          /* brand green */
  --accent-ink: #ffffff;
  --tier-a: #1c5cab;          /* ordinal blue ramp, steps 550/400/250 */
  --tier-b: #3987e5;
  --tier-c: #86b6ef;
  --tier-dead: #b8b6ad;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141413; --surface: #1a1a19; --surface-2: #232321; --border: #33332f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8d8b82;
    --accent: #4f9a6a; --accent-ink: #0b0b0b;
    --tier-a: #5598e7; --tier-b: #3987e5; --tier-c: #1c5cab; --tier-dead: #55544e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413; --surface: #1a1a19; --surface-2: #232321; --border: #33332f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #8d8b82;
  --accent: #4f9a6a; --accent-ink: #0b0b0b;
  --tier-a: #5598e7; --tier-b: #3987e5; --tier-c: #1c5cab; --tier-dead: #55544e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Top nav */
.nav { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1001; }
.nav .brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; text-decoration: none; }
.nav .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.nav .links { display: flex; gap: 4px; margin-left: 8px; }
.nav .links a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--text-2); }
.nav .links a.active, .nav .links a:hover { background: var(--surface-2); color: var(--text); }
.nav .spacer { flex: 1; }
.nav .role { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.mock-banner { font-size: 12px; text-align: center; padding: 4px 8px; background: var(--surface-2); color: var(--text-2); border-bottom: 1px solid var(--border); }

/* Layout */
.page { padding: 16px; max-width: 1400px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card .hd h2 { margin: 0; font-size: 15px; font-weight: 650; }
.card .bd { padding: 16px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--text-2); margin: 0 0 16px; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 2px; line-height: 1.1; }
.tile .delta { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* Badges and tiers */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tier { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; }
.tier.A { background: var(--tier-a); } .tier.B { background: var(--tier-b); } .tier.C { background: var(--tier-c); color: #0b0b0b; } .tier.dead, .tier.dnc { background: var(--tier-dead); color: #0b0b0b; }
:root[data-theme="dark"] .tier.C, :root:not([data-theme="light"]) .tier.C { color: #fff; }
.status { font-size: 12px; color: var(--text-2); }
.yes { color: var(--good); font-weight: 600; } .no { color: var(--text-3); }

/* Map */
.map-wrap { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
#map { height: 560px; border-radius: var(--radius); border: 1px solid var(--border); }
.leaflet-container { font: 13px var(--font); background: var(--surface-2); }
.pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; }
.pin span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: 12px; }
.pin.A { background: var(--tier-a); } .pin.B { background: var(--tier-b); } .pin.C { background: var(--tier-c); } .pin.C span { color: #0b0b0b; } .pin.dead, .pin.dnc { background: var(--tier-dead); } .pin.dead span, .pin.dnc span { color: #0b0b0b; }
.pin.listing { border-style: dashed; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 13px; color: var(--text-2); margin-top: 8px; align-items: center; }
.legend .tier { width: 18px; height: 18px; font-size: 10px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.chip { padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 13px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Lead list */
.lead-list { max-height: 560px; overflow: auto; }
.lead-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; color: inherit; }
.lead-row:hover, .lead-row.sel { background: var(--surface-2); }
.lead-row .t { font-weight: 600; font-size: 14px; }
.lead-row .m { font-size: 12px; color: var(--text-2); }
.lead-row .fit { font-weight: 650; text-align: right; }
.lead-row .fit small { display: block; font-weight: 400; color: var(--text-3); font-size: 11px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); font-weight: 600; }
tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Buttons and forms */
.btn { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--critical); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--text-2); }
.field input, .field select, .field textarea { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Detail page */
.detail { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
.score-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.breakdown { display: grid; grid-template-columns: 1fr 70px 2fr; gap: 6px 12px; font-size: 13px; align-items: center; }
.breakdown .w { color: var(--text-3); text-align: right; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.timeline .d { color: var(--text-3); font-size: 13px; }
#minimap { height: 220px; border-radius: 8px; border: 1px solid var(--border); }

/* Role gating */
body[data-role="viewer"] .admin-only { display: none !important; }
.viewer-note { display: none; font-size: 13px; color: var(--text-2); }
body[data-role="viewer"] .viewer-note { display: block; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 12px; margin: 14px 0; }
.divider:before, .divider:after { content: ""; flex: 1; height: 1px; background: var(--border); }

@media (max-width: 900px) {
  .map-wrap, .detail { grid-template-columns: 1fr; }
  #map { height: 380px; }
  .nav .links { display: none; }
  .kv { grid-template-columns: 1fr; }
}

/* Timeline band (37% rule) */
.tl-band { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 10px; font-size: 12px; color: var(--text-2); }
.tl-row { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin-bottom: 6px; }
.tl-phase.look { color: var(--tier-b); } .tl-phase.commit { color: var(--accent); font-weight: 600; }
.tl-bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: visible; }
.tl-look { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px 0 0 5px; background: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--tier-b) 25%, transparent) 4px 8px); }
.tl-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--accent); opacity: .85; }
.tl-tick { position: absolute; top: -3px; width: 2px; height: 16px; margin-left: -1px; background: var(--text-3); }
.tl-tick.rule { background: var(--tier-b); width: 3px; height: 20px; top: -5px; }
.tl-tick.task { height: 10px; top: 0; opacity: .6; }
.tl-tick.past { opacity: .35; }
.tl-now { position: absolute; top: -4px; width: 12px; height: 18px; margin-left: -6px; border-radius: 3px; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.tl-labels { position: relative; height: 26px; margin-top: 4px; }
.tl-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-size: 10px; color: var(--text-3); }
.tl-labels span.past { opacity: .5; }
.tl-labels span.alt { top: 13px; }
.tl-labels span:last-child { transform: translateX(-100%); }
@media (max-width: 900px) { .tl-labels { display: none; } }
