/* Offline app: no web font services. Segoe UI where installed (Windows); elsewhere Selawik, Microsoft's
   metric-compatible Segoe UI stand-in (SIL OFL, bundled under the public brand folder so the sign-in page
   can load it), so pages render alike on every OS. */
@font-face { font-family: "Selawik"; src: url("/static/brand/fonts/selawik-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Selawik"; src: url("/static/brand/fonts/selawik-semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Selawik"; src: url("/static/brand/fonts/selawik-bold.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }
:root {
  /* Design tokens: every size, radius, height and shadow below comes from here. */
  --text-xs: 12px; --text-sm: 13px; --text-md: 14px; --text-lg: 16px; --text-xl: 18px; --text-2xl: 20px; --text-3xl: 24px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 10px; --radius-full: 999px;
  --control-sm: 32px; --control-md: 36px; --control-lg: 40px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05); --shadow-md: 0 8px 24px rgba(16, 24, 40, .12); --shadow-lg: 0 24px 56px rgba(16, 24, 40, .24);
  --border: #e3e8ef; --border-strong: #cfd6df;
  /* Buttons, links and accents all use the logo orange #ff5a0a (client choice, 2026-10-30).
     White on it is about 3:1, below WCAG AA for body-size text; #d04708 is the AA-passing shade if needed. */
  --brand-strong: #ff5a0a; --brand-strong-hover: #e64f05;
  --gutter: var(--space-10);
}
:root {
  --bar: #1a2e47; --bar-ink: #e8edf2; --bar-muted: #9fb0c3; --brand: #ff5a0a;
  --canvas: #eef1f4; --panel: #fff; --ink: #18222d; --muted: #5d6c7b; --faint: #8a97a4; --line: #dde2e8;
  --soft: #f6f7f9; --accent: #ff5a0a; --accent-ink: #c2410c; --accent-soft: #fff1e6;
  --ok: #2f7d3f; --ok-soft: #e9f5ec; --warn: #8a6100; --warn-soft: #fbf3dc; --bad: #9a2f22; --bad-soft: #fbecea;
  --info: #1d4ed8; --info-soft: #eaf1fe;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --bar-h: 56px;
  font: var(--text-md)/1.5 "Segoe UI Variable Text", "Segoe UI", "Selawik", system-ui, -apple-system, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--canvas); }
[hidden] { display: none !important; }
a { color: var(--accent-ink); }
h1, h2, h3 { line-height: 1.25; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- top bar ------------------------------------------------------------------ */
.bar { position: sticky; top: 0; z-index: 10; height: var(--bar-h); background: var(--bar); color: var(--bar-ink);
       display: flex; align-items: center; gap: 24px; padding: 0 28px 0 32px; box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; flex: none; }
.brand img { flex: none; display: block; }
.brand b { font-size: var(--text-xl); font-weight: 700; letter-spacing: -.005em; }
.brand-sep { width: 1px; height: 24px; background: rgba(255, 255, 255, .22); margin: 0 4px; }
.brand span { font-size: var(--text-md); color: var(--bar-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.bar nav { display: flex; height: 100%; margin-left: auto; }
.bar nav a { position: relative; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4); color: var(--bar-ink);
        text-decoration: none; font-weight: 500; font-size: var(--text-md); }
.bar nav a:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.bar nav a[aria-current="page"] { color: #fff; font-weight: 600; }
/* The active tab's line sits a little above the bar's edge so content below never hides it. */
.bar nav a[aria-current="page"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px;
        border-radius: var(--radius-sm); background: var(--brand); }
.count { font: 700 var(--text-xs)/1 var(--mono); min-width: 22px; padding: 5px 6px; border-radius: var(--radius-sm); text-align: center;
         background: rgba(255, 255, 255, .14); color: #fff; }
.count.hot { background: var(--brand); }
.bar .note { margin: 0 0 0 auto; display: flex; align-items: center; gap: 12px; max-width: 400px; padding: 8px 14px; border-radius: var(--radius-lg);
             background: rgba(255, 255, 255, .08); font-size: var(--text-xs); line-height: 1.4; color: var(--bar-ink); }
/* Desktop only (data sources and privacy); the web edition keeps it hidden. */
.bar .note[hidden] { display: none; }
.bar .note[hidden] + .user { margin-left: auto; }
.bar .note svg { flex: none; width: 22px; height: 22px; color: var(--bar-ink); }

.user { position: relative; flex: none; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px; border: 0; border-radius: var(--radius-full); background: none; color: var(--bar-ink);
            cursor: pointer; }
.user-btn:hover { background: rgba(255, 255, 255, .08); }
.user-btn svg { width: 18px; height: 18px; transition: transform .15s; }
.user-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.user .avatar { width: 40px; height: 40px; border-radius: 50%; background: #a593f7; color: #fff; display: grid; place-items: center;
                font-weight: 700; font-size: var(--text-md); letter-spacing: .02em; text-transform: uppercase; }
.user-menu { position: absolute; right: 0; top: calc(100% + 10px); min-width: 240px; background: var(--panel); color: var(--ink);
             border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(19, 33, 61, .18); padding: 6px; }
.user-menu .user-email { margin: 0; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); font-size: var(--text-sm); color: var(--muted);
                         overflow-wrap: anywhere; }
.user-menu .user-email b { display: block; color: var(--faint); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.menu-item { display: block; width: 100%; margin-top: 6px; padding: 9px 12px; border: 0; border-radius: var(--radius-md); background: none; font: inherit;
             font-size: var(--text-sm); font-weight: 600; text-align: left; color: var(--ink); cursor: pointer; }
.menu-item:hover { background: var(--soft); color: var(--bad); }
@media (max-width: 1240px) { .bar .note { display: none; } .user { margin-left: auto; } }

/* --- new screen view ------------------------------------------------------------- */
.workspace { display: grid; grid-template-columns: 400px minmax(0, 1fr); height: calc(100vh - var(--bar-h)); }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.side form { padding: var(--space-5) var(--space-5) var(--space-2); flex: 1; }
.side footer { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: var(--space-4) var(--space-5); }
h1 { font-size: var(--text-2xl); font-weight: 700; margin: 0 0 var(--space-1); letter-spacing: -.01em; }
.lede { margin: 0 0 16px; color: var(--muted); font-size: var(--text-sm); }
.section { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.section-title { font-size: var(--text-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #4a5a70; margin: 0 0 6px; }
label { display: block; font-size: var(--text-sm); font-weight: 600; color: #3b4a64; margin: var(--space-3) 0 6px; }
input, select { height: var(--control-md); }
input[type=file] { height: auto; }
input, select, textarea { width: 100%; font: inherit; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-md);
                          background: var(--panel); color: var(--ink); }
input:hover, select:hover, textarea:hover { border-color: #c4ccd5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
/* Dropdown lists open directly under their box, full width, in the app's style (Chrome 135+);
   other browsers keep their native list. */
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
  select::picker-icon { color: var(--muted); transition: rotate .15s; }
  select:open::picker-icon { rotate: 180deg; }
  ::picker(select) { margin-top: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-md);
                     background: var(--panel); box-shadow: var(--shadow-md); }
  option { display: flex; align-items: center; gap: var(--space-2); padding: 8px 10px; border-radius: 6px; color: var(--ink); cursor: pointer; }
  option:hover, option:focus-visible { background: var(--soft); outline: none; }
  option:checked { color: var(--brand-strong); font-weight: 600; }
  option::checkmark { color: var(--brand-strong); }
  option:disabled { color: var(--faint); cursor: default; background: none; }
}
input[type=number] { font-family: var(--mono); font-size: var(--text-sm); }
/* Placeholders are examples, never mistaken for entered values: lighter, and in the text font. */
input::placeholder, textarea::placeholder { color: #9aa6b4; opacity: 1; font-family: "Segoe UI Variable Text", "Segoe UI", "Selawik", system-ui, -apple-system, sans-serif; }
input[type=number]::placeholder { font-size: var(--text-sm); }
textarea { font: var(--text-sm)/1.45 var(--mono); padding: 8px 10px; }
input[type=file] { padding: 5px; font-size: var(--text-sm); background: var(--soft); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { font: inherit; font-size: var(--text-sm); height: var(--control-sm); padding: 0 var(--space-3); border: 1px solid var(--line); background: var(--soft);
                  border-radius: var(--radius-md); cursor: pointer; color: var(--ink); }
.presets button:hover { border-color: var(--accent); background: var(--accent-soft); }
details { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--soft); }
details[open] { background: var(--panel); }
summary { cursor: pointer; font-size: var(--text-sm); font-weight: 600; padding: 9px 12px; list-style: none; display: flex; justify-content: space-between; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font: 600 var(--text-md)/1 var(--mono); color: var(--faint); }
details[open] summary::after { content: "−"; }
details > :not(summary) { margin-left: 12px; margin-right: 12px; }
details > :last-child { margin-bottom: 12px; }
.hint { font-size: var(--text-xs); color: var(--muted); margin: 6px 0 0; }
.error { color: var(--bad); background: var(--bad-soft); border-radius: var(--radius-md); padding: 8px 10px; font-size: var(--text-sm); margin: 0 0 10px; }
.side footer .hint { margin-top: 8px; }

.map-pane { position: relative; background: #cfdbe5; min-height: 420px; }
#map-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.map-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.coords { position: absolute; left: 14px; bottom: 52px; z-index: 2; background: rgba(22, 32, 43, .88); color: var(--bar-ink);
          border-radius: var(--radius-md); padding: 8px 12px; font: var(--text-xs)/1.5 var(--mono); pointer-events: none; }
.coords b { color: #fff; font-weight: 600; }

/* --- shared: status chips and actions ---------------------------------------------- */
.chip { font-size: var(--text-xs); font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.chip.done { color: var(--ok); background: var(--ok-soft); }
.chip.running, .chip.queued { color: var(--warn); background: var(--warn-soft); }
.chip.failed { color: var(--bad); background: var(--bad-soft); }
/* A finished cycle: waiting for a reviewer (blue), then approved (green). */
.chip.ready_for_review { color: var(--info); background: var(--info-soft); }
.chip.approved { color: var(--ok); background: var(--ok-soft); }
.chip.rejected, .chip.project-rejected { color: var(--bad); background: var(--bad-soft); }
/* Project approval: a draft is neutral, waiting for approval amber. */
.chip.project-draft { color: var(--muted); background: #eef1f5; }
.chip.project-pending_approval { color: var(--warn); background: var(--warn-soft); }
.chip.demo { color: var(--muted); background: var(--soft); border: 1px solid var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--text-sm); }
.actions a { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.actions a:hover { text-decoration: underline; }
.link-btn { font: inherit; font-size: var(--text-sm); background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; }
.link-btn:hover { color: var(--bad); text-decoration: underline; }
.log { margin: 6px 0 0; padding: 0; list-style: none; font-size: var(--text-xs); color: var(--muted); }
.log li::before { content: "› "; color: var(--faint); }
.log li:last-child { color: var(--ink); }

/* --- history view ------------------------------------------------------------------- */
.page { max-width: 1600px; margin: 0 auto; padding: var(--space-6) var(--gutter) var(--space-10); }
.page h1, .project-head h1, .res-title h1 { font-size: var(--text-3xl); font-weight: 700; letter-spacing: -.01em; margin: 0; }
.page-head p { font-size: var(--text-md); }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-sm); }
.tools { display: flex; gap: 8px; }
.tools input { width: 240px; } .tools select { width: 150px; }
.table-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--text-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #4a5a70;
     background: #f3f5f8; padding: 10px 14px; border-bottom: 1px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: var(--text-sm); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
td .name { font-weight: 600; }
td .sub { color: var(--muted); font: var(--text-xs)/1.5 var(--mono); }
td .err { color: var(--bad); font-size: var(--text-xs); margin-top: 4px; max-width: 52ch; }
td.num { font-family: var(--mono); font-size: var(--text-sm); white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.demo { margin-top: 14px; display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px dashed #c9d1da;
        border-radius: var(--radius-lg); padding: 12px 16px; font-size: var(--text-sm); }
.demo p { margin: 0; color: var(--muted); flex: 1; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); height: auto; }
  .side { border-right: 0; } .map-pane { height: 60vh; order: -1; }
  .bar { gap: 8px; padding: 0 12px; } .bar nav a { padding: 0 10px; }
  .bar .note, .brand span, .brand-sep { display: none; } .user { margin-left: auto; }
  #view-history .col-opt { display: none; }
  .tools input { width: 160px; }
}

/* --- results view (#screen/<id>) ------------------------------------------------------ */
.results { display: grid; grid-template-rows: auto minmax(0, 1fr); height: calc(100vh - var(--bar-h)); }
.res-top { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--text-sm); color: var(--faint); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent-ink); text-decoration: underline; }
.crumbs span[aria-current] { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--faint); }
.res-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 6px; flex-wrap: wrap; }
.res-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.res-title h1 { font-size: var(--text-xl); margin: 0; }
.res-meta { margin: 1px 0 0; font-size: var(--text-sm); color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.res-meta .basis { font-weight: 600; padding: 1px 8px; border-radius: var(--radius-sm); background: var(--soft); border: 1px solid var(--line); }
.res-meta .basis-partial, .res-meta .basis-complete { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.res-nav { display: flex; align-items: center; gap: 8px; }
.res-pos { font: var(--text-xs) var(--mono); color: var(--faint); }
.tabbar { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; }
.tabs button { font: inherit; font-size: var(--text-sm); font-weight: 600; padding: 9px 16px; border: 0; background: none; cursor: pointer;
               color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:disabled { color: var(--faint); cursor: default; }
.exports { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 8px; }
.res-body { position: relative; background: var(--canvas); min-height: 0; }
.res-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.res-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }
.card-view { position: absolute; inset: 0; overflow-y: auto; padding: 22px 20px 40px; }

/* Evidence card */
.ecard { max-width: 1040px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-6); }
.ecard h2 { font-size: var(--text-lg); margin: 0 0 4px; }
.ecard .tier { display: inline-block; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-sm); margin-right: 8px; }
.tier.Low { color: var(--bad); background: var(--bad-soft); } .tier.Moderate { color: var(--warn); background: var(--warn-soft); }
.tier.High { color: var(--ok); background: var(--ok-soft); }
.ecard .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.ecard .stat { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 10px 12px; }
.ecard .stat b { display: block; font: 600 var(--text-xl) var(--mono); }
.ecard .stat span { font-size: var(--text-xs); color: var(--muted); }
.ecard ul { margin: 6px 0 14px; padding-left: 18px; color: var(--muted); font-size: var(--text-sm); }
.ecard table td, .ecard table th { font-size: var(--text-sm); padding: 8px 10px; }
.reading { font-weight: 700; font-size: var(--text-xs); padding: 2px 7px; border-radius: var(--radius-sm); }
.reading.supportive { color: var(--ok); background: var(--ok-soft); } .reading.unfavourable { color: var(--bad); background: var(--bad-soft); }
.reading.neutral { color: var(--muted); background: var(--soft); } .reading.unknown { color: var(--faint); background: var(--soft); }
.ecard .method { font-size: var(--text-xs); color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin: 14px 0 0; }

@media print {
  body.print-card > *:not(#view-screen) { display: none !important; }
  body.print-card .res-top { display: none !important; }
  body.print-card .results, body.print-card .res-body, body.print-card .card-view { display: block; position: static; height: auto; overflow: visible; }
  body.print-card .ecard { border: 0; padding: 0; max-width: none; }
}

/* --- projects --------------------------------------------------------------------------- */
.ghost.wide { margin-top: var(--space-2); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 20px; }
.pcard { position: relative; display: flex; flex-direction: column; background: var(--panel); border: 1px solid #e3e8ef; border-radius: var(--radius-lg);
         padding: var(--space-5); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; }
.pcard:hover { border-color: #f3b38e; box-shadow: 0 10px 28px rgba(19, 33, 61, .10); transform: translateY(-1px); }
.pcard:focus-within { border-color: var(--brand); }
.pc-head { display: flex; align-items: center; gap: 10px; }
.pcard h3 { flex: 1; min-width: 0; margin: 0; font-size: var(--text-lg); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-link { color: var(--ink); text-decoration: none; }
.pc-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }   /* the whole card opens the project */
.pc-link:focus-visible { outline: none; }
.pcard .chip { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); font-weight: 500; letter-spacing: 0; padding: 4px 10px; border-radius: var(--radius-sm); }
.pcard .chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.idle { color: var(--muted); background: #eef1f5; }
.pc-menu { position: relative; z-index: 2; flex: none; }
.pc-more { width: 32px; height: 32px; margin-right: -8px; border: 0; border-radius: var(--radius-md); background: none; color: var(--muted); cursor: pointer;
           display: grid; place-items: center; }
.pc-more:hover, .pc-more[aria-expanded="true"] { background: var(--soft); color: var(--ink); }
.pc-more .ico svg { width: 20px; height: 20px; }
.pc-items { position: absolute; right: -8px; top: calc(100% + 4px); min-width: 180px; padding: 6px; background: var(--panel);
            border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 12px 30px rgba(19, 33, 61, .16); }
.pc-items a, .pc-items button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-md); background: none; font: inherit;
                                font-size: var(--text-sm); text-align: left; color: var(--ink); text-decoration: none; cursor: pointer; }
.pc-items a:hover, .pc-items button:hover { background: var(--soft); }
.pc-items .pc-remove { color: var(--bad); border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; }
.pcard .where { margin: 6px 0 0; padding-bottom: 14px; border-bottom: 1px solid #e8ecf1; font-size: var(--text-sm); color: var(--muted); }
.pcard .where .sep { margin: 0 10px; }
.pcard .facts { display: grid; grid-template-columns: repeat(3, 1fr); padding: 16px 0; border-bottom: 1px solid #e8ecf1; }
.pcard .fact { display: flex; gap: 12px; align-items: flex-start; padding: 0 12px; min-width: 0; border-left: 1px solid #e8ecf1; }
.pcard .fact:first-child { padding-left: 0; border-left: 0; }
.pcard .fact .ico svg { width: 24px; height: 24px; color: var(--ink); margin-top: 2px; }
.pcard .fact b { display: block; font-size: var(--text-lg); font-weight: 700; line-height: 1.3; }
.pcard .fact span { font-size: var(--text-sm); color: var(--muted); white-space: nowrap; }
.pcard .foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; padding-top: 14px; font-size: var(--text-sm); color: var(--muted); }
.pcard .foot > span { display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; white-space: nowrap; border-left: 1px solid #e3e8ef; }
.pcard .foot > span:first-child { padding-left: 0; border-left: 0; }
.pcard .foot .ico svg { width: 18px; height: 18px; display: block; }
#view-projects .page-head, #view-history .page-head { margin-bottom: var(--space-5); align-items: center; }
#view-projects .tools, #view-history .tools { gap: var(--space-3); align-items: center; }
.search { position: relative; margin: 0; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink); pointer-events: none; }
.tools .search input { width: 280px; padding-left: 36px; font-size: var(--text-md); }
#unassigned { margin-top: 26px; font-size: var(--text-md); }
#unassigned a { color: var(--brand); }
.map-panel .map-off { background: var(--soft); }
.empty-hero { background: var(--panel); border: 1px dashed #c9d1da; border-radius: var(--radius-lg); padding: 40px 24px; text-align: center; }
.empty-hero h2 { margin: 0 0 6px; font-size: var(--text-xl); } .empty-hero p { color: var(--muted); margin: 0 0 16px; }
#view-project .crumbs { margin-bottom: 8px; }
#name { margin-bottom: 14px; }
.project-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
/* Cards and panels: one container style everywhere (white, 1px border, 10px corners, a faint shadow). */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); margin-bottom: var(--space-5);
         box-shadow: var(--shadow-sm); }
.panel h2 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -.01em; color: var(--ink); margin: 0 0 var(--space-3); }
.panel h2 + h2, .panel * + h2 { margin-top: var(--space-5); }
.panel .table-card { border-radius: var(--radius-lg); }
.map-panel { position: sticky; top: calc(var(--bar-h) + 16px); padding: 0; overflow: hidden; height: 520px; }
.map-panel iframe { width: 100%; height: 100%; border: 0; display: block; }
.data-list { list-style: none; margin: 10px 0; padding: 0; }
.data-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.data-list li:last-child { border-bottom: 0; }
.data-list .file-wrap { flex: 1; min-width: 0; }
.data-list .file-wrap .file { display: block; }
.data-list li { flex-wrap: wrap; }
.chip.status-pending { color: var(--warn); background: var(--warn-soft); }
.chip.status-qualified { color: var(--ok); background: var(--ok-soft); }
.chip.status-excluded { color: var(--bad); background: var(--bad-soft); }
.status-actions { display: inline-flex; gap: 10px; }
.status-btn:hover { color: var(--accent-ink); }
.exclude-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.exclude-form input { font: inherit; font-size: var(--text-sm); padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; width: 220px; max-width: 100%; }
.ghost.small { padding: 4px 10px; }
.data-note { margin: 8px 0 0; padding: 7px 10px; border-radius: var(--radius-md); background: var(--warn-soft); color: var(--warn); font-size: var(--text-sm); }
.data-list .kind { font-size: var(--text-xs); font-weight: 700; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--soft); border: 1px solid var(--line); color: var(--muted); }
.data-list .file { flex: 1; font-family: var(--mono); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- data page (#data/...) and the check before a run --------------------------------------- */
.data-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.example-note { margin: 0 0 14px; padding: 9px 12px; border-radius: var(--radius-md); background: var(--warn-soft); color: var(--warn);
                font-size: var(--text-sm); font-weight: 600; }
.dstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 0 0 12px; }
.dstat { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 8px 10px; }
.dstat b { display: block; font: 600 var(--text-lg) var(--mono); }
.dstat span { font-size: var(--text-xs); color: var(--muted); }
.warn-list, .col-list { margin: 0 0 14px; padding-left: 18px; font-size: var(--text-sm); }
.warn-list li { color: var(--warn); margin-bottom: 4px; }
.warn-list li.ok { color: var(--ok); }
.col-list li { color: var(--muted); margin-bottom: 3px; }
.col-list code { font: var(--text-xs) var(--mono); color: var(--ink); background: var(--soft); padding: 1px 5px; border-radius: var(--radius-sm); }
.dmap svg, .dhist svg { width: 100%; height: auto; display: block; border-radius: var(--radius-md); }
.dmap svg { border: 1px solid var(--line); }
.dhist { max-width: 720px; margin-top: 6px; }
.dlegend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: var(--text-xs); color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 12px; height: 12px; display: inline-block; background: var(--c); }
.lg.dot i { border-radius: 50%; }
.lg.hollow i { border-radius: 50%; background: #fff; border: 2px solid var(--c); width: 9px; height: 9px; }
.lg.line i { height: 3px; }
.lg.cross i { background: none; position: relative; }
.lg.cross i::before { content: "×"; position: absolute; inset: -5px 0 0; color: var(--c); font-weight: 700; font-size: var(--text-lg); line-height: 1; }
.lg.box i { border: 1px solid #55606b; }
.lg-note { flex-basis: 100%; font-style: italic; }
.table-scroll { overflow-x: auto; }
.table-scroll table td, .table-scroll table th { white-space: nowrap; padding: 7px 10px; font-size: var(--text-sm); }
th.hot { color: var(--accent-ink); }
td.hot { background: var(--accent-soft); font-weight: 600; }
@media (max-width: 900px) { .data-grid { grid-template-columns: minmax(0, 1fr); } }

/* --- hosted read-only demo ----------------------------------------------------------------- */
.demo-banner { margin: 0; display: flex; align-items: center; gap: var(--space-3); height: var(--control-lg); padding: 0 20px 0 32px; background: #e3e9f2;
               color: var(--ink); border-bottom: 1px solid #d3dbe7; font-size: var(--text-sm); }
.demo-banner svg { flex: none; width: 20px; height: 20px; color: #2563eb; }
.demo-banner span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-banner button { flex: none; width: 32px; height: 32px; border: 0; border-radius: var(--radius-md); background: none; color: var(--muted);
                      cursor: pointer; display: grid; place-items: center; }
.demo-banner button:hover { background: rgba(19, 33, 61, .07); color: var(--ink); }
.demo-banner button svg { color: inherit; width: 18px; height: 18px; }
body.has-banner .workspace, body.has-banner .results { height: calc(100vh - var(--bar-h) - 44px); }
body.demo-mode .link-btn:not(#sign-out), body.demo-mode .add-data, body.demo-mode #add-toggle,
body.demo-mode #project-ledger { display: none; }

/* Data readiness panel */
#plan-panel .row-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#plan-panel .plan-sub { margin-top: 16px; }
#plan-panel .table-scroll td.plan-step { white-space: normal; min-width: 280px; }
#plan-panel .table-scroll td { white-space: normal; }   /* long cost and lead-time notes wrap, no side scroll */
body.demo-mode .pc-remove { display: none; }
@media (max-width: 700px) {
  #view-projects .tools { width: 100%; gap: 10px; } .search { flex: 1; } .tools .search input { width: 100%; }
  #view-projects { padding-left: 16px; padding-right: 16px; }
  .cards { grid-template-columns: minmax(0, 1fr); } .pcard { padding: 18px 18px 16px; }
}

/* --- cycle history (#history) ------------------------------------------------------------- */
#view-history .tools select { width: 180px; font-size: var(--text-md); }
.history-table { overflow: visible; }                 /* the ⋮ menus open past the table's edge */
.history-table thead th:first-child { border-top-left-radius: 10px; }
.history-table thead th:last-child { border-top-right-radius: 10px; }
.history-table th { padding: 10px var(--space-4); }
.history-table td { padding: var(--space-3) var(--space-4); font-size: var(--text-md); color: var(--ink); vertical-align: middle; }
.history-table td.col-opt { color: var(--muted); }
.history-table td.nowrap { white-space: nowrap; }
.history-table td .name { display: block; font-size: var(--text-md); font-weight: 600; color: var(--ink); text-decoration: none; }
.history-table td .name:hover { color: var(--accent-ink); }
.history-table .project-link { display: block; margin-top: 2px; font-size: var(--text-sm); color: var(--muted); text-decoration: none; }
.history-table .project-link:hover { color: var(--accent-ink); text-decoration: underline; }
.history-table td .sub { margin-top: 4px; font-size: var(--text-sm); }
.history-table tbody tr:hover td { background: #f7f9fc; }
.history-table .chip { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); font-weight: 500; letter-spacing: 0;
                                      padding: 4px 10px; border-radius: var(--radius-sm); }
.history-table .chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.row-actions { display: flex; align-items: center; gap: var(--space-3); }
.row-items { right: 0; min-width: 190px; z-index: 5; }
.row-items a, .row-items button { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); padding: 8px 10px; }
.row-items .ico svg { width: 16px; height: 16px; display: block; }
.row-items .pc-remove { border-radius: 0 0 6px 6px; }
body.demo-mode .row-items .pc-remove, body.demo-mode .row-items .approve-item { display: none; }
@media (max-width: 900px) {
  #view-history { padding-left: 16px; padding-right: 16px; }
  #view-history .tools { width: 100%; } #view-history .search { flex: 1; } #view-history .tools .search input { width: 100%; }
  .history-table td, .history-table th { padding: 12px; }
  .row-actions { gap: 10px; }
}

/* --- new project: options and evidence points --------------------------------------------- */
.side .section-title { font-size: var(--text-xs); color: var(--muted); }
.side details { border-color: #e1e6ee; border-radius: var(--radius-lg); }
.side summary { padding: 13px 16px; font-size: var(--text-md); }
/* The three option boxes (evidence point, block boundary, project data) share one look: icon, title, chevron. */
.opt-box[open] { background: #f5f8fc; border-color: #dfe6f0; }
/* Same size and weight as the form's field labels, so the options read as options, not headings. */
.opt-box > summary { font-size: var(--text-md); font-weight: 600; color: #3b4a64; padding: 11px 14px; align-items: center; }
.opt-box > summary::after { content: ""; width: 7px; height: 7px; margin: 0 4px 3px 0; border: solid var(--muted); border-width: 0 2px 2px 0;
                            transform: rotate(45deg); font: inherit; }
.opt-box[open] > summary::after { content: ""; transform: rotate(-135deg); margin: 3px 4px 0 0; }
.opt-box > .hint { font-size: var(--text-sm); line-height: 1.55; margin: 0 14px 10px; color: var(--muted); }
.sum-title { display: inline-flex; align-items: center; gap: 10px; }
.sum-title svg { width: 17px; height: 17px; color: var(--muted); }
.more-btn { font: inherit; font-size: var(--text-sm); border: 0; padding: 0; background: none; color: #2563eb; cursor: pointer;
            display: inline-flex; align-items: center; gap: 4px; }
.more-btn::after { content: ""; width: 6px; height: 6px; margin-left: 3px; border: solid currentColor; border-width: 0 1.6px 1.6px 0;
                   transform: rotate(45deg) translateY(-2px); }
.more-btn[aria-expanded="true"]::after { transform: rotate(-135deg) translate(-1px, -1px); }
.more-btn:hover { text-decoration: underline; }
.points { list-style: none; margin: 0 12px; padding: 0; display: grid; gap: 10px; }
.point { display: grid; grid-template-columns: minmax(0, 1fr) 96px 96px 30px; align-items: end; gap: 10px; padding: 10px 12px;
         background: var(--panel); border: 1px solid #e6ebf2; border-radius: var(--radius-lg); }
.pt-name { display: flex; align-items: center; gap: 10px; align-self: center; margin-top: 18px; font-size: var(--text-sm); color: var(--ink); min-width: 0; }
.pt-name svg { flex: none; width: 20px; height: 20px; }
.pt-field { margin: 0; font-size: var(--text-sm); font-weight: 500; color: var(--muted); }
.pt-field input { margin-top: 3px; padding: 6px 9px; }
.pt-remove { width: 30px; height: 34px; border: 0; border-radius: var(--radius-md); background: none; color: var(--muted); cursor: pointer;
             display: grid; place-items: center; }
.pt-remove svg { width: 20px; height: 20px; }
.pt-remove:hover { color: var(--bad); background: var(--bad-soft); }
.add-point { display: flex; align-items: center; gap: var(--space-2); width: calc(100% - 24px); margin: 10px 12px 14px; height: var(--control-md); padding: 0 var(--space-3); border: 0;
             border-radius: var(--radius-md); background: #e6eefa; color: #2563eb; font: inherit; font-size: var(--text-md); font-weight: 500; cursor: pointer; }
.add-point svg { width: 16px; height: 16px; }
.add-point:hover:not(:disabled) { background: #dbe6f8; }
.add-point:disabled { opacity: .5; cursor: default; }
.side footer .hint .more-btn { font-size: var(--text-xs); }
@media (max-width: 440px) { .point { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px; } .pt-name { grid-column: 1 / -1; margin-top: 0; } }
.workspace { grid-template-columns: clamp(420px, 34vw, 640px) minmax(0, 1fr); }
@media (max-width: 900px) { .workspace { grid-template-columns: minmax(0, 1fr); } }

/* Results: which evidence point's card is shown */
.point-switch { max-width: 1040px; margin: 0 auto 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.point-switch button { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: var(--text-sm); font-weight: 600; padding: 7px 12px;
                       border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); color: var(--ink); cursor: pointer; }
.point-switch button:hover { border-color: var(--accent); }
.point-switch button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.point-switch .tier { font-size: var(--text-xs); padding: 1px 7px; border-radius: var(--radius-sm); }
/* An open ⋮ menu sits above the next rows' buttons. */
.pc-menu:has(.pc-items:not([hidden])) { z-index: 6; }

/* --- new project map: centre / cursor bar ---------------------------------------------- */
.map-bar { left: 16px; bottom: 16px; display: flex; align-items: center; gap: 14px; max-width: calc(100% - 180px); padding: 12px 20px;
           border-radius: var(--radius-lg); background: #1a2b40; color: #fff; font: var(--text-md)/1.3 "Segoe UI Variable Text", "Segoe UI", "Selawik", system-ui, -apple-system, sans-serif;
           box-shadow: 0 4px 16px rgba(19, 33, 61, .25); white-space: nowrap; overflow: hidden; }
.map-bar svg { width: 20px; height: 20px; flex: none; }
.map-bar b { font-weight: 500; }
.map-bar .bar-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .3); margin: 0 6px; }
#coords-where, #coords-cursor { overflow: hidden; text-overflow: ellipsis; }

/* --- results header (#screen/<id>) --------------------------------------------------------- */
.res-top { padding: var(--space-4) var(--gutter) 0; }
.res-top .crumbs { font-size: var(--text-sm); }
.res-head { margin-top: 10px; align-items: flex-start; }
.res-name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.res-title h1 { font-size: var(--text-3xl); font-weight: 700; letter-spacing: -.01em; }
#res-status .chip { display: inline-flex; font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; padding: 4px 10px; border-radius: var(--radius-md); }
.caveats-chip { font: inherit; font-size: var(--text-sm); padding: 4px 12px; border-radius: var(--radius-full); cursor: pointer; white-space: nowrap;
                background: #fff4e6; color: #a35a12; border: 1px solid #f6cf9f; }
.caveats-chip:hover { background: #ffe9d1; }
.res-meta { gap: 6px 0; margin-top: var(--space-2); font-size: var(--text-sm); }
.res-meta .meta-item { display: inline-flex; align-items: center; gap: 8px; }
.res-meta .meta-item svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.res-meta > * + *::before { content: "·"; margin: 0 14px; color: var(--faint); }
.res-meta .basis { margin-left: 6px; } .res-meta .basis::before { content: none; }
.res-top .tabbar { margin-top: var(--space-3); align-items: center; border-top: 1px solid var(--line); }
.res-top .tabs { gap: 14px; }
.res-top .tabs button { font-size: var(--text-md); font-weight: 600; padding: 12px var(--space-4); border-bottom-width: 2px; }
.res-top .tabs button[aria-selected="true"] { color: var(--accent); }
.res-top .exports { padding: var(--space-2) 0; gap: var(--space-2); }
.res-top .exports .ghost .ico svg { width: 16px; height: 16px; display: block; }
.res-body { padding: 0; }
@media (max-width: 900px) { .res-top { padding: 12px 16px 0; } .res-meta > * + *::before { margin: 0 8px; } }

/* --- new project: project data -------------------------------------------------------------- */
.data-box > .box-lede { font-size: var(--text-sm); line-height: 1.55; margin: 0 16px 6px; }
.file-field { margin: 0 16px; }
.file-field label { margin: 12px 0 6px; font-size: var(--text-sm); color: var(--ink); }
.file-field input[type=file] { padding: 7px 8px; border-color: #e6ebf1; border-radius: var(--radius-md); background: #f4f6f9; font-size: var(--text-md); }
.file-field input[type=file]::file-selector-button { font: inherit; font-size: var(--text-md); margin-right: 10px; padding: 3px 10px; border: 1px solid #b9c2cc;
                                                      border-radius: var(--radius-sm); background: #f8f9fb; color: var(--ink); cursor: pointer; }
.file-field input[type=file]::file-selector-button:hover { background: #eef1f5; }
details.sources { margin: 16px 12px 14px; border: 0; border-radius: var(--radius-lg); background: #f2f6fb; }
details.sources > summary { font-size: var(--text-md); font-weight: 700; padding: 14px 16px; }
details.sources > summary::after { content: ""; width: 9px; height: 9px; margin: 3px 4px 0 0; border: solid var(--ink); border-width: 0 2px 2px 0;
                                   transform: rotate(45deg); font: inherit; }
details.sources[open] > summary::after { content: ""; transform: rotate(-135deg); margin-top: 8px; }
.source-list { list-style: none; margin: 0 16px; padding: 0; }
.source-list li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid #e1e7ef; font-size: var(--text-sm); line-height: 1.55; color: var(--muted); }
.source-list li:first-child { padding-top: 2px; }
.source-list svg { flex: none; width: 24px; height: 24px; margin-top: 4px; color: var(--ink); }
.source-list svg.ok { color: #15803d; }
.source-list b { display: block; color: var(--ink); font-size: var(--text-md); font-weight: 600; margin-bottom: 2px; }
details.sources > .hint { margin: 12px 16px 0; font-size: var(--text-sm); line-height: 1.55; }
.less-btn { display: flex; align-items: center; gap: 6px; margin: 4px 16px 14px auto; font: inherit; font-size: var(--text-md); border: 0; padding: 0;
            background: none; color: #2563eb; cursor: pointer; }
.less-btn::after { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.8px 1.8px 0; transform: rotate(-135deg) translate(-1px, -1px); }
.less-btn:hover { text-decoration: underline; }

/* ============================================================================================
   Breakpoints (desktop first; the same four are used for every page from here on)
     xl  ≥ 1440px  full layout: 40px page gutters, list + map side by side (1.45 : 1)
     lg  1200–1439 same layout, map column narrows (1.25 : 1)
     md  1024–1199 header drops the user email; project actions keep one row; meta row wraps
     sm   768–1023 one column: map above the list (360px), tabs scroll sideways, toolbars wrap,
                   24px gutters, optional table columns (.col-opt) hidden
     xs     < 768 phone: 16px gutters, header shows the mark and icons only, action buttons stack
                   full width, tables scroll sideways, dialogs fill the width
   ============================================================================================ */

/* --- top bar: brand on the left, menu in the centre, account on the right ------------------- */
.bar nav { margin-left: 40px; }
/* Centred on the bar, not between brand and account; the desktop app's note needs the room, so it keeps the menu left. */
@media (min-width: 1024px) {
  .bar:has(.note[hidden]) nav { position: absolute; top: 0; left: 50%; transform: translateX(-50%); margin-left: 0; }
}
.bar .note[hidden] + .user, .user { margin-left: auto; }
.user-btn { padding: 4px 8px 4px 4px; gap: 10px; }
.user .avatar { width: var(--control-sm); height: var(--control-sm); background: var(--brand-strong); font-size: var(--text-sm); }
.user-name { font-size: var(--text-md); color: var(--bar-ink); max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- buttons shared by the project pages and the dialog -------------------------------------- */
/* --- Buttons: four roles, three sizes ----------------------------------------------------------
   primary     .btn-brand  .primary  .ghost.solid      filled brand, one per view
   secondary   .btn-ghost  .ghost    .btn-outline      white with a border (.btn-outline: brand text)
   destructive .btn-danger                             filled red, only in dialogs
   tertiary    .text-btn   .link-btn .more-btn .less-btn   text only
   Sizes: 36px (default), 32px (.small, rows, toolbars), 40px (.primary: the one full-width call to action). */
.btn-brand, .primary, .ghost, .btn-ghost, .btn-outline, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-md); padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-md); font: inherit; font-size: var(--text-md); font-weight: 600; line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s; }
.btn-brand svg, .primary svg, .ghost svg, .btn-ghost svg, .btn-outline svg, .btn-danger svg { width: 16px; height: 16px; flex: none; }
.btn-brand, .primary, .ghost.solid { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-brand:hover:not(:disabled), .primary:hover:not(:disabled), .ghost.solid:hover:not(:disabled) { background: var(--brand-strong-hover); border-color: var(--brand-strong-hover); color: #fff; }
.ghost, .btn-ghost { background: var(--panel); border-color: var(--border-strong); color: var(--ink); }
.ghost:hover:not(:disabled), .btn-ghost:hover:not(:disabled) { background: var(--soft); border-color: #b9c3cf; }
.btn-outline { background: var(--panel); border-color: var(--brand-strong); color: var(--brand-strong); }
.btn-outline:hover { background: var(--accent-soft); color: var(--brand-strong-hover); }
.btn-danger { background: #c9372c; border-color: #c9372c; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a92b22; border-color: #a92b22; }
.primary { width: 100%; height: var(--control-lg); }
.ghost.small, .btn-brand.small, .btn-ghost.small, .btn-outline { height: var(--control-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
.ghost.wide { width: 100%; }
.btn-brand:disabled, .primary:disabled, .ghost:disabled, .btn-ghost:disabled, .btn-danger:disabled { opacity: .5; cursor: default; }
.text-btn { font: inherit; font-size: var(--text-md); font-weight: 600; border: 0; padding: 0; background: none; color: #1d4ed8; cursor: pointer; }
.text-btn:hover { text-decoration: underline; }
/* Icon-only buttons (⋮, ✕): one 32px square. */
.pc-more, .row-more, .dialog-x, .demo-banner button { width: var(--control-sm); height: var(--control-sm); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- one project (#project/<id>) ------------------------------------------------------------ */
#view-project .crumbs { font-size: var(--text-md); margin-bottom: 8px; }
.project-head { align-items: flex-start; flex-wrap: nowrap; margin-bottom: 18px; }
.project-head > .project-title { flex: 1; }
.project-head > .project-actions { flex: none; padding-top: 4px; }
.project-head h1 { margin-bottom: var(--space-2); }
.project-title { min-width: 0; }
.meta-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); color: #3b4a64; }
.meta-row li { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.meta-row .ico svg { width: 16px; height: 16px; display: block; color: #3b4a64; }
.project-actions { gap: var(--space-2); align-items: center; flex-wrap: wrap; }

/* tabs */
.ptabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); margin-bottom: var(--space-5); overflow-x: auto; scrollbar-width: none; }
.ptabs button { display: inline-flex; align-items: center; gap: var(--space-2); flex: none; padding: 10px var(--space-4); border: 0; border-bottom: 2px solid transparent;
                margin-bottom: -1px; background: none; font: inherit; font-size: var(--text-md); font-weight: 600; color: var(--ink); cursor: pointer; }
.ptabs button:hover { color: var(--accent-ink); }
.ptabs button[aria-selected="true"] { color: var(--brand-strong); border-bottom-color: var(--brand); }
.tcount { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--radius-sm); background: #e6ebf3;
          color: var(--ink); font-size: var(--text-sm); font-weight: 700; }
.tcount.warm { background: var(--accent-soft); color: var(--accent-ink); }

/* two columns: tab content + map */
.project-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 20px; align-items: start; }
#view-project .panel { padding: var(--space-5); margin-bottom: var(--space-5); }
#view-project .panel h2 { margin: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); }
#view-project .panel-lede { font-size: var(--text-sm); line-height: 1.55; color: var(--muted); margin: 0; }
#view-project .panel-lede a { color: var(--accent-ink); }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding-top: var(--space-3); margin-top: var(--space-1);
              border-top: 1px solid #eef1f5; font-size: var(--text-sm); color: var(--muted); }

/* tables on the project page: columns give way to the panel's own width (container queries) */
.project-main { container-type: inline-size; min-width: 0; }
@container (max-width: 720px) { .cycles-table th.col-opt, .cycles-table td.col-opt { display: none; } }
@container (max-width: 640px) { .data-table th.col-opt, .data-table td.col-opt { display: none; } }
.cycles-table, .data-table { border: 0; border-radius: var(--radius-lg); overflow: visible; }
.cycles-table th, .data-table th { padding: 10px var(--space-4); }
.cycles-table thead th:first-child, .data-table thead th:first-child { border-top-left-radius: 8px; }
.cycles-table thead th:last-child, .data-table thead th:last-child { border-top-right-radius: 8px; }
.cycles-table td, .data-table td { padding: var(--space-3) var(--space-4); font-size: var(--text-md); vertical-align: middle; border-bottom-color: #eef1f5; }
td.nowrap { white-space: nowrap; } td.muted { color: var(--muted); }
th.col-actions, td.col-actions { text-align: right; width: 1%; white-space: nowrap; }
.sort-btn { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; border: 0; padding: 0; background: none; cursor: pointer;
            display: inline-flex; gap: 6px; align-items: center; }
.sort-btn:hover { color: var(--ink); }
.cycles-table td:first-child { min-width: 170px; }
.cycles-table td .name { font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.cycles-table td .name:hover { color: var(--accent-ink); }
.cycles-table .chip, .data-table .chip, .history-table .chip, .pcard .chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm);
  font-weight: 500; letter-spacing: 0; padding: 3px 10px; border-radius: var(--radius-full); }
.cycles-table .chip::before, .data-table .chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.cycles-table .chip.running::before, .cycles-table .chip.queued::before { width: 9px; height: 9px; background: none; border: 2px solid currentColor;
                                         border-right-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cycles-table .chip::before { animation: none !important; } }
.row-more { background: none; }
.row-more:hover, .row-more[aria-expanded="true"] { background: var(--soft); }
.row-items { right: 0; }
.file-cell { display: flex; align-items: center; gap: 14px; min-width: 0; }
.file-cell > .ico svg { width: 20px; height: 20px; display: block; color: #334155; }
.file-cell .file { display: block; font-weight: 500; overflow-wrap: anywhere; }
.file-cell .kind { display: block; font-size: var(--text-sm); color: var(--muted); }
.data-table .reason { margin-top: 6px; font-size: var(--text-sm); color: var(--muted); max-width: 32ch; }
.chip.status-excluded::before { background: currentColor; }

/* add data: type, drop zone, Add */
#add-toggle .chev svg { width: 16px; height: 16px; transition: transform .15s; }
#add-toggle[aria-expanded="true"] .chev svg { transform: rotate(180deg); }
.add-data { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) auto; gap: var(--space-3); align-items: end;
            padding: var(--space-4); margin-bottom: var(--space-4); border: 1px solid #e3e8ef; border-radius: var(--radius-lg); background: #f6f8fb; }
.add-kind label { margin: 0 0 6px; font-size: var(--text-sm); color: var(--ink); }
.add-kind .req { color: #c9372c; }
.dropzone { display: grid; place-items: center; gap: 2px; margin: 0; min-height: 60px; padding: var(--space-2) var(--space-4); border: 1.5px dashed #b9c3cf;
            border-radius: var(--radius-lg); background: var(--panel); text-align: center; cursor: pointer; font-weight: 400; color: var(--ink); }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--accent-soft); }
.dropzone:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: #9fc7a8; background: #f3faf5; }
.dz-main { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-md); }
.dz-main svg { width: 16px; height: 16px; }
.dz-main u { color: #1d4ed8; text-decoration: none; font-weight: 600; }
.dz-hint { font-size: var(--text-sm); color: var(--muted); }

/* map: satellite switch (viewer), centre pill, zoom (viewer) */
#view-project .map-panel { position: sticky; top: calc(var(--bar-h) + var(--space-4)); padding: 0; height: 560px; border-radius: var(--radius-lg); overflow: hidden;
                           margin-bottom: 20px; container-type: inline-size; }
.map-panel iframe { width: 100%; height: 100%; border: 0; display: block; }
#project-coords { top: 16px; left: 136px; right: auto; bottom: auto; display: block; height: var(--control-md); max-width: calc(100% - 210px); padding: 0 12px;
                  border-radius: var(--radius-md); background: #1a2b40; color: #fff; font: var(--text-sm)/36px "Segoe UI Variable Text", "Segoe UI", "Selawik", system-ui, sans-serif;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 2px 8px rgba(19, 33, 61, .2); }
#project-coords b { font-weight: 500; }
#project-coords .pill-sep { display: inline-block; width: 1px; height: 18px; margin: 0 12px; vertical-align: -4px; background: rgba(255, 255, 255, .35); }
@container (max-width: 520px) { #project-coords { top: 64px; left: 16px; max-width: calc(100% - 92px); } }

/* --- data readiness tab ------------------------------------------------------------------------ */
.caveat-box { display: flex; gap: var(--space-3); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5); border: 1px solid #f5cfae; border-radius: var(--radius-lg); background: #fff6ee; }
.caveat-ico svg { width: 22px; height: 22px; color: var(--brand); display: block; }
.caveat-body { flex: 1; min-width: 0; }
.caveat-body h3 { margin: 1px 0 6px; font-size: var(--text-md); color: var(--accent-ink); }
.caveat-body ul { margin: 0; padding-left: 18px; columns: 2 360px; column-gap: var(--space-10); font-size: var(--text-sm); line-height: 1.55; color: #3b4a64; }
.caveat-body li { break-inside: avoid; margin-bottom: 4px; }
.caveat-body li::marker { color: var(--brand); }
.register-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4) var(--space-6); flex-wrap: wrap; margin-bottom: var(--space-4); }
.register-head .panel-lede { margin-top: 4px !important; }
.register-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.tally { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.tally-item { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-md); padding: 0 var(--space-3); border: 1px solid #e3e8ef; border-radius: var(--radius-lg);
              background: #f7f9fc; font: inherit; text-align: left; cursor: pointer; }
.tally-item:hover { border-color: #c4ccd5; }
.tally-item i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tally-item b { font-size: var(--text-sm); font-weight: 600; }
.tally-item small { display: none; }
.tally-item.bad i { background: #d92d20; } .tally-item.warn i { background: #f59e0b; } .tally-item.ok i { background: #16a34a; }
.reg-search input { width: 260px; padding-left: 36px; font-size: var(--text-md); }
#plan-filter { width: auto; min-width: 150px; }
.register-table, .plan-options .table-card { border-radius: var(--radius-lg); }
#view-project .table-scroll th { padding: 10px var(--space-3); }
#view-project .table-scroll td { white-space: normal; padding: 10px var(--space-3); font-size: var(--text-sm); vertical-align: middle; }
#view-project td.plan-step { min-width: 320px; }
td.plan-step a { color: #1d4ed8; font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.bad { color: #b42318; background: #fdecea; } .pill.warn { color: #9a5b00; background: #fff4e0; } .pill.ok { color: #1f7a3a; background: #e8f5ec; }
.options-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-3); }
#view-project .options-head h2 { font-size: var(--text-lg); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.plan-options tr:target td { background: var(--accent-soft); }

/* --- dialog (one for the whole app) ----------------------------------------------------------- */
.dialog { padding: 0; border: 0; border-radius: var(--radius-lg); width: min(480px, calc(100% - 32px)); max-height: calc(100% - 48px);
          box-shadow: var(--shadow-lg); color: var(--ink); background: var(--panel); }
.dialog.wide { width: min(720px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(11, 26, 53, .45); }
.dialog[open] { animation: dialog-in .16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .dialog[open] { animation: none; } }
.dialog-card { display: flex; flex-direction: column; max-height: calc(100vh - 48px); margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-2); }
.dialog-head h2 { margin: 0; font-size: var(--text-xl); font-weight: 700; letter-spacing: -.01em; }
.dialog-x { border: 0; border-radius: var(--radius-lg); background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.dialog-x:hover { background: var(--soft); color: var(--ink); }
.dialog-x svg { width: 20px; height: 20px; }
.dialog-body { padding: var(--space-1) var(--space-5) var(--space-2); overflow-y: auto; font-size: var(--text-md); line-height: 1.55; color: #3b4a64; }
.dialog-body p { margin: 0 0 12px; }
.dialog-body label { margin: 4px 0 6px; font-size: var(--text-sm); color: var(--ink); }
.dialog-body input { margin-bottom: var(--space-2); }
.dialog-body .error { margin: 8px 0 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid #eef1f5; margin-top: 8px; }
.run-list li { align-items: flex-start; padding: 10px 0; }
.run-list .sum { flex: 1; min-width: 0; }
.run-list .sum div { color: var(--muted); font-size: var(--text-sm); }
.run-list .sum .warn { color: var(--warn); } .run-list .sum .err { color: var(--bad); }
.run-list .kind { margin-top: 2px; }

/* --- breakpoints ------------------------------------------------------------------------------ */
@media (max-width: 1439px) { .project-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
@media (max-width: 1199px) {
  .user-name { display: none; }
  .meta-row { column-gap: 18px; }
  .add-data { grid-template-columns: minmax(0, 1fr) auto; }
  .add-data .dropzone { grid-column: 1 / -1; grid-row: 2; }
  .add-data .btn-brand { grid-row: 1; grid-column: 2; }
}
@media (max-width: 1023px) {
  #view-project { padding-left: 24px; padding-right: 24px; }
  .project-head { flex-wrap: wrap; }
  .bar nav { margin-left: 16px; }
  .project-grid { grid-template-columns: minmax(0, 1fr); }
  #view-project .map-panel { position: relative; top: auto; height: 360px; order: -1; }
  .reg-search { flex: 1; } .reg-search input { width: 100%; }
}
@media (max-width: 767px) {
  #view-project { padding-left: 16px; padding-right: 16px; }
  .bar { gap: 4px; padding: 0 12px; } .bar nav { margin-left: 4px; } .bar nav a { padding: 0 10px; font-size: var(--text-md); }
  .brand b, .brand-sep, .brand span { display: none; }
  .bar nav a { white-space: nowrap; }
  .reg-search { flex: 1 1 100%; }
  .project-head h1 { font-size: var(--text-3xl); }
  .project-actions { width: 100%; }
  .project-actions > * { flex: 1 1 auto; }
  .meta-row { column-gap: 14px; } .meta-row li { font-size: var(--text-sm); }
  .ptabs button { padding: 10px 14px 12px; font-size: var(--text-md); }
  #view-project .panel { padding: var(--space-4); }
  #view-project .map-panel { padding: 0; }
  .panel-head { flex-wrap: wrap; }
  .cycles-table, .data-table { overflow-x: auto; }
  .cycles-table table, .data-table table { min-width: 560px; }
  .add-data { grid-template-columns: minmax(0, 1fr); }
  .add-data .dropzone, .add-data .btn-brand { grid-column: 1; grid-row: auto; }
  .register-tools, .tally { width: 100%; } .tally-item { flex: 1; }
  #plan-filter, #plan-download { flex: 1; }
  .caveat-box { padding: 16px; }
  .dialog-foot { flex-direction: column-reverse; } .dialog-foot > * { width: 100%; }
}
@media (max-width: 479px) { .bar nav a[data-view="new"] { display: none; } }
/* History on phones: the 3D view button shows its icon only, so the cycle name keeps the room. */
@media (max-width: 767px) {
  .history-table td, .history-table th { padding: 10px 12px; }
  .history-table .btn-outline { font-size: 0; gap: 0; width: var(--control-sm); padding: 0; }
  .demo { flex-wrap: wrap; }
}

/* Copper model result on the evidence card */
.ecard .model-line { border: 1px solid var(--line); border-left: 4px solid #c2410c; border-radius: 10px; padding: 12px 16px; margin: 14px 0 6px; }
.ecard .model-line h3, .ecard .surface-head { margin: 0 0 4px; font-size: 15px; }
.ecard .surface-head { margin-top: 18px; }
.ecard .model-line .stats { margin: 8px 0; }
.ecard .model-line .hint { margin: 0; }

/* --- pagination (pager.js): History, a project's cycle runs, Projects -------------------------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4);
         margin-top: var(--space-3); font-size: var(--text-sm); color: var(--muted); }
.pager-info { margin: 0; }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.pager-btn { min-width: var(--control-sm); height: var(--control-sm); padding: 0 var(--space-2); border: 1px solid var(--border-strong);
             border-radius: var(--radius-md); background: var(--panel); font: inherit; font-size: var(--text-sm); font-weight: 600;
             color: var(--ink); cursor: pointer; }
.pager-btn:hover:not(:disabled) { background: var(--soft); border-color: #b9c3cf; }
.pager-btn:disabled { opacity: .5; cursor: default; }
.pager-btn.current { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; opacity: 1; }
.pager-gap { padding: 0 var(--space-1); }
.pager-size { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-sm); font-weight: 400; color: var(--muted); }
.pager-size select { width: auto; height: var(--control-sm); padding: 0 28px 0 10px; font-size: var(--text-sm); }
.panel-foot.pager { margin-top: var(--space-1); }
/* A list waiting for its next page: dimmed, not clickable, announced as busy. */
.is-loading { opacity: .55; pointer-events: none; transition: opacity .12s; }

/* --- approving a cycle run (app.js: approveCycle) ------------------------------------------------ */
.approve-form .req { color: #c9372c; }
.approve-form .comment-input { display: block; min-height: 96px; resize: vertical; font: var(--text-md)/1.5 "Segoe UI Variable Text", "Segoe UI", "Selawik", system-ui, -apple-system, sans-serif; }
.approve-form .comment-input[aria-invalid] { border-color: var(--bad); }
.approve-form .field-error { margin: 6px 0 0; font-size: var(--text-sm); color: var(--bad); }
.approve-form .error { margin: 12px 0 0; }
#dialog-ok[aria-busy="true"] { cursor: progress; }

/* --- toasts (app.js: toast) -------------------------------------------------------------------- */
.toasts { position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: 30; display: grid; gap: var(--space-2); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--space-2); max-width: min(420px, calc(100vw - 32px)); padding: 10px var(--space-4);
         border-radius: var(--radius-md); background: var(--bar); color: #fff; font-size: var(--text-md); box-shadow: var(--shadow-md);
         animation: dialog-in .16s ease-out; }
.toast .ico svg { width: 18px; height: 18px; display: block; color: #7ee2a0; }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
@media (max-width: 640px) { .toasts { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); } }

/* --- accounts and approvals (database edition) ------------------------------------------------- */
.user-email .user-role { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--muted); font-weight: 400; }
.menu-item.plain:hover { color: var(--ink); }
.state-banner { margin: 0 0 var(--space-4); padding: 10px var(--space-4); border-radius: var(--radius-md); font-size: var(--text-md); }
.state-banner.draft { background: #eef1f5; color: var(--ink); }
.state-banner.pending_approval { background: var(--warn-soft); color: var(--warn); }
.state-banner.rejected { background: var(--bad-soft); color: var(--bad); }
.danger-text { color: var(--bad); }
.secret { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border: 1px solid var(--line);
          border-radius: var(--radius-md); background: var(--soft); }
.secret code { flex: 1; font: 600 var(--text-lg)/1.3 var(--mono); letter-spacing: .02em; overflow-wrap: anywhere; }
.file-clear, .dz-clear { display: inline-block; margin-top: 4px; font-size: var(--text-sm); color: var(--bad); }
.add-data .dz-clear { align-self: center; }
.approve-form .muted { font-weight: 400; color: var(--muted); }
.approve-form select, .approve-form input { height: var(--control-md); }
td .sub { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }
body.demo-mode #project-submit, body.demo-mode #project-approve, body.demo-mode #project-reject { display: none; }
#users td .sub, #orgs td .sub { font-family: inherit; }
