/* ============================================================
   Terenova — app layer (technical / GIS adaptation)
   Cream chrome, neutral work surfaces, forest primary, full
   status + provenance system. Built on the --zn-* design tokens
   (legacy namespace, intentionally retained).
   ============================================================ */

:root {
  /* status semantics (extends DS semantic palette) */
  --st-ok:        #2A7355;  --st-ok-bg:   #DCEADF;
  --st-uwaga:     #B07D12;  --st-uwaga-bg:#F7EACB;  --st-uwaga-ink:#8A6209; /* fill vs AA text (4.6:1 on bg) */
  --st-ryzyko:    #9C4B10;  --st-ryzyko-bg:#FAE3CF;  /* AA: 4.95:1 on bg (was #C2611F 3.37:1) */
  --st-kryt:      #A8362A;  --st-kryt-bg: #F6DAD4;   /* AA: 4.93:1 on bg (was #B23B2E 4.47:1) */
  --st-part:      #45688A;  --st-part-bg: #DCE7F0;   /* dane częściowe / do weryfikacji */
  --st-brak:      #585D52;  --st-brak-bg: #E7E9E0;   /* brak danych — AA 5.5:1 (was #6E7468 3.93:1) */
  --st-pokr:      #5E6356;  --st-pokr-bg: #EFF0EA;   /* brak pokrycia (AA: 5.4:1 on bg) */
  --st-doc:       #1F6E5B;  --st-doc-bg:  #D2EBE2;   /* potwierdzone dokumentem */

  /* provenance */
  --pv-public:    #3F5A73;  --pv-public-bg:#DEE7EF;  /* źródło publiczne */
  --pv-system:    #5E6B62;  --pv-system-bg:#E7EBE5;  /* interpretacja systemu */
  --pv-arch:      #5B4B9E;  --pv-arch-bg: #E6E1F4;   /* korekta architekta */
  --pv-assume:    #79611E;  --pv-assume-bg:#F4ECD2;  /* założenie robocze — AA 5.0:1 (was #9A7B2E 3.39:1) */

  /* work surfaces — cooler than cream for the technical screens */
  --work-bg:      #F2F3EF;
  --panel:        #FFFFFF;
  --panel-2:      #FBFBF8;
  --hairline:     #E4E5DD;

  --sidebar-w: 232px;
  --topbar-h: 60px;
  --context-h: 46px;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--zn-font-sans);
  background: var(--work-bg);
  color: var(--zn-fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--zn-forest-100); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #D5D7CC; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #C2C4B7; background-clip: padding-box; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  overflow: hidden;
}
.app--public {
  grid-template-columns: minmax(0, 1fr);
}
.sidebar { grid-row: 1 / 3; grid-column: 1; }
.topbar  { grid-row: 1; grid-column: 2; }
.workarea {
  grid-row: 2; grid-column: 2;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app--public .topbar,
.app--public .workarea {
  grid-column: 1;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--zn-forest-900);
  color: var(--zn-cream-50);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0a1f16;
  /* As a grid item spanning both rows the sidebar's height is bounded by
     the 100vh .app grid. min-height:0 overrides the default min-height:auto
     so this flex column can shrink to that bound instead of growing to fit
     its content — letting the flex:1; overflow-y:auto .sidebar__nav scroll
     within the viewport rather than pushing its last navitem off-screen. */
  min-height: 0;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--zn-forest-600);
  display: grid; place-items: center; flex: none;
}
.sidebar__name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.sidebar__name small { display: block; font-weight: 500; font-size: 11px; opacity: 0.6; letter-spacing: 0.02em; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.sidebar__group { font-size: 12px; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: rgba(250,246,238,0.52); padding: 14px 10px 6px; }
.navitem {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  min-height: 44px;
  border: 0; background: none;
  color: rgba(250,246,238,0.82);
  font-size: 14px; font-weight: 500;
  border-radius: 8px;
  text-align: left;
  transition: background var(--zn-dur-fast), color var(--zn-dur-fast);
  position: relative;
}
.navitem:hover { background: rgba(255,255,255,0.06); color: var(--zn-cream-50); }
.navitem--active { background: var(--zn-forest-700); color: #fff; }
.navitem--active::before { content:''; position:absolute; left:-10px; top:6px; bottom:6px; width:3px; border-radius:0 3px 3px 0; background: var(--zn-terracotta-500); }
.navitem svg { flex: none; opacity: 0.9; }
.navitem__badge { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--zn-terracotta-600); color:#fff; border-radius: 999px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; }
.navitem__badge--muted { background: rgba(255,255,255,0.14); color: rgba(255,255,255,0.85); }
.sidebar__advanced { margin-top: 6px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 7px; }
.sidebar__advanced-summary {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 2px;
  padding: 8px 10px;
  min-height: 38px;
  border-radius: 8px;
  color: rgba(250,246,238,0.72);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  list-style: none;
  transition: background var(--zn-dur-fast), color var(--zn-dur-fast);
}
.sidebar__advanced-summary:hover { background: rgba(255,255,255,0.06); color: var(--zn-cream-50); }
.sidebar__advanced-summary::-webkit-details-marker { display:none; }
.sidebar__advanced[open] .sidebar__advanced-summary { color: var(--zn-cream-50); }

/* ---------- Topbar ---------- */
.topbar {
  background: rgba(250,246,238,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  min-width: 0;
}
.topbar__search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--zn-border);
  border-radius: 10px;
  padding: 8px 12px;
  flex: 0 1 320px;
  min-width: 220px;
  color: var(--zn-fg-muted);
  font-size: 13.5px;
}
.topbar__search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; font-size: 13.5px; color: var(--zn-fg); }
.topbar__spacer { flex: 1 1 auto; min-width: 0; }
.topbar--public {
  gap: 12px;
  padding: 0 22px;
}
.topbar__public-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--zn-forest-900);
  font-family: var(--zn-font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}
