/* ==========================================================================
   Adilet UI kit — tokens and components of the 2026-09-17 redesign
   ==========================================================================
   Loaded only when SITE_UI_V2 is on (adilet/settings.py), and every rule is
   scoped under body.ui2, which base.html sets from the same flag. Two reasons
   for the scope, both learned the hard way on this site:

   * No :root block. style.css and page stylesheets declare --radius, --primary
     and friends on :root; a second :root declaration later in the cascade wins
     document-wide (law-list.css turned every filled control navy that way).
     These tokens have their own names and live on .ui2.
   * Bootstrap 5 and style.css style bare a, h1-h6, p, button. A class scoped
     under .ui2 outranks those without !important.

   Rules of the system (they are what makes it read as one product):
   * One filled red button per screen (.ui-btn). Everything else is the grey
     .ui-btn2, the outlined .ui-btn3 or a red text link (.ui-link).
   * Greys come from the tokens below, never from a new hex.
   * Status pills say what we know and nothing more: .ok / .void / .pend /
     .alert / .clear / .na / .info mirror the honesty contracts in CLAUDE.md
     («не значится» is .clear, «источник недоступен» is .na, and the two must
     never share a look).
   * Icons are the sprite at static/core/images/ui-icons.svg:
       <svg class="ui-ic" aria-hidden="true"><use href="{{ UI_ICONS }}#i-search"></use></svg>
   Breakpoints: phone < 734px, tablet < 1068px (Apple's), the shell switches
   to its phone bar below 1024px (see site-shell.css).
   ========================================================================== */

body.ui2 {
  --ink: #1d1d1f;
  /* WCAG 1.4.3 AA for the small text this system is full of (meta lines, captions,
     table headers, phone tab labels). Apple's own #6e6e73/#86868b are 4.37:1 and
     3.62:1 on white and worse on --fill, i.e. below the 4.5:1 an 11-15px label
     needs; these clear it on white, --fill, --fill2 and the glass bars, and keep
     the same hierarchy (--ink3 stays the lighter of the two). */
  --ink2: #5f5f64;
  --ink3: #6a6a6f;
  --hair: #d2d2d7;
  --sep: rgba(60, 60, 67, 0.14);
  --fill: #f5f5f7;
  --fill2: #e8e8ed;
  --fill3: #dcdce1;
  --glass: rgba(255, 255, 255, 0.8);
  --brand: #8b0000;
  --brand-hover: #730c0b;
  --brand-press: #5e0a09;
  --logo: #730b0a;
  --tint: rgba(139, 0, 0, 0.08);
  --tint2: rgba(139, 0, 0, 0.13);
  --ok: #1f9d55;
  --ok-ink: #147a42;
  --warn: #e07a00;
  --warn-ink: #a55a00;
  --info: #2f6feb;
  --urgent: #c5221f;
  --lift: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 14px -8px rgba(16, 24, 40, 0.2);
  --ui-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ui-wrap: 1180px;
  --ui-gutter: 22px;

  /* style.css pads the public body by 50px a side, which the full-bleed bars
     and bands of this system cannot live with. Page content is re-gutted by
     .ui-wrap and by Bootstrap's .container, which keeps its own padding. */
  padding-left: 0;
  padding-right: 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--ui-font);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

@media (max-width: 733.98px) {
  body.ui2 { --ui-gutter: 16px; }
}

