/* Atticlet component layer. Requires dist/tokens.css and src/base.css.
 *
 * Two kinds of class live here, and the difference decides whether an app can use
 * one at all.
 *
 * STRUCTURE-ONLY classes carry layout, size and hit target, and hold no opinion
 * about skin. A component library has no equivalent to collide with, so these are
 * consumable as-is in any app: .at-shell, .at-nav, .at-header, .at-control,
 * .at-field, .at-sr-only.
 *
 * SKINNED classes bake fill, border, radius and shadow into structure. In an app
 * whose component library sits in @layer mui, these LOSE — layer order outranks
 * specificity, so `.at-btn` at 0-1-0 cannot beat `.MuiButton-root` at 0-1-0 in a
 * later layer, and a more specific selector does not help. They are therefore the
 * SPECIFICATION that dist/mui.js translates into theme overrides, and they render
 * directly only in an app with no layered component library (hub).
 *
 * That is not a reason to delete them: they are the only place these invariants —
 * 44px targets, --at-on-* pairing, hover progression, disabled treatment — exist as
 * runnable code rather than prose. Prose cannot be re-synced.
 */

@layer atticlet-components {
  /* Button ---------------------------------------------------------- skinned */

  .at-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--at-space-2);
    min-height: var(--at-control-md);
    padding: var(--at-space-3) var(--at-space-6);
    border: var(--at-border-width-thick) solid transparent;
    border-radius: var(--at-radius-pill);
    background: var(--at-primary);
    color: var(--at-on-primary);
    font-size: var(--at-text-button-size);
    line-height: var(--at-text-button-line);
    font-weight: var(--at-text-button-weight);
    text-decoration: none;
    cursor: pointer;
    transition:
      background-color var(--at-duration-fast) var(--at-ease-standard),
      border-color var(--at-duration-fast) var(--at-ease-standard),
      color var(--at-duration-fast) var(--at-ease-standard);
  }

  /* Every variant restates BOTH background and colour on :hover and :active.
     .at-btn:hover and .at-btn:active (0,2,0) outrank a variant's resting rule (0,1,0),
     so a state the variant leaves out falls through to primary: the outline button
     went white-on-grey on hover and flooded blue on press. check-artifacts gates it. */
  .at-btn:hover { background: var(--at-primary-hover); color: var(--at-on-primary); }
  .at-btn:active { background: var(--at-primary-active); color: var(--at-on-primary); }

  .at-btn--action { background: var(--at-action); color: var(--at-on-action); }
  .at-btn--action:hover { background: var(--at-action-hover); color: var(--at-on-action); }
  .at-btn--action:active { background: var(--at-action-active); color: var(--at-on-action); }

  .at-btn--danger { background: var(--at-danger); color: var(--at-on-danger); }
  .at-btn--danger:hover { background: var(--at-danger-hover); color: var(--at-on-danger); }
  .at-btn--danger:active { background: var(--at-danger-active); color: var(--at-on-danger); }

  .at-btn--secondary {
    background: transparent;
    color: var(--at-link);
    border-color: currentColor;
  }
  .at-btn--secondary:hover { background: var(--at-state-hover); color: var(--at-link); }
  .at-btn--secondary:active { background: var(--at-state-pressed); color: var(--at-link); }

  .at-btn--ghost { background: transparent; color: var(--at-text); }
  .at-btn--ghost:hover { background: var(--at-state-hover); color: var(--at-text); }
  .at-btn--ghost:active { background: var(--at-state-pressed); color: var(--at-text); }

  /* A control sitting ON a brand fill: it inverts rather than restating the fill. */
  .at-btn--inverse {
    background: var(--at-surface);
    color: var(--at-text);
    border-color: transparent;
  }
  .at-btn--inverse:hover { background: var(--at-surface-hover); color: var(--at-text); }
  .at-btn--inverse:active { background: var(--at-surface-active); color: var(--at-text); }

  /* Tonal: every action in a row except the one solid button (S9). A peer-surface
     fill, no border, the label in --at-text and the icon in --at-link. Hover and press
     are the translucent state layers over that fill, so the button reads the same on
     --at-bg and on --at-surface. Lifted from fbudget's ActionButton. */
  .at-btn--tonal { background: var(--at-surface-alt); color: var(--at-text); border-color: transparent; }
  .at-btn--tonal:hover {
    background: linear-gradient(var(--at-state-hover), var(--at-state-hover)) var(--at-surface-alt);
    color: var(--at-text);
  }
  .at-btn--tonal:active {
    background: linear-gradient(var(--at-state-pressed), var(--at-state-pressed)) var(--at-surface-alt);
    color: var(--at-text);
  }
  .at-btn--tonal > svg { color: var(--at-link); }
  /* The icon colour above is set on the svg, so the disabled label colour cannot reach
     it; disabled hands it back. */
  .at-btn--tonal[disabled] > svg,
  .at-btn--tonal[aria-disabled='true'] > svg { color: inherit; }
  /* A destructive action that is not the screen's solid button («Очистить данные»). */
  .at-btn--tonal-danger { background: var(--at-danger-tint); color: var(--at-on-danger-tint); border-color: transparent; }
  .at-btn--tonal-danger:hover {
    background: linear-gradient(var(--at-state-hover), var(--at-state-hover)) var(--at-danger-tint);
    color: var(--at-on-danger-tint);
  }
  .at-btn--tonal-danger:active {
    background: linear-gradient(var(--at-state-pressed), var(--at-state-pressed)) var(--at-danger-tint);
    color: var(--at-on-danger-tint);
  }

  /* Small keeps the 44px target: the box shrinks, the hit area does not. Shipping
     a 36px control while the same package calls 44px non-negotiable was a defect. */
  .at-btn--sm {
    min-height: var(--at-control-sm);
    padding: var(--at-space-2) var(--at-space-4);
    font-size: var(--at-text-button-sm-size);
    position: relative;
  }
  /* The target is centred on the box and at least --at-hit-target tall, whatever the
     border. An absolute box is placed against the PADDING box, so an inset of
     (36 − 44) / 2 gave 44 − 2 × border: 40px under .at-btn's 2px transparent border. */
  .at-btn--sm::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: 50%;
    height: max(100%, var(--at-hit-target));
    transform: translateY(-50%);
  }
  /* The action-row size (S9): 36px box, 44px target, button-sm, 16px icon. */
  .at-btn--sm > svg { flex: none; width: var(--at-icon-sm); height: var(--at-icon-sm); }
  .at-btn--lg {
    min-height: var(--at-control-lg);
    padding: var(--at-space-4) var(--at-space-8);
    font-size: var(--at-text-button-lg-size);
  }

  /* Disabled is carried by the attribute and by three tokens, not by opacity. Opacity
     alone kept each variant's own colours, faded: a disabled orange button still read
     as the page's one orange action. Every variant converges on one treatment, and
     :hover/:active are restated at (0,3,0) so no variant's state rule repaints it.
     The label sits 3.00:1 light and 3.35:1 dark on its fill — exempt from 1.4.3,
     floored by the `disabled-label` ladder in tokens/source.mjs. */
  .at-btn[disabled],
  .at-btn[disabled]:hover,
  .at-btn[disabled]:active,
  .at-btn[aria-disabled='true'],
  .at-btn[aria-disabled='true']:hover,
  .at-btn[aria-disabled='true']:active {
    background: var(--at-fill-disabled);
    color: var(--at-text-disabled);
    border-color: var(--at-border-subtle);
    cursor: not-allowed;
  }

  /* Icon button ----------------------------------------------------- skinned */

  .at-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--at-hit-target);
    height: var(--at-hit-target);
    padding: 0;
    border: 0;
    border-radius: var(--at-radius-pill);
    background: transparent;
    color: var(--at-text);
    cursor: pointer;
    transition: background-color var(--at-duration-fast) var(--at-ease-standard);
  }
  .at-icon-btn:hover { background: var(--at-state-hover); }
  .at-icon-btn:active { background: var(--at-state-pressed); }

  /* Field ------------------------------------------------- structure-only */

  .at-field { display: block; }

  .at-field__label {
    display: block;
    margin-bottom: var(--at-space-2);
    font-size: var(--at-text-body-sm-size);
    font-weight: var(--at-weight-bold);
    color: var(--at-text);
  }
  .at-field__required { color: var(--at-danger-text); }

  .at-control {
    width: 100%;
    min-height: var(--at-control-md);
    padding: var(--at-space-3) var(--at-space-4);
    border: var(--at-border-width-thin) solid var(--at-border);
    border-radius: var(--at-radius-md);
    background: var(--at-surface);
    color: var(--at-text);
    transition: border-color var(--at-duration-fast) var(--at-ease-standard);
  }
  .at-control::placeholder { color: var(--at-text-muted); }
  .at-control:hover { border-color: var(--at-border-strong); }
  .at-control:focus-visible { border-color: var(--at-focus); }
  .at-control[disabled] {
    background: var(--at-fill-disabled);
    color: var(--at-text-disabled);
    cursor: not-allowed;
  }
  .at-control[aria-invalid='true'] { border-color: var(--at-danger-text); }
  .at-control--sm { min-height: var(--at-control-sm); padding: var(--at-space-2) var(--at-space-3); }

  .at-field__help { margin: var(--at-space-2) 0 0; font-size: var(--at-text-caption-size); color: var(--at-text-muted); }
  .at-field__error { margin: var(--at-space-2) 0 0; font-size: var(--at-text-caption-size);
                     font-weight: var(--at-weight-bold); color: var(--at-danger-text); }

  .at-choice { display: flex; align-items: center; gap: var(--at-space-3); min-height: var(--at-hit-target); }
  .at-choice input { width: var(--at-icon-md); height: var(--at-icon-md); margin: 0; accent-color: var(--at-primary); }

  /* Segments ------------------------------------- layout structure-only, item skinned
     A group of mutually exclusive options: role="group" (or radiogroup) on the
     container, aria-pressed (or a checked radio) on each item. The layout rules on
     .at-segments touch only its children's flex sizing, so they work around MUI
     Buttons too; .at-segments__item is the skin for apps without a library.

     Four or more options in a container narrower than 480px fold into a two-column
     grid of equal cells. The fold reads the CONTAINER's width, not the viewport's,
     without a container query: a container query would need the app to declare an
     ancestor container, and with none declared it silently never matches. Instead
     each item's basis is clamped — (480px − 100%) × 999 is hugely positive below
     480px (→ half width) and negative above it (→ 0, one row). max-width does the
     inverse so an odd last item keeps its half instead of stretching. */
  .at-segments {
    --_at-segments-gap: var(--at-space-1);
    display: flex;
    flex-wrap: wrap;
    gap: var(--_at-segments-gap);
  }
  .at-segments > * { flex: 1 1 0; min-width: 0; }
  .at-segments:has(> :nth-child(4)) > * {
    flex-basis: clamp(0px, (480px - 100%) * 999, calc(50% - var(--_at-segments-gap) / 2));
    max-width: max(calc(50% - var(--_at-segments-gap) / 2), (100% - 480px) * 999);
  }

  .at-segments__item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--at-hit-target);
    padding: var(--at-space-2) var(--at-space-4);
    border: var(--at-border-width-thin) solid var(--at-border);
    border-radius: var(--at-radius-pill);
    background: var(--at-surface);
    color: var(--at-text);
    font-size: var(--at-text-button-sm-size);
    font-weight: var(--at-text-button-weight);
    line-height: var(--at-text-button-line);
    text-align: center;
    cursor: pointer;
    transition:
      background-color var(--at-duration-fast) var(--at-ease-standard),
      border-color var(--at-duration-fast) var(--at-ease-standard);
  }
  .at-segments__item:hover { background: var(--at-surface-hover); }
  /* Selected is a fill, a border AND a weight — never the tint alone. */
  .at-segments__item[aria-pressed='true'],
  .at-segments__item[aria-checked='true'],
  .at-segments__item:has(input:checked) {
    background: var(--at-primary-tint);
    color: var(--at-on-primary-tint);
    border-color: var(--at-primary);
    font-weight: var(--at-weight-bold);
  }
  .at-segments__item input { position: absolute; opacity: 0; pointer-events: none; }
  .at-segments__item:has(input:focus-visible) {
    outline: var(--at-focus-width) solid var(--at-focus);
    outline-offset: var(--at-focus-offset);
  }

  /* Card ------------------------------------------------------------ skinned */

  .at-card {
    padding: var(--at-space-5);
    border: var(--at-border-width-hairline) solid var(--at-border-subtle);
    border-radius: var(--at-radius-20);
    background: var(--at-surface);
    box-shadow: var(--at-elevation-raised);
  }
  /* Structure without the skin, for apps whose cards are colour blocks. */
  .at-card--flat { border: 0; box-shadow: none; background: transparent; }
  .at-card__title { margin: var(--at-space-3) 0 var(--at-space-2);
                    font-size: var(--at-text-body-lg-size); font-weight: var(--at-weight-bold);
                    letter-spacing: -0.02em; }
  .at-card__body { margin: 0; font-size: var(--at-text-body-sm-size); color: var(--at-text-secondary); }

  /* Badge ----------------------------------------------------------- skinned */

  .at-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--at-space-2);
    padding: 5px var(--at-space-3);
    border-radius: var(--at-radius-pill);
    background: var(--at-surface-alt);
    color: var(--at-text-secondary);
    font-size: var(--at-text-label-size);
    font-weight: var(--at-weight-bold);
    line-height: var(--at-text-label-line);
    /* A badge is a state, at most three words. One that wraps is carrying an
       explanation, which belongs next to it as --at-text-muted text. */
    white-space: nowrap;
  }
  /* Opt-in caps, because a badge that always shouts cannot be quiet. */
  .at-badge--caps { text-transform: uppercase; letter-spacing: var(--at-text-label-tracking); }
  .at-badge--live { background: var(--at-action); color: var(--at-on-action); }
  .at-badge--success { background: var(--at-success-tint); color: var(--at-on-success-tint); }
  .at-badge--info { background: var(--at-info-tint); color: var(--at-on-info-tint); }
  .at-badge--warning { background: var(--at-warning-tint); color: var(--at-on-warning-tint); }
  .at-badge--danger { background: var(--at-danger-tint); color: var(--at-on-danger-tint); }
  .at-badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

  /* Navigation ------------------------------------------- structure-only */

  .at-header { background: var(--at-surface); border-bottom: var(--at-border-width-hairline) solid var(--at-border-subtle); }
  .at-header__inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--at-space-6); min-height: var(--at-header-height);
  }
  /* A fixed-height row with no wrap does not fit a 390px phone. */
  @media (max-width: 600px) {
    .at-header__inner {
      flex-direction: column; align-items: stretch;
      min-height: 0; gap: var(--at-space-3);
      padding-block: var(--at-space-3);
    }
  }
  .at-header__logo { display: block; width: 148px; flex: 0 0 auto; }
  @media (max-width: 600px) { .at-header__logo { width: 132px; } }
  .at-header--sticky { position: sticky; top: 0; z-index: var(--at-z-sticky); }

  .at-nav { display: flex; flex-wrap: wrap; gap: var(--at-space-1); margin: 0; padding: 0; list-style: none; }
  .at-nav a {
    display: flex; align-items: center; min-height: var(--at-hit-target);
    padding: var(--at-space-2) var(--at-space-4);
    border-radius: var(--at-radius-pill);
    color: var(--at-text-secondary);
    font-size: var(--at-text-body-sm-size); font-weight: var(--at-weight-bold); text-decoration: none;
    transition: background-color var(--at-duration-fast) var(--at-ease-standard);
  }
  .at-nav a:hover { background: var(--at-state-hover); color: var(--at-text); }
  .at-nav a[aria-current='page'] { background: var(--at-primary); color: var(--at-on-primary); }

  /* A nav that would wrap to a second or third line on a phone scrolls sideways
     instead, opt-in. Edge fades say there is more: with scroll-driven animations each
     fade grows only while there is something to scroll toward on its side, and is
     gone when the row fits. Without them, a static fade sits over padding of the same
     width, so at either end it covers padding, not a label. Scroll the current page
     into view on load — README has the line of JS. */
  .at-nav--scroll {
    --_at-nav-ring-room: calc(var(--at-focus-width) + var(--at-focus-offset));
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    /* overflow clips the focus ring; this gives it room without moving the row. */
    padding: var(--_at-nav-ring-room);
    margin: calc(-1 * var(--_at-nav-ring-room));
    /* `black` is an alpha stop for the mask, not a colour anyone sees. */
    mask-image: linear-gradient(to right,
      transparent, black var(--_at-nav-fade-start),
      black calc(100% - var(--_at-nav-fade-end)), transparent);
  }
  .at-nav--scroll::-webkit-scrollbar { display: none; }
  .at-nav--scroll > * { flex: 0 0 auto; }
  .at-nav--scroll a { white-space: nowrap; }

  @keyframes at-nav-fade {
    0% { --_at-nav-fade-start: 0px; --_at-nav-fade-end: var(--at-space-6); }
    10% { --_at-nav-fade-start: var(--at-space-6); }
    90% { --_at-nav-fade-end: var(--at-space-6); }
    100% { --_at-nav-fade-start: var(--at-space-6); --_at-nav-fade-end: 0px; }
  }
  @supports (animation-timeline: scroll()) {
    /* The shorthand resets animation-timeline, so the timeline comes after it. */
    .at-nav--scroll { animation: at-nav-fade linear both; animation-timeline: scroll(self inline); }
  }
  @supports not (animation-timeline: scroll()) {
    .at-nav--scroll {
      --_at-nav-fade-start: var(--at-space-6);
      --_at-nav-fade-end: var(--at-space-6);
      padding-inline: var(--at-space-6);
    }
  }

  /* Surfaces ------------------------------------------------------- skinned */

  .at-panel { padding: var(--at-space-5); border-radius: var(--at-radius-20); background: var(--at-surface);
              border: var(--at-border-width-hairline) solid var(--at-border-subtle); }
  .at-divider { height: 1px; border: 0; margin: var(--at-space-6) 0; background: var(--at-border-subtle); }

  /* Chrome over photography: theme-stable, because the image is dark in both themes. */
  .at-on-image { color: var(--at-on-image); text-shadow: var(--at-text-shadow-on-image); }
  .at-on-image-secondary { color: var(--at-on-image-secondary); text-shadow: var(--at-text-shadow-on-image); }

  /* Quiet link ------------------------------------------------------ skinned
     For links that sit in dense UI — table rows, card footers, "show all" — where a
     standing underline on every one turns the block into noise. It is still a link
     by colour at rest and gains the underline on hover AND keyboard focus, so focus
     changes more than the ring. Running text keeps the default underlined link. */
  .at-link--quiet { color: var(--at-link); text-decoration: none; text-underline-offset: 0.18em; }
  .at-link--quiet:hover,
  .at-link--quiet:focus-visible { color: var(--at-link-hover); text-decoration: underline; }

  /* Toast ----------------------------------------------------------- skinned
     One toast on screen at a time; the rest queue (README). Anchored bottom centre,
     never wider than --at-toast-max; below --at-bp-sm (600px — a media query cannot
     read a custom property) it spans the screen inside the small gutter and clears
     the home indicator. The action is --at-link-on-inverse: --at-link is tuned for
     the opposite ground and fails on this one. Its focus ring is in base.css, in the
     guards layer, because a ring colour set here would lose to the default one. */
  .at-toast {
    position: fixed;
    z-index: var(--at-z-toast);
    bottom: calc(var(--at-space-6) + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--at-space-3);
    width: max-content;
    max-width: min(var(--at-toast-max), calc(100% - var(--at-shell-gutter-sm) * 2));
    min-height: var(--at-control-lg);
    padding: var(--at-space-2) var(--at-space-2) var(--at-space-2) var(--at-space-4);
    border-radius: var(--at-radius-12);
    background: var(--at-surface-inverse);
    color: var(--at-on-inverse);
    box-shadow: var(--at-elevation-overlay);
    font-size: var(--at-text-body-sm-size);
    line-height: var(--at-text-body-sm-line);
  }
  .at-toast__message { flex: 1 1 auto; min-width: 0; padding-block: var(--at-space-1); }
  .at-toast__action {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: var(--at-hit-target);
    padding: 0 var(--at-space-3);
    border: 0;
    border-radius: var(--at-radius-8);
    background: transparent;
    color: var(--at-link-on-inverse);
    font-size: var(--at-text-button-size);
    font-weight: var(--at-text-button-weight);
    line-height: var(--at-text-button-line);
    text-decoration: none;
    cursor: pointer;
  }
  .at-toast__action:hover { text-decoration: underline; }
  @media (width < 600px) {
    .at-toast {
      left: var(--at-shell-gutter-sm);
      right: var(--at-shell-gutter-sm);
      bottom: calc(var(--at-shell-gutter-sm) + env(safe-area-inset-bottom, 0px));
      transform: none;
      width: auto;
      max-width: none;
    }
  }

  /* Alert ----------------------------------------------------------- skinned
     A message that stays until the situation changes. The tone is reinforcement;
     the text says what happened. Below --at-bp-sm the action drops under the text
     and keeps to the right, so the text gets the whole width rather than a column
     squeezed beside a button. */
  .at-alert {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--at-space-2) var(--at-space-3);
    padding: var(--at-space-3) var(--at-space-4);
    border-radius: var(--at-radius-12);
    background: var(--at-surface-alt);
    color: var(--at-text);
    font-size: var(--at-text-body-sm-size);
    line-height: var(--at-text-body-sm-line);
  }
  .at-alert__icon { flex: 0 0 auto; display: inline-flex; width: var(--at-icon-md); height: var(--at-icon-md);
                    margin-top: 1px; }
  .at-alert__body { flex: 1 1 0; min-width: 0; }
  .at-alert__title { margin: 0 0 var(--at-space-1); font-weight: var(--at-weight-bold); }
  .at-alert__action { flex: 0 0 auto; display: flex; align-items: center; gap: var(--at-space-2);
                      margin-left: auto; }
  .at-alert--info { background: var(--at-info-tint); color: var(--at-on-info-tint); }
  .at-alert--success { background: var(--at-success-tint); color: var(--at-on-success-tint); }
  .at-alert--warning { background: var(--at-warning-tint); color: var(--at-on-warning-tint); }
  .at-alert--danger { background: var(--at-danger-tint); color: var(--at-on-danger-tint); }
  @media (width < 600px) {
    .at-alert__action { flex-basis: 100%; justify-content: flex-end; }
  }

  /* Dialog actions -------------------------------------------- structure-only
     Wide: a right-aligned row, primary last (rightmost). Below --at-bp-sm: a stack of
     full-width buttons with the primary on top — column-reverse, so the DOM order
     and therefore the tab order stay the same at every width. */
  .at-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--at-space-3);
  }
  @media (width < 600px) {
    .at-dialog__actions { flex-direction: column-reverse; align-items: stretch; gap: var(--at-space-2); }
    .at-dialog__actions > * { width: 100%; }
  }

  /* Table --------------------------------------------------- structure-only */

  .at-table { width: 100%; border-collapse: collapse; }
  .at-table th, .at-table td {
    padding: var(--at-space-2) var(--at-space-3);
    text-align: left;
    border-bottom: var(--at-border-width-hairline) solid var(--at-border-subtle);
  }
  .at-table th { font-size: var(--at-text-label-size); font-weight: var(--at-weight-bold);
                 text-transform: uppercase; letter-spacing: var(--at-text-label-tracking);
                 color: var(--at-text-muted); }
  .at-table td.at-numeric, .at-table th.at-numeric { text-align: right; font-variant-numeric: var(--at-font-numeric); }
  .at-table--striped tbody tr:nth-child(even) { background: var(--at-fill-stripe); }
  .at-table tbody tr[aria-selected='true'] { background: var(--at-row-emphasis); color: var(--at-on-row-emphasis); }
  .at-table--sticky thead th { position: sticky; top: 0; z-index: var(--at-z-sticky); background: var(--at-surface); }
  /* Wide tables scroll inside their own container; the page never scrolls sideways. */
  .at-table-scroll { overflow-x: auto; }

  /* Table as cards, below --at-bp-sm. Each row becomes a card: the cell marked
     data-role="primary" is its title, data-role="amount" sits to the right of the
     title on the same line, data-role="actions" is a row of controls at the bottom,
     and every other cell shows its column name from data-label above its value.
     The header row is hidden visually but stays in the accessibility tree.
     Changing a table's display drops its table semantics in some engines (Safari),
     so the markup carries explicit roles — README has the example. */
  @media (width < 600px) {
    .at-table--cards,
    .at-table--cards tbody,
    .at-table--cards tfoot { display: block; width: 100%; }
    .at-table--cards thead {
      position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
      overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
    }
    .at-table--cards tr {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: var(--at-space-2) var(--at-space-3);
      padding: var(--at-space-3) var(--at-space-4);
      border: var(--at-border-width-hairline) solid var(--at-border-subtle);
      border-radius: var(--at-radius-12);
      background: var(--at-surface);
    }
    .at-table--cards tr + tr { margin-top: var(--at-space-2); }
    .at-table--cards td,
    .at-table--cards td.at-numeric { grid-column: 1 / -1; padding: 0; border: 0; text-align: left; }
    .at-table--cards td[data-label]::before {
      content: attr(data-label);
      display: block;
      margin-bottom: var(--at-space-1);
      font-size: var(--at-text-label-size);
      line-height: var(--at-text-label-line);
      font-weight: var(--at-weight-bold);
      letter-spacing: var(--at-text-label-tracking);
      text-transform: uppercase;
      color: var(--at-text-muted);
    }
    .at-table--cards td[data-role='primary'] {
      grid-column: 1; grid-row: 1;
      font-size: var(--at-text-body-size); font-weight: var(--at-weight-bold);
    }
    .at-table--cards td[data-role='amount'] {
      grid-column: 2; grid-row: 1;
      text-align: right; white-space: nowrap;
      font-weight: var(--at-weight-bold); font-variant-numeric: var(--at-font-numeric);
    }
    /* Last in auto-placement whatever its position in the row. */
    .at-table--cards td[data-role='actions'] {
      order: 1;
      display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--at-space-2);
      padding-top: var(--at-space-2);
      border-top: var(--at-border-width-hairline) solid var(--at-border-subtle);
    }
    .at-table--cards td[data-role]::before { content: none; }
  }

  /* ====================================================================== SCREEN
     The classes below carry SCREEN_RULES.md (S1–S14), the composition rules extracted
     from fbudget on 2026-11-12. Each is the system form of a local fbudget solution
     (page-head, hint, action-button, .fb-rows, .fb-details, .fb-page--narrow, the
     overview tile rows, the action drawer), not a new design. All of them are
     structure-only or skin a bare element MUI has no component for, so they work in
     an MUI app as they are. */

  /* Page --------------------------------------------------- structure-only
     S14: vertical padding 32 (24 below --at-bp-sm), 20 between page blocks. A list
     page adds --narrow: every block keeps to --at-column-narrow and stays left in the
     shell, so the header and the shell keep their full width. */
  .at-page { display: flex; flex-direction: column; gap: var(--at-space-5); padding-block: var(--at-space-8); }
  .at-page--narrow > * { max-width: var(--at-column-narrow); }
  @media (width < 600px) {
    .at-page { padding-block: var(--at-space-6); }
  }

  /* Page head ------------------------------------- structure, back chip skinned
     S1, S4, S8, S9: [overline] h1 [lede] and one action row. Wide: actions right of
     the title, aligned to its baseline row. Below --at-bp-sm: actions under it,
     wrapping. __heading is the row that holds the back chip, the h1 and anything
     that sits beside the title (a chip, a «?»); without those the h1 can stand alone. */
  .at-page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--at-space-3) var(--at-space-4);
  }
  .at-page-head__main { display: flex; flex-direction: column; gap: var(--at-space-1); min-width: 0; }
  .at-page-head__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--at-space-1) var(--at-space-2);
    min-width: 0;
  }
  .at-page-head__overline {
    margin: 0;
    font-size: var(--at-text-label-size);
    line-height: var(--at-text-label-line);
    font-weight: var(--at-text-label-weight);
    letter-spacing: var(--at-text-label-tracking);
    text-transform: uppercase;
    color: var(--at-text-muted);
  }
  .at-page-head__title {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--at-text);
    font-size: var(--at-text-h1-size);
    line-height: var(--at-text-h1-line);
    font-weight: var(--at-text-h1-weight);
    letter-spacing: var(--at-text-h1-tracking);
  }
  /* S4: one sentence of data or state, never an instruction. */
  .at-page-head__lede {
    margin: 0;
    font-size: var(--at-text-body-sm-size);
    line-height: var(--at-text-body-sm-line);
    color: var(--at-text-muted);
  }
  .at-page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--at-space-2); }
  @media (width < 600px) {
    .at-page-head { flex-direction: column; align-items: stretch; }
  }

  /* The back chip before the h1 on a detail page (S8). A link, but not a quiet one: a
     pill on --at-surface-alt, --at-text, no underline. 36px box and a 44px target from
     a pseudo-element, like .at-btn--sm, so the title row does not grow. It may shrink
     and wrap: a long or translated label must not push past a 320px screen. */
  .at-page-head__back {
    position: relative;
    display: inline-flex;
    flex: 0 1 auto;
    min-inline-size: 0;
    max-inline-size: 100%;
    align-items: center;
    gap: var(--at-space-1);
    min-height: var(--at-control-sm);
    padding: 0 var(--at-space-3) 0 var(--at-space-2);
    border-radius: var(--at-radius-pill);
    background: var(--at-surface-alt);
    color: var(--at-text);
    font-size: var(--at-text-button-sm-size);
    line-height: var(--at-text-button-sm-line);
    font-weight: var(--at-text-button-sm-weight);
    letter-spacing: var(--at-text-button-sm-tracking);
    text-decoration: none;
    overflow-wrap: anywhere;
  }
  .at-page-head__back::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: 50%;
    height: max(100%, var(--at-hit-target));
    transform: translateY(-50%);
  }
  .at-page-head__back:hover {
    background: linear-gradient(var(--at-state-hover), var(--at-state-hover)) var(--at-surface-alt);
    color: var(--at-text);
  }
  .at-page-head__back:active {
    background: linear-gradient(var(--at-state-pressed), var(--at-state-pressed)) var(--at-surface-alt);
    color: var(--at-text);
  }
  .at-page-head__back > svg { flex: none; width: var(--at-icon-sm); height: var(--at-icon-sm); }

  /* Hint ------------------------------------------------ skinned bare <button>
     S4: an explanation sits behind a «?» right after the heading text. Pressing it
     (aria-expanded, aria-controls) shows the plate under the heading; hover opens
     nothing. The button keeps its 44px target but sits in the heading row on negative
     margins, so the row is no taller than the heading. At most 160 characters on the
     plate; longer is help content. */
  .at-hint__row { display: flex; align-items: center; gap: var(--at-space-1); min-width: 0; }
  /* The heading gives way to the button, never the reverse: it shrinks and breaks
     inside a long word rather than pushing the «?» past a 320px screen. */
  .at-hint__row > :not(.at-hint) { min-inline-size: 0; overflow-wrap: anywhere; }
  .at-hint {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--at-hit-target);
    height: var(--at-hit-target);
    margin-block: calc((var(--at-icon-md) - var(--at-hit-target)) / 2);
    padding: 0;
    border: 0;
    border-radius: var(--at-radius-pill);
    background: transparent;
    color: var(--at-text-muted);
    font-size: var(--at-text-button-size);
    font-weight: var(--at-weight-bold);
    line-height: 1;
    cursor: pointer;
    transition:
      background-color var(--at-duration-fast) var(--at-ease-standard),
      color var(--at-duration-fast) var(--at-ease-standard);
  }
  .at-hint:hover { background: var(--at-state-hover); color: var(--at-text); }
  .at-hint:active { background: var(--at-state-pressed); color: var(--at-text); }
  .at-hint[aria-expanded='true'] { color: var(--at-text); }
  .at-hint > svg { width: var(--at-icon-md); height: var(--at-icon-md); }
  .at-hint__plate {
    margin: 0;
    padding: var(--at-space-2) var(--at-space-3);
    border-radius: var(--at-radius-8);
    background: var(--at-surface-alt);
    color: var(--at-text-secondary);
    font-size: var(--at-text-body-sm-size);
    line-height: var(--at-text-body-sm-line);
  }

  /* Disclosure ------------------------------ skinned bare <button> or <details>
     S7: the one way secondary content is closed. A text button whose label carries
     the count while closed («Показать историю (12)» / «Скрыть историю»), the content
     right under it, closed on every visit. Either a <button aria-expanded> with
     __content, or native <details class="at-disclosure"> with <summary>. */
  .at-disclosure__toggle,
  .at-disclosure > summary {
    display: inline-flex;
    align-items: center;
    gap: var(--at-space-2);
    min-height: var(--at-hit-target);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--at-link);
    font-size: var(--at-text-button-size);
    line-height: var(--at-text-button-line);
    font-weight: var(--at-text-button-weight);
    text-align: left;
    list-style: none;
    cursor: pointer;
  }
  .at-disclosure > summary::-webkit-details-marker { display: none; }
  /* A chevron drawn from two borders: right while closed, down while open. */
  .at-disclosure__toggle::before,
  .at-disclosure > summary::before {
    content: '';
    flex: none;
    width: var(--at-space-2);
    height: var(--at-space-2);
    margin-inline: var(--at-space-1);
    border-right: var(--at-border-width-thick) solid currentColor;
    border-bottom: var(--at-border-width-thick) solid currentColor;
    transform: rotate(-45deg);
    transition: transform var(--at-duration-fast) var(--at-ease-standard);
  }
  .at-disclosure__toggle[aria-expanded='true']::before,
  .at-disclosure[open] > summary::before { transform: rotate(45deg); }
  .at-disclosure__toggle:hover,
  .at-disclosure > summary:hover { color: var(--at-link-hover); text-decoration: underline; }
  .at-disclosure__content { margin-top: var(--at-space-2); }

  /* Empty state ---------------------------------------------- structure-only
     S13: one card, one muted sentence, at most one button. Put it on the card:
     <div class="at-card at-empty"> or an MUI Card with className="at-empty". It
     carries its own padding (S14: 20, 16 on a phone), because an MUI Card has none
     and clips its overflow: without it the button sat on the card edge with its 44px
     target and focus ring cut off. The padding is wider than both. */
  .at-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--at-space-3);
    padding: var(--at-space-5);
  }
  @media (width < 600px) {
    .at-empty { padding: var(--at-space-4); }
  }
  .at-empty__text { margin: 0; color: var(--at-text-muted); }

  /* Rows ------------------------------------------------------ structure-only
     S10: the default unit for a list of things with a value. Title and an optional
     caption on the left; the value — bold, tabular, a number never broken inside — and
     a chevron if the row navigates on the right. When the two do not fit side by side
     (320px, a long amount, enlarged text) the value and chevron — grouped in __end —
     wrap under the title, at the end of the row: a wrapping flex row, so it follows the content, not
     a breakpoint. Nothing is clipped: the card is not overflow-hidden; the first and
     last rows take its radius instead, so a hovered row still fills to the edge.
     The whole row is one target, at least 44px; rows sit on hairlines, all of a list
     in one card: the list IS the card, <ul class="at-card at-rows"> (or an MUI Card
     component="ul"), and .at-rows zeroes the card's padding. Declared after .at-card
     on purpose: equal specificity, so the later padding wins. In a list where some
     rows navigate and some do not, give the others an empty __chevron so values align. */
  .at-rows { margin: 0; padding: 0; list-style: none; }
  .at-rows > * + * { border-top: var(--at-border-width-hairline) solid var(--at-border-subtle); }
  .at-rows > :first-child,
  .at-rows > :first-child > .at-row {
    border-start-start-radius: inherit;
    border-start-end-radius: inherit;
  }
  .at-rows > :last-child,
  .at-rows > :last-child > .at-row {
    border-end-start-radius: inherit;
    border-end-end-radius: inherit;
  }
  .at-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--at-space-1) var(--at-space-3);
    min-height: var(--at-hit-target);
    padding: var(--at-space-3) var(--at-space-4);
    color: inherit;
    text-decoration: none;
  }
  a.at-row,
  button.at-row { cursor: pointer; transition: background-color var(--at-duration-fast) var(--at-ease-standard); }
  button.at-row { width: 100%; border: 0; background: transparent; text-align: left; }
  @media (hover: hover) {
    a.at-row:hover,
    button.at-row:hover { background: var(--at-surface-hover); color: inherit; }
  }
  /* The title keeps at least ~10 characters beside the value before the value wraps. */
  .at-row__main { display: flex; flex: 1 1 10em; flex-direction: column; min-width: 0; }
  .at-row__title {
    color: var(--at-text);
    font-size: var(--at-text-body-size);
    line-height: var(--at-text-body-line);
    overflow-wrap: anywhere;
  }
  .at-row__caption {
    color: var(--at-text-muted);
    font-size: var(--at-text-body-sm-size);
    line-height: var(--at-text-body-sm-line);
    overflow-wrap: anywhere;
  }
  /* The trailing group (2.4.1): value and chevron wrap TOGETHER, as one flex item at
     the end of the row. Without it the chevron, a flex item of its own, wrapped alone
     to the start of the next line. */
  .at-row__end {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    gap: var(--at-space-3);
    min-width: 0;
    max-width: 100%;
    margin-inline-start: auto;
  }
  .at-row__value {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    margin-inline-start: auto;
    color: var(--at-text);
    font-size: var(--at-text-body-size);
    line-height: var(--at-text-body-line);
    font-weight: var(--at-weight-bold);
    font-variant-numeric: var(--at-font-numeric);
    text-align: end;
    white-space: nowrap;
  }
  .at-row__chevron {
    flex: none;
    display: inline-flex;
    width: var(--at-icon-md);
    height: var(--at-icon-md);
    color: var(--at-text-muted);
    transition:
      color var(--at-duration-fast) var(--at-ease-standard),
      transform var(--at-duration-fast) var(--at-ease-standard);
  }
  .at-row__chevron > svg { width: 100%; height: 100%; }
  @media (hover: hover) {
    a.at-row:hover .at-row__chevron,
    button.at-row:hover .at-row__chevron { color: var(--at-text); transform: translateX(var(--at-space-1)); }
  }
  /* 2.4.0 markup — value and chevron as direct children of the row — keeps working: the
     chevron leaves the flow and sits at the row's end, centred, over padding reserved
     for it, so it cannot wrap away from the value. Prefer __end in new code. */
  .at-row:has(> .at-row__chevron) {
    position: relative;
    padding-inline-end: calc(var(--at-space-4) + var(--at-icon-md) + var(--at-space-3));
  }
  .at-row > .at-row__chevron {
    position: absolute;
    inset-inline-end: var(--at-space-4);
    top: 50%;
    transform: translateY(-50%);
  }
  @media (hover: hover) {
    a.at-row:hover > .at-row__chevron,
    button.at-row:hover > .at-row__chevron { transform: translate(var(--at-space-1), -50%); }
  }

  /* Panel form ------------------------ structure; native <dialog> placement skinned
     S11: a form opens in a side panel — --at-panel-sm (480) for a simple form, --md
     (720) for a wizard or planner, the full screen below --at-bp-sm. A fixed head
     (title in h3, a hint, close), a body that alone scrolls, a fixed footer. Put
     .at-dialog__actions on the footer too: primary right, «Отмена» as text left of it,
     stacked primary-first on a phone.
     A panel is a MODAL DIALOG: focus moves in, the page behind is inert, Escape closes,
     focus returns to the opener. A class cannot do any of that, so the panel is only
     ever the content of something that does: in MUI the only child of a
     Drawer anchor="right" (whose paper it sizes); without a library the element
     itself is a native <dialog class="at-panel-form">, opened with showModal() —
     README has the lifecycle. There is no positioned-div variant on purpose. */
  .at-panel-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    width: min(var(--at-panel-sm), 100vw);
    background: var(--at-surface);
    color: var(--at-text);
  }
  .at-panel-form--md { width: min(var(--at-panel-md), 100vw); }
  /* Native modal dialog: docked to the end edge, full height, over --at-overlay. A
     closed <dialog> must stay hidden — display: flex above would otherwise show it,
     because any author rule beats the user-agent's dialog:not([open]). */
  dialog.at-panel-form {
    inset-block: 0;
    inset-inline: auto 0;
    max-width: 100vw;
    max-height: none;
    height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: var(--at-elevation-overlay);
  }
  dialog.at-panel-form:not([open]) { display: none; }
  dialog.at-panel-form::backdrop { background: var(--at-overlay); }
  .at-panel-form__head {
    flex: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--at-space-3);
    padding: var(--at-space-4) var(--at-space-3) var(--at-space-4) var(--at-space-6);
    border-bottom: var(--at-border-width-hairline) solid var(--at-border-subtle);
  }
  /* Title and hint text level with the 44px close button. */
  .at-panel-form__heading {
    display: flex;
    flex-direction: column;
    gap: var(--at-space-1);
    min-width: 0;
    padding-top: var(--at-space-2);
  }
  .at-panel-form__title {
    margin: 0;
    color: var(--at-text);
    font-size: var(--at-text-h3-size);
    line-height: var(--at-text-h3-line);
    font-weight: var(--at-text-h3-weight);
    letter-spacing: var(--at-text-h3-tracking);
  }
  /* S14: panel body 20×24 (16 on a phone), 12 between fields. */
  .at-panel-form__body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--at-space-3);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--at-space-5) var(--at-space-6);
  }
  .at-panel-form__footer {
    flex: none;
    padding: var(--at-space-4) var(--at-space-6);
    border-top: var(--at-border-width-hairline) solid var(--at-border-subtle);
  }
  @media (width < 600px) {
    .at-panel-form,
    .at-panel-form--md { width: 100vw; }
    .at-panel-form__head { padding-left: var(--at-space-4); }
    .at-panel-form__body { padding: var(--at-space-4); }
    .at-panel-form__footer {
      padding: var(--at-space-3) var(--at-space-4) calc(var(--at-space-3) + env(safe-area-inset-bottom, 0px));
    }
  }
}