.topbar__public-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
  color: #fff;
  background: var(--zn-forest-700);
}
.topbar__runmenu { position: relative; flex: 0 1 260px; min-width: 184px; }
.topbar__variant {
  display: flex; align-items: center; gap: 8px;
  background: var(--zn-forest-50);
  border: 1px solid var(--zn-forest-200);
  border-radius: 10px; padding: 6px 8px 6px 12px;
  cursor: pointer;
  width: 100%;
  min-width: 0;
}
.topbar__variant > div { min-width: 0; }
.topbar__variant .lbl { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--zn-forest-600); }
.topbar__variant .val { font-size: 13.5px; font-weight: 600; color: var(--zn-forest-900); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__recalc {
  font-size: 12px; color: var(--zn-fg-tertiary);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.topbar__recalc .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st-ok); }
.topbar__recalc.is-stale .dot { background: var(--st-uwaga); }
.topbar__demo-label-short { display: none; }

@media (max-height: 760px) {
  .sidebar__nav { padding-top: 6px; }
  .sidebar__group { padding: 10px 10px 5px; }
  .navitem { padding: 7px 10px; font-size: 13px; }
}

@media (max-width: 1120px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar__search { min-width: 190px; }
  .topbar__variant { min-width: 170px; }
}

@media (max-width: 1320px) {
  .topbar__demo-label { display: none; }
  .topbar__demo-label-short { display: none; }
  .topbar > button.btn:last-of-type { width: 38px; padding-left: 0; padding-right: 0; gap: 0; }
}
.iconbtn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--zn-border);
  background: var(--panel);
  display: grid; place-items: center; color: var(--zn-fg-secondary);
  position: relative;
  transition: color var(--zn-dur-fast), border-color var(--zn-dur-fast);
}
.iconbtn:hover { color: var(--zn-fg); border-color: var(--zn-border-strong); }
/* WCAG 2.5.5 touch target: invisible 44x44 hit-area that beats inline width/height on dialog close buttons, without resizing the visible control. */
.iconbtn::before, .toggle::before { content:''; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:44px; height:44px; }
.iconbtn__dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--zn-terracotta-600); border: 1.5px solid var(--panel); }
.avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--zn-forest-700); color: var(--zn-cream-50);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  flex: 0 0 38px;
}

/* ---------- Parcel context bar ---------- */
.contextbar {
  height: var(--context-h);
  background: var(--panel);
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 0;
  padding: 0 18px;
  flex: none;
  overflow-x: auto;
}
.ctx { display: flex; align-items: center; gap: 8px; padding: 0 16px; height: 100%; border-right: 1px solid var(--hairline); white-space: nowrap; }
.ctx:first-child { padding-left: 0; }
.ctx:last-child { border-right: 0; }
.ctx__k { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--zn-fg-muted); }
.ctx__v { font-size: 14px; font-weight: 600; color: var(--zn-fg); }
.ctx__v.mono { font-family: var(--zn-font-mono); font-weight: 500; font-size: 12.5px; }
.ctx__score { display:flex; align-items:center; gap:8px; }
.scorechip { font-weight: 800; font-size: 14px; padding: 3px 9px; border-radius: 8px; font-feature-settings:"tnum" 1; }

/* ---------- Screen scroll container ---------- */
.screen { flex: 1; overflow-y: auto; }
.screen__inner { padding: 24px 28px 64px; max-width: 1320px; }
.screen__inner--wide { max-width: none; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.pagehead__t { font-family: var(--zn-font-display); font-weight: 600; font-size: 27px; letter-spacing: -0.02em; margin: 0; }
.pagehead__sub { color: var(--zn-fg-secondary); font-size: 14px; margin: 5px 0 0; max-width: 640px; }
.pagehead__actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================
   Cards & primitives
   ============================================================ */
.card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--zn-shadow-xs);
}
.card--pad { padding: 18px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--hairline); }
.card__title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; display:flex; align-items:center; gap:9px; }
.card__title svg { color: var(--zn-fg-tertiary); }
.card__body { padding: 18px; }
.card--readonly { background: repeating-linear-gradient(135deg, #fff, #fff 16px, #fcfbf6 16px, #fcfbf6 32px); }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--zn-fg-brand); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1180px){ .grid-4 { grid-template-columns: repeat(2,1fr);} .grid-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 767px){ .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
/* Two-column layouts (sidebar + content, split panels) that set an inline
   grid-template-columns: collapse to a single column on narrow viewports.
   !important overrides the inline desktop template (intentional). */
@media (max-width: 767px){
  .grid--collapse { grid-template-columns: minmax(0, 1fr) !important; }
  .grid--collapse > * { min-width: 0; }
  .autopilot-pagehead { align-items: flex-start; flex-direction: column; gap: 12px; }
  .autopilot-pagehead > * { min-width: 0; max-width: 100%; }
  .autopilot-pagehead__status { justify-content: flex-start !important; width: 100%; }
}

/* metric */
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric__k { font-size: 12px; font-weight: 600; color: var(--zn-fg-tertiary); letter-spacing: 0.01em; display:flex; align-items:center; gap:6px; }
.metric__v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--zn-fg); font-feature-settings:"tnum" 1; line-height: 1.1; }
.metric__v small { font-size: 14px; font-weight: 600; color: var(--zn-fg-tertiary); margin-left: 3px; }
.metric__sub { font-size: 12px; color: var(--zn-fg-tertiary); }
.metric--lg .metric__v { font-size: 34px; }

