/* Layout: a deal desk. Sticky top bar with tabs; one working column for the
   queue, a map-plus-list split for sites, a board for the pipeline. */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --sunk: #e8ecf0;
  --line: #d3dae1;
  --fg: #16202b;
  --muted: #5a6876;
  --accent: #b86e00;        /* light-bar amber, darkened for contrast on light */
  --accent-ink: #ffffff;
  --accent-soft: #fbefdc;
  --go: #1f7a4d; --go-soft: #e1f2e9;
  --watch: #2a5f9e; --watch-soft: #e3ecf7;
  --stop: #b3261e; --stop-soft: #f8e3e1;
  --dot: #8a96a3;
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --f-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #11171d; --surface: #182029; --sunk: #0d1217; --line: #2a3541; --fg: #e6ebf0; --muted: #93a1af;
  --accent: #f0a529; --accent-ink: #1a1204; --accent-soft: #3a2a10;
  --go: #4cc489; --go-soft: #133325; --watch: #74a7e6; --watch-soft: #15263b; --stop: #f07b72; --stop-soft: #3a1714;
  --dot: #66727f; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #11171d; --surface: #182029; --sunk: #0d1217; --line: #2a3541; --fg: #e6ebf0; --muted: #93a1af;
  --accent: #f0a529; --accent-ink: #1a1204; --accent-soft: #3a2a10;
  --go: #4cc489; --go-soft: #133325; --watch: #74a7e6; --watch-soft: #15263b; --stop: #f07b72; --stop-soft: #3a1714;
  --dot: #66727f; color-scheme: dark }

* { box-sizing: border-box }
[hidden] { display: none !important }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--f-body); margin: 0; -webkit-text-size-adjust: 100% }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface) }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1180px; margin: 0 auto }
.num, .data { font-family: var(--f-data); font-variant-numeric: tabular-nums }

header.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line) }
.bar .wrap { display: flex; align-items: center; gap: 16px; padding-block: 10px; flex-wrap: wrap }
.brand { font: 700 22px/1 var(--f-display); letter-spacing: .02em; text-transform: uppercase; display: flex; align-items: center; gap: 8px }
.brand i { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); display: inline-block }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0 }
nav.tabs a { border: 0; background: none; padding: 6px 12px; border-radius: var(--r); font: 600 15px/1.2 var(--f-display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap }
nav.tabs a[aria-current="page"] { color: var(--fg); background: var(--sunk) }
nav.tabs .count { font: 500 11px var(--f-data); background: var(--accent); color: var(--accent-ink); border-radius: 9px; padding: 1px 6px; margin-left: 4px; vertical-align: 2px }
.asof { font: 12px var(--f-data); color: var(--muted) }
.pausedflag { font: 600 12px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--stop); background: var(--stop-soft); padding: 3px 8px; border-radius: 4px }

main { padding-block: 20px 60px }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0 }
h2 { font-size: 26px; font-weight: 600; letter-spacing: .01em }
h3 { font-size: 20px; font-weight: 600 }
.eyebrow { font: 600 12px var(--f-display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted) }
.muted { color: var(--muted) }
.stack { display: flex; flex-direction: column; gap: 16px }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }

/* Brief */
.brief { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: end; padding-bottom: 18px; border-bottom: 1px solid var(--line) }
.brief p { margin: 6px 0 0; max-width: 68ch }
.tally { display: flex; gap: 22px }
.tally div { display: flex; flex-direction: column }
.tally b { font: 600 28px/1 var(--f-display) }
.tally span { font-size: 12px; color: var(--muted) }
@media (max-width: 640px) { .brief { grid-template-columns: 1fr } }

