/* Layout: a working tool, summary first. One column of facility sections,
   each a row of headline tiles, a list of things to look at, then detail
   cards in a two-up grid that stacks on phones. */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eaeef2;
  --ink: #17212b;
  --ink-2: #4d5b69;
  --line: #d5dce3;
  --accent: #1f5f8b;        /* steel blue, roll-up door */
  --accent-ink: #ffffff;
  --rented: #1f5f8b;
  --vacant: #b9c6d2;
  --unavailable: #c98a2b;
  --good: #1e7a4c;
  --warn: #a8640f;
  --bad: #b3261e;
  --focus: #e0a526;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151b;
    --surface: #17202a;
    --surface-2: #1f2b37;
    --ink: #e6edf3;
    --ink-2: #9fb0c0;
    --line: #2c3a48;
    --accent: #6fb1e0;
    --accent-ink: #0f151b;
    --rented: #5aa2d6;
    --vacant: #3b4c5c;
    --unavailable: #d9a24e;
    --good: #5cc28b;
    --warn: #e0a64f;
    --bad: #ef7d74;
    --focus: #f0c45a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); padding-bottom: env(safe-area-inset-bottom, 0px); }
.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 12px; }
.brand { font-weight: 750; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand span { font-weight: 450; color: var(--ink-2); }
.privacy-pill { font-size: 0.8rem; font-weight: 600; color: var(--good); border: 1px solid currentColor; border-radius: 999px; padding: 2px 10px; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Feedback: a button in the top bar and a card under the results. */
.feedback-btn { display: inline-flex; align-items: center; gap: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.05rem; text-decoration: none; border-radius: 999px; padding: 12px 22px; white-space: nowrap; box-shadow: 0 1px 2px rgb(0 0 0 / 0.15); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.feedback-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgb(0 0 0 / 0.18); }
.feedback-btn::after { content: "→"; font-size: 1.1em; }
.feedback-btn-small { font-size: 0.85rem; padding: 6px 14px; gap: 6px; }
.feedback-time { font-size: 0.8rem; font-weight: 600; background: color-mix(in srgb, var(--accent-ink) 22%, transparent); border-radius: 999px; padding: 2px 8px; }
.feedback-card { display: flex; align-items: center; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap; margin-block: 8px 28px; padding: 24px 28px; border-radius: var(--radius); border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.feedback-card > div { flex: 1 1 340px; }
.feedback-card h2 { font-size: 1.3rem; margin-bottom: 6px; }
.feedback-card p { margin: 0; color: var(--ink-2); max-width: 62ch; }
@media (max-width: 560px) { .topbar .privacy-pill { display: none; } .feedback-card { padding: 20px; } .feedback-card .feedback-btn { width: 100%; justify-content: center; } }
@media (prefers-reduced-motion: reduce) { .feedback-btn { transition: none; } .feedback-btn:hover { transform: none; } }

.intro { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; padding-block: 40px 24px; align-items: start; }
.intro h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); letter-spacing: -0.02em; max-width: 22ch; }
.lede { font-size: 1.1rem; color: var(--ink-2); max-width: 60ch; }
.steps { padding-left: 1.2em; color: var(--ink-2); display: grid; gap: 4px; margin: 0; }
.privacy-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.privacy-box h2 { font-size: 1rem; margin-bottom: 8px; }
.privacy-box p { margin: 0 0 8px; color: var(--ink-2); font-size: 0.95rem; }
.privacy-box p:last-child { margin: 0; }

.loader { display: grid; gap: 12px; padding-bottom: 24px; }
.dropzone { position: relative; display: grid; place-items: center; text-align: center; gap: 4px; min-height: 140px; padding: 24px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--surface-2); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-title { font-weight: 650; font-size: 1.1rem; }
.dz-sub { color: var(--ink-2); font-size: 0.9rem; }
.loader-actions { display: flex; gap: 8px; flex-wrap: wrap; }
button { font: inherit; border-radius: 8px; padding: 8px 14px; cursor: pointer; border: 1px solid transparent; }
.btn-secondary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: var(--line); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-list li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 0; }
.file-list .fname { font-family: var(--mono); font-size: 0.82rem; overflow-wrap: anywhere; }
.tag { font-size: 0.75rem; font-weight: 650; border-radius: 6px; padding: 1px 8px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag.ok { color: var(--good); }
.tag.err { color: var(--bad); }
.file-list .msg { color: var(--ink-2); flex-basis: 100%; }

.results { display: grid; gap: 40px; padding-bottom: 32px; }
.portfolio, .facility { display: grid; gap: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.section-head h2 { font-size: 1.5rem; letter-spacing: -0.01em; }
.asof { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 0.9rem; flex-wrap: wrap; }
.asof input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.note { color: var(--ink-2); font-size: 0.85rem; margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.tile-label { font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.tile-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile-sub { font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tile.bad .tile-value { color: var(--bad); }
.tile.warn .tile-value { color: var(--warn); }

.actions { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 16px 20px; }
.actions h3 { font-size: 1.05rem; margin-bottom: 8px; }
.actions ol { margin: 0; padding-left: 1.2em; display: grid; gap: 10px; }
.actions li b { display: block; }
.actions li span { color: var(--ink-2); font-size: 0.93rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.card h3 { font-size: 1.05rem; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw-rented { background: var(--rented); }
.sw-vacant { background: var(--vacant); }
.sw-unavailable { background: var(--unavailable); }
.sw-in { background: var(--rented); }
.sw-out { background: var(--unavailable); }

.size-rows { display: grid; gap: 10px; }
.size-row { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; font-variant-numeric: tabular-nums; }
.size-name { font-weight: 650; }
.stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.stack span { display: block; height: 100%; }
.stack .s-rented { background: var(--rented); }
.stack .s-vacant { background: var(--vacant); }
.stack .s-unavailable { background: var(--unavailable); }
.size-count { font-size: 0.85rem; white-space: nowrap; }
.size-rates { grid-column: 2 / -1; font-size: 0.8rem; color: var(--ink-2); }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) auto; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bad); border-radius: 4px; }
.bar-fill.mild { background: var(--warn); }
.bar-value { white-space: nowrap; }

.moves-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; align-items: end; height: 180px; border-bottom: 1px solid var(--line); position: relative; }
.month { display: grid; grid-template-rows: 1fr auto 1fr; height: 100%; min-width: 0; }
.month .up, .month .down { display: flex; justify-content: center; }
.month .up { align-items: flex-end; }
.month .down { align-items: flex-start; }
.month .up span, .month .down span { width: 70%; max-width: 22px; border-radius: 3px; }
.month .up span { background: var(--rented); }
.month .down span { background: var(--unavailable); }
.month .axis { height: 1px; background: var(--line); }
.month-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; font-size: 0.72rem; color: var(--ink-2); text-align: center; }
.reasons { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 0.9rem; }
.reasons li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--line); padding-bottom: 2px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.mini th, .mini td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.mini th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); font-weight: 650; }
.mini td.num, .mini th.num { text-align: right; }

