/* Milagro Metrics — light, left-rail layout */
:root {
  --ink: #111A17;
  --ink-2: #2D3834;
  --muted: #42504B;
  --subtle: #5B6763;
  --ground: #F5F7F6;
  --panel: #FFFFFF;
  --line: #E1E6E4;
  --line-2: #EEF1F0;
  --field: #C9D2CF;
  --accent: #0B7A61;
  --accent-ink: #075A47;
  --accent-soft: #EAF3EF;
  --land: #2D63C8;
  --cost: #D99A1E;
  --pass-bg: #DDF1E8; --pass-fg: #0B5F4B;
  --risk-bg: #FBF0DA; --risk-fg: #7E5200;
  --unk-bg: #F0F3F2; --unk-fg: #42504B;
  --todo-bg: #E8EEF9; --todo-fg: #1F4F8F;
  --loss-bg: #F8E1DC; --loss-fg: #8E2A1E;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font); font-size: 15px; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.rail { width: 248px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-size: 11px; color: var(--subtle); letter-spacing: .06em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 14px; }
.nav a svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.nav a.active { background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--subtle); }
.tree-block { display: flex; flex-direction: column; gap: 8px; }
.tree-block .eyebrow { padding: 0 10px; }
.tree-block input { font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 7px; border: 1px solid #D5DDDA; background: var(--ground); color: var(--ink); margin: 0 4px; }
.tree { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.tree .state { display: flex; justify-content: space-between; padding: 8px 10px 4px; font-weight: 700; color: var(--ink); text-decoration: none; border-radius: 6px; }
.tree .county { padding: 6px 10px 2px 18px; font-size: 12px; color: var(--subtle); }
.tree .city { display: flex; justify-content: space-between; padding: 6px 10px 6px 26px; color: var(--ink); text-decoration: none; border-radius: 6px; }
.tree .city.empty { color: var(--subtle); }
.tree .count { font-family: var(--mono); color: var(--subtle); }
.tree .active { background: var(--ink); color: #fff; }
.tree .active .count { color: #fff; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 28px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.crumbs { flex: 1 1 auto; font-size: 13px; color: var(--subtle); }
.crumbs a { color: var(--subtle); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .here { color: var(--ink); font-weight: 600; }
#search { font: inherit; font-size: 13px; width: 260px; max-width: 100%; padding: 9px 12px; border-radius: 7px; border: 1px solid #D5DDDA; background: var(--ground); color: var(--ink); }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); display: grid; place-items: center; color: var(--ink); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.menu-btn { display: none; }

#view { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 18px; outline: none; }
.loading, .empty-state { color: var(--subtle); padding: 24px 0; }

/* Buttons, tags */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 7px; border: 1px solid var(--field); background: var(--panel); color: var(--ink); text-decoration: none; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 38px; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.btn-dark:hover { background: #24302C; color: #fff; }
.btn[disabled] { opacity: .6; cursor: progress; }
.tag { display: inline-block; flex: none; align-self: start; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 7px; border-radius: 4px; white-space: nowrap; }
.tag.pass { background: var(--pass-bg); color: var(--pass-fg); }
.tag.risk { background: var(--risk-bg); color: var(--risk-fg); }
.tag.unknown { background: var(--unk-bg); color: var(--unk-fg); }
.tag.todo { background: var(--todo-bg); color: var(--todo-fg); }
.tag.loss { background: var(--loss-bg); color: var(--loss-fg); }
.tag.lg { font-size: 11px; padding: 4px 8px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #F0F3F2; color: var(--ink-2); }
.chip.unknown { background: transparent; border: 1px dashed #A9B5B1; color: var(--muted); }

/* Page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head .title-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.page-head h1 { font-size: 34px; font-weight: 700; letter-spacing: -.015em; line-height: 1.1; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 80ch; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.meta-row .mono { font-size: 12px; color: var(--subtle); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.kpi { background: var(--panel); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--subtle); font-weight: 600; }
.kpi .value { font-family: var(--mono); font-size: 23px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kpi .value.good { color: var(--accent); }
.kpi .value.bad { color: var(--loss-fg); }
.kpi .sub { font-size: 12px; color: var(--subtle); }

/* Panels */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); gap: 18px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; font-weight: 700; }
.panel-head .note, .note { font-size: 12px; color: var(--subtle); }
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 13px; align-items: start; }
.row .name { font-weight: 600; }
.row .detail { color: var(--subtle); font-size: 12px; }
.row.kv { grid-template-columns: 150px minmax(0, 1fr) auto; }
.row.kv .k { color: var(--subtle); }
.row.split { grid-template-columns: minmax(0, 1fr) auto; }

/* Scenario switch */
.scenario-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.segmented { display: flex; flex-wrap: wrap; gap: 4px; background: #F0F3F2; border-radius: 8px; padding: 3px; }
.segmented button { font: inherit; font-size: 13px; font-weight: 500; padding: 7px 12px; min-height: 36px; border: 0; border-radius: 6px; cursor: pointer; background: transparent; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--panel); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(17,26,23,.12); }

/* Strategy cards */
.strategies { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.strategy { border: 1px dashed var(--field); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.strategy.on { border: 1px solid var(--accent); background: #F1F9F5; }
.strategy .s-name { font-weight: 700; font-size: 14px; }
.strategy .s-value { font-family: var(--mono); font-size: 21px; }
.strategy.on .s-value { color: var(--accent); }
.strategy:not(.on) .s-name { color: var(--muted); }
.strategy:not(.on) .s-value { color: #8A9692; }
.strategy .s-sub { font-size: 12px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); font-weight: 700; padding: 9px 10px; white-space: nowrap; }
table.data td { padding: 10px; border-top: 1px solid var(--line-2); }
table.data .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data a { font-weight: 700; }

/* Sensitivity grid */
table.grid { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 380px; font-size: 14px; }
table.grid th { font-size: 12px; color: var(--subtle); font-weight: 700; padding: 4px; }
table.grid th.rowhead { text-align: left; font-size: 13px; color: var(--muted); }
table.grid th.rowhead.sel { color: var(--ink); }
table.grid td { text-align: center; font-family: var(--mono); padding: 12px 6px; border-radius: 6px; }
table.grid td.sel { outline: 2px solid var(--ink); outline-offset: -2px; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) 70px; gap: 12px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--cost); }
.bar-fill.land { background: var(--land); }
.bar-fill.subject { background: var(--ink); }
.bar-fill.comp { background: #9FB0AB; }
.bar-row .val { font-family: var(--mono); text-align: right; }
.est { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; background: #F0F3F2; color: var(--subtle); margin-left: 4px; }

/* Timeline */
.gantt { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; align-items: center; font-size: 13px; }
.gantt .scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--subtle); }
.gantt .lane { position: relative; height: 18px; background: repeating-linear-gradient(90deg, var(--line-2) 0, var(--line-2) 1px, transparent 1px, transparent 25%); }
.gantt .seg { position: absolute; top: 3px; height: 12px; border-radius: 3px; }

/* Scorecard */
.score-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; gap: 2px; }
.score-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0 18px; }
.score-grid .row { font-size: 12px; }

/* Map and site plan */
.map { height: 380px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.map-placeholder { height: 260px; border-radius: 8px; border: 1px dashed #B8C2BF; background-color: #F2F5F4; background-image: linear-gradient(#E6ECEA 1px, transparent 1px), linear-gradient(90deg, #E6ECEA 1px, transparent 1px); background-size: 28px 28px; display: grid; place-items: center; padding: 20px; }
.map-placeholder .card { display: flex; flex-direction: column; gap: 8px; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; text-align: center; align-items: center; }
.map-toggle { display: flex; gap: 4px; }
.siteplan svg { width: 100%; height: auto; max-height: 420px; display: block; }
.facts4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; font-size: 12px; }
.facts4 div { display: flex; flex-direction: column; gap: 2px; }
.facts4 span:first-child { color: var(--subtle); }
.facts4 span:last-child { font-family: var(--mono); }
.message { font-size: 13px; padding: 10px 12px; border-radius: 7px; }
.message.ok { background: var(--pass-bg); color: var(--pass-fg); }
.message.err { background: var(--loss-bg); color: var(--loss-fg); }

/* Market stats */
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stats3 > div { background: var(--ground); border-radius: 8px; padding: 12px; }
.stats3 .s-label { font-size: 12px; color: var(--subtle); }
.stats3 .s-value { font-family: var(--mono); font-size: 18px; }
.warn { font-size: 12px; color: var(--risk-fg); font-weight: 600; }

/* City sections (locations page) */
.city-section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.city-head { padding: 16px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; border-bottom: 1px solid var(--line); }
.city-head .names { display: flex; flex-direction: column; gap: 2px; flex: 1 1 260px; }
.city-head .names span { font-size: 12px; color: var(--subtle); }
.city-head h2 { font-size: 20px; }
.city-head .chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 2 1 420px; justify-content: flex-end; }
.city-section table.data th:first-child, .city-section table.data td:first-child { padding-left: 18px; }
.city-section table.data thead { background: #FAFBFB; }
.city-empty { padding: 16px 18px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }

/* Forms */
form.panel label.f { font-size: 13px; font-weight: 700; }
form.panel .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
form.panel input[type=text], form.panel input[type=url], form.panel textarea, form.panel select { font: inherit; font-size: 14px; padding: 11px 12px; border: 1px solid var(--field); border-radius: 7px; background: var(--panel); color: var(--ink); }
form.panel fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
form.panel legend { font-size: 13px; font-weight: 700; padding: 0 6px; }
form.panel .check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; min-height: 28px; }
form.panel .check input { width: 18px; height: 18px; margin: 1px 0 0; }
.fields-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.optional { font-weight: 500; color: var(--subtle); }
.error-text { color: var(--loss-fg); font-size: 13px; }

/* How it works */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.step.last { background: var(--ink); color: #fff; border-color: var(--ink); }
.step .num { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.step.last .num { color: #8FD3BC; }
.step .t { font-weight: 700; font-size: 17px; }
.step .d { font-size: 13px; color: var(--muted); line-height: 1.45; }
.step.last .d { color: #D8E0DD; }

/* Phone */
@media (max-width: 900px) {
  .rail { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .rail.open { transform: none; }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 14px; }
  #search { order: 5; width: 100%; }
  #view { padding: 16px 14px 40px; }
  .page-head h1 { font-size: 26px; }
  .row.kv { grid-template-columns: 110px minmax(0, 1fr) auto; }
  .bar-row { grid-template-columns: 120px minmax(0, 1fr) 60px; }
  .gantt { grid-template-columns: 110px minmax(0, 1fr); }
  .facts4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats3 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }

/* Sign in */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; align-items: stretch; }
.login-brand { justify-content: center; }
.login-card { gap: 14px; padding: 24px; }
.login-card h1 { font-size: 22px; }
.login-card .field { display: flex; flex-direction: column; gap: 6px; }
.login-card label.f { font-size: 13px; font-weight: 700; }
.login-card input { font: inherit; font-size: 15px; padding: 11px 12px; border: 1px solid var(--field); border-radius: 7px; background: var(--panel); color: var(--ink); }
.login-btn { justify-content: center; min-height: 44px; font-size: 14px; }
.login-wrap > .note { text-align: center; }
.rail-user { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.rail-user .who { display: flex; flex-direction: column; min-width: 0; }
.rail-user .who strong { overflow: hidden; text-overflow: ellipsis; }
.rail-user button { font: inherit; font-size: 12px; font-weight: 600; background: none; border: 1px solid var(--field); border-radius: 6px; padding: 6px 10px; cursor: pointer; color: var(--ink); min-height: 32px; }
.rail-user button:hover { border-color: var(--ink); }