/* Site card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 12px }
.card-head { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: start }
.card-head h3 { overflow-wrap: anywhere }
.score { font: 700 30px/1 var(--f-display); color: var(--accent); text-align: right }
.score small { display: block; font: 500 11px var(--f-data); color: var(--muted); letter-spacing: 0 }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden }
.facts div { background: var(--sunk); padding: 8px 10px; min-width: 0 }
.facts dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em }
.facts dd { margin: 0; font: 500 15px var(--f-data); overflow-wrap: anywhere }
.chips { display: flex; gap: 6px; flex-wrap: wrap }
.chip { font-size: 12.5px; padding: 3px 8px; border-radius: 4px; background: var(--sunk); color: var(--fg); border: 1px solid var(--line) }
.chip.high { background: var(--stop-soft); border-color: transparent; color: var(--stop) }
.chip.medium { background: var(--accent-soft); border-color: transparent; color: var(--accent) }
.chip.good { background: var(--go-soft); border-color: transparent; color: var(--go) }
.note { margin: 0; max-width: 72ch }
.why { font: 12px var(--f-data); color: var(--muted) }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); padding-top: 12px }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: var(--r); font-weight: 600 }
.btn:hover { border-color: var(--muted) }
.btn.pursue { background: var(--go); border-color: var(--go); color: var(--surface) }
.btn.watch { color: var(--watch); border-color: var(--watch) }
.btn.pass { color: var(--muted) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.btn.danger { color: var(--stop); border-color: var(--stop) }
.btn:disabled { opacity: .5; cursor: not-allowed }
.status { font: 600 12px var(--f-display); letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 4px }
.status.pursue { background: var(--go-soft); color: var(--go) }
.status.watch { background: var(--watch-soft); color: var(--watch) }
.status.pass { background: var(--sunk); color: var(--muted) }
.passbox { display: flex; gap: 6px; flex-wrap: wrap; align-items: center }
.linkish { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px }

/* Sites */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted) }
.filters select, .filters input { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; min-width: 0 }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start }
@media (max-width: 860px) { .split { grid-template-columns: 1fr } }
.mapbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 70px) }
.mapbox svg { width: 100%; height: auto; display: block }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 4px 6px 2px }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: 0 }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r) }
table { border-collapse: collapse; width: 100%; font-size: 13.5px }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap }
th { font: 600 12px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); position: sticky; top: 0; background: var(--surface); cursor: pointer }
td.name { white-space: normal; min-width: 180px }
tbody tr { cursor: pointer }
tbody tr:hover, tbody tr.sel { background: var(--sunk) }
td.r, th.r { text-align: right }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 20 }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); z-index: 21; overflow-y: auto; border-left: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 24px) 16px }
.drawer .close { float: right }
.kv { display: grid; grid-template-columns: 140px minmax(0,1fr); gap: 4px 12px; font-size: 14px }
.kv dt { color: var(--muted) }
.kv dd { margin: 0; overflow-wrap: anywhere }
textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 90px; resize: vertical }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13.5px }
.timeline li { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 8px }

/* Pipeline */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px }
.col { background: var(--sunk); border-radius: var(--r); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px }
.col h4 { margin: 0; font: 600 13px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; font-size: 13.5px; cursor: pointer }
.mini b { display: block; font-weight: 600 }

/* Outbox */
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 10px }
.msg input[type=text] { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px }
.blocked { color: var(--stop); font-size: 13px }

/* Health */
.health { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px }
.hcell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px }
.lamp { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--go) }
.lamp.warn { background: var(--accent) } .lamp.bad { background: var(--stop) }

/* Ask */
.answer { white-space: pre-wrap; font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 0 }

.empty { padding: 28px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); text-align: center }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: var(--r); z-index: 30; font-weight: 500 }
@media (prefers-reduced-motion: no-preference) { .card, .msg { transition: border-color .15s } }

nav.tabs a { text-decoration: none; display: inline-flex; align-items: center }
.dotflag { width: 8px; height: 8px; border-radius: 50%; background: var(--stop); display: inline-block; margin-left: 5px }
a.btn { text-decoration: none; display: inline-block; color: inherit }
.btn.big { padding: 12px 18px; font-size: 16px; width: 100% }
.selectable { user-select: all; word-break: break-all }
hr { border: 0; border-top: 1px solid var(--line); width: 100% }

/* Sign-in and setup */
body.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px }
.gatebox { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; display: grid; gap: 16px }
.gatebox.wide { width: min(520px, 100%) }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted) }
.field input { font-size: 16px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); color: var(--fg) }

/* Today: items that need Ian */
.needs { display: grid; gap: 8px }
.need { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 12px 14px; text-decoration: none; color: inherit }
.need.bad { border-left-color: var(--stop) }
.need b { font-weight: 600 }
.need .n { font: 700 26px/1 var(--f-display); color: var(--accent); min-width: 28px; text-align: center }
.need.bad .n { color: var(--stop) }
.allclear { padding: 14px; border-radius: var(--r); background: var(--go-soft); color: var(--go); font-weight: 500 }
.msg.focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft) }
.siterows { display: none }
.srow { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); cursor: pointer }
.srow .sc { font: 700 20px/1 var(--f-display); color: var(--accent); text-align: center }
.srow small { display: block; color: var(--muted); font-size: 12.5px }
details.mapfold > summary { cursor: pointer; font: 600 13px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 6px 2px; list-style: none }
details.mapfold > summary::-webkit-details-marker { display: none }