/* Registered so the nav's edge fades can animate, and so that an inactive scroll
   timeline (nothing to scroll) falls back to 0px — no fade — rather than to an
   invalid mask. Top level: @property is not a layered rule. */
@property --_at-nav-fade-start { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --_at-nav-fade-end { syntax: '<length>'; inherits: false; initial-value: 0px; }

/* ============================================================================
   3.0 (2026-11-13) — ревью экранов fbudget и dandf, принято владельцем.
   Правила ниже идут в том же слое после 2.x и при равной специфичности побеждают:
   здесь то, что 3.0 меняет в существующих компонентах, и новые компоненты.
   Описание и живые примеры — guide/index.html; правила экранов — SCREEN_RULES.md.
   ========================================================================= */
@layer atticlet-components {
  /* --- Текст --------------------------------------------------------------- */
  /* Вторичный текст — --at-text-secondary. --at-text-muted остаётся только на белой
     поверхности и только для того, что можно не прочитать (плейсхолдер, отметка времени). */
  .at-page-head__lede {
    font-size: var(--at-text-body-size);
    line-height: var(--at-text-body-line);
    color: var(--at-text-secondary);
  }
  .at-page-head { align-items: flex-start; }
  .at-page-head__main { gap: var(--at-space-2); }
  .at-page-head__actions { min-height: calc(var(--at-text-h1-size) * var(--at-text-h1-line)); }

  /* --- Кнопки --------------------------------------------------------------
     Три уровня: главная (заливка, одна на экран), обычная (белая с рамкой),
     тихая (текст). Серая заливка на тёплом фоне давала границу 1.1:1. */
  .at-btn--tonal {
    background: var(--at-surface);
    color: var(--at-text);
    border: var(--at-border-width-thin) solid var(--at-border);
  }
  .at-btn--tonal:hover { background: var(--at-surface-hover); border-color: var(--at-border-strong); color: var(--at-text); }
  .at-btn--tonal:active { background: var(--at-surface-active); color: var(--at-text); }
  .at-btn--tonal > svg { color: currentColor; }
  .at-btn--tonal-danger {
    background: var(--at-surface);
    color: var(--at-danger-text);
    border: var(--at-border-width-thin) solid currentColor;
  }
  .at-btn--tonal-danger:hover { background: var(--at-danger-tint); color: var(--at-on-danger-tint); }
  .at-btn--tonal-danger:active { background: var(--at-danger-tint); color: var(--at-on-danger-tint); }
  .at-btn--text { background: transparent; color: var(--at-link); border-color: transparent; padding-inline: var(--at-space-3); }
  .at-btn--text:hover { background: var(--at-state-hover); color: var(--at-link); }
  .at-btn--text:active { background: var(--at-state-pressed); color: var(--at-link); }
  .at-btn--icon { padding-inline: 0; width: var(--at-control-sm); }
  .at-btn > svg { flex: none; width: var(--at-icon-sm); height: var(--at-icon-sm); }

  /* Группа действий: одна высота, один зазор, не больше двух уровней. */
  .at-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--at-space-2); }

  /* --- Ссылка-переход в интерфейсе: текст без стрелки, никогда не пилюля. -- */
  .at-link--go { display: inline-flex; align-items: center; gap: var(--at-space-1); min-height: var(--at-hit-target);
                 color: var(--at-link); font-weight: var(--at-weight-semibold); text-decoration: none; }
  .at-link--go:hover { text-decoration: underline; }

  /* --- Бейдж: 13 semibold, один на строку. --------------------------------- */
  .at-badge { font-size: var(--at-text-caption-size); font-weight: var(--at-weight-semibold); padding: 3px var(--at-space-3);
              color: var(--at-text); }
  .at-badge--success { color: var(--at-on-success-tint); }
  .at-badge--info { color: var(--at-on-info-tint); }
  .at-badge--warning { color: var(--at-on-warning-tint); }
  .at-badge--danger { color: var(--at-on-danger-tint); }
  .at-badge--live { color: var(--at-on-action); }

  /* --- Список фактов через точку: разделитель ставит система, не автор. ---- */
  .at-meta { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--at-space-2);
             margin: 0; padding: 0; list-style: none;
             color: var(--at-text-secondary); font-size: var(--at-text-body-sm-size); line-height: var(--at-text-body-sm-line); }
  .at-meta > * { display: inline-flex; align-items: center; gap: var(--at-space-1); }
  .at-meta > :not(:last-child)::after { content: '·'; margin-inline-start: var(--at-space-1); color: var(--at-text-muted); }
  .at-meta svg { width: var(--at-icon-sm); height: var(--at-icon-sm); }

  /* --- Карточка: один внутренний отступ, заголовок внутри. ----------------- */
  .at-card { padding: var(--at-inset); }
  .at-card.at-rows { padding: 0; }
  .at-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--at-space-3);
                   min-height: var(--at-control-sm); margin-bottom: var(--at-space-3); }
  .at-card__head :is(h2, h3) { min-width: 0; margin: 0; }
  .at-card__head-main { display: flex; align-items: center; gap: var(--at-space-1); min-width: 0; }
  /* Строки и таблица внутри карточки идут от края до края; текст стоит на той же
     вертикали, что и заголовок карточки, потому что inline-отступ у них общий. */
  .at-card > .at-rows,
  .at-card > .at-table-scroll { margin-inline: calc(-1 * var(--at-inset)); }
  .at-card > .at-rows:last-child,
  .at-card > .at-table-scroll:last-child { margin-bottom: calc(-1 * var(--at-inset)); }
  .at-card > .at-rows { border-top: var(--at-border-width-hairline) solid var(--at-border-subtle); }
  .at-card__foot { margin-top: var(--at-space-3); }
  .at-card--accent { border-color: var(--at-primary); border-width: var(--at-border-width-thick); }

  /* --- Строка: фиксированные зоны. ----------------------------------------- */
  .at-row { padding: var(--at-space-3) var(--at-inset); gap: var(--at-space-1) var(--at-space-3); align-items: center; }
  .at-row__lead { flex: none; display: inline-flex; width: var(--at-icon-md); height: var(--at-icon-md); color: var(--at-text-secondary); }
  .at-row__lead > svg { width: 100%; height: 100%; }
  .at-row__caption { color: var(--at-text-secondary); }
  .at-row__actions { flex: none; display: flex; align-items: center; gap: var(--at-space-2); }
  @media (width < 600px) {
    .at-row__actions { flex-basis: 100%; }
    .at-row:has(.at-row__lead) .at-row__actions { padding-inline-start: calc(var(--at-icon-md) + var(--at-space-3)); }
  }

  /* --- Плитка итога: подпись, цифра, пояснение. ---------------------------- */
  .at-tile { display: flex; flex-direction: column; gap: var(--at-space-1); color: inherit; text-decoration: none; }
  .at-tile__label { display: flex; align-items: center; justify-content: space-between; gap: var(--at-space-2);
                    font-size: var(--at-text-body-sm-size); line-height: var(--at-text-body-sm-line); color: var(--at-text-secondary); }
  .at-tile__label svg { width: var(--at-icon-md); height: var(--at-icon-md); }
  .at-tile__value { font-size: var(--at-text-h2-size); line-height: var(--at-text-h2-line); font-weight: var(--at-weight-bold);
                    letter-spacing: var(--at-text-h2-tracking); font-variant-numeric: var(--at-font-numeric); color: var(--at-text); }
  .at-tile__note { font-size: var(--at-text-body-sm-size); line-height: var(--at-text-body-sm-line); color: var(--at-text-secondary); }
  a.at-tile:hover { background: var(--at-surface-hover); color: inherit; }

  /* --- Сетки: ряд равной высоты, содержимое от верха. ---------------------- */
  .at-grid { display: grid; gap: var(--at-space-5); align-items: stretch;
             grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .at-cols { display: grid; gap: var(--at-space-5); align-items: start;
             grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
  .at-col { display: flex; flex-direction: column; gap: var(--at-space-5); min-width: 0; }
  @media (width < 900px) { .at-cols { grid-template-columns: minmax(0, 1fr); } }

  /* --- Сообщение: факт основным текстом, одно действие обычной кнопкой. ---- */
  .at-alert { align-items: center; padding: var(--at-space-3) var(--at-inset);
              font-size: var(--at-text-body-size); line-height: var(--at-text-body-line); color: var(--at-text); }
  .at-alert--info, .at-alert--success, .at-alert--warning, .at-alert--danger { color: var(--at-text); }
  .at-alert__icon { margin-top: 0; }
  .at-alert--warning .at-alert__icon { color: var(--at-warning-text); }
  .at-alert--danger .at-alert__icon { color: var(--at-danger-text); }
  .at-alert--info .at-alert__icon { color: var(--at-info-text); }

  /* --- Таблица: заголовок столбца обычным регистром, ячейка = body. -------- */
  .at-table th, .at-table td { padding: var(--at-space-3) var(--at-space-3); vertical-align: middle; }
  .at-table th:first-child, .at-table td:first-child { padding-inline-start: var(--at-inset); }
  .at-table th:last-child, .at-table td:last-child { padding-inline-end: var(--at-inset); }
  .at-table th { font-size: var(--at-text-body-sm-size); font-weight: var(--at-weight-semibold);
                 text-transform: none; letter-spacing: 0; color: var(--at-text-secondary); }
  .at-table tbody tr:last-child td { border-bottom: 0; }
  .at-table tfoot td { font-weight: var(--at-weight-bold); border-bottom: 0;
                       border-top: var(--at-border-width-thin) solid var(--at-border); }
  .at-table td small { display: block; font-size: var(--at-text-body-sm-size); color: var(--at-text-secondary); }

  /* --- Поля. ---------------------------------------------------------------- */
  .at-field__help { color: var(--at-text-secondary); }
  /* Поле — 40: выше кнопки 36, ниже прежних 50. Текст 16 (iOS не увеличивает страницу),
     скругление 12 — поле не пилюля, пилюля остаётся признаком кнопки. */
  .at-control { font-size: var(--at-text-body-size); line-height: 1.25; min-height: var(--at-field-height);
                padding: var(--at-space-2) var(--at-space-3); border-radius: var(--at-radius-12); }
  .at-fields { display: flex; flex-direction: column; gap: var(--at-space-3); }

  /* --- Сегменты: одна слитная форма. --------------------------------------- */
  .at-segments { --_at-segments-gap: 0px; display: inline-flex; flex-wrap: nowrap; max-width: 100%;
                 border: var(--at-border-width-thin) solid var(--at-border); border-radius: var(--at-radius-pill);
                 background: var(--at-surface); overflow: hidden; }
  .at-segments > * { flex: 1 1 auto; }
  .at-segments:has(> :nth-child(4)) > * { flex-basis: auto; max-width: none; }
  .at-segments__item { border: 0; border-radius: 0; min-height: calc(var(--at-control-sm) - 2px); padding-block: 0;
                       font-size: var(--at-text-button-sm-size); white-space: nowrap; }
  .at-segments__item + .at-segments__item { border-inline-start: var(--at-border-width-thin) solid var(--at-border); }
  .at-segments__item[aria-pressed='true'] { border-color: var(--at-border); }

  /* --- Подсказка и раскрытие. ---------------------------------------------- */
  .at-hint { color: var(--at-text-secondary); }
  .at-hint__plate { padding: var(--at-space-3) var(--at-space-4); color: var(--at-text); }
  .at-disclosure__toggle, .at-disclosure > summary { font-size: var(--at-text-button-size); }

  /* --- Пустое состояние. ---------------------------------------------------- */
  .at-empty { padding: var(--at-inset); }
  .at-empty__text { color: var(--at-text-secondary); }

  /* --- Шапка: марка слева, меню сразу за ней, служебное справа. ------------ */
  .at-header__inner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
                      gap: var(--at-space-6); min-height: var(--at-header-height); }
  .at-brand { display: inline-flex; align-items: center; gap: var(--at-space-3); min-height: var(--at-hit-target);
              color: var(--at-text); text-decoration: none; font-size: var(--at-text-body-lg-size);
              font-weight: var(--at-weight-bold); letter-spacing: -0.02em; white-space: nowrap; }
  .at-brand:hover { color: var(--at-text); }
  .at-brand img { width: 32px; height: 32px; }
  .at-icon-btn > svg { width: var(--at-icon-md); height: var(--at-icon-md); }
  .at-header__tools { display: flex; align-items: center; gap: var(--at-space-1); }
  .at-nav a { font-size: var(--at-text-button-sm-size); font-weight: var(--at-weight-semibold); min-height: var(--at-control-sm);
              padding: var(--at-space-2) var(--at-space-3); position: relative; }
  .at-nav a::after { content: ''; position: absolute; inset-inline: 0; top: 50%; height: var(--at-hit-target); transform: translateY(-50%); }
  /* Активный пункт — подложка-тинт и жирный текст. Сплошная синяя заливка осталась
     только у главного действия экрана. */
  .at-nav a[aria-current='page'] { background: var(--at-primary-tint); color: var(--at-on-primary-tint); font-weight: var(--at-weight-bold); }
  .at-nav__count { margin-inline-start: var(--at-space-2); padding: 0 6px; border-radius: var(--at-radius-pill);
                   background: var(--at-danger-tint); color: var(--at-on-danger-tint);
                   font-size: var(--at-text-caption-size); font-weight: var(--at-weight-bold); font-variant-numeric: var(--at-font-numeric); }
  @media (width < 900px) {
    .at-header__inner { grid-template-columns: minmax(0, 1fr) auto; gap: var(--at-space-1) var(--at-space-3);
                        padding-block: var(--at-space-2); flex-direction: initial; }
    .at-header__inner > nav { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  }

  /* --- Подвал: один формат на все приложения. ------------------------------ */
  .at-footer { margin-top: var(--at-space-12); border-top: var(--at-border-width-hairline) solid var(--at-border-subtle); }
  .at-footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
                      gap: var(--at-space-2) var(--at-space-6); min-height: var(--at-header-height);
                      padding-block: var(--at-space-2);
                      font-size: var(--at-text-body-sm-size); color: var(--at-text-secondary); }
  .at-footer__brand { display: inline-flex; align-items: center; min-height: var(--at-hit-target); }
  .at-footer__brand img { display: block; height: 22px; width: auto; }
  .at-footer__links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--at-space-1) var(--at-space-5);
                      margin: 0; padding: 0; list-style: none; }
  .at-footer__links a { display: inline-flex; align-items: center; min-height: var(--at-hit-target);
                        color: var(--at-text-secondary); text-decoration: none; font-weight: var(--at-weight-semibold); }
  .at-footer__links a:hover { color: var(--at-text); text-decoration: underline; }
  .at-footer__note { margin: 0; }
  @media (width < 600px) {
    .at-footer__inner { flex-direction: column; align-items: flex-start; padding-block: var(--at-space-4); }
  }

  /* --- Меню «⋯» для третьего и следующих действий. ------------------------- */
  .at-menu { position: relative; }
  .at-menu > summary { list-style: none; }
  .at-menu > summary::-webkit-details-marker { display: none; }
  .at-menu__list { position: absolute; z-index: var(--at-z-dropdown); inset-inline-end: 0; top: calc(100% + var(--at-space-1));
                   min-width: 200px; margin: 0; padding: var(--at-space-1); list-style: none;
                   border: var(--at-border-width-hairline) solid var(--at-border-subtle); border-radius: var(--at-radius-12);
                   background: var(--at-surface-raised, var(--at-surface)); box-shadow: var(--at-elevation-overlay); }
  .at-menu__list button { display: flex; align-items: center; width: 100%; min-height: var(--at-hit-target);
                          padding: 0 var(--at-space-3); border: 0; border-radius: var(--at-radius-8); background: transparent;
                          color: var(--at-text); font-size: var(--at-text-body-size); text-align: left; cursor: pointer; }
  .at-menu__list button:hover { background: var(--at-state-hover); }
  .at-menu__list .is-danger { color: var(--at-danger-text); }

  /* --- Отметка-кружок в начале строки (план → факт). ----------------------- */
  .at-check { flex: none; position: relative; width: var(--at-icon-lg); height: var(--at-icon-lg); padding: 0;
              border: var(--at-border-width-thick) solid var(--at-border-strong); border-radius: 50%; background: var(--at-surface); cursor: pointer; }
  .at-check::after { content: ''; position: absolute; inset: -10px; }
  .at-check:hover { border-color: var(--at-primary); }


  /* --- Выпадающий список: свой, в размер поля. -----------------------------
     В разметке остаётся <select class="at-control">; скрипт системы ставит рядом
     кнопку и список, сам <select> хранит значение формы. */
  .at-select { position: relative; display: block; }
  .at-select > select { display: none; }
  .at-select__button { display: flex; align-items: center; justify-content: space-between; gap: var(--at-space-2);
                       width: 100%; text-align: start; cursor: pointer; }
  .at-select__button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .at-select__button > svg { flex: none; width: var(--at-icon-sm); height: var(--at-icon-sm); color: var(--at-text-secondary);
                             transition: transform var(--at-duration-fast) var(--at-ease-standard); }
  .at-select__button[aria-expanded='true'] { border-color: var(--at-focus); }
  .at-select__button[aria-expanded='true'] > svg { transform: rotate(180deg); }
  .at-select__list { position: absolute; z-index: var(--at-z-dropdown); inset-inline: 0; top: calc(100% + var(--at-space-1));
                     max-height: 264px; overflow: auto; margin: 0; padding: var(--at-space-1); list-style: none;
                     border: var(--at-border-width-hairline) solid var(--at-border-subtle); border-radius: var(--at-radius-12);
                     background: var(--at-surface-raised, var(--at-surface)); box-shadow: var(--at-elevation-overlay); }
  .at-select__list.is-up { top: auto; bottom: calc(100% + var(--at-space-1)); }
  .at-select__option { display: flex; align-items: center; justify-content: space-between; gap: var(--at-space-3);
                       min-height: var(--at-field-height); padding: 0 var(--at-space-3); border-radius: var(--at-radius-8);
                       color: var(--at-text); font-size: var(--at-text-body-size); cursor: pointer; }
  .at-select__option > svg { flex: none; width: var(--at-icon-sm); height: var(--at-icon-sm); visibility: hidden; }
  .at-select__option.is-active { background: var(--at-state-hover); }
  .at-select__option[aria-selected='true'] { font-weight: var(--at-weight-bold); color: var(--at-on-primary-tint); }
  .at-select__option[aria-selected='true'] > svg { visibility: visible; }
  @media (width < 600px) { .at-select__option { min-height: var(--at-hit-target); } }

  /* --- Шапка страницы объекта. ---------------------------------------------
     Строка заголовка — только текст: ссылка назад, название, один бейдж.
     Всё, что нажимается, стоит в зоне действий и выглядит одинаково. */
  .at-page-head__heading { gap: var(--at-space-2) var(--at-space-3); }
  .at-menu__list.is-start { inset-inline: 0 auto; }
  .at-menu__list [aria-checked='true'] { font-weight: var(--at-weight-bold); color: var(--at-on-primary-tint); }

  /* --- График: всегда на белой карточке; план и факт — один цвет серии. ----
     Факт — сплошной, план — тот же цвет: светлая заливка и контур. */
  .at-legend { display: flex; flex-wrap: wrap; gap: var(--at-space-1) var(--at-space-4); margin: 0 0 var(--at-space-3); padding: 0; list-style: none;
               font-size: var(--at-text-body-sm-size); color: var(--at-text-secondary); }
  .at-legend > li { display: inline-flex; align-items: center; gap: var(--at-space-2); }
  .at-legend__swatch { flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--_c, var(--at-series-1));
                       border: 1.5px solid var(--_c, var(--at-series-1)); }
  .at-legend__swatch--plan { background: color-mix(in oklab, var(--_c, var(--at-series-1)) 26%, var(--at-surface)); }

  .at-titlebar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--at-space-2) var(--at-space-3); min-width: 0; }
  .at-titlebar__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--at-space-3); min-width: 0;
                        margin-inline-end: var(--at-space-2); }
  .at-titlebar__title > :is(h1, h2, h3) { margin: 0; }
  /* Вид объекта — значок перед названием, тот же, что у строки в списке. */
  .at-titlebar__mark { flex: none; display: inline-flex; align-self: center; width: var(--at-icon-lg); height: var(--at-icon-lg);
                       color: var(--at-text-secondary); }
  .at-titlebar__mark > svg { width: 100%; height: 100%; }
  .at-titlebar__title:has(.at-titlebar__mark) { align-items: center; gap: var(--at-space-2); }
  .at-titlebar__kind { font-size: var(--at-text-body-sm-size); color: var(--at-text-secondary); white-space: nowrap; }
  .at-titlebar__actions { display: flex; align-items: center; gap: var(--at-space-2); }
  .at-titlebar__actions .at-btn { white-space: nowrap; }
  @media (width < 600px) { .at-titlebar__actions { flex-basis: 100%; } }

  /* Каркас приложения: подвал прижат к низу окна на коротких страницах. */
  .at-app-frame { display: flex; flex-direction: column; min-height: 100dvh; }
  .at-app-frame > main { flex: 1 0 auto; }

  /* Один внутренний отступ карточки, строки, таблицы и сообщения: 20, на телефоне 16. */
  @media (width < 600px) { body { --at-inset: var(--at-inset-sm); } }

  /* Изображение под тему (логотип в подвале): свой файл на светлую и тёмную. */
  /* !important: класс скрывает элемент, какой бы display ни задал ему компонент
     (.at-footer__brand img специфичнее и иначе показывал оба логотипа сразу). */
  .at-only-light { display: var(--at-only-light-display, revert) !important; }
  .at-only-dark { display: var(--at-only-dark-display, revert) !important; }
  .at-footer__brand :is(.at-only-light, .at-only-dark) { display: block; }
}