/* metric band: read-only metric strip as one bordered unit with dividers,
   instead of a mosaic of single-metric cards (design audit T15). Reuses
   .grid-3/.grid-4 for the column count + their <=1180px collapse. */
.metricband { display: grid; gap: 0; border: 1px solid var(--hairline); border-radius: 14px; background: var(--panel); box-shadow: var(--zn-shadow-xs); overflow: hidden; }
.metricband > .metric { padding: 15px 18px; border-right: 1px solid var(--hairline); }
.metricband > .metric:last-child { border-right: 0; }
@media (max-width: 1180px){ .metricband > .metric:nth-child(2n) { border-right: 0; } }

/* key-value rows */
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--hairline); min-width: 0; }
.kv:last-child { border-bottom: 0; }
.kv__k { font-size: 14px; color: var(--zn-fg-secondary); display:flex; align-items:center; gap:7px; min-width: 0; }
.kv__v { font-size: 14px; font-weight: 600; color: var(--zn-fg); text-align: right; font-feature-settings:"tnum" 1; min-width: 0; overflow-wrap: anywhere; }

/* ============================================================
   Status & provenance badges
   ============================================================ */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 4px 9px 4px 8px; border-radius: 999px;
  letter-spacing: 0.02em; white-space: nowrap;
  color: var(--c, var(--zn-fg)); background: var(--bg, var(--zn-ink-100));
}
.tag .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex:none; }
.tag--sq { border-radius: 6px; }
.tag--ok    { --c: var(--st-ok);    --bg: var(--st-ok-bg); }
.tag--uwaga { --c: var(--st-uwaga-ink); --bg: var(--st-uwaga-bg); }
.tag--ryzyko{ --c: var(--st-ryzyko);--bg: var(--st-ryzyko-bg); }
.tag--kryt  { --c: var(--st-kryt);  --bg: var(--st-kryt-bg); }
.tag--part  { --c: var(--st-part);  --bg: var(--st-part-bg); }
.tag--brak  { --c: var(--st-brak);  --bg: var(--st-brak-bg); }
.tag--pokr  { --c: var(--st-pokr);  --bg: var(--st-pokr-bg); }
.tag--doc   { --c: var(--st-doc);   --bg: var(--st-doc-bg); }

/* provenance: outlined, with leading marker */
.pv {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; line-height: 1;
  padding: 3px 8px; border-radius: 6px;
  letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  color: var(--c); background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
}
.pv .m { width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex:none; }
.pv--public { --c: var(--pv-public); --bg: var(--pv-public-bg); }
.pv--system { --c: var(--pv-system); --bg: var(--pv-system-bg); }
.pv--arch   { --c: var(--pv-arch);   --bg: var(--pv-arch-bg); }
.pv--arch .m { border-radius: 999px; }
.pv--assume { --c: var(--pv-assume); --bg: var(--pv-assume-bg); }
.pv--assume .m { background: repeating-linear-gradient(45deg, var(--c), var(--c) 2px, transparent 2px, transparent 4px); border:1px solid var(--c); }
.pv--doc    { --c: var(--st-doc);    --bg: var(--st-doc-bg); }
.pv--verify { --c: var(--st-ryzyko); --bg: var(--st-ryzyko-bg); }

/* ============================================================
   Buttons (extend DS)
   ============================================================ */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; font-weight:600; font-size:14px; line-height:1; padding:10px 16px; border-radius:10px; border:1px solid transparent; transition: background var(--zn-dur-fast), color var(--zn-dur-fast), border-color var(--zn-dur-fast), transform var(--zn-dur-fast); white-space:nowrap; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline:none; box-shadow: var(--zn-shadow-focus); }
