/* Page layouts: grids and the few pieces only one page has. A look that two pages share is a
   component (components.css), not a page rule. Only var(--…) tokens. */

@layer pages {
  /* ---------------------------------------------------------------- shared lists */
  .item-list { list-style: none; padding: 0; }
  .item-list > li { padding: var(--space-2) 0; border-top: var(--border-thin) solid var(--color-border); }
  .item-list > li:first-child { border-top: 0; }
  .item-list ul { margin-top: var(--space-2); }

  /* ---------------------------------------------------------------- inventory (overview)
     One rhythm of 24 px between the header, a message, the Pendenzen and the list (margins collapse). */
  .todo, .case-list { margin-top: var(--space-5); }
  .case-list > .tabs { margin-bottom: var(--space-4); }
  /* Pendenzen: one aligned row each, kind | object with ONE quiet line | action (Max, 25 Nov 2026).
     The rows share the list's columns (subgrid), so every kind, title and button lines up. */
  .todo { border-color: var(--color-primary); }
  .todo__list {
    list-style: none; padding: 0;
    display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; column-gap: var(--space-4);
  }
  .todo__item {
    grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center;
    padding: var(--space-3) 0; border-top: var(--border-thin) solid var(--color-border);
  }
  .todo__item:first-child { border-top: 0; padding-top: var(--space-1); }
  .todo__item:last-child { padding-bottom: 0; }
  .todo__item + .todo__item { margin-top: 0; }
  .todo__what { display: grid; gap: 2px; min-width: 0; }
  /* the object as in the table below: dark and bold, underlined on hover (the button is the action) */
  .todo__what > a { font-weight: var(--weight-semibold); color: var(--color-text); text-decoration: none; overflow-wrap: anywhere; }
  .todo__what > a:hover { color: var(--color-link); text-decoration: underline; }
  .todo__meta {
    font-size: var(--text-sm); color: var(--color-text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; /* a long note ends in "…": the case page has it all */
  }
  .todo__item > .btn { justify-self: end; }
  .todo__item::after { display: none; } /* the phone's chevron (below) */
  /* search, sort and "Filter" in one row, every control as tall as a button; canton and verdict behind
     "Filter". The fields take the one field look (components.css, forms); "Filter" looks like a
     secondary button with the disclosure's chevron. */
  .filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
  .filters label { display: grid; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text); }
  .filters__search { flex: 2 1 14rem; }
  .filters > label:not(.filters__search) { flex: 0 1 16rem; }
  .filters__more { flex: 0 0 auto; }
  .filters__more[open] { flex: 1 1 100%; order: 1; }
  .filters__more > summary {
    display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-height); padding: 0 var(--space-4);
    cursor: pointer; list-style: none; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text);
    border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-xs);
  }
  .filters__more > summary::-webkit-details-marker { display: none; }
  /* the chevron of .select (components.css), so the row's three controls end alike */
  .filters__more > summary::after { --icon: var(--icon-chevron-down); color: var(--color-text-muted); transition: transform 0.2s; }
  .filters__more[open] > summary::after { transform: rotate(180deg); }
  .filters__more > summary:hover { background: var(--color-accent); }
  .filters__more > summary:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .filters__more[open] > summary { width: fit-content; }
  .filters__active {
    display: inline-grid; place-items: center; min-width: 1.375rem; height: 1.375rem; padding: 0 var(--space-1); border-radius: var(--radius-pill);
    font-size: var(--text-xs); font-variant-numeric: var(--font-numeric); background: var(--color-primary); color: var(--color-on-primary);
  }
  .filters__row { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }
  .filters__row > label { flex: 1 1 10rem; max-width: 16rem; }
  @media (max-width: 40rem) {
    /* phone: the kind above the object, the title is the link (the "Kaufangebot erfassen" button stays) */
    .todo__list { display: block; }
    .todo__item { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-1); }
    .todo__item > .badge { justify-self: start; }
    .todo__item > .btn { display: none; }
    /* the whole row is the link on a phone, with a chevron at its right (review of 26 Nov 2026); the
       Kaufangebot row keeps its own button */
    .todo__item:not(.todo__item--offer) { position: relative; padding-right: var(--space-6); }
    .todo__item:not(.todo__item--offer) .todo__what > a::before { content: ""; position: absolute; inset: 0; }
    .todo__item:not(.todo__item--offer)::after {
      --icon: var(--icon-chevron-right); display: inline-block; position: absolute; right: 0; top: 50%; margin-top: -0.5rem;
      color: var(--color-text-muted);
    }
    .todo__meta { white-space: normal; }
    .filters__search { flex-basis: 100%; }
    /* the status tabs wrap on a phone instead of being cut without a hint */
    .filters > label:not(.filters__search) { flex: 1 1 auto; }
    .filters__row > label { max-width: none; }
  }

  /* ---------------------------------------------------------------- case table (the overview's list)
     Max, 25 Nov 2026: Ort and Objektart as columns, the title in one or two lines, nothing cut. All
     nine columns fit the page's 1152 px (every window from 1200 px); a narrower window leaves out
     the least needed column instead of cutting one: Objektart below 1200 px, Freigabe below 1056 px
     (the case page has both), Ort below 912 px, Status below 832 px (the tabs filter by it).
     Objekt, Beurteilung, Gewinn and Max. Kaufpreis always stay; a phone shows cards. */
  /* 12 px between columns (4 + 8) instead of 24: the room goes to the title (a card keeps its own) */
  @media (min-width: 40.01rem) {
    .case-table :is(th, td) { padding-left: var(--space-1); padding-right: var(--space-2); }
    .case-table :is(th, td):last-child { padding-right: var(--space-3); }
    .case-table .case-table__review { padding-left: var(--space-3); } /* apart from the figures before it */
    .case-table .col-check { padding-left: var(--space-3); }
  }
  .case-table thead th { white-space: normal; }
  /* a long badge ("Kaufangebot abgegeben", "Keine Kriterien hinterlegt") takes two lines; the
     verdict column is wide enough for the others in one */
  .case-table .badge { white-space: normal; }
  .case-table__verdict { min-width: 9.25rem; }
  /* the title in at most two lines; a longer one ends in "…" (the full title is the link's tooltip) */
  .case-table__title { min-width: 11.75rem; }
  .case-table__title > a {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
  /* a long one-word municipality ("Niederhelfenschwil SG") breaks with a hyphen instead of widening the table */
  .case-table__place { min-width: 7rem; hyphens: auto; -webkit-hyphens: auto; }
  .case-table__profit { min-width: 6.25rem; }
  .case-table__bid { min-width: 9.5rem; }
  .case-table__bid .cell-sub { white-space: normal; text-wrap: balance; }
  .case-table__card-line { display: none; }
  @media (max-width: 74.98rem) { .case-table__type { display: none; } }
  @media (max-width: 65.98rem) { .case-table__review { display: none; } }
  @media (max-width: 56.98rem) { .case-table__place { display: none; } }
  @media (max-width: 51.98rem) { .case-table__status { display: none; } .case-table__title { min-width: 8rem; } }
  @media (max-width: 45rem) { .case-table__bid { min-width: 8.5rem; } }
  @media (max-width: 40rem) {
    /* a card: Ort and Objektart are one line under the title; Status and Freigabe are fields again */
    .case-table__title { min-width: 0; }
    .case-table__title > a { display: inline; overflow: visible; }
    .case-table__bid { min-width: 0; }
    .case-table .case-table__card-line { display: block; }
    .case-table tbody :is(.case-table__place, .case-table__type) { display: none; }
    .case-table tbody :is(.case-table__review, .case-table__status) { display: block; }
  }

  /* ---------------------------------------------------------------- narrow pages: login, new and edit case */
  .narrow { max-width: var(--narrow-max); }
  /* the login block of shadcn: one Card in the middle of the page, full-width buttons */
  .login { max-width: 24rem; margin: var(--space-7) auto 0; }
  .login > * + * { margin-top: var(--space-4); }
  .login .card__title { font-size: var(--text-xl); }
  .login .card__content > .btn, .login .actions > .btn { width: 100%; }
  .login .card__footer > .hint { margin: 0; }
  @media (max-width: 40rem) { .login { margin-top: var(--space-4); } }
  .qr { display: block; margin: var(--space-2) auto; padding: var(--space-2); background: var(--color-surface); border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md); }
  .secret { display: inline-block; margin: var(--space-1) 0; font-size: var(--text-lg); letter-spacing: 0.05em; }

  /* ---------------------------------------------------------------- case page */
  .history { list-style: none; padding: 0; }
  .history > li { padding: var(--space-3) 0 var(--space-3) var(--space-5); border-left: var(--border-thin) solid var(--color-border); position: relative; }
  .history > li + li { margin-top: 0; }
  .history > li::before {
    content: ""; position: absolute; left: calc(-0.25rem - 0.5px); top: calc(var(--space-3) + 0.35em);
    width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--color-border-strong); box-shadow: 0 0 0 3px var(--color-bg);
  }
  .when, .by { color: var(--color-text-muted); font-size: var(--text-sm); font-variant-numeric: var(--font-numeric); }
  .case-next { margin-top: 0; }
  .case-sub { margin-top: var(--space-6); }
  h2 + .case-sub { margin-top: var(--space-3); }
  .case-sub + * { margin-top: var(--space-2); }
  .case-facts { margin-top: var(--space-4); }
  .case-facts + .disclosure { margin-top: var(--space-4); }
  /* the status form asks for a reason with "dropped" and for the offer with "offer made" only
     (without :has() every field shows; the server checks either way) */
  .status-form:has(select[name=new_status]) .when-dropped,
  .status-form:has(select[name=new_status]) .when-offer { display: none; }
  .status-form:has(select[name=new_status] option[value=dropped]:checked) .when-dropped,
  .status-form:has(select[name=new_status] option[value=offer_made]:checked) .when-offer { display: grid; }

  /* ---------------------------------------------------------------- documents: three ways in, reading, confirming */
  .doc-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--space-4); }
  /* waiting for the AI or the registers: a card with a turning ring (no script; reduced motion: still) */
  .reading .spinner {
    position: relative; padding: var(--space-4) var(--space-5) var(--space-4) calc(var(--space-5) + 1.25rem + var(--space-3));
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
  }
  .reading .spinner::before {
    content: ""; position: absolute; left: var(--space-5); top: var(--space-4); width: 1.25rem; height: 1.25rem; border-radius: 50%;
    border: var(--border-thick) solid var(--color-border); border-top-color: var(--color-primary); animation: spin 0.9s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .reading .spinner::before { animation: none; } }
  .confirm-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
  .doc-view { position: sticky; top: var(--space-2); }
  .doc-view iframe { width: 100%; height: 80vh; border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
  /* a listing's text: the page's own font, wrapped (also a long word or link), scrolled inside its box */
  .doc-text {
    white-space: pre-wrap; overflow-wrap: anywhere; max-height: 80vh; overflow: auto; padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans); font-size: var(--text-sm); line-height: var(--leading-body); color: var(--color-text);
    background: var(--color-surface); border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md);
  }
  .proposal { padding-bottom: var(--space-3); border-bottom: var(--border-thin) solid var(--color-border); }
  .proposal > * + * { margin-top: var(--space-1); }
  /* a value the document did not give: marked by colour AND by the text "Nicht im Dokument gefunden." */
  .proposal.missing :is(input, select, .affix) { border-color: var(--color-caution-solid); background-color: var(--color-caution-bg); }
  .proposal__source { font-size: var(--text-sm); color: var(--color-text-muted); }
  .proposal__source .quote-reveal__summary { margin-left: 0; }
  .quote { font-size: var(--text-sm); color: var(--color-text-muted); overflow-wrap: anywhere; }
  @media (max-width: 52rem) {
    .confirm-layout { grid-template-columns: minmax(0, 1fr); }
    .doc-view { position: static; }
    .doc-view iframe { height: 60vh; }
  }

  /* ---------------------------------------------------------------- Schnell-Check: entry (/new) and the one screen */
  .new-upload .actions { justify-content: center; margin-top: var(--space-3); }
  .new-other { margin-top: var(--space-5); }
  /* the example: a Card directly under the drop area */
  .new-example { margin-top: var(--space-4); }
  /* "Ohne Dokument erfassen": a row like the accordion rows above it, a chevron at the right */
  .new-manual {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: var(--space-4) 0; border-bottom: var(--border-thin) solid var(--color-border);
    font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: var(--leading-snug); color: var(--color-text); text-decoration: none;
  }
  .new-manual::after { --icon: var(--icon-chevron-right); color: var(--color-text-muted); }
  .new-manual:hover .new-manual__title { text-decoration: underline; text-underline-offset: 4px; }
  .new-manual:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  /* two columns on a wide screen: the form column (its notes on top, never wider than a form) and the
     document as a side column of its own width, its text wrapped and scrolled inside it */
  .quick-layout { display: grid; grid-template-columns: minmax(0, var(--form-max)); gap: var(--space-6); align-items: start; }
  .quick-layout--doc { grid-template-columns: minmax(0, calc(var(--form-max) + 1rem)) minmax(16rem, 1fr); }
  /* the document comes first in the page (on a phone: a disclosure at the top), beside the form on a wide screen */
  .quick-layout--doc > .doc-view { grid-column: 2; grid-row: 1; min-width: 0; }
  .quick-layout--doc > .quick-main { grid-column: 1; grid-row: 1; }
  .quick-main { min-width: 0; }
  .quick-main > .alert, .quick-main > .error-summary { margin: 0 0 var(--space-4); }
  .quick-layout--doc .doc-text { max-height: calc(100vh - 2 * var(--space-5)); }
  .quick-form .form-section > * + * { margin-top: var(--space-4); }
  .quick-form .form-section > .form-section__title + * { margin-top: var(--space-2); }
  .quick-form .proposal { border-bottom: 0; padding-bottom: 0; }
  .quick-form .kv { padding: var(--space-3) var(--space-4); }
  .quick-levels > * + * { margin-top: var(--space-3); }
  .quick-z { max-width: 26rem; }
  /* the sale price itself reads as the screen's key figure; the reason field under it is an ordinary field */
  .quick-z > .field:first-child input { font-size: var(--text-md); font-weight: var(--weight-semibold); }
  .quick-form > .actions .btn--primary { min-height: var(--control-height-lg); padding-inline: var(--space-6); }
  @media (max-width: 52rem) {
    .quick-layout--doc { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
    .quick-layout--doc > .doc-view, .quick-layout--doc > .quick-main { grid-column: 1; grid-row: auto; }
    .quick-form > .actions .btn--primary { width: 100%; }
  }
  @media (max-width: 40rem) {
    /* the level cards: the measures in two lines at most (the result lists them all) */
    .quick-levels .choice--cards { gap: var(--space-2); }
    .quick-levels .choice--cards .choice__option { padding: var(--space-2) var(--space-3); }
    .quick-levels .choice__body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-3); }
    .quick-levels .choice__note { flex-basis: 100%; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
    /* X and the purchase date side by side */
    .quick-xdate { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
    .quick-form .form-section { padding: var(--space-3); }
    .quick-xdate .field__hint { font-size: var(--text-xs); }
    .quick-form .kv { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-1) var(--space-3); font-size: var(--text-sm); }
    .quick-form .kv dt { margin-top: 0; }
  }

  /* ---------------------------------------------------------------- screening form */
  /* fields of the other property type are hidden once a type is chosen (no JavaScript needed) */
  .screen-form:has(select[name=property_type] option[value=house]:checked) .only-condo { display: none; }
  .screen-form:has(select[name=property_type] option[value=condo]:checked) .only-house { display: none; }
  /* the Steuerfuss belongs to the AG, chosen on the same step */
  .screen-form:has(input[name=buyer_type][value=private]:checked) .when-ag { display: none; }
  /* one step per screen: the step line (with the running total on the renovation step) sticks above
     the step at every width (ui.steps in ui.sticky_summary) */
  .form-shell { max-width: calc(var(--form-max) + 8rem); }
  .form-shell > .sticky-summary { margin-bottom: var(--space-4); }
  .form-shell__main { min-width: 0; }
  .form-section__step { display: block; margin-bottom: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-regular); letter-spacing: 0; color: var(--color-text-muted); }
  .plan-add { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
  .plan-add > .field { flex: 1 1 16rem; }
  .review-step + .review-step { margin-top: var(--space-5); }
  .review-step__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
  .review-step__head h3 { font-size: var(--text-md); }
  /* every block of the review with the same label column, so the values line up down the page */
  .review-step .kv { grid-template-columns: minmax(0, 16rem) minmax(0, 1fr); }
  .review-step .kv :is(dt, dd) { padding-top: var(--space-2); padding-bottom: var(--space-2); }
  @media (max-width: 40rem) { .review-step .kv { grid-template-columns: minmax(0, 1fr); } }
  .form-section > * + * { margin-top: var(--space-4); }
  /* the renovation step (SPEC design decision 8): one compact row per measure, the columns named once
     above the list. Wide: name | quantity | value-adding share | cost | remove, the details below. Phone:
     the name and "Entfernen" on one line, quantity, share and cost under the three column heads. */
  .plan-intro { font-size: var(--text-sm); color: var(--color-text-muted); }
  .form-section > .stats { grid-template-columns: minmax(0, 24rem); } /* the running total, one wide card */
  .plan-list {
    --plan-cols: minmax(0, 1fr) 6.5rem 7rem 6rem 5.5rem;
    border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface);
  }
  .plan-list--no-share { --plan-cols: minmax(0, 1fr) 6.5rem 0 6rem 5.5rem; }
  .plan-list__head, .plan-row {
    display: grid; grid-template-columns: var(--plan-cols); column-gap: var(--space-3); align-items: center;
    padding: var(--space-2) var(--space-3);
  }
  /* the column heads in the look of a table head (components.css, tables) */
  .plan-list__head {
    font-size: var(--text-sm); font-weight: var(--weight-medium); letter-spacing: 0;
    color: var(--color-text); background: var(--color-surface-sunken); border-bottom: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .plan-list--no-share .plan-list__head > :nth-child(3) { visibility: hidden; }
  .plan-row { grid-template-areas: "name qty share cost act" "more more more more more"; row-gap: 0; }
  .plan-row + .plan-row { border-top: var(--border-thin) solid var(--color-border); }
  .plan-row__name { grid-area: name; min-width: 0; font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
  .plan-row__qty { grid-area: qty; min-width: 0; }
  .plan-row__share { grid-area: share; min-width: 0; }
  .plan-row__cost { grid-area: cost; font-variant-numeric: var(--font-numeric); font-weight: var(--weight-semibold); }
  .plan-row__act { grid-area: act; justify-self: end; }
  .plan-row__more { grid-area: more; display: flex; flex-wrap: wrap; gap: 0 var(--space-4); }
  .plan-row__more > .disclosure[open] { flex-basis: 100%; }
  .plan-row__meta { display: block; font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--color-text-muted); }
  .plan-row__none { color: var(--color-text-muted); font-size: var(--text-sm); }
  /* the inputs of a row: named by the column head (their labels stay for screen readers), compact */
  .plan-row__qty .field > label, .plan-row__share .field > label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .plan-row__qty .affix__unit, .plan-row__share .affix__unit { min-width: 2.25rem; padding: 0 var(--space-2); }
  .plan-row__qty input, .plan-row__share input { padding-inline: var(--space-2); }
  .plan-row :is(.plan-row__qty, .plan-row__share) .field-error { font-weight: var(--weight-medium); font-size: var(--text-xs); }
  .plan-row .actions { margin-top: var(--space-3); }
  @media (max-width: 40rem) {
    .plan-list { --plan-cols: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 0.95fr); }
    .plan-list--no-share { --plan-cols: minmax(0, 1.15fr) 0 minmax(0, 0.95fr); }
    .plan-list__head > .plan-list__name { display: none; }
    .plan-row { grid-template-areas: "name name act" "qty share cost" "more more more"; row-gap: var(--space-2); padding: var(--space-3); }
    .plan-list__head { padding-inline: var(--space-3); letter-spacing: 0; white-space: nowrap; }
    .plan-row__act .btn { padding-inline: 0; }
  }
  @media (max-width: 24rem) {
    /* a small phone (320 px): tighter cells, the column heads may wrap (hyphenated, not in capitals) */
    .plan-list__head, .plan-row { column-gap: var(--space-2); padding-inline: var(--space-2); }
    .plan-list__head { white-space: normal; text-transform: none; font-size: var(--text-xs); hyphens: auto; align-items: end; }
    .plan-row__qty .affix__unit, .plan-row__share .affix__unit { min-width: 0; padding: 0 var(--space-1); }
    .plan-row__qty input, .plan-row__share input { padding-inline: var(--space-1); }
  }

  /* ---------------------------------------------------------------- result page */
  /* the assumptions beside the calculation; on a phone above it */
  .result-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: var(--space-6);
    align-items: start; margin-top: var(--space-6);
  }
  .result-layout__aside { grid-column: 2; grid-row: 1; position: sticky; top: var(--space-4); }
  .result-layout__main { grid-column: 1; grid-row: 1; min-width: 0; }
  .result-layout__main > .section-nav:first-child { margin-top: 0; }
  .result-layout__main > .section:first-of-type { margin-top: var(--space-5); }
  .result-layout__title { font-size: var(--text-md); margin-bottom: var(--space-3); }
  /* the assumptions: label over value, one hairline between the pairs */
  .result-layout__aside .kv { grid-template-columns: minmax(0, 1fr); padding: var(--space-1) var(--space-4); }
  .result-layout__aside .kv dt { padding-bottom: 0; font-size: var(--text-xs); }
  .result-layout__aside .kv dd { padding-top: 2px; }
  .result-layout__aside .kv dt:not(:first-of-type) + dd { border-top: 0; }
  @media (max-width: 64rem) {
    .result-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
    .result-layout__aside, .result-layout__main { grid-column: 1; grid-row: auto; position: static; }
  }
  @media (max-width: 40rem) {
    /* phone: the assumptions as two narrow columns, so they stay short */
    .result-layout__aside .kv { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 0; }
    .result-layout__aside .kv dt, .result-layout__aside .kv dd { padding: var(--space-2) 0; }
    .result-layout__aside .kv dt { padding-right: var(--space-3); }
    .result-layout__aside .kv dt { hyphens: auto; -webkit-hyphens: auto; font-size: var(--text-sm); }
    .result-layout__aside .kv dt:not(:first-of-type) + dd { border-top: var(--border-thin) solid var(--color-border); }
    /* phone: the low, base and high columns fit beside the sticky labels, so no key number is off screen */
    /* the label column and three numbers fit 375 px: smaller type, tight padding, long words hyphenated */
    :is(.result-layout, .result-moves) .data--sticky { font-size: 0.75rem; }
    :is(.result-layout, .result-moves) .data--sticky tr > :first-child { min-width: 7rem; max-width: 8.5rem; hyphens: auto; -webkit-hyphens: auto; }
    :is(.result-layout, .result-moves) .data tr.sub > th { padding-left: var(--space-4); }
    .data--waterfall tr.sub > th { padding-left: calc(var(--space-2) + 1.1em); }
    :is(.result-layout, .result-moves) .data--sticky .num { padding-left: var(--space-1); padding-right: var(--space-2); }
    /* "Was das Ergebnis am stärksten bewegt" fits a 375 px screen (it was 7 px too wide) */
    .result-moves .data thead th { white-space: normal; letter-spacing: 0; }
    .result-moves .data--sticky tr > :first-child { min-width: 6rem; }
  }
  .verdict__link { font-weight: var(--weight-semibold); color: var(--color-danger-text); }
  .review-panel--act { border-color: var(--color-primary); }
  .result-more { margin-top: var(--space-6); }
  .run-meta { color: var(--color-text-muted); font-size: var(--text-sm); font-variant-numeric: var(--font-numeric); overflow-wrap: anywhere; }

  /* warnings: one disclosure per tier (ui.disclosure with marker and count); each warning a list item
     with its bold short title on one line and the explanation under it */
  .tiers .disclosure__summary { color: var(--color-text); }
  /* each warning a row: its title in medium weight, the text in muted under it; the tier's badge in the
     summary carries the tone. On a wide screen the rows start under the summary's title. */
  .warnings { list-style: none; padding: 0; max-width: calc(var(--measure) + 10rem); }
  .warnings > .warning { display: grid; gap: 2px; padding: var(--space-2) 0; }
  .warnings > .warning + .warning { margin-top: 0; border-top: var(--border-thin) solid var(--color-border); }
  .tiers .disclosure--marked > .disclosure__body { padding-left: calc(6.5rem + var(--space-3)); }
  .warning__title { font-weight: var(--weight-medium); }
  .warning__text { color: var(--color-text-muted); line-height: var(--leading-snug); }
  .warning__more { margin-top: var(--space-1); font-size: var(--text-sm); }
  .warning__more > summary {
    --icon: var(--icon-chevron-down);
    display: inline-flex; align-items: center; gap: var(--space-1); width: fit-content; cursor: pointer; list-style: none;
    color: var(--color-link); font-weight: var(--weight-medium);
  }
  .warning__more > summary::-webkit-details-marker { display: none; }
  .warning__more > summary::after { width: 0.875rem; height: 0.875rem; transition: transform 0.2s; }
  .warning__more[open] > summary::after { transform: rotate(180deg); }
  @media (max-width: 40rem) { .tiers .disclosure--marked > .disclosure__body { padding-left: 0; } }
  .warning__more > ul { margin-top: var(--space-2); }
  .warning__more > .warnings { padding-left: 0; }

  /* the profit waterfall: the operator in its own column, so every label starts at the same place */
  .data--waterfall .data__op { display: inline-block; width: 1.1em; color: var(--color-text-muted); }
  .data--waterfall tr.sub > th { padding-left: calc(var(--space-3) + 1.1em + var(--space-3)); }
  .data tr.subtotal > * { font-weight: var(--weight-semibold); border-top: var(--border-thin) solid var(--color-border-strong); }
  /* the standard assumptions: the label column wide enough for "Eigenkapital beim Kauf in % des Kaufpreises" */
  .defaults th[scope="row"] { width: 55%; }
  .defaults td.num { width: 20%; }
  /* the result's top blocks share one width (Max, 25 Nov 2026: "the grey bar is too small") */
  .verdict__lead b { font-variant-numeric: var(--font-numeric); }
  /* "Zur Kenntnis schicken": out of sight until the header's button opens it */
  .share-form > .disclosure:not([open]):not(:target) { display: none; }
  .share-form > .disclosure { border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-xl); padding: 0 var(--space-5); background: var(--color-surface); box-shadow: var(--shadow-sm); }

  /* ---------------------------------------------------------------- compare */
  .compare thead th { text-transform: none; letter-spacing: 0; font-size: var(--text-sm); min-width: 10rem; }
  .compare thead th:first-child { min-width: 0; }
  .compare .badge { white-space: normal; }
  /* each case column reads as one column: words, badges and numbers end at the same right edge */
  .compare tbody td { text-align: right; }
  /* the case's name heads its column at the same right edge as its values (Max, 26 Nov 2026) */
  .compare thead th.title-cell { text-align: right; vertical-align: bottom; }
  @media (max-width: 40rem) {
    /* phone: labels and two cases fit on the screen; a third and fourth scroll beside the labels */
    .compare thead th { min-width: 6.5rem; }
    .compare .num { padding-left: var(--space-1); }
    .compare.data--sticky tr > :first-child { min-width: 6.5rem; max-width: 7.5rem; hyphens: auto; }
  }


  /* ---------------------------------------------------------------- case page: add rows, Kaufangebot
     "Dokument hinzufügen" and "Offerte erfassen" as compact rows under the lists they fill */
  .add-rows { margin-top: var(--space-4); }
  .offer-form { margin-top: var(--space-4); }
  .offer-form .form-grid { max-width: 36rem; }
  /* the Pendenz "Freigegeben": its button opens the Kaufangebot form, so it stays on a phone too */
  @media (max-width: 40rem) { .todo__item--offer > .btn { display: inline-flex; } }
  /* a date brings up the digit keyboard (inputmode numeric) but reads left to right like text */
  .field input[inputmode="numeric"][placeholder="TT.MM.JJJJ"] { text-align: left; }
}

