/* nagoon-inventory — minimal admin GUI. Plain CSS, no build step. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #111;
  --bg-2: #1a1a1a;
  --bg-3: #222;
  --fg: #eee;
  --fg-2: #aaa;
  /* Dim text still has to be readable: #666 measured 2.77:1 – 3.29:1 against
     the three surfaces, below the 4.5:1 AA floor everywhere it is used (and
     it is only ever used at ≤0.85rem). #8a8a8a clears it on all three:
     5.47:1 on --bg, 5.04:1 on --bg-2, 4.61:1 on --bg-3. */
  --fg-dim: #8a8a8a;
  --accent: #4a9eff;
  --accent-dim: #2a5d9e;
  /* Button hover fill. Not --accent: white on #4a9eff is 2.75:1, so the label
     would be least readable exactly when the pointer is on it. */
  --accent-hover: #3b7fd4;
  --good: #4caf50;
  --warn: #ff9800;
  --bad: #f44336;
  --border: #333;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}

header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
header .brand {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
}
header #nav {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}
header #nav a {
  color: var(--fg-2);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
}
header #nav a:hover {
  color: var(--fg);
  background: var(--bg-3);
}
header #actor {
  color: var(--fg-2);
  font-size: 0.9rem;
  margin-left: auto;
}
header #logout-btn {
  margin-left: 0;
}
#project-nav:empty { display: none; }
#project-nav { background: #192126; border-bottom: 1px solid #344046; }
.project-nav { max-width: 1800px; margin: auto; padding: 0 1.5rem; display: flex; gap: 0.2rem; overflow-x: auto; }
.project-nav a { flex: none; padding: 0.7rem 0.85rem 0.6rem; color: #c2ccd0; text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.project-nav a:hover { color: #fff; background: #ffffff0c; }
.project-nav a[aria-current=page] { color: #f4faf9; border-bottom-color: #58d6b8; font-weight: 650; }
.project-nav a:focus-visible, .project-home a:focus-visible { outline: 2px solid #83e6d0; outline-offset: -3px; }
.hidden { display: none !important; }

main {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

h1 { font-size: 1.4rem; margin-bottom: 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; color: var(--fg-2); }

.project-home { margin: 1.7rem 0 2.5rem; }
.project-home-hero { position: relative; overflow: hidden; min-height: 260px; padding: clamp(1.4rem, 4vw, 2.5rem); border: 1px solid #3c5b61; border-radius: 14px; background: radial-gradient(circle at 88% 25%, #3587753a, transparent 38%), linear-gradient(125deg, #1c3034, #182128 70%); }
.project-home-hero::after { content: ''; position: absolute; width: 360px; height: 360px; right: -90px; top: -100px; border: 1px solid #77cbb028; border-radius: 50%; box-shadow: 0 0 0 48px #77cbb00d, 0 0 0 95px #77cbb009; pointer-events: none; }
.project-home-hero > * { position: relative; z-index: 1; max-width: 580px; }
.project-eyebrow, .project-home-card-kicker { color: #8bdcc7; font-size: 0.74rem; font-weight: 750; letter-spacing: 0.11em; }
.project-home-hero h2 { color: #f5faf8; font-size: clamp(1.7rem, 3.5vw, 2.5rem); line-height: 1.15; margin: 0.75rem 0; }
.project-home-hero p:not(.project-eyebrow):not(.project-home-summary) { color: #c9d7d4; font-size: 1rem; line-height: 1.5; }
.project-home-primary { display: inline-flex; align-items: center; justify-content: space-between; gap: 2rem; min-width: 225px; margin-top: 1.3rem; padding: 0.85rem 1rem; border-radius: 7px; background: #51bea4; color: #102521; font-weight: 750; text-decoration: none; }
.project-home-primary:hover { background: #74d9c0; }
.project-home-summary { color: #b6d0c9; margin-top: 1.25rem; font-size: 0.85rem; }
.project-home-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; margin-top: 0.9rem; }
.project-home-card { display: flex; flex-direction: column; gap: 0.35rem; min-height: 130px; padding: 1.2rem 1.35rem; border: 1px solid #364349; border-radius: 10px; background: #1b2327; color: #c7d0d1; text-decoration: none; }
.project-home-card:hover { border-color: #70cbb6; background: #223033; }
.project-home-card strong { color: #f1f7f6; font-size: 1.15rem; }
.project-home-card > span:last-child { font-size: 0.9rem; line-height: 1.45; }
.project-data-heading { border-bottom: 1px solid var(--border); padding: 0.6rem 0 1.1rem; }
.project-data-heading h2 { color: var(--fg); font-size: 1.45rem; margin: 0.5rem 0 0.3rem; }
.sweeps-section { margin-top: 1.5rem; }
.sweeps-section > summary { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; padding: 0.75rem 1rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; }
.sweeps-section > summary::before { content: '▸'; color: var(--fg-2); }
.sweeps-section[open] > summary::before { content: '▾'; }
.sweeps-section > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sweeps-section > summary h2 { margin: 0; flex: 1; }
.sweeps-section > summary h2 .meta { margin-left: 0.75rem; font-size: 0.85rem; }
.sweeps-toggle { color: var(--accent); font-size: 0.85rem; white-space: nowrap; }
.sweeps-section > p { margin: 0.75rem 0; }
.sweeps-filters { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.sweeps-filters .form-group { margin: 0; min-width: 0; flex: 1; }
.sweeps-filters .form-group:nth-child(2) { flex: 2; }
.sweeps-filters input, .sweeps-filters select { width: 100%; }
.sweeps-pagination { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin: 0.75rem 0; }
.sweeps-pagination [role=status] { margin-right: auto; }
.sweeps-table > .card { max-height: 34rem; }
.sweeps-table thead { position: sticky; top: 0; background: var(--bg-2); }
@media (max-width: 640px) { .sweeps-filters .form-group { flex: 1 1 100%; } .sweeps-filters .form-group:nth-child(2) { flex: 1 1 100%; } .sweeps-pagination [role=status] { flex-basis: 100%; } }
@media (max-width: 640px) { .project-nav { padding: 0 0.9rem; } .project-home-actions { grid-template-columns: 1fr; } .project-home-hero::after { opacity: 0.35; } }

.loading { color: var(--fg-dim); padding: 2rem 0; text-align: center; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.45rem 0.7rem;
}
button {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: white;
  cursor: pointer;
  transition: background 80ms;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.subtle { background: var(--bg-3); color: var(--fg); }
button.subtle:hover { background: #2c2c2c; }
button.danger { background: #6a2828; border-color: #6a2828; }
button.danger:hover { background: var(--bad); border-color: var(--bad); }

input[type=text], input[type=password] {
  width: 100%;
  font-family: ui-monospace, "SF Mono", monospace;
}
input[type=file] { background: transparent; border: none; padding: 0; }

.form-group { margin-bottom: 0.75rem; }
/* The <label> WRAPS its control (see field() in app.js) — that is what gives
   the control an accessible name, since nothing here allocates the ids a
   `for=` pair would need. `.lbl` is the same caption for the cases that
   caption a *group* of controls and so must not be a <label> at all. */
.form-group label, .form-group .lbl { display: block; color: var(--fg-2); font-size: 0.85rem; margin-bottom: 0.25rem; }
/* …and because the control now sits inside the caption, it would inherit the
   caption's smaller, dimmer type via `font: inherit` above. Re-assert its own.
   0.875rem is body's 14px (rem is relative to the 16px root, not to body). */
.form-group label > input:not([type=checkbox]),
.form-group label > select,
.form-group label > textarea {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--fg);
}

.row { display: flex; gap: 0.5rem; align-items: center; }
.row > * { flex-shrink: 0; }
.row > .grow { flex-grow: 1; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.card h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.card .meta { color: var(--fg-2); font-size: 0.85rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; font-size: 0.9rem; }
.kv dt { color: var(--fg-2); }
.kv dd { color: var(--fg); font-family: ui-monospace, monospace; }

.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.78rem;
  background: var(--bg-3);
  color: var(--fg-2);
}
.tag.valid { background: #1e3b21; color: #8de094; }
.tag.invalid { background: #4a1f1f; color: #f08080; }
.tag.error { background: #4a3a1f; color: #f0c060; }
.tag.dispatched { background: #1c3b4a; color: #80c8f0; }

.progress {
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
  height: 6px;
  margin: 0.4rem 0;
}
.progress > div {
  background: var(--accent);
  height: 100%;
  /* Starts empty: the uploader only sets a width once an upload begins, and at
     width:auto an idle card reads as a finished 100% bar. */
  width: 0;
  transition: width 100ms;
}

.pipeline { margin-top: 0.75rem; }
.pipeline-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
  color: var(--fg-dim);
}
.pipeline-rows { display: flex; flex-direction: column; }
.pipeline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--border);
}
.pipeline-row:first-child { border-top: none; }
.pipeline-name {
  min-width: 140px;
  color: var(--fg);
}
.pipeline-meta {
  color: var(--fg-dim);
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.status {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 200ms;
  pointer-events: none;
}
.status.show { opacity: 1; }
.status.error { border-color: var(--bad); color: #f08080; }

a { color: var(--accent); }

/* ---- tables ---- */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tbl th {
  color: var(--fg-2);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tbl tbody tr:hover { background: var(--bg-3); }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .num { font-family: ui-monospace, monospace; }
.tbl .mono { font-family: ui-monospace, monospace; font-size: 0.82rem; color: var(--fg-2); }

/* ---- expandable survey result detail ---- */

.tbl tr.detail-row:hover { background: transparent; }
.tbl tr.detail-row > td { background: var(--bg); padding: 0.75rem 0.6rem; }
.survey-detail .card { background: var(--bg-3); margin-bottom: 0.6rem; }
.survey-detail .card:last-child { margin-bottom: 0; }
.survey-detail .tbl { margin-top: 0.5rem; }
.survey-text {
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--fg);
  margin: 0.5rem 0;
}
pre.json {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  background: var(--bg-3);
  padding: 0.6rem;
  border-radius: 4px;
  overflow: auto;
  max-height: 340px;
}

/* ---- inline code chip (token, sweep id, etc.) ---- */

.code {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  background: var(--bg-3);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  cursor: pointer;
  user-select: all;
}
.code:hover { background: #2c2c2c; }

/* ---- sections within a project page ---- */

.section {
  margin-top: 1.5rem;
}
.section > h2 {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 0.5rem;
}
/* The caption span next to a section title. Scoped off anchors: this selector
   outranks `a { color: var(--accent) }`, so the Review/Catalog/Report links
   that share the class were rendering in caption grey. */
.section > h2 .meta:not(a) {
  font-weight: normal;
  color: var(--fg-dim);
  font-size: 0.85rem;
}
.section > h2 a.meta { font-weight: normal; font-size: 0.85rem; }
.section > h2 a.meta:hover { color: var(--fg); }
.empty {
  color: var(--fg-dim);
  font-style: italic;
  padding: 1rem 0;
}

/* ---- selectors ---- */

select {
  cursor: pointer;
}

/* ---- redeem callout ---- */

.callout {
  background: var(--bg-2);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.callout h3 { color: var(--accent); margin-bottom: 0.4rem; }

/* ---- catalog (listings) ---- */

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
/* A real <button> (opening the detail modal is its only job), reset back to
   card looks — same trick as .cat-side-row. A clickable <div> was unreachable
   by keyboard, which made the whole detail/edit path mouse-only. */
.catalog-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0;
  color: inherit;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.catalog-card:hover { background: var(--bg-2); border-color: var(--accent-dim); }
.catalog-photo {
  height: 150px;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.catalog-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.catalog-noimg { color: var(--fg-dim); font-size: 0.8rem; }
.catalog-body {
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.catalog-title { font-weight: 600; }
.catalog-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.catalog-edit { padding: 0.5rem 0; }
.catalog-edit .form-group { flex: 1 1 9rem; margin-bottom: 0; }

/* ----- Catalog: grid / list / map + detail ----- */
.cat-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.6rem 0 0.9rem; }
.cat-views { display: inline-flex; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.cat-view-btn { background: transparent; border: none; color: var(--fg-2); padding: 0.25rem 0.75rem; cursor: pointer; font-size: 0.85rem; text-transform: capitalize; }
.cat-view-btn:hover { background: var(--bg-3); color: var(--fg); }
.cat-view-btn.on { background: var(--accent-dim); color: #fff; }
.cat-search { background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; color: var(--fg); padding: 0.3rem 0.6rem; flex: 1 1 150px; max-width: 260px; }
.cat-ctl { font-size: 0.82rem; color: var(--fg-2); display: inline-flex; align-items: center; gap: 0.25rem; }
.cat-ctl select { background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; color: var(--fg); padding: 0.25rem 0.4rem; }
.cat-count { margin-left: auto; }

/* overview strip: category chips + totals */
.cat-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 0 0 1rem; padding: 0.6rem 0.75rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cat-chip { display: inline-flex; align-items: center; gap: 0.35rem; background: var(--bg-3); border: 1px solid var(--border); border-radius: 999px; color: var(--fg-2); padding: 0.25rem 0.7rem; font-size: 0.82rem; cursor: pointer; text-transform: capitalize; }
.cat-chip:hover { color: var(--fg); border-color: var(--fg-dim); }
.cat-chip.on { background: var(--accent-dim); color: #fff; border-color: var(--accent-dim); }
.cat-chip b { font-weight: 700; }
.cat-totals { margin-left: auto; font-size: 0.82rem; color: var(--fg-2); white-space: nowrap; }

/* collapsible group header */
/* Collapse toggle — a <button>, so a keyboard user can open a collapsed group. */
.cat-group { display: flex; width: 100%; text-align: left; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--fg); font-weight: 600; margin: 0.9rem 0 0.5rem; padding: 0.35rem 0.55rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; cursor: pointer; user-select: none; text-transform: capitalize; }
.cat-group:hover { background: var(--bg-2); border-color: var(--accent-dim); }
.cat-group.collapsed { color: var(--fg-2); background: transparent; }
.cat-caret { color: var(--fg-2); font-size: 0.75rem; width: 0.8em; display: inline-block; }
.cat-gcount { margin-left: auto; color: var(--fg-2); font-weight: 400; background: var(--bg-3); border-radius: 999px; padding: 0.05rem 0.55rem; font-size: 0.78rem; }

.cat-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.cat-table th { text-align: left; color: var(--fg-2); font-weight: 500; font-size: 0.78rem; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); }
.cat-th { cursor: pointer; user-select: none; }
.cat-th:hover { color: var(--fg); }
.cat-th.on { color: var(--accent); }
.cat-row { cursor: pointer; border-bottom: 1px solid #262626; }
.cat-row:hover { background: var(--bg-2); }
.cat-row td { padding: 0.35rem 0.5rem; vertical-align: middle; }
/* The row's keyboard route into the detail modal — the <tr> keeps its own
   click for the mouse, but only this is focusable. */
.cat-rowtitle { font-weight: 600; background: none; border: none; border-radius: 0; padding: 0; color: inherit; font-size: inherit; text-align: left; cursor: pointer; }
.cat-rowtitle:hover { background: none; color: var(--accent); }
.cat-thumb { width: 30px; height: 30px; border-radius: 4px; overflow: hidden; background: #0a0a0a; display: flex; align-items: center; justify-content: center; }
.cat-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cat-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; }

.cat-floortabs { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.cat-floortab { background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; color: var(--fg-2); padding: 0.25rem 0.75rem; cursor: pointer; font-size: 0.82rem; }
.cat-floortab.on { background: var(--accent-dim); color: #fff; border-color: var(--accent-dim); }
.cat-map { background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.cat-mapsvg { display: block; }
.cat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; margin-top: 0.5rem; font-size: 0.8rem; color: var(--fg-2); }
.cat-markup-hint { margin: 0.5rem 0 0.3rem; }
.cat-legitem { display: inline-flex; align-items: center; gap: 0.3rem; text-transform: capitalize; }

.cat-detail { display: flex; flex-wrap: wrap; gap: 1.2rem; padding: 1.2rem; max-width: 760px; margin: 1.5rem auto; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; }
.cat-detail-photo { flex: 0 0 260px; height: 200px; background: #0a0a0a; border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.cat-detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.cat-detail-body { flex: 1 1 240px; }
.cat-info { width: 100%; font-size: 0.9rem; margin-top: 0.6rem; }
.cat-info td { padding: 0.25rem 0; }
.cat-info td:first-child { width: 110px; }

/* ----- Review / triage surface ----- */
.rv-bar { display: flex; align-items: center; gap: 0.75rem; margin: 0.5rem 0 1rem; }
.rv-count { font-size: 0.9rem; color: var(--fg); }
.rv-keys { margin-left: auto; font-size: 0.8rem; }
.rv-list { display: flex; flex-direction: column; gap: 0.4rem; }
.rv-row { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 0.8rem; background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid transparent; border-radius: 6px; cursor: pointer; }
.rv-row:hover { background: var(--bg-3); }
.rv-row.on { border-color: var(--accent); border-left-color: var(--accent); background: var(--bg-3); }
.rv-row.needs { border-left-color: var(--warn); }
.rv-row.needs.on { border-color: var(--accent); }
.rv-body { flex: 1 1 auto; min-width: 0; }
.rv-head { display: flex; align-items: center; gap: 0.5rem; }
.rv-name { font-weight: 600; }
.rv-conf { margin-left: auto; color: var(--fg-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.rv-needs { background: #6e4a23; color: #ffd9a8; }
.rv-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.rv-chip { font-size: 0.78rem; color: var(--fg-2); background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; padding: 0.05rem 0.4rem; }
.rv-note { margin-top: 0.35rem; font-size: 0.82rem; color: var(--fg-dim); font-style: italic; }
/* a–d grade chip: prefilled from the machine grade; confirm endorses/edits it */
.rv-grade { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.35rem; }
.rv-grade-btn { min-width: 1.9em; padding: 0.1rem 0.4rem; border-radius: 4px; border: 1px solid var(--border); background: var(--bg-3); color: var(--fg-2); cursor: pointer; font: inherit; font-size: 0.82rem; text-transform: uppercase; }
.rv-grade-btn.on { background: #1e3b21; color: #8de094; border-color: #2ecc71; font-weight: 600; }
.rv-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }
.rv-ok, .rv-no { border: none; border-radius: 5px; padding: 0.35rem 0.7rem; cursor: pointer; font-size: 0.85rem; white-space: nowrap; }
.rv-ok { background: #1e3b21; color: #8de094; }
.rv-ok:hover { background: #265029; }
.rv-no { background: #4a1f1f; color: #f08080; }
.rv-no:hover { background: #5e2727; }

/* C9 blind-first review: per-row reveal button (blind rows reuse .pr-crop) */
.rv-reveal { margin-top: 0.35rem; font-size: 0.82rem; }

/* ----- "Samma objekt?" pair review (rides the rv-row chrome) ----- */
.pr-crop { flex: 0 0 auto; width: 128px; height: 128px; border-radius: 5px; overflow: hidden; background: var(--bg-3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.pr-crop img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pr-missing { font-size: 0.78rem; color: var(--fg-dim); font-style: italic; }
.pr-unsure { border: 1px solid var(--border); border-radius: 5px; padding: 0.35rem 0.7rem; cursor: pointer; font-size: 0.85rem; white-space: nowrap; background: var(--bg-3); color: var(--fg-2); }
.pr-unsure:hover { background: var(--border); }

/* ----- Report (pre-demolition reuse audit) ----- */
.rep-builder { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.2rem; margin: 1rem 0; }
.rep-row { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-bottom: 0.8rem; }
.rep-row > div { display: flex; flex-direction: column; gap: 0.3rem; min-width: 160px; }
.rep-lbl { font-size: 0.78rem; color: var(--fg-2); }
.rep-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rep-chip { font-size: 0.82rem; padding: 0.25rem 0.7rem; border-radius: 4px; border: 1px solid var(--border); background: var(--bg-3); color: var(--fg-2); cursor: pointer; }
.rep-chip.on { background: var(--accent-dim); color: #fff; border-color: var(--accent-dim); }
.rep-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.8rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }
.rep-quicksum { font-size: 0.9rem; color: var(--fg-2); }
.rep-actions { display: flex; gap: 0.5rem; }

.rep-doc { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; }
.rep-head { border-bottom: 1px solid var(--border); padding-bottom: 0.8rem; margin-bottom: 1rem; }
.rep-doctitle { font-size: 0.78rem; color: var(--fg-2); }
.rep-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; margin-bottom: 1.2rem; }
.rep-metric { background: var(--bg-3); border-radius: 6px; padding: 0.8rem 1rem; }
.rep-metric-lbl { font-size: 0.78rem; color: var(--fg-2); margin-bottom: 0.2rem; }
.rep-metric-val { font-size: 1.4rem; font-weight: 600; }
.rep-metric-sub { font-size: 0.76rem; color: var(--fg-dim); margin-top: 0.1rem; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.rep-table th { text-align: left; font-size: 0.76rem; color: var(--fg-2); font-weight: 500; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.rep-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.rep-table td.num, .rep-table th.num { text-align: right; }
.rep-roomrow td { background: var(--bg-3); font-weight: 600; font-size: 0.8rem; color: var(--fg-2); padding: 0.4rem 0.5rem; }
.rep-subtotal td { border-top: 1px solid var(--border); border-bottom: 2px solid var(--border); color: var(--fg); }
.rep-staging { background: #1c3b4a; color: #a8d8f0; border-radius: 6px; padding: 0.5rem 0.8rem; margin-bottom: 1rem; font-size: 0.85rem; }
.rep-step { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.7rem; overflow: hidden; }
.rep-step-head { display: flex; align-items: center; gap: 0.6rem; background: var(--bg-3); padding: 0.5rem 0.7rem; }
.rep-step-n { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-dim); color: #fff; font-size: 0.8rem; font-weight: 600; flex: 0 0 auto; }
.rep-step-room { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.7rem 0.4rem 2.1rem; border-top: 1px solid var(--border); font-size: 0.9rem; }
@media print { .rep-staging { color: #10475a; background: #e0f0f8; } }
.rep-precon { background: #4a3a1f; color: #f0c060; border-radius: 6px; padding: 0.5rem 0.8rem; margin-bottom: 1rem; font-size: 0.85rem; }
.rep-stage { display: inline-block; margin-top: 0.25rem; font-size: 0.72rem; color: var(--fg-2); background: var(--bg-3); border-radius: 4px; padding: 0.05rem 0.4rem; }
.rep-flag { margin-top: 0.25rem; font-size: 0.78rem; color: var(--warn); }
.rep-flag-hard { color: #f0a060; font-weight: 600; }

@media print { .rep-precon { color: #7a5a10; background: #fff6e0; } }

@media print {
  /* The app theme is dark (--fg #eee on --bg #111). Browsers print text
     color but not backgrounds by default, so without this override the
     report prints near-white text on white paper. Re-map the palette to
     print-friendly values — every component color rides on the variables. */
  :root {
    --bg: #fff;
    --bg-2: #fff;
    --bg-3: #f2f2f2;
    --fg: #111;
    --fg-2: #444;
    --fg-dim: #6b6b6b;   /* 5.28:1 on white; #777 was 4.48:1, just under AA */
    --accent: #1a5d9e;
    --border: #bbb;
  }
  body { background: #fff; color: #111; }
  header, .rep-builder, #status { display: none !important; }
  .rep-doc { border: none; padding: 0; }
}

/* --- catalog two-pane layout: floor→room tree + scoped content ------------ */
.cat-layout { display: flex; gap: 1rem; align-items: flex-start; }
.cat-side { flex: 0 0 220px; position: sticky; top: 0.5rem; max-height: calc(100vh - 4rem); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 0.45rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; }
.cat-content { flex: 1 1 auto; min-width: 0; }
.cat-side-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%; text-align: left; background: none; border: none; border-radius: 4px; color: var(--fg-2); padding: 0.32rem 0.5rem; font-size: 0.85rem; cursor: pointer; }
.cat-side-row:hover { background: var(--bg-3); color: var(--fg); }
.cat-side-row.on { background: var(--accent-dim); color: #fff; }
.cat-side-row.sub { padding-left: 1.3rem; font-size: 0.82rem; }
.cat-side-n { font-variant-numeric: tabular-nums; opacity: 0.75; }
.cat-dash-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.2rem; width: 100%; }
.cat-kinds, .cat-steps { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.cat-kind { background: var(--bg-3); border: 1px solid var(--border); border-radius: 5px; color: var(--fg-2); padding: 0.25rem 0.6rem; font-size: 0.82rem; cursor: pointer; }
.cat-kind:hover { color: var(--fg); border-color: var(--fg-dim); }
.cat-kind.on { background: var(--accent-dim); color: #fff; border-color: var(--accent-dim); }
.cat-steps { margin-left: auto; }
.cat-step { background: none; border: 1px solid transparent; border-radius: 5px; color: var(--fg-2); padding: 0.25rem 0.5rem; font-size: 0.82rem; cursor: pointer; white-space: nowrap; }
.cat-step:hover { color: var(--fg); border-color: var(--border); }
.cat-step.on { border-color: var(--accent-dim); color: var(--fg); background: var(--bg-3); }
@media (max-width: 900px) { .cat-layout { flex-direction: column; } .cat-side { position: static; flex-basis: auto; width: 100%; max-height: 40vh; } }

/* Phone widths. Not a mobile redesign — just enough that nothing is clipped:
   the header is a nowrap flex row, so below ~640px "Log out" is pushed past
   the right edge and the whole document scrolls sideways. Let it wrap. */
@media (max-width: 640px) {
  header { flex-wrap: wrap; gap: 0.5rem 0.75rem; padding: 0.6rem 0.9rem; }
  header #nav { margin-left: 0; }
  main { padding: 0 0.9rem; }
}