.btn--primary { background: var(--zn-primary); color: var(--zn-on-primary); }
.btn--primary:hover { background: var(--zn-primary-hover); }
.btn--accent { background: var(--zn-accent); color:#fff; }
.btn--accent:hover { background: var(--zn-accent-hover); }
.btn--secondary { background: var(--panel); color: var(--zn-fg-brand); border-color: var(--zn-forest-200); }
.btn--secondary:hover { background: var(--zn-forest-50); }
.btn--ghost { background: var(--panel); color: var(--zn-fg); border-color: var(--zn-border); }
.btn--ghost:hover { background: var(--zn-bg-sunken); }
.btn--quiet { background: transparent; color: var(--zn-fg-secondary); border-color: transparent; padding: 8px 10px; }
.btn--quiet:hover { background: var(--zn-bg-sunken); color: var(--zn-fg); }
.btn--sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; min-height: 36px; }
.btn--lg { padding: 13px 22px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.linklike { color: var(--zn-fg-brand); font-weight:600; cursor:pointer; font-size:13px; display:inline-flex; align-items:center; gap:5px; background:none; border:0; padding:6px 2px; min-height:36px; border-radius:6px; }
.linklike:hover { color: var(--zn-forest-800); }

/* ============================================================
   Tables
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--zn-fg-tertiary); padding: 10px 14px; border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--panel-2); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl td.num, .tbl th.num { text-align: right; font-feature-settings:"tnum" 1; }
.tbl .cite { font-size: 12px; color: var(--zn-fg-tertiary); font-style: italic; }
.tbl .param { font-weight: 600; color: var(--zn-fg); }
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll > .tbl { min-width: 820px; }
.table-scroll--compact > .tbl { min-width: 640px; }
.table-scroll--wide > .tbl { min-width: 1120px; }
.table-scroll--audit > .tbl { min-width: 980px; }
.tbl td, .tbl th { overflow-wrap: anywhere; }
.tbl .tag, .tbl .btn { white-space: normal; }

/* Report data tables keep their compact audit layout on desktop and become
   labelled records on mobile. This avoids hiding half of a source result
   behind an inner horizontal scroller on a phone. */
@media (max-width: 767px) {
  .report-pagehead { align-items: stretch; flex-direction: column; gap: 14px; }
  .report-page-actions { width: 100%; }
  .report-page-actions .btn { flex: 1 1 150px; min-width: 0; }
  .report-paper-head { padding: 20px 16px !important; }
  .report-paper-body { padding: 20px 16px 28px !important; }
  .report-paper-heading { align-items: flex-start; gap: 10px; }
  .report-paper-heading > .row { justify-content: flex-start !important; }
  .report-caveat .tag {
    max-width: 100%;
    line-height: 1.25;
    white-space: normal;
  }
  .report-source-results,
  .report-metric-results { overflow: visible; }
  .report-source-results > .tbl,
  .report-metric-results > .tbl {
    display: block;
    min-width: 0;
    border: 0 !important;
  }
  .report-source-results thead,
  .report-metric-results thead { display: none; }
  .report-source-results tbody,
  .report-metric-results tbody { display: block; }
  .report-source-results tr,
  .report-metric-results tr {
    display: block;
    padding: 10px 0;
    border-top: 1px solid var(--hairline);
  }
  .report-source-results td,
  .report-metric-results td {
    display: block;
    width: 100%;
    min-width: 0 !important;
    padding: 5px 0;
    border: 0;
  }
  .report-source-results td::before,
  .report-metric-results td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--zn-fg-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}
@supports selector(:has(*)) {
  .card:has(> .tbl),
  .card:has(.card__body > .tbl) {
    overflow-x: auto;
  }
  .card:has(> .tbl) > .tbl,
  .card:has(.card__body > .tbl) .card__body > .tbl {
    min-width: 760px;
  }
}

.variant-compare-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: 8px; background: #fff; }
.variant-compare { width: 100%; min-width: 720px; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.variant-compare th, .variant-compare td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; overflow-wrap: anywhere; }
.variant-compare th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--zn-fg-tertiary); background: var(--panel-2); }
.variant-compare tr:last-child td { border-bottom: 0; }
.variant-compare td:first-child { font-weight: 650; color: var(--zn-fg); }
.variant-compare td.best { background: #1f6f43; color: #fff; font-weight: 700; }
.variant-overlay-legend {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--hairline);
  background: rgba(255,255,255,.72);
}
.variant-overlay-legend__item {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 220px; font-size: 12px; color: var(--zn-fg-secondary);
}
.variant-overlay-legend__item input { flex: none; }
.variant-overlay-legend__item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variant-hover-tip {
  position: absolute; right: 10px; top: 10px; z-index: 2;
  max-width: min(260px, calc(100% - 20px));
  padding: 6px 9px; border-radius: 6px;
  background: rgba(20,58,43,.88); color: #fff;
  font-size: 12px; line-height: 1.3; pointer-events: none;
  box-shadow: var(--zn-shadow-sm);
}

/* Tabular figures: align digit columns (metrics, KV, score chips, tables) */
.metric__v, .kv__v, .scorechip, .ctx__v, .tbl td, .tbl th, .variant-compare td, .variant-compare th { font-variant-numeric: tabular-nums; }

/* ============================================================
   GIS map / canvas
   ============================================================ */