.ui2 .ui-wrap { width: min(var(--ui-wrap), 100% - 2 * var(--ui-gutter)); margin-inline: auto; }
.ui2 .ui-ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ui2 .ui-tnum { font-variant-numeric: tabular-nums; }
.ui2 .ui-ell { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ui2 .ui-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ui2 :focus-visible { outline: 2px solid rgba(139, 0, 0, 0.55); outline-offset: 2px; }

/* ---------------------------------------------------------------- type */
.ui2 :is(.ui-display, .ui-h1, .ui-h2, .ui-h3, .ui-title) { margin: 0; color: var(--ink); font-weight: 600; text-wrap: balance; }
.ui2 .ui-eyebrow { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.2px; color: var(--brand); }
.ui2 .ui-display { font-size: 64px; line-height: 1.05; letter-spacing: -0.03em; }
.ui2 .ui-h1 { font-size: 48px; line-height: 1.08; letter-spacing: -0.022em; }
.ui2 .ui-h2 { font-size: 40px; line-height: 1.1; letter-spacing: -0.022em; }
.ui2 .ui-h3 { font-size: 28px; line-height: 1.14; letter-spacing: -0.02em; }
.ui2 .ui-title { font-size: 21px; line-height: 1.25; letter-spacing: -0.012em; }
.ui2 .ui-sub { margin: 0; font-size: 21px; line-height: 1.38; letter-spacing: -0.012em; color: var(--ink2); text-wrap: balance; }
.ui2 .ui-body { margin: 0; font-size: 17px; line-height: 1.47; letter-spacing: -0.2px; }
.ui2 .ui-small { margin: 0; font-size: 15px; line-height: 1.4; color: var(--ink2); }
.ui2 .ui-meta { margin: 0; font-size: 13px; line-height: 1.35; color: var(--ink2); }
.ui2 .ui-micro { margin: 0; font-size: 12px; line-height: 1.35; color: var(--ink3); }

@media (max-width: 733.98px) {
  .ui2 .ui-eyebrow { font-size: 15px; }
  .ui2 .ui-display { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.022em; }
  .ui2 .ui-h1 { font-size: 34px; line-height: 1.1; font-weight: 700; }
  .ui2 .ui-h2 { font-size: 28px; line-height: 1.14; font-weight: 700; }
  .ui2 .ui-h3 { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -0.012em; }
  .ui2 .ui-title { font-size: 19px; }
  .ui2 .ui-sub { font-size: 17px; line-height: 1.45; }
}

/* ------------------------------------------------------------- buttons */
.ui2 :is(.ui-btn, .ui-btn2, .ui-btn3) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 980px; font-family: inherit; line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}
.ui2 .ui-btn { height: 44px; padding: 0 22px; background: var(--brand); color: #fff; font-size: 17px; font-weight: 400; }
.ui2 .ui-btn:hover { background: var(--brand-hover); color: #fff; }
.ui2 .ui-btn:active { background: var(--brand-press); }
.ui2 .ui-btn .ui-ic { width: 18px; height: 18px; stroke-width: 2.1; }
.ui2 .ui-btn.sm { height: 28px; padding: 0 13px; gap: 4px; font-size: 13px; }
.ui2 .ui-btn.sm .ui-ic { width: 13px; height: 13px; stroke-width: 2.4; margin-left: -2px; }
.ui2 .ui-btn.full { width: 100%; height: 50px; }

.ui2 .ui-btn2 { height: 34px; padding: 0 17px; background: var(--fill2); color: var(--brand); font-size: 15px; font-weight: 600; }
.ui2 .ui-btn2:hover { background: var(--fill3); color: var(--brand); }
.ui2 .ui-btn2:active { background: var(--hair); }
.ui2 .ui-btn2 .ui-ic { width: 16px; height: 16px; stroke-width: 2; }
.ui2 .ui-btn2.lg { height: 44px; padding: 0 24px; font-size: 17px; }
.ui2 .ui-btn2.ink { color: var(--ink); }
.ui2 .ui-btn2.full { width: 100%; height: 50px; font-size: 17px; }

.ui2 .ui-btn3 { height: 34px; padding: 0 16px; background: #fff; box-shadow: inset 0 0 0 1px var(--hair); color: var(--ink); font-size: 15px; }
.ui2 .ui-btn3:hover { background: var(--fill); color: var(--ink); }
.ui2 .ui-btn3 .ui-ic { width: 16px; height: 16px; }

.ui2 :is(.ui-btn, .ui-btn2, .ui-btn3):disabled,
.ui2 :is(.ui-btn, .ui-btn2, .ui-btn3)[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.ui2 .ui-link { display: inline-flex; align-items: center; gap: 2px; color: var(--brand); font-size: 17px; text-decoration: none; white-space: nowrap; background: none; border: 0; padding: 0; cursor: pointer; }
.ui2 .ui-link:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.ui2 .ui-link .ui-ic { width: 12px; height: 12px; stroke-width: 2.6; margin-top: 1px; }
.ui2 .ui-link.sm { font-size: 15px; }
.ui2 .ui-link.xs { font-size: 13px; }

.ui2 .ui-icbtn { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--fill); color: var(--ink); cursor: pointer; transition: background-color 0.2s; }
.ui2 .ui-icbtn:hover { background: var(--fill2); }
.ui2 .ui-icbtn .ui-ic { width: 18px; height: 18px; }

/* ------------------------------------------------ chips + side scrollers */
.ui2 .ui-chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 16px; border: 0; border-radius: 980px; background: var(--fill); color: var(--ink); font-size: 14px; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background-color 0.2s; }
.ui2 .ui-chip:hover { background: var(--fill2); color: var(--ink); }
.ui2 .ui-chip.on, .ui2 .ui-chip[aria-pressed="true"], .ui2 .ui-chip[aria-current] { background: var(--ink); color: #fff; }
.ui2 .ui-chip .ui-ic { width: 15px; height: 15px; }
.ui2 .ui-hs { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 4px 0; }
.ui2 .ui-hs::-webkit-scrollbar { display: none; }
.ui2 .ui-hs > * { flex: none; }
@media (max-width: 733.98px) {
  .ui2 .ui-chip { height: 36px; padding: 0 15px; font-size: 15px; }
  .ui2 .ui-hs { margin-inline: calc(-1 * var(--ui-gutter)); padding-inline: var(--ui-gutter); }
}

/* -------------------------------------------------------------- fields */
.ui2 .ui-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.ui2 .ui-help { margin: 6px 0 0; font-size: 12px; line-height: 1.4; color: var(--ink3); }
.ui2 .ui-field { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px; background: var(--fill); color: var(--ink); font-size: 17px; transition: box-shadow 0.2s, background-color 0.2s; }
.ui2 .ui-field :is(input, textarea, select) { flex: 1; min-width: 0; height: 100%; margin: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; resize: none; box-shadow: none; }
.ui2 .ui-field :is(input, textarea)::placeholder { color: var(--ink3); opacity: 1; }
.ui2 .ui-field > .ui-ic { width: 17px; height: 17px; color: var(--ink2); }
.ui2 .ui-field:focus-within { box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.12); }
.ui2 .ui-field.sm { height: 36px; padding: 0 12px; border-radius: 10px; font-size: 15px; }
.ui2 .ui-field.line { background: #fff; box-shadow: inset 0 0 0 1px var(--hair); }
.ui2 .ui-field.line:focus-within { box-shadow: inset 0 0 0 1px var(--hair), 0 0 0 3px rgba(139, 0, 0, 0.12); }
/* The line above zeroes the control's own outline, so the wrapper has to carry
   the focus signal — and the 0.12 tint above is a 1.27:1 ring on white, i.e. a
   decoration, not a focus indicator (WCAG 2.4.7 / 1.4.11 want 3:1). That tint
   stays for the mouse, where the caret already says where you are; a keyboard
   focus gets the solid brand ring, which clears 3:1 on white, on --fill and on
   --fill2. :focus-visible rather than :focus-within so clicking into a field
   does not paint a keyboard ring, and note that browsers DO match
   :focus-visible on a clicked <select> — which is the control the audit found
   indistinguishable focused and unfocused, because it has no caret at all. */
.ui2 .ui-field:has(:focus-visible) { box-shadow: 0 0 0 2px var(--brand); }
.ui2 .ui-field.line:has(:focus-visible) { box-shadow: inset 0 0 0 1px var(--hair), 0 0 0 2px var(--brand); }
.ui2 .ui-field.area { height: auto; min-height: 96px; align-items: flex-start; padding: 12px 14px; }
/* iOS zooms any focused field under 16px; phones get 17px. */
@media (max-width: 733.98px) { .ui2 .ui-field.sm { font-size: 16px; } }

.ui2 .ui-check { display: flex; align-items: center; gap: 10px; min-height: 32px; margin: 0; font-size: 15px; cursor: pointer; }
.ui2 .ui-check .ui-n { margin-left: auto; font-size: 13px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.ui2 .ui-check > input[type="checkbox"], .ui2 .ui-check > input[type="radio"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 0;
  border: 1.5px solid var(--ink3); background: #fff; display: grid; place-items: center; cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.ui2 .ui-check > input[type="checkbox"] { border-radius: 5px; }
.ui2 .ui-check > input[type="radio"] { border-radius: 50%; }
.ui2 .ui-check:hover > input { border-color: var(--ink); }
.ui2 .ui-check > input[type="checkbox"]:checked { background: var(--brand); border-color: var(--brand); }
.ui2 .ui-check > input[type="checkbox"]:checked::after { content: ""; width: 9px; height: 5px; margin-top: -2px; border: solid #fff; border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.ui2 .ui-check > input[type="radio"]:checked { border: 5.5px solid var(--brand); }

.ui2 .ui-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; font-size: 15px; cursor: pointer; }
.ui2 .ui-switch > input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 40px; height: 24px; margin: 0;
  border-radius: 12px; background: var(--fill2); cursor: pointer; transition: background-color 0.2s;
}
.ui2 .ui-switch > input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.04); transition: transform 0.2s; }
.ui2 .ui-switch > input[type="checkbox"]:checked { background: #34c759; }
.ui2 .ui-switch > input[type="checkbox"]:checked::after { transform: translateX(16px); }

/* ------------------------------------------ segmented control + tabs */
.ui2 .ui-seg { display: inline-flex; height: 32px; padding: 2px; border-radius: 9px; background: rgba(118, 118, 128, 0.12); }
.ui2 .ui-seg > :is(a, button, label) { display: flex; align-items: center; justify-content: center; margin: 0; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer; }
.ui2 .ui-seg > .on, .ui2 .ui-seg > [aria-current], .ui2 .ui-seg > [aria-pressed="true"], .ui2 .ui-seg > label:has(input:checked) { background: #fff; font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
/* The real radio is invisible, so the label has to show its focus: without
   this a keyboard user tabbing into a segmented control (the header search's
   «Юристы / Законы» scope) sees nothing move, and cannot tell that the arrow
   keys now change the scope. :has() rather than :focus-within, so a click does
   not paint a keyboard ring. */
.ui2 .ui-seg > label > input { position: absolute; opacity: 0; pointer-events: none; }
.ui2 .ui-seg > label:has(> input:focus-visible) { outline: 2px solid rgba(139, 0, 0, 0.55); outline-offset: 2px; }

.ui2 .ui-tabs { display: flex; gap: 28px; height: 48px; border-bottom: 1px solid var(--hair); overflow-x: auto; scrollbar-width: none; }
.ui2 .ui-tabs::-webkit-scrollbar { display: none; }
.ui2 .ui-tabs > a { position: relative; flex: none; display: flex; align-items: center; gap: 6px; color: var(--ink2); font-size: 15px; white-space: nowrap; text-decoration: none; }
.ui2 .ui-tabs > a:hover { color: var(--ink); }
.ui2 .ui-tabs > a.on, .ui2 .ui-tabs > a[aria-current] { color: var(--ink); font-weight: 600; }
.ui2 .ui-tabs > a.on::after, .ui2 .ui-tabs > a[aria-current]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: var(--ink); }

/* ------------------------------------------------------------ surfaces */
.ui2 .ui-band { background: var(--fill); }
.ui2 .ui-list { margin: 0; padding: 0; list-style: none; }
.ui2 .ui-list > * + * { border-top: 1px solid var(--hair); }
.ui2 .ui-list.soft > * + * { border-top-color: var(--fill2); }
.ui2 .ui-card { background: #fff; border-radius: 18px; padding: 24px 28px; }
.ui2 .ui-card.line { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07); }
.ui2 .ui-card.float { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.05); }
.ui2 .ui-tile { position: relative; overflow: hidden; background: #fff; border-radius: 24px; text-align: center; padding: 52px 48px; }
@media (max-width: 733.98px) {
  .ui2 .ui-card { padding: 18px; }
  .ui2 .ui-tile { border-radius: 20px; padding: 36px 22px; }
}

/* ------------------------------------------------------------- avatars */
.ui2 .ui-ava { display: grid; place-items: center; flex: none; overflow: hidden; border-radius: 12px; background: var(--fill2); color: var(--ink); font-weight: 600; letter-spacing: -0.01em; }
.ui2 .ui-ava > img { width: 100%; height: 100%; object-fit: cover; }
.ui2 .ui-ava.round { border-radius: 50%; }
.ui2 .ui-ava.x28 { width: 28px; height: 28px; border-radius: 50%; font-size: 12px; }
.ui2 .ui-ava.x40 { width: 40px; height: 40px; font-size: 15px; }
.ui2 .ui-ava.x64 { width: 64px; height: 64px; border-radius: 16px; font-size: 22px; }
.ui2 .ui-ava.x88 { width: 88px; height: 88px; border-radius: 20px; font-size: 26px; }

/* ------------------------------------------------------ rating, status */
.ui2 .ui-rate { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ui2 .ui-rate .ui-ic { width: 14px; height: 14px; color: #ff9f0a; fill: currentColor; stroke: none; }
.ui2 .ui-new { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 980px; background: rgba(118, 118, 128, 0.12); color: var(--ink2); font-size: 12px; font-weight: 500; white-space: nowrap; }

.ui2 .ui-status { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 980px; background: var(--fill); color: var(--ink2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.ui2 .ui-status > i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: currentColor; }
.ui2 .ui-status.ok { background: rgba(31, 157, 85, 0.1); color: var(--ok-ink); }
.ui2 .ui-status.void { background: var(--fill); color: var(--ink2); }
.ui2 .ui-status.pend { background: rgba(224, 122, 0, 0.12); color: var(--warn-ink); }
.ui2 .ui-status.alert { background: rgba(197, 34, 31, 0.1); color: #b3261e; }
.ui2 .ui-status.clear { background: #fff; box-shadow: inset 0 0 0 1px var(--hair); color: var(--ink); }
.ui2 .ui-status.na { background: repeating-linear-gradient(135deg, #f1f1f4 0 4px, #e6e6ea 4px 8px); color: var(--ink2); }
.ui2 .ui-status.info { background: rgba(47, 111, 235, 0.1); color: #2459c6; }

.ui2 .ui-track { height: 6px; overflow: hidden; border-radius: 3px; background: var(--fill2); }
.ui2 .ui-track > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }

/* --------------------------------------------------- popover + sheet */
.ui2 .ui-pop { min-width: 220px; padding: 6px; border-radius: 14px; background: #fff; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.06); }
.ui2 .ui-pop-h { margin: 0; padding: 6px 10px 4px; font-size: 12px; color: var(--ink3); }
.ui2 .ui-pop :is(a, button).ui-pop-i { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-size: 15px; text-align: left; text-decoration: none; cursor: pointer; }
.ui2 .ui-pop :is(a, button).ui-pop-i:hover { background: var(--fill); color: var(--ink); }
.ui2 .ui-pop .ui-pop-i .ui-ic { width: 18px; height: 18px; color: var(--ink2); }
.ui2 .ui-pop .ui-pop-i[aria-current] { font-weight: 600; }
.ui2 .ui-pop-sep { height: 1px; margin: 6px 4px; background: var(--fill2); }

/* --------------------------------------------------------------- crumbs */
.ui2 .ui-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--ink2); }
.ui2 .ui-crumbs a { color: inherit; text-decoration: none; }
.ui2 .ui-crumbs a:hover { color: var(--ink); text-decoration: underline; }
.ui2 .ui-crumbs .ui-ic { width: 10px; height: 10px; stroke-width: 2.6; color: var(--ink3); }

@media (prefers-reduced-motion: reduce) {
  .ui2 *, .ui2 *::before, .ui2 *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