/* Phones: bottom tab bar, bigger touch targets, list instead of table */
@media (max-width: 700px) {
  body { font-size: 16px }
  header.bar .wrap { padding-block: 8px; gap: 10px }
  .brand { font-size: 20px }
  .asof { display: none }
  nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--surface); border-top: 1px solid var(--line);
    justify-content: space-around; gap: 0; padding: 4px 4px calc(env(safe-area-inset-bottom, 0px) + 4px); overflow: visible }
  nav.tabs a { flex: 1; justify-content: center; padding: 10px 2px; font-size: 13px; letter-spacing: .03em; position: relative }
  nav.tabs a[data-tab="audit"] { display: none }
  nav.tabs .count { position: absolute; top: 0; left: calc(50% + 24px); margin: 0; font-size: 10px; padding: 0 5px }
  nav.tabs .dotflag { position: absolute; top: 6px; left: calc(50% + 26px); margin: 0 }
  .facts { grid-template-columns: 1fr 1fr }
  .facts div:last-child:nth-child(odd) { grid-column: span 2 }
  main { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 90px) }
  h2 { font-size: 24px }
  .card, .msg { padding: 14px }
  .btn { padding: 10px 14px; font-size: 15px }
  .actions .btn { flex: 1 1 auto }
  .tally b { font-size: 24px }
  .tablewrap.sites { display: none }
  .siterows { display: block; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden }
  .mapbox { position: static }
  .drawer { width: 100%; border-left: 0 }
  .kv { grid-template-columns: 110px minmax(0,1fr) }
  .board { grid-template-columns: repeat(5, minmax(220px, 80vw)); scroll-snap-type: x mandatory }
  .col { scroll-snap-align: start }
  textarea { font-size: 16px }
  .msg input[type=text] { font-size: 16px }
  .filters label { flex: 1 1 45% }
  .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 80px) }
}
.msg, .need { scroll-margin-top: 80px }
.filters select, .filters input { height: 36px; font-size: 14px }
@media (max-width: 700px) { .filters select, .filters input { height: 42px; font-size: 16px } }

/* Aerial maps */
.aerialwrap { display: grid; gap: 4px }
.aerial { width: 100%; border: 1px solid var(--line); border-radius: var(--r); display: block; background: var(--sunk) }
.aerial.none { padding: 28px; text-align: center; color: var(--muted); font-size: 13px }
.locnote { margin: 0; font-size: 12.5px; color: var(--accent) }
.maplinks { gap: 16px }
.mini { display: grid; gap: 8px; cursor: default }
.mini .aerial { border-radius: 4px }
.minilink { text-decoration: none; color: inherit; display: grid }
.minilink:hover b { text-decoration: underline }
.watchgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px }

/* Site page */
.crumbs { margin: 0 }
.sitepage h2 { font-size: 30px }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 10px; align-content: start }
.panel h3 { font-size: 18px; letter-spacing: .02em }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px }
.scoretab { font-size: 14.5px }
.scoretab td { white-space: normal; border-bottom: 1px solid var(--line) }
.scoretab td.num { width: 56px; text-align: right; font-family: var(--f-data); font-weight: 500 }
.scoretab td.pos { color: var(--go) } .scoretab td.neg { color: var(--stop) }
.scoretab tr.total td { font-weight: 700; border-bottom: 0 }
table.fin th { position: static; cursor: default; white-space: normal; width: 34%; font: 600 13px var(--f-body); letter-spacing: 0; text-transform: none; color: var(--fg); background: none }
table.fin td { white-space: normal }
table.fin td.num { white-space: nowrap }
.warntext { color: var(--stop) }
.small { font-size: 12.5px; margin: 0 }
h4.sub { margin: 6px 0 0; font: 600 13px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted) }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px }
.checks label { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer }
.checks input { width: 18px; height: 18px; accent-color: var(--go) }
.checks input:checked + span { color: var(--muted); text-decoration: line-through }
@media (max-width: 700px) {
  .sitepage h2 { font-size: 24px }
  table.fin tr { display: grid; grid-template-columns: minmax(0,1fr) auto; border-bottom: 1px solid var(--line) }
  table.fin th, table.fin td { border: 0; width: auto }
  table.fin td.muted { grid-column: 1 / -1; padding-top: 0; font-size: 12.5px }
  .checks label { padding: 10px 4px }
}
