/* Atrium console — what is Atrium's own. The shell, controls, cards, tables, dialogs, palette and
   toast come from the family's shared package (ui/v1/shell.css, loaded first); this file maps the
   console's variable names onto its tokens and keeps the launcher, marketplace and administration.
   The brand is Open Color **grape #9c36b5** — the Dredd family's own hue, which no sibling app
   wears — confined to things that read as an identity rather than a control: the app mark, the
   avatar, the focus ring. Dark mode lightens it for text-weight use. */

/* Aliases: this console's names → the shared tokens. No raw colour below this block except the
   module marks, which are identities. */
:root {
  --bg: var(--at-canvas);
  --surface: var(--at-surface);
  --surface-2: var(--at-sunken);
  --surface-hover: var(--at-surface-hover);
  --border: var(--at-border);
  --border-input: var(--at-border-strong);
  --text: var(--at-text);
  --text-secondary: var(--at-text-secondary);
  --text-muted: var(--at-text-muted);
  --text-faint: var(--at-text-faint);
  --accent: var(--at-primary);
  --accent-text: var(--at-primary-fg);
  --ok: var(--at-success-text);
  --ok-bg: var(--at-success-soft);
  --warn: var(--at-warning-text);
  --warn-bg: var(--at-warning-soft);
  --err: var(--at-danger-text);
  --err-bg: var(--at-danger-soft);
  --radius: var(--at-radius-xl);
  --radius-sm: var(--at-radius-lg);
  --shadow: var(--at-shadow-md);
  --mono: var(--at-font-mono);
  --sans: var(--at-font-sans);

  /* `--brand-bg` carries ICONS (3:1); `--brand-ink` is one step darker for the avatar's initials
     (4.5:1). */
  --brand: #9c36b5;
  --brand-bg: #9c36b5;
  --brand-ink: #862e9c;
  --brand-fg: #f8f0fc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --brand: #da77f2; }
}
:root[data-theme="dark"] { --brand: #da77f2; }

/* ── module marks ──────────────────────────────────────────────────────── */
/* A module's identity on its tile: the module's own hue, not Atrium's brand — a launcher is a row of
   other apps' marks. Filled grounds are the same in both themes, so a tile is recognisable whatever
   the viewer's theme. Shades are picked for glyph contrast and, for the siblings, to match their own
   app marks exactly (Galena violet9, Sygna cyan8, Counsel Scorecard orange7). The class list is the
   server's HUES allowlist; tests/test_marketplace_unit.py fails when they drift. */
.mi {
  --mi: 40px;
  width: var(--mi); height: var(--mi); flex: none;
  border-radius: calc(var(--mi) * .25);
  background: var(--mi-bg); color: var(--mi-fg);
  display: inline-flex; align-items: center; justify-content: center;
}
.mi svg { width: 100%; height: 100%; display: block; }
.mi.h-grape { --mi-bg: #9c36b5; --mi-fg: #f8f0fc; }
.mi.h-violet { --mi-bg: #5f3dc4; --mi-fg: #f3f0ff; }
.mi.h-indigo { --mi-bg: #3b5bdb; --mi-fg: #edf2ff; }
.mi.h-blue { --mi-bg: #1971c2; --mi-fg: #e7f5ff; }
.mi.h-cyan { --mi-bg: #0c8599; --mi-fg: #e3fafc; }
.mi.h-teal { --mi-bg: #099268; --mi-fg: #e6fcf5; }
.mi.h-green { --mi-bg: #2f9e44; --mi-fg: #ebfbee; }
.mi.h-lime { --mi-bg: #5c940d; --mi-fg: #f4fce3; }
.mi.h-yellow { --mi-bg: #e67700; --mi-fg: #fff9db; }
.mi.h-orange { --mi-bg: #f76707; --mi-fg: #fff4e6; }
.mi.h-red { --mi-bg: #e03131; --mi-fg: #fff5f5; }
.mi.h-pink { --mi-bg: #c2255c; --mi-fg: #fff0f6; }
.mi.h-gray { --mi-bg: #495057; --mi-fg: #f8f9fa; }

/* ── launcher: Home ────────────────────────────────────────────────────── */
/* Home takes the workspace's whole column, like every other page: the greeting and the search box stay
   one readable 800px column in the middle, the numbers and the admin overview below use the full width.
   :where() keeps this at one class, so the chatting rules (three classes) still win. */
.home { margin-top: 24px; }
.home > :where(.home-mark, .home-title, .home-sub, .banner, .home-answer, .home-box, .home-results, #homeKeys) {
  max-width: 800px; margin-inline: auto;
}
.home-title, .home-sub { text-align: center; }
.home-mark { width: 48px; height: 48px; padding: 9px; border-radius: var(--at-radius-xl);
  border: 1px solid var(--at-border); background: var(--at-surface); box-shadow: var(--at-shadow-xs); }
.home-mark .logo { width: 100%; height: 100%; display: block; }
.home-title { margin: 28px auto 0; font-size: 40px; line-height: 1.1; font-weight: 600; letter-spacing: -0.04em; }
.home-q { color: var(--at-text-muted); }
.home-sub { margin-top: 14px; color: var(--at-text-secondary); font-size: 15px; }
.home-label { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 40px 0 12px; font-size: 12px; font-weight: 500; color: var(--at-text-secondary); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--at-text-secondary); }
.btn.ghost:hover { background: var(--at-hover); color: var(--at-text); }
/* Home's search box: legalwork's composer shape (24px card, quiet shadow, round send button), with
   the module scope where legalwork has its project bar. */
.home-box { margin-top: 32px; }
.home-input {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  padding: 12px 10px 8px 18px; border-radius: 24px; border: 1px solid var(--at-border);
  background: var(--at-surface); color: var(--at-text-muted);
  box-shadow: 0 8px 32px rgb(0 0 0 / .04), 0 2px 5px rgb(0 0 0 / .03);
}
.home-input:focus-within { border-color: var(--at-border-strong); box-shadow: 0 0 0 3px var(--at-focus-ring); }
.home-line { display: flex; align-items: flex-start; gap: 12px; }
.home-line > svg { flex: none; margin-top: 3px; }
/* ponytail: field-sizing grows the box with its text natively (Chromium); elsewhere it stays one line and scrolls. */
.home-input textarea {
  flex: 1; min-width: 0; min-height: 28px; max-height: 200px; padding: 0; border: 0; background: none; box-shadow: none;
  outline: none; resize: none; field-sizing: content; overflow-y: auto;
  color: var(--at-text); font: inherit; font-size: 17px; line-height: 1.5; letter-spacing: var(--at-tracking-title);
}
.home-send {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--at-primary); color: var(--at-primary-fg); cursor: pointer;
}
.home-send:hover { background: var(--at-primary-hover); }
.home-send.stop { background: var(--at-text); color: var(--at-canvas); }
/* The scope, the model and the send button: the composer's bottom row, inside the card. */
.home-scope {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px;
  font-size: 12px; color: var(--at-text-secondary);
}
.home-tools { margin-left: auto; display: inline-flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.home-scope-mod { display: inline-flex; align-items: center; gap: 6px; color: var(--at-text); }
/* The model picker sits at the end of the scope bar; the answer is a quiet card, plain text only. */
.home-model { display: inline-flex; align-items: center; gap: 8px; }
.home-model select { min-height: 32px; padding: 2px 8px; font-size: 12px; max-width: 260px; }
.home-model > span:empty { display: none; }
.home-answer {
  margin-top: 20px; padding: 14px 16px; border: 1px solid var(--at-border); border-radius: var(--at-radius-2xl);
  background: var(--at-surface);
}
.ha-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12px; color: var(--at-text-secondary);
}
.ha-head > span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ha-turns { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.ha-ref { font-size: 12px; vertical-align: super; text-decoration: none; margin-left: 1px; }
.ha-sources { white-space: normal; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--at-border); display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.ha-sources-h { font-weight: 600; }
.ha-source blockquote { white-space: pre-line; margin: 4px 0 0; padding-left: 10px; border-left: 2px solid var(--at-border); color: var(--at-text-muted); font-size: 12px; overflow-wrap: anywhere; }
.ha-turn { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: 14px; color: var(--at-text); }
.ha-turn.user { align-self: flex-end; max-width: 85%; padding: 8px 12px; border-radius: 16px; background: var(--at-surface-hover); }
.ha-status { margin-top: 4px; }
.ha-quote { font-size: 12px; overflow-wrap: anywhere; }
.ha-quote.ok { color: var(--at-text-muted); }
.ha-quote.bad { color: var(--at-danger-text); }
.ha-flag { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.ha-flag.weak { color: var(--at-warning-text); }
.ha-flag.bad { color: var(--at-danger-text); }
.ha-table { white-space: normal; overflow-x: auto; margin-top: 10px; }
.ha-table table { border-collapse: collapse; font-size: 13px; width: 100%; }
.ha-table th, .ha-table td { text-align: left; vertical-align: top; padding: 4px 8px; border-bottom: 1px solid var(--at-border); }
.ha-table th { color: var(--at-text-muted); font-weight: 500; }
.ha-table th, .ha-table td { overflow-wrap: normal; }
.ha-table td:first-child { white-space: nowrap; }
.ha-table td:last-child { min-width: 16em; }
.ha-table td.nw { white-space: nowrap; }
/* The platform's links are plain text until hovered; in a table that hides them, so a quiet underline. */
.ha-table a { text-decoration: underline; text-decoration-color: var(--at-border-strong); text-underline-offset: 3px; }
.ha-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--at-text-muted); }
.ha-trace { margin-top: 8px; white-space: normal; overflow-wrap: anywhere; }
.ha-trace summary { cursor: pointer; }
/* A conversation open: the greeting and the figures step aside, the history reads downwards and the composer
   stays docked at the bottom of the window (the window scrolls, not .content, so sticky holds). Opaque, or
   the history shows through the scope bar's negative margin. */
.home-new { display: none; }
.home.chatting .home-mark, .home.chatting .home-title, .home.chatting .home-sub,
.home.chatting .home-stats, .home.chatting .home-admin { display: none; }
/* While chatting the page itself stops scrolling: the window is as tall as the screen, the conversation
   scrolls in its own box (scrollbar at the workspace's edge, text in one 800px column) and the composer sits
   under it, in the same column. */
#app:has(.home.chatting) { height: 100vh; height: 100dvh; min-height: 0; }
.main:has(.home.chatting) { min-height: 0; }
.content:has(.home.chatting) { display: flex; flex-direction: column; min-height: 0; padding-top: 0; padding-bottom: 0; padding-inline: 0; }
.home.chatting { flex: 1; min-height: 0; max-width: none; width: 100%; margin: 0; display: flex; flex-direction: column; }
.home.chatting .home-answer {
  flex: 1; min-height: 0; margin: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable both-edges;
  padding: 24px 16px 16px; border: 0; border-radius: 0; background: none;
}
.home.chatting .home-answer > *, .home.chatting .home-box { width: 100%; max-width: 800px; margin-inline: auto; }
/* A table needs more room than a line of text: it leaves the 800px column, up to the conversation's whole
   width (1200px at most), centred on the column. Never narrower than the column. */
.home.chatting .home-answer { container-type: inline-size; }
.home.chatting .ha-table { --tw: max(100%, min(100cqw, 1200px)); width: var(--tw); margin-left: calc((100% - var(--tw)) / 2); }
.home.chatting .home-box { flex: none; margin-top: 0; padding: 8px 16px 16px; box-sizing: border-box; max-width: 832px; }
.home.chatting .home-new { display: inline-flex; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.home-results { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.hr-group { border: 1px solid var(--at-border); border-radius: var(--at-radius-2xl); background: var(--at-surface); padding: 6px; }
.hr-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; font-size: 12px; font-weight: 550; color: var(--at-text-secondary); }
.hr-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--at-radius-lg);
  color: var(--at-text);
}
.hr-item:hover, .hr-item:focus-visible { background: var(--at-hover); text-decoration: none; }
.hr-kind { flex: none; width: 104px; font-size: 12px; color: var(--at-text-muted); }
.hr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hr-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-sub { font-size: 12px; color: var(--at-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-go { flex: none; color: var(--at-text-faint); display: inline-flex; }
.hr-item:hover .hr-go { color: var(--at-text); }
.hr-note { padding: 12px 14px; font-size: 13px; color: var(--at-text-secondary); }
.banner.welcome { margin-bottom: 16px; white-space: pre-line; }

/* ── marketplace ───────────────────────────────────────────────────────── */
.cats { gap: 6px; }
/* The catalogue's two tabs (Moduły · Moje wnioski): an underline, so they never read as one more row of category chips. */
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--at-border-subtle); margin: -4px 0 16px; }
.tabs button { border: 0; background: none; font: inherit; cursor: pointer; }
.tabs a, .tabs button { padding: 8px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--at-text-secondary); font-size: 14px; }
.tabs a:hover, .tabs button:hover { color: var(--at-text); text-decoration: none; }
.tabs a.on, .tabs button.on { color: var(--at-text); border-bottom-color: var(--at-text); font-weight: 550; }
a.chip { cursor: pointer; font-size: 12px; padding: 3px 10px; }
a.chip:hover { background: var(--surface-hover); text-decoration: none; }
.chip.on, .chip.on:hover { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mcard {
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
}
.mcard { box-shadow: var(--at-shadow-xs); transition: border-color var(--at-dur-fast) var(--at-ease), box-shadow var(--at-dur-fast) var(--at-ease); }
.mcard:hover { border-color: var(--border-input); box-shadow: var(--at-shadow-sm); text-decoration: none; }
.mtop { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mtxt { min-width: 0; }
.mname { font-weight: 650; font-size: 15px; }
.mtag { color: var(--text-secondary); font-size: 13px; }
.mchips { margin-top: auto; gap: 6px; }
.mchips:empty { display: none; }
.mhead { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.mhead .mhtxt { flex: 1; min-width: 220px; }
.mhead h2 { margin: 0 0 2px; font-size: 24px; font-weight: 600; letter-spacing: var(--at-tracking-title); }
.mhead .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.prose { white-space: pre-line; color: var(--text-secondary); max-width: 72ch; }

/* ── administration ────────────────────────────────────────────────────── */
.grid-admin { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.grid-admin > div > .card + .card { margin-top: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.acts-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sw {
  padding: 2px; border: 2px solid transparent; border-radius: 10px; background: none; cursor: pointer;
  display: inline-flex;
}
.sw.on { border-color: var(--text); }
.radio, .check { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; cursor: pointer; }
.assign { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.assign select, .modal .row select {
  flex: 1; min-width: 0; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
h4.minor { margin: 4px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }
.btncol { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
pre.diff {
  margin: 6px 0 0; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2);
  font: 11.5px/1.4 var(--mono); white-space: pre-wrap; word-break: break-word; max-width: 46ch;
}
/* A skill's body and the line diff between its versions: as wide as the card, + and − tinted. */
pre.diff.lines { max-width: none; }
pre.diff .add { color: var(--ok); background: var(--ok-bg); }
pre.diff .del { color: var(--err); background: var(--err-bg); }
/* A skill's checking procedure: numbered step cards in one column, in the order the model reads them. */
.plan-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.plan-steps { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plan-step { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--at-border); border-radius: var(--at-radius-lg); background: var(--surface); }
.plan-num {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-secondary); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.plan-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.plan-name { font-weight: 550; overflow-wrap: anywhere; }
.plan-main details .prose { margin-top: 4px; }
.plan-chips, .plan-acts { gap: 4px; }
.plan-acts { flex: none; }
.plan-group + .plan-group { margin-top: 18px; }
.plan-group-h { font-size: 13px; font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.plan-group .tablewrap { margin-bottom: 8px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.plan-ex { display: flex; align-items: flex-start; gap: 8px; }
.plan-ex-text { flex: 1; min-width: 0; }
.plan-ex textarea, .plan-ex select {
  width: 100%; box-sizing: border-box; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.plan-ex textarea { resize: vertical; line-height: 1.45; }
.plan-count { text-align: right; font-variant-numeric: tabular-nums; }
/* A version's trial and standards check (Próba) */
.trial-head { margin-bottom: 4px; }
.trial-part { display: flex; flex-direction: column; gap: 8px; font-variant-numeric: tabular-nums; }
.trial-part + .trial-part { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--at-border-subtle); }
.trial-part h4.minor { margin: 0; }
.trial-advice { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.trial-advice li { display: flex; flex-direction: column; gap: 2px; }
.trial-std { font-weight: 550; overflow-wrap: anywhere; }
.trial-line { font-variant-numeric: tabular-nums; }
/* The one field that ever holds a secret: a freshly minted app token, shown once and never again.
   Monospace so it can be proof-read character by character, because where the clipboard API is
   unavailable — plain HTTP is not a secure context — copying it by hand is the fallback. */
.field > input.secret { font-family: var(--mono); font-size: 12.5px; }
.card.settings { max-width: 680px; }
.unit {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0 10px calc(var(--depth, 0) * 22px); border-bottom: 1px solid var(--border);
}
.unit:last-child { border-bottom: 0; }
.unit-main { flex: 1; min-width: 200px; }
.unit-main .cell svg { color: var(--text-muted); flex: none; }
.unit-main .mono { margin-left: 26px; }
.unit-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.card.units { padding-top: 6px; padding-bottom: 6px; }

/* ── breakpoints (Atrium's own; the shell's are in shell.css) ───────────── */
@media (max-width: 980px) { .grid-admin { grid-template-columns: 1fr; } }

@media (max-width: 640px) {
  .home { margin-top: 4px; }
  .modrow-h { flex-basis: 100%; }
  .home-title { font-size: 28px; }
  .home-label { margin-top: 28px; }
  .home-box { margin-top: 22px; }
  .home-input { border-radius: 20px; padding-left: 14px; }
  .home-scope > span:first-child { display: none; }
  .home-tools { width: 100%; flex-wrap: nowrap; }
  .home-model { flex: 1; min-width: 0; }
  .home-model > span:first-child { display: none; }
  .home-model select { width: 100%; max-width: none; }
  /* A phone: every row is a card, each cell under its own label; nothing scrolls sideways. */
  .ha-table thead { display: none; }
  .ha-table table, .ha-table tbody, .ha-table tr, .ha-table td { display: block; }
  .ha-table tr { padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--at-border); border-radius: var(--at-radius-lg); }
  .ha-table td { border: 0; padding: 2px 0; min-width: 0; white-space: normal; }
  .ha-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--at-text-muted); }
  .ha-table td:first-child::before { content: none; }
  .ha-table td:first-child { font-weight: 600; }
  .home.chatting .home-box { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .hr-kind { display: none; }

  .unit { padding-left: calc(var(--depth, 0) * 12px); }
  .plan-step { flex-wrap: wrap; }
  .plan-acts { width: 100%; justify-content: flex-end; }
  .unit-main { min-width: 0; flex-basis: 100%; }
  .unit-acts { margin-left: 26px; }
  .mhead { gap: 14px; }
  .mhead .acts { width: 100%; }
  .mhead .acts .btn { flex: 1; justify-content: center; }
  .mcards { grid-template-columns: 1fr; }
  pre.diff { max-width: 100%; }
}

/* ── modules inside the frame (#/m/<slug>) ─────────────────────────────── */
/* The page stops scrolling and the module scrolls inside its iframe, full width, in the workspace; the module's own chrome is hidden, so the frame is the only chrome. */
#app.framed { height: 100dvh; overflow: hidden; }
#app.framed .content { padding: 0; display: flex; min-height: 0; overflow: hidden; }
.modframe { flex: 1; width: 100%; border: 0; display: block; background: var(--at-canvas); }
.setframe { height: calc(100vh - 130px); min-height: 420px; border-radius: 8px; }
/* A module's nav, mirrored under its entry: indented on a hairline, like a tree. A mirrored item keeps
   the module's own active class, `.active` or `.on`. */
.modnav { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px 10px;
  margin-left: 17px; border-left: 1px solid var(--at-border-subtle); }
/* Children read quieter than their parent, as legalwork's folder entries do. */
.modnav .nav-item { min-height: 34px; font-size: 13.5px; color: var(--at-text-secondary); }
.modnav .nav-item svg { width: 16px; height: 16px; color: var(--at-text-muted); }
.modnav .nav-item.active, .modnav .nav-item.on { background: var(--at-active); color: var(--at-text); font-weight: 550; }
.modnav .nav-sep { padding-top: 10px; }
#app.nav-min .modnav { display: none; }
/* The column beside the rail (renderNav): an open module's menu, or the screens of Ustawienia or
   Administracja. Collapsing the sidebar folds it away, as legalwork's does: the rail stays. */
.modcol { display: none; }
#app.mod-col:not(.nav-min) .modcol {
  display: flex; flex-direction: column; flex: none; width: 228px;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  background: var(--at-sidebar); border-right: 1px solid var(--at-border-subtle);
}
.modcol-head {
  display: flex; align-items: center; gap: 10px; flex: none;
  min-height: var(--at-topbar-h); padding: 12px 16px 10px; font-weight: 600; font-size: 15px;
}
.modcol-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modcol .modnav { flex: 1; margin-left: 0; border-left: 0; padding: 4px 10px 10px; overflow-y: auto; }
.mod-tools { display: flex; align-items: center; gap: 2px; }
.mod-tools:empty { display: none; }
.modcrumb { display: inline-flex; align-items: center; gap: 6px; }
.navprefs { display: grid; gap: 4px; }
.navpref { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--at-radius-lg); cursor: pointer; }
.navpref:hover { background: var(--at-hover); }
/* A module's unread badge on a mirrored tool (Compass's and Sygna's bell). */
.iconbtn .cnt {
  position: absolute; top: 1px; right: 0;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 999px; background: var(--at-danger); color: #fff;
  font: 600 10px/15px var(--at-font-sans); text-align: center;
  font-variant-numeric: tabular-nums;
}
/* A row's buttons stay side by side in a table instead of stacking into a two-line cell. */
@media (min-width: 881px) { td.acts-cell > .row { flex-wrap: nowrap; justify-content: flex-end; } }

/* The foldable Administracja header: a .nav-sep that is a button, with a chevron that turns. */
button.nav-sep.fold { width: 100%; border: 0; background: none; font-family: inherit; cursor: pointer; text-align: left; }
button.nav-sep.fold:hover { color: var(--at-text); }
button.nav-sep.fold svg { width: 14px; height: 14px; margin-left: auto; transition: transform .15s; }
button.nav-sep.fold[aria-expanded="false"] svg { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { button.nav-sep.fold svg { transition: none; } }
/* On the icon rail a folded group still shows its icons (its head is gone, so nothing could unfold
   it), and "Dostosuj listę" leaves: beside Ustawienia it would be a second gear. */
@media (min-width: 881px) {
  #app:is(.nav-min, .mod-col) .sidebar [id^="navGroup_"][hidden] { display: block; }
  #app:is(.nav-min, .mod-col) .sidebar .nav-tune { display: none; }
}

/* ── home: "W skrócie" — stat tiles and 14-day column charts (inline SVG, no library) ── */
.home-stats:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--at-radius-xl); background: var(--surface); color: var(--text);
}
a.stat:hover { text-decoration: none; background: var(--at-surface-hover); }
.stat-v { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-l { font-size: 12px; color: var(--at-text-muted); }
.stat.warn .stat-v { color: var(--at-warning-text); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.card.chart { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.chart-h { display: flex; flex-direction: column; gap: 1px; }
.chart-h b { font-size: 13px; }
.chart-h span, .chart-x { font-size: 11px; color: var(--at-text-muted); }
.chart-v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 72px; display: block; }
.spark .bar { fill: var(--chart-1, var(--at-text)); }
.spark .bar.zero { fill: var(--border); }
.spark rect:hover { opacity: .75; }
.chart-x { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.hbars { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.hbar { display: grid; grid-template-columns: minmax(0, 150px) 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.hbar code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.hbar-t { height: 8px; border-radius: 4px; background: var(--at-sunken); overflow: hidden; }
.hbar-t i { display: block; height: 100%; border-radius: 4px; background: var(--chart-1, var(--at-text)); }
.hbar b { font-variant-numeric: tabular-nums; }
.chart-more { font-size: 12px; color: var(--text-secondary); margin-top: auto; }
/* Data-viz only (UI chrome stays monochrome): Open Color grape, Atrium's identity hue. */
:root { --chart-1: #ae3ec9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-1: #da77f2; } }
:root[data-theme="dark"] { --chart-1: #da77f2; }
.charts > .card { margin: 0; }
/* "Z modułów": one row of tiles per module, under the module's own mark. */
/* "Z modułów": a folded quick-access shelf — one row per module, compact number+label chips. */
.modquick > summary { justify-content: flex-start; cursor: pointer; list-style: none; user-select: none; }
.modquick > summary::-webkit-details-marker { display: none; }
.modquick > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border: solid currentColor;
  border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform var(--at-dur-fast) var(--at-ease); }
.modquick[open] > summary::after { transform: rotate(-135deg); }
.modquick > summary:hover { color: var(--at-text); }
.modquick-icons { display: inline-flex; gap: 6px; opacity: .8; }
.modquick-warn { color: var(--at-warning-text); }
.modrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0; border-top: 1px solid var(--border); }
.modrow-h { display: inline-flex; align-items: center; gap: 6px; min-width: 140px; font-size: 13px; font-weight: 600; }
.modchip { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text); font-size: 12px; }
.modchip b { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.modchip span { color: var(--at-text-muted); }
a.modchip:hover { text-decoration: none; background: var(--at-surface-hover); }
.modchip.warn b { color: var(--at-warning-text); }
/* The sidebar's "Dostosuj listę": a quiet last entry of the Aplikacje section. */
.nav-item.nav-tune { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; color: var(--at-text-muted); }
.nav-item.nav-tune:hover { color: var(--at-text); }

/* The contract review panel beside the chat (chatReview / reviewOpen in app.js). Off-canvas on the
   right; `transform` transitions, `visibility` flips at once (a delayed `visibility` sticks when
   frames are throttled). Full width on a phone. */
.review-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(560px, 100vw);
  display: flex; flex-direction: column; background: var(--at-surface);
  border-left: 1px solid var(--at-border); box-shadow: -8px 0 24px rgba(0, 0, 0, .08);
  transform: translateX(100%); visibility: hidden; transition: transform .2s ease;
}
.review-panel.open { transform: none; visibility: visible; }
.review-panel .rp-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--at-border);
}
.review-panel .rp-body { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; min-height: 0; overflow: auto; }
.review-panel .rp-report { flex: 1; min-height: 320px; width: 100%; border: 1px solid var(--at-border); border-radius: 8px; background: #fff; }
.review-panel .rp-accept { display: flex; flex-direction: column; gap: 8px; }
.ha-turn .ha-report { margin-top: 8px; }