.gis {
  position: relative; border-radius: 12px; overflow: hidden;
  background:
    radial-gradient(circle at 25% 30%, rgba(185,214,197,0.45) 0%, transparent 35%),
    radial-gradient(circle at 75% 70%, rgba(201,169,74,0.18) 0%, transparent 40%),
    linear-gradient(160deg, #E9EFE8 0%, #DFE8DD 100%);
  border: 1px solid var(--hairline);
}
.gis__grid { position:absolute; inset:0; background-image: linear-gradient(rgba(28,86,64,0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(28,86,64,0.07) 1px, transparent 1px); background-size: 32px 32px; pointer-events:none; }
.gis svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gis__chip { position:absolute; background: rgba(255,255,255,0.92); border:1px solid var(--hairline); border-radius:8px; padding:5px 9px; font-size:11px; font-weight:600; box-shadow: var(--zn-shadow-sm); display:flex; align-items:center; gap:6px; }
.gis__legend { position:absolute; left:12px; bottom:12px; background:rgba(255,255,255,0.94); border:1px solid var(--hairline); border-radius:10px; padding:10px 12px; box-shadow:var(--zn-shadow-sm); font-size:11.5px; display:flex; flex-direction:column; gap:6px; }
.gis__legend .row { display:flex; align-items:center; gap:8px; color: var(--zn-fg-secondary); }
.gis__legend .sw { width:14px; height:11px; border-radius:3px; flex:none; }
.gis__scale { position:absolute; right:12px; bottom:12px; background:rgba(255,255,255,0.9); border:1px solid var(--hairline); border-radius:8px; padding:4px 8px; font-size:10.5px; font-weight:600; color:var(--zn-fg-secondary); display:flex; align-items:center; gap:6px; }
.gis__scale .bar { width:46px; height:4px; border-bottom:2px solid var(--zn-fg-secondary); border-left:2px solid var(--zn-fg-secondary); border-right:2px solid var(--zn-fg-secondary); }

/* ============================================================
   Evidence drawer & recalc panel
   ============================================================ */
.scrim { position: fixed; inset: 0; background: rgba(14,42,31,0.32); z-index: 90; opacity: 0; pointer-events: none; transition: opacity var(--zn-dur-base); }
.scrim.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 440px; max-width: 92vw;
  background: var(--panel); z-index: 95;
  box-shadow: var(--zn-shadow-xl);
  transform: translateX(100%); transition: transform var(--zn-dur-base) var(--zn-ease-out);
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer__head { padding: 18px 20px; border-bottom: 1px solid var(--hairline); display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.drawer__body { flex:1; overflow-y:auto; padding: 18px 20px; }
.drawer__foot { padding: 14px 20px; border-top: 1px solid var(--hairline); display:flex; gap:10px; }
.evidence-hero { border: 1px solid var(--zn-forest-100); background: var(--zn-forest-50); border-radius: 12px; padding: 13px 14px; margin-bottom: 12px; }
.evidence-hero__label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--zn-fg-brand); margin-bottom: 4px; }
.evidence-hero__title { font-size: 15px; font-weight: 750; color: var(--zn-fg); line-height: 1.35; text-wrap: pretty; }
.evidence-hero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--zn-fg-secondary); }
.evidence-summary { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.evidence-summary strong { font-size: 12.5px; color: var(--zn-fg); font-weight: 650; text-wrap: pretty; }
.evidence-summary span { font-size: 11.5px; color: var(--zn-fg-tertiary); }
.evidence-proof { border: 1px solid var(--hairline); border-radius: 12px; background: var(--panel); padding: 12px 13px; margin: 10px 0; box-shadow: var(--zn-shadow-xs); }
.evidence-proof--muted { background: var(--panel-2); box-shadow: none; }
.evidence-proof__title { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--zn-fg); margin-bottom: 8px; }
.evidence-proof__title svg { color: var(--zn-fg-tertiary); }
.evidence-code { max-width: 100%; overflow: auto; white-space: nowrap; word-break: normal; border: 1px solid var(--hairline); background: var(--zn-bg-sunken); border-radius: 8px; padding: 8px 9px; font-size: 11px; line-height: 1.45; color: var(--zn-fg-secondary); }
.evidence-code--small { white-space: pre-wrap; word-break: break-word; }
.evidence-artifact { padding: 7px 0; border-top: 1px dashed var(--hairline); }
.evidence-artifact:first-of-type { border-top: 0; padding-top: 0; }
.evidence-artifact__uri { font-size: 11px; color: var(--zn-fg-secondary); word-break: break-all; }
.evidence-feature { border-top: 1px dashed var(--hairline); padding-top: 10px; margin-top: 10px; }
.evidence-feature:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.evidence-feature__grid { display: grid; grid-template-columns: 1fr; gap: 7px; }
.evidence-feature__item { display: grid; gap: 2px; min-width: 0; }
.evidence-feature__item span { font-size: 11px; color: var(--zn-fg-tertiary); }
.evidence-feature__item strong { font-size: 12px; color: var(--zn-fg); font-weight: 650; word-break: break-word; line-height: 1.35; }
.evidence-details { margin: 10px 0; }
.evidence-details > summary { cursor: pointer; color: var(--zn-fg-secondary); font-size: 12px; font-weight: 600; }

/* Manual checks: decision first, audit/support material second. */
.manual-check-card__grid {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr);
  overflow: hidden;
  border-radius: 14px;
}
.manual-check-card__body { padding: 16px 18px 18px; min-width: 0; }
.manual-check-card__header { --g: 10px; margin-bottom: 10px; }
.manual-check-card__badges { --g: 8px; }
.manual-check-card__title {
  max-width: 760px;
  margin-bottom: 6px;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  text-wrap: pretty;
}
.manual-check-card__reason {
  max-width: 860px;
  margin-bottom: 12px;
  font-size: 13.5px;
  line-height: 1.48;
}
.manual-context {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 13px;
  border: 1px solid color-mix(in srgb, var(--st-part) 18%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--st-part-bg) 46%, #fff);
  color: var(--zn-fg-secondary);
  font-size: 12.5px;
  line-height: 1.5;
}
.manual-context svg { flex: none; margin-top: 1px; color: var(--st-part); }
.conflict-reason {
  flex: 1 1 320px;
  min-width: 260px;
  max-width: 620px;
  line-height: 1.35;
  text-align: right;
}
.support-details {
  border-top: 1px dashed var(--hairline);
  padding-top: 8px;
}
.support-details > summary {
  cursor: pointer;
  color: var(--zn-fg-tertiary);
  font-size: 12.5px;
  font-weight: 650;
}

.recalc {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  width: 340px; background: var(--panel);
  border: 1px solid var(--zn-forest-200);
  border-radius: 14px; box-shadow: var(--zn-shadow-lg);
  overflow: hidden;
}
.recalc__head { padding: 13px 16px; background: var(--zn-forest-50); border-bottom: 1px solid var(--zn-forest-200); display:flex; align-items:center; gap:10px; }
.recalc__body { padding: 14px 16px; }
.recalc__pulse { width:9px; height:9px; border-radius:50%; background: var(--st-uwaga); box-shadow: 0 0 0 0 rgba(176,125,18,0.5); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(176,125,18,0.5);} 70%{box-shadow:0 0 0 8px rgba(176,125,18,0);} 100%{box-shadow:0 0 0 0 rgba(176,125,18,0);} }

/* ============================================================
   Misc utilities
   ============================================================ */