/* ---------------------------------------------------------------- sale-price forecast (templates/_price.html) */
@layer pages {
  .price-band { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); font-size: var(--text-sm); color: var(--color-text-muted); }
  .price-band b { color: var(--color-text); font-variant-numeric: var(--font-numeric); }
  .price-source { font-size: var(--text-sm); color: var(--color-text-muted); }
  .quick-z > * + * { margin-top: var(--space-2); }
  .quick-z > .field + .field { margin-top: var(--space-4); }
  .price-now { max-width: calc(var(--measure) + 10rem); }
  h3.price-group { margin-top: var(--space-5); font-size: var(--text-md); }
  h3.price-group + .hint { margin-top: var(--space-1); }
}
@layer pages {
  /* step "Verkauf": the model's proposal above the three sale prices */
  .price-proposal { padding: var(--space-3) var(--space-4); background: var(--color-surface-sunken); border-radius: var(--radius-md); }
  .price-proposal > * + * { margin-top: var(--space-1); }
  .price-proposal .actions { margin-top: var(--space-2); }
  .price-proposal b { font-variant-numeric: var(--font-numeric); }
}

/* ---------------------------------------------------------------- style guide (/styleguide): the docs layout of shadcn */
@layer pages {
  .sg-layout { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: var(--space-7); align-items: start; }
  .sg-nav { position: sticky; top: var(--space-5); font-size: var(--text-sm); }
  .sg-nav__title { margin-bottom: var(--space-2); font-weight: var(--weight-medium); }
  .sg-nav ul { list-style: none; padding: 0; }
  .sg-nav li + li { margin-top: 0; }
  .sg-nav a { display: block; padding: var(--space-1) 0; color: var(--color-text-muted); font-weight: var(--weight-regular); text-decoration: none; }
  .sg-nav a:hover { color: var(--color-text); }
  .sg-main { min-width: 0; }
  .sg-section { padding-bottom: var(--space-6); scroll-margin-top: var(--space-5); }
  .sg-section + .sg-section { padding-top: var(--space-6); border-top: var(--border-thin) solid var(--color-border); }
  .sg-section > h2 { font-size: var(--text-xl); }
  .sg-section > h2 code { margin-left: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-regular); color: var(--color-text-muted); }
  .sg-section > h3 { margin-top: var(--space-5); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-muted); }
  .sg-lead { margin: var(--space-1) 0 var(--space-4); color: var(--color-text-muted); }
  /* a preview frame as on shadcn's docs: the component on the page background in a bordered box */
  .sg-preview { padding: var(--space-6) var(--space-5); border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg); }
  * + .sg-preview { margin-top: var(--space-3); }
  .sg-preview > .actions:first-child { margin-top: 0; }
  .sg-preview > p + p { margin-top: var(--space-3); }
  .sg-preview--grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: var(--space-4); align-items: start; }
  .sg-preview--grid > * + * { margin-top: 0; }
  .sg-preview--stack > * + * { margin-top: var(--space-4); }
  .sg-preview > .section-nav { margin: 0; }
  .sg-icons { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); }
  .sg-icons > span { display: inline-flex; align-items: center; gap: var(--space-2); }
  .sg-icons code { font-size: var(--text-xs); color: var(--color-text-muted); }
  @media (max-width: 52rem) {
    .sg-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .sg-nav { display: none; }
    .sg-preview { padding: var(--space-4); }
  }
}

/* ---------------------------------------------------------------- address facts (templates/_address.html) */
/* one row per rule: badge and title | its ONE line; the rows divided like a table, no caption under them */
@layer pages {
  h3.address-group { margin-top: var(--space-5); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-muted); }
  h3.address-group + * { margin-top: var(--space-2); }
  .flag-list { list-style: none; padding: 0; border-top: var(--border-thin) solid var(--color-border); }
  .flag-list__row {
    display: grid; grid-template-columns: minmax(14rem, 22rem) minmax(0, 1fr); gap: var(--space-1) var(--space-5); align-items: baseline;
    padding: var(--space-2) 0; border-bottom: var(--border-thin) solid var(--color-border);
  }
  .flag-list__row + .flag-list__row { margin-top: 0; }
  .flag-list__title { font-weight: var(--weight-medium); }
  .flag-list__title > .badge { margin-right: var(--space-1); }
  .flag-list__text { color: var(--color-text-muted); }
  .disclosure__body > .flag-list { border-top: 0; }
  @media (max-width: 40rem) { .flag-list__row { grid-template-columns: minmax(0, 1fr); } }
}