.definitions { margin-block: 8px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.definitions summary { cursor: pointer; font-weight: 650; }
.definitions dl { margin: 12px 0 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 0.92rem; }
.definitions dt { font-weight: 650; }
.definitions dd { margin: 0; color: var(--ink-2); }
.footer { color: var(--ink-2); font-size: 0.85rem; padding-block: 8px 32px; border-top: 1px solid var(--line); }
.footer p { margin: 8px 0 0; }

@media (max-width: 760px) {
  .intro { grid-template-columns: 1fr; gap: 20px; padding-block: 24px 16px; }
  .definitions dl { grid-template-columns: 1fr; }
  .definitions dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* v2: trends, charts, file controls */
:root { --econ: #2f8f6b; --noi: #2f8f6b; --revenue: #1f5f8b; --expenses: #c98a2b; --collected: #7a4fb3; }
@media (prefers-color-scheme: dark) { :root { --econ: #5cc28b; --noi: #5cc28b; --revenue: #5aa2d6; --expenses: #d9a24e; --collected: #b48be6; } }
.card.wide { grid-column: 1 / -1; }
/* Cards paired by height; both stretch to the taller one. */
.cards.pair { align-items: stretch; }
.cards > .wide { grid-column: 1 / -1; }
.cards > .actions { min-width: 0; }
/* When paired with a taller card, the aging bars spread to fill it. */
.card.aging { grid-template-rows: auto 1fr; }
.card.aging .bars { align-content: space-evenly; }
/* A wide card's content side by side, stacking on narrow screens. */
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px 32px; align-items: start; }
.split-col { display: grid; gap: 12px; align-content: start; min-width: 0; }
.trends { display: grid; gap: 12px; }
.trends-head { font-size: 1.1rem; padding-top: 8px; border-top: 1px solid var(--line); }
.sw-occ, .sw-revenue { background: var(--revenue); }
.sw-econ, .sw-noi { background: var(--econ); }
.sw-expenses { background: var(--expenses); }
.sw-collected { background: var(--collected); }
svg.chart { display: block; overflow: visible; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .zero { stroke: var(--ink-2); stroke-width: 1; }
svg.chart .axis { fill: var(--ink-2); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
svg.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .line.occ, svg.chart .dot.occ { stroke: var(--revenue); }
svg.chart .line.econ, svg.chart .dot.econ { stroke: var(--econ); }
svg.chart .line.noi, svg.chart .dot.noi { stroke: var(--noi); }
svg.chart .line.collected, svg.chart .dot.collected { stroke: var(--collected); stroke-dasharray: 5 4; }
svg.chart .dot { fill: var(--surface); stroke-width: 2; }
svg.chart .dot.collected { stroke-dasharray: none; }
svg.chart .bar.revenue { fill: var(--revenue); }
svg.chart .bar.expenses { fill: var(--expenses); }
.remember { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; cursor: pointer; }
.remember input { width: 16px; height: 16px; }
.loader-actions { align-items: center; }
.loader-actions .note { flex-basis: 100%; }
.file-list .assign { display: inline-flex; gap: 6px; align-items: center; font-size: 0.85rem; color: var(--ink-2); }
.file-list select { font: inherit; font-size: 0.85rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px; max-width: 100%; }
.file-list .remove { margin-left: auto; padding: 0 8px; line-height: 1.6; background: transparent; border: 1px solid var(--line); color: var(--ink-2); }

/* trailing 12-month NOI */
:root { --ttm: #17212b; }
@media (prefers-color-scheme: dark) { :root { --ttm: #e6edf3; } }
.sw-ttm { background: var(--ttm); }
svg.chart .line.ttm { stroke: var(--ttm); stroke-width: 3; }
svg.chart .dot.ttm { stroke: var(--ttm); fill: var(--ttm); }

/* v3: calmer layout. Card titles carry a small source label instead of a
   sentence; the loader shrinks once there are results. */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.card-head .src { font-size: 0.75rem; color: var(--ink-2); }
.loader.compact .dropzone { min-height: 0; padding: 12px 16px; }
.loader.compact .dz-sub { display: none; }
.howto { font-size: 0.9rem; color: var(--ink-2); }
.howto summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.howto .steps { margin-top: 8px; }
.steps-optional { color: var(--ink-2); font-size: 0.92rem; margin: 10px 0 0; }

/* How a rent roll was read, in the file list. */
.file-list .readas { flex-basis: 100%; display: grid; gap: 4px; font-size: 0.85rem; color: var(--ink-2); border-top: 1px dashed var(--line); padding-top: 6px; }
.file-list .readas p { margin: 0; overflow-wrap: anywhere; }
.file-list .readas b { color: var(--ink); font-weight: 600; }
.file-list .readas-look { color: var(--warn); font-weight: 600; }
.readas-edit summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.readas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 6px 16px; margin-top: 8px; }
.readas-grid label, .readas-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.readas-grid label > span:first-child, .readas-line > span, .readas-statuses > span { color: var(--ink); }
.readas-grid select { max-width: 60%; }
.readas-grid .fixed { font-family: var(--mono); font-size: 0.8rem; }
.readas-line { margin-top: 8px; justify-content: flex-start; }
.readas-statuses { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; }
.readas-statuses label { display: inline-flex; gap: 6px; align-items: center; }
.readas-statuses label.unsorted { color: var(--warn); font-weight: 600; }