.row { display:flex; align-items:center; gap: var(--g,12px); }
.col { display:flex; flex-direction:column; gap: var(--g,12px); }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--zn-fg-tertiary); overflow-wrap: anywhere; }
.sec { color: var(--zn-fg-secondary); }
.mono { font-family: var(--zn-font-mono); }
.datalink { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--zn-forest-300, currentColor); display:inline-flex; align-items:center; min-height:28px; max-width:100%; overflow-wrap:anywhere; word-break:break-word; }
.datalink:hover { text-decoration-color: var(--zn-forest-600, currentColor); }
.divider { height:1px; background: var(--hairline); border:0; margin: 0; }
.note { font-size: 12.5px; color: var(--zn-fg-secondary); background: var(--zn-forest-50); border:1px solid var(--zn-forest-100); border-radius: 10px; padding: 11px 13px; display:flex; gap:9px; line-height:1.5; }
.note svg { flex:none; color: var(--zn-forest-600); margin-top:1px; }
.note--info { background: var(--st-part-bg); border-color: color-mix(in srgb, var(--st-part) 22%, transparent); }
.note--info svg { color: var(--st-part); }

.bar { height: 7px; border-radius: 999px; background: var(--zn-ink-100); overflow: hidden; }
.bar > span { display:block; height:100%; border-radius:999px; background: var(--zn-forest-600); }

.seg { display:inline-flex; background: var(--zn-bg-sunken); border:1px solid var(--hairline); border-radius:9px; padding:3px; gap:2px; }
.seg button { border:0; background:none; padding:6px 12px; border-radius:7px; font-size:12.5px; font-weight:600; color:var(--zn-fg-secondary); min-height:32px; }
.seg button.on { background: var(--panel); color: var(--zn-fg); box-shadow: var(--zn-shadow-xs); }

input[type=range]{ -webkit-appearance:none; appearance:none; height:5px; border-radius:999px; background: var(--zn-ink-100); outline:none; }
input[type=range]::-webkit-slider-thumb{ -webkit-appearance:none; width:17px; height:17px; border-radius:50%; background: var(--zn-forest-700); border:2px solid #fff; box-shadow: var(--zn-shadow-sm); cursor:pointer; }

.fieldlabel { font-size:12px; font-weight:600; color: var(--zn-fg); margin-bottom:6px; display:block; }
.input, .select { font-size:13.5px; padding:9px 11px; border:1px solid var(--zn-border); border-radius:9px; background: var(--panel); color: var(--zn-fg); width:100%; }
.input:focus, .select:focus { outline:none; border-color: var(--zn-primary); box-shadow: var(--zn-shadow-focus); }
/* a11y (design-review): keyboard focus ring for inline-styled inputs/textareas
   that bypass .input/.select (topbar parcel search + shell.jsx fields) — they
   otherwise render NO :focus indicator. outline-only, so the resting look and
   layout are unchanged; shows only on keyboard focus. */
input:not(.input):not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus-visible,
textarea:not(.input):focus-visible { outline: 2px solid var(--zn-primary); outline-offset: 1px; }

.toggle { width:38px; height:22px; border-radius:999px; background: var(--zn-ink-200); border:0; position:relative; transition: background var(--zn-dur-fast); flex:none; }
.toggle.on { background: var(--zn-forest-600); }
.toggle::after { content:''; position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%; background:#fff; box-shadow: var(--zn-shadow-xs); transition: transform var(--zn-dur-fast); }
.toggle.on::after { transform: translateX(16px); }

.empty { text-align:center; padding: 48px 24px; color: var(--zn-fg-tertiary); }
.empty svg { color: var(--zn-ink-300); margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--zn-fg); }
.empty p { margin: 0 auto; max-width: 360px; font-size: 13.5px; }

/* stepper */
.steps { display:flex; align-items:center; gap:0; margin-bottom: 22px; }
.step { display:flex; align-items:center; gap:9px; font-size:13px; font-weight:600; color: var(--zn-fg-muted); }
.step__n { width:24px; height:24px; border-radius:50%; border:1.5px solid var(--zn-border-strong); display:grid; place-items:center; font-size:12px; color: var(--zn-fg-muted); background:var(--panel); }
.step.done .step__n { background: var(--zn-forest-600); border-color: var(--zn-forest-600); color:#fff; }
.step.active { color: var(--zn-fg); }
.step.active .step__n { border-color: var(--zn-forest-700); color: var(--zn-forest-700); }
.step__line { width:38px; height:1.5px; background: var(--zn-border); margin: 0 12px; }
.step.done + .step .step__line, .step.done .step__line { background: var(--zn-forest-300, var(--zn-forest-200)); }

/* tornado chart bars */
.torn { display:grid; grid-template-columns: 150px 1fr; align-items:center; gap:12px; padding:7px 0; }
.torn__label { font-size:12.5px; color: var(--zn-fg-secondary); text-align:right; }
.torn__track { position:relative; height:22px; }
.torn__mid { position:absolute; left:50%; top:-4px; bottom:-4px; width:1px; background: var(--zn-border-strong); }
.torn__neg, .torn__pos { position:absolute; top:3px; height:16px; border-radius:4px; }
.torn__neg { right:50%; background: var(--st-ryzyko); }
.torn__pos { left:50%; background: var(--st-ok); }

/* ============ integration additions (real API frontend) ============ */

/* mock screens: fixed badge + muted numbers */
.mockwrap { position: relative; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.mockbadge {
  position: absolute; top: 14px; right: 22px; z-index: 50;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--pv-assume); background: var(--pv-assume-bg);
  border: 1.5px dashed var(--pv-assume); border-radius: 8px; padding: 6px 11px;
  pointer-events: auto; box-shadow: var(--zn-shadow-sm);
}
.mockwrap .metric__v,
.mockwrap .kv__v,
.mockwrap .scorechip,
.mockwrap td.num { opacity: 0.65; filter: saturate(0.55); }

/* loading state */
.loadbox {
  display: grid;
  gap: 18px;
  padding: 28px;
  color: var(--zn-fg-tertiary);
  font-size: 13.5px;
}
.loadbox__status { display: flex; align-items: center; gap: 11px; }
.spin {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--zn-ink-100); border-top-color: var(--zn-forest-600);
  animation: tn-spin 0.8s linear infinite;
}
@keyframes tn-spin { to { transform: rotate(360deg); } }
.skeleton-page {
  display: grid;
  gap: 12px;
  max-width: 980px;
}
.skeleton-line,
.skeleton-card,
.skeleton-panel {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--panel-2), #eceee7, var(--panel-2));
  background-size: 220% 100%;
  animation: tn-skeleton 1.5s ease-in-out infinite;
}
.skeleton-line { height: 14px; width: min(100%, 540px); }
.skeleton-line--title { height: 28px; width: min(68%, 420px); }
.skeleton-line--subtitle { width: min(92%, 640px); }
.skeleton-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.skeleton-card { height: 78px; }
.skeleton-panel { height: 210px; }
@keyframes tn-skeleton { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }

/* error-envelope rendering */
.note--err { background: var(--st-kryt-bg); border-color: color-mix(in srgb, var(--st-kryt) 30%, transparent); align-items: flex-start; }
.note--err svg { color: var(--st-kryt); }

/* data_gaps: long machine identifiers must wrap instead of inflating the
   column like a nowrap .tag would (map screen side column regression) */
.datagap {
  font-size: 11px; line-height: 1.45;
  color: var(--st-uwaga-ink); background: var(--st-uwaga-bg);
  border-radius: 6px; padding: 5px 8px;
  white-space: normal; overflow-wrap: anywhere;
}

/* capacity claims — assumption_based must be visually distinct from supported */
.claim { border: 1px solid var(--hairline); border-left-width: 4px; border-radius: 12px; padding: 12px 14px; background: #fff; }
.claim--supported { border-left-color: var(--st-ok); }
.claim--assumption_based { border-left-color: var(--st-uwaga); background: color-mix(in srgb, var(--st-uwaga-bg) 45%, #fff); }
.claim--unsupported { border-left-color: var(--st-kryt); background: color-mix(in srgb, var(--st-kryt-bg) 40%, #fff); }
.claim--manual_check_required { border-left-color: var(--st-part); background: color-mix(in srgb, var(--st-part-bg) 40%, #fff); }

/* Spec 019: GESUT colour-convention legend swatch for the utility WMS layers
   (colour comes inline from the bundle legend.color_hint — single source of
   truth is the backend descriptor, never a CSS palette) */
.legend-swatch {
  display: inline-block; flex: none;
  width: 14px; height: 14px; border-radius: 4px;
  border: 1px solid var(--hairline);
}

/* Spec 019 US4 (T043): utility GetFeatureInfo popup — honest state styling
   (objects / empty / no-coverage / error / loading share one wrapper) */
.gfi-popup { font-size: 12px; line-height: 1.45; max-width: 320px; }
.gfi-popup__obj { border-top: 1px dashed var(--hairline); margin-top: 6px; padding-top: 6px; }
.gfi-popup__src { font-size: 10.5px; color: var(--zn-fg-tertiary); margin-top: 4px; }
.gfi-popup__mock { font-size: 10.5px; color: var(--st-uwaga-ink); margin-top: 6px; font-weight: 600; }

/* ============================================================
   Multi-parcel graphical picker
   ============================================================ */
.parcel-selection-layout {
  grid-template-columns: minmax(480px, 1.35fr) minmax(330px, .78fr);
  align-items: start;
}
.parcel-selection-tray { min-width: 0; }
.parcel-selection-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--panel-2);
}
.parcel-selection-row--resolved {
  border-color: color-mix(in srgb, var(--st-ok) 28%, var(--hairline));
  background: color-mix(in srgb, var(--st-ok-bg) 34%, var(--panel));
}
.parcel-selection-row--ambiguous,
.parcel-selection-row--invalid,
.parcel-selection-row--error {
  border-color: color-mix(in srgb, var(--st-uwaga) 30%, var(--hairline));
}
.parcel-selection-row__main {
  display: grid;
  gap: 7px;
  min-width: 0;
  flex: 1;
}
.parcel-selection-row__main .mono { overflow-wrap: anywhere; }
.parcel-selection-row__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex: none;
}
.parcel-selection-row__actions .btn,
.parcel-candidate-picker .btn { background: var(--panel); border-color: var(--zn-border); color: var(--zn-fg); }
.parcel-selection-row__actions .btn:hover,
.parcel-candidate-picker .btn:hover { background: var(--zn-bg-sunken); }
.parcel-selection-row__reason {
  color: var(--st-uwaga-ink);
  font-size: 12px;
  line-height: 1.45;
}
.parcel-candidate-picker {
  display: grid;
  gap: 7px;
  padding: 10px;
  border-radius: 9px;
  background: var(--st-uwaga-bg);
}
.parcel-candidate-picker .btn {
  align-items: stretch;
  flex-direction: column;
  width: 100%;
  white-space: normal;
  text-align: left;
}
.parcel-candidate-picker__identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.parcel-candidate-picker__evidence {
  display: grid;
  gap: 2px;
  width: 100%;
  color: var(--zn-fg-tertiary);
  font-size: 10.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.parcel-evidence {
  color: var(--zn-fg-tertiary);
  font-size: 10.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.parcel-evidence summary {
  width: max-content;
  max-width: 100%;
  color: var(--zn-fg-secondary);
  cursor: pointer;
  font-weight: 650;
}
.parcel-evidence code,
.parcel-site-provenance code,
.parcel-candidate-picker__evidence code { overflow-wrap: anywhere; white-space: normal; }
.parcel-evidence--missing { color: var(--st-uwaga-ink); }
.parcel-selection-preview {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--zn-bg-sunken);
  font-size: 12px;
  font-feature-settings: "tnum" 1;
}
.parcel-selection-live-status {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.parcel-selection-preview .muted { text-align: right; }
.parcel-site-summary { border-color: color-mix(in srgb, var(--st-ok) 32%, var(--hairline)); }
.parcel-site-summary__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--hairline);
}
.parcel-site-summary__metrics > div {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  background: var(--panel-2);
}
.parcel-site-summary__metrics strong { font-size: 17px; font-feature-settings: "tnum" 1; }
.parcel-site-summary__members { display: flex; flex-wrap: wrap; gap: 6px; }
.parcel-site-summary__members span {
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 5px 8px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--panel-2);
  font-size: 11.5px;
}
.parcel-site-provenance {
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--zn-fg-secondary);
  font-size: 11px;
}
.parcel-site-provenance > summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--zn-fg);
  font-weight: 700;
}
.parcel-site-provenance__body {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--hairline);
}
.parcel-site-provenance__body > *:first-child { margin-top: 12px; }
.parcel-site-provenance__grid {
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
  gap: 5px 10px;
  align-items: baseline;
}
.parcel-site-provenance__refs,
.parcel-site-provenance__members { display: grid; gap: 6px; margin-top: 6px; }
.parcel-site-provenance__refs code,
.parcel-site-provenance__members > div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--panel);
  overflow-wrap: anywhere;
}
.parcel-selection-map-card { min-width: 0; overflow: hidden; }
.parcel-selection-map-card .card__head .muted { text-align: right; font-size: 11.5px; }
.parcel-selection-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 9px;
  color: var(--zn-fg-secondary);
  font-size: 11.5px;
}
.parcel-selection-map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.parcel-selection-swatch {
  display: inline-block;
  width: 20px;
  height: 10px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--st-ok) 18%, transparent);
  border: 2px solid var(--st-ok);
}
.parcel-selection-swatch--site {
  background: color-mix(in srgb, var(--zn-forest-900) 12%, transparent);
  border-color: var(--zn-forest-900);
  border-width: 3px;
}
.parcel-selection-swatch--attempt {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: conic-gradient(
    var(--st-part) 0 33%,
    var(--st-uwaga) 33% 66%,
    var(--st-kryt) 66% 100%
  );
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--zn-border-strong);
}
[data-testid="confirmation-error-summary"]:focus-visible {
  outline: 2px solid var(--st-kryt);
  outline-offset: 2px;
}

@media (max-width: 1040px) {
  .parcel-selection-layout { grid-template-columns: minmax(400px, 1.1fr) minmax(300px, .9fr); }
}

@media (max-width: 767px) {
  .parcel-selection-row { flex-direction: column; }
  .parcel-selection-row__actions { width: 100%; justify-content: stretch; }
  .parcel-selection-row__actions .btn { flex: 1; }
  [data-testid="multi-parcel-selection-mode"] .btn,
  [data-testid="multi-parcel-selection-mode"] .input { min-height: 44px; }
  .parcel-selection-preview { grid-template-columns: 1fr 1fr; }
  .parcel-selection-preview .muted { grid-column: 1 / -1; text-align: left; }
  .parcel-selection-map-card [data-testid="parcel-selection-map"] { min-height: 280px; }
}

/* ============================================================
   Reduced motion — honor OS-level preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Mobile shell — off-canvas sidebar below 768px (design audit T8)
   ============================================================ */
.topbar__burger { display: none; }
.nav-backdrop { display: none; }
@media (max-width: 767px) {
  .app { grid-template-columns: 1fr; }
  .topbar, .workarea { grid-column: 1; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar__search { flex: 1 1 auto; min-width: 0; padding-left: 10px; padding-right: 10px; }
  .topbar__runmenu,
  .topbar__live-launcher,
  .topbar > [data-testid="global-live-mode"],
  .topbar > [data-testid="run-mode-badge"],
  .topbar > .topbar__spacer,
  .topbar > .avatar { display: none; }
  .topbar > button.btn:last-of-type { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; }
  .topbar__rate-limit {
    position: fixed; z-index: 90; top: calc(var(--topbar-h) + 8px); left: 12px; right: 12px;
    justify-content: center;
  }
  .topbar--public { padding: 0 14px; }
  .topbar__public-brand { font-size: 16px; }
  .contextbar {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    height: auto; min-height: 104px; padding: 0; overflow: visible;
  }
  .ctx {
    min-width: 0; height: 52px; padding: 7px 12px;
    flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
    border-bottom: 1px solid var(--hairline);
  }
  .ctx:first-child { padding-left: 12px; }
  .ctx:nth-child(2n) { border-right: 0; }
  .ctx:nth-last-child(-n + 2) { border-bottom: 0; }
  .ctx__v, .ctx__v.mono { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar {
    grid-row: 1 / 3; grid-column: 1;
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w); z-index: 80;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--zn-dur-base, .2s) var(--zn-ease-out, ease);
  }
  .app--nav-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    box-shadow: var(--zn-shadow-lg);
  }
  .nav-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(14, 42, 31, 0.45);
    z-index: 70; opacity: 0; pointer-events: none;
    transition: opacity var(--zn-dur-base, .2s);
  }
  .app--nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .topbar__burger {
    display: grid; place-items: center; flex: none;
    width: 44px; height: 44px; border: 0; background: none;
    color: var(--zn-fg-secondary); border-radius: 8px;
  }
}
