/* Единая система оформления сайта. Образец — страница входа (auth.css): светлый серо-голубой фон, белые карточки
   с мягкой тенью, синие кнопки, спокойные поля ввода.

   Здесь только внешний вид. Шаблоны по-прежнему собраны из классов Tailwind, поэтому общие вещи (карточки, кнопки,
   поля, таблицы) оформляются «по признаку»: правило находит элемент по набору его классов, а не требует переписать
   разметку. Идентификаторы, названия полей и классы, с которыми работают скрипты, не меняются.
   Сложные части — бланк декларации (.sad…) и таблица «было / стало» (.diff…) — описаны в app.css; ниже они только
   приведены к общему стилю. */

:root {
  --ui-bg: #f3f6fa;
  --ui-surface: #ffffff;
  --ui-text: #1f2937;
  --ui-strong: #111827;
  --ui-muted: #5b6b80;
  --ui-border: #dce4ed;
  --ui-border-soft: #e6ecf3;
  --ui-field: #f7f9fc;
  --ui-blue: #2f80ed;
  --ui-blue-btn: #1f6fe0;       /* белый текст на нём — контраст 4,8:1 */
  --ui-blue-deep: #1762cc;
  --ui-blue-tint: #e8f1fe;
  --ui-green-btn: #16924f;      /* белый текст — контраст 4,6:1 */
  --ui-green-deep: #127a42;
  --ui-red-btn: #d92d20;
  --ui-red-deep: #b42318;
  --ui-radius: 0.625rem;
  --ui-radius-lg: 1.125rem;
  --ui-shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px -14px rgba(23, 105, 210, 0.16);
  --ui-shadow-pop: 0 1px 2px rgba(16, 24, 40, 0.06), 0 18px 40px -16px rgba(15, 23, 42, 0.28);
  --ui-ring: 0 0 0 4px rgba(47, 128, 237, 0.16);
  --ui-font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", "Noto Sans",
    "Noto Sans Georgian", "DejaVu Sans", Arial, sans-serif;
}

/* ---------- основа страницы ---------- */
.ui-app { font-family: var(--ui-font); color: var(--ui-text); background-color: var(--ui-bg);
  background-image:
    radial-gradient(52rem 30rem at 92% -6%, rgba(47, 128, 237, 0.10), transparent 62%),
    radial-gradient(44rem 30rem at -4% 104%, rgba(88, 156, 255, 0.08), transparent 60%),
    linear-gradient(180deg, #f7f9fc 0%, #eef3f9 100%);
  background-repeat: no-repeat; background-attachment: fixed; }
.ui-wrap { width: 100%; max-width: 90rem; margin-inline: auto; padding-inline: 1rem; }
@media (min-width: 640px) { .ui-wrap { padding-inline: 1.500rem; } }
.ui-main { padding-block: 1.500rem 2rem; flex: 1 1 auto; }
.ui-app main h1 { color: var(--ui-strong); letter-spacing: -0.01em; }
.ui-app :focus-visible { outline-color: var(--ui-blue); }

/* ---------- шапка ---------- */
.ui-header { background: rgba(255, 255, 255, 0.86); border-bottom: 1px solid var(--ui-border-soft);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); }
.ui-header-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 1.250rem; padding-block: 0.625rem 0.375rem; }
.ui-brand-group { display: flex; align-items: center; gap: 0.625rem; }
.ui-brand { display: inline-flex; align-items: center; gap: 0.625rem; color: var(--ui-strong); font-weight: 700;
  font-size: 1.0625rem; letter-spacing: -0.01em; text-decoration: none; border-radius: 0.625rem; }
.ui-brand-mark { width: 2.125rem; height: 2.125rem; border-radius: 0.625rem; display: grid; place-items: center; color: #fff;
  flex: none; background: linear-gradient(145deg, #4b97f5 0%, #1762cc 100%);
  box-shadow: 0 6px 14px -6px rgba(23, 105, 210, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.ui-nav { display: flex; align-items: center; gap: 0.125rem; flex: 1 1 auto; min-width: 0; }
.ui-nav-link { padding: 0.4375rem 0.750rem; border-radius: 0.625rem; font-size: 0.9375rem; font-weight: 500; color: #3b4a5e;
  text-decoration: none; white-space: nowrap; transition: background-color 0.15s ease, color 0.15s ease; }
.ui-nav-link:hover { background: #eef3f9; color: var(--ui-strong); }
.ui-nav-link[aria-current="page"] { background: var(--ui-blue-tint); color: var(--ui-blue-deep); font-weight: 600; }
.ui-nav-admin { color: var(--ui-blue-deep); }
.ui-header-tools { display: flex; align-items: center; gap: 0.625rem; margin-left: auto; }
.ui-user { display: inline-flex; align-items: center; gap: 0.500rem; max-width: 16rem; min-width: 0; color: #3b4a5e;
  font-size: 0.875rem; }
.ui-avatar { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ui-blue-tint); color: var(--ui-blue-deep); font-weight: 700; font-size: 0.875rem; }
.ui-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-logout { display: inline-flex; align-items: center; gap: 0.375rem; height: 2.250rem; padding: 0 0.750rem; border-radius: 0.625rem;
  border: 1px solid var(--ui-border); background: #fff; color: #3b4a5e; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.ui-logout:hover { background: #f1f5f9; border-color: #c5d1df; color: var(--ui-strong); }
.lang-switch { border-color: var(--ui-border); border-radius: 0.625rem; background: #fff; padding: 0.125rem; gap: 0.125rem; }
.lang-switch a { padding: 0.3125rem 0.5625rem; border-radius: 0.4375rem; font-size: 0.750rem; letter-spacing: 0.02em; }
.lang-switch a + a { border-left: 0; }
.lang-switch a:hover { background: #eef3f9; }
.lang-switch a.is-active { background: var(--ui-blue-btn); color: #fff; }
/* меню — отдельной строкой под названием сайта: его длина зависит от языка (грузинские названия длиннее),
   а так шапка выглядит одинаково на всех языках; на узком экране строка листается пальцем */
.ui-nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; margin-inline: -0.375rem; padding-bottom: 0.125rem; }
.ui-nav::-webkit-scrollbar { display: none; }
@media (max-width: 639px) {
  .ui-user-name { display: none; }
  .ui-logout span { display: none; }
  .ui-logout { padding: 0 0.625rem; }
}

/* ---------- полосы объявлений под шапкой ---------- */
.ui-banner { border-bottom: 1px solid; padding-block: 0.625rem; font-size: 0.9063rem; }

/* ---------- подпись сайта ---------- */
#site-footer { border-top-color: rgba(148, 163, 184, 0.28); }

/* ---------- карточки ---------- */
.ui-card, .ui-app main [class~="bg-white"][class~="rounded-xl"], .admin-panel, .admin-card, .diff-section {
  background: var(--ui-surface); border: 1px solid var(--ui-border-soft); border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-card); }
.ui-card { padding: clamp(1.125rem, 2.200vw, 1.750rem); }
.ui-card-title { font-size: 1.250rem; font-weight: 700; color: var(--ui-strong); letter-spacing: -0.01em; }
.ui-card-sub { color: var(--ui-muted); font-size: 0.9375rem; margin-top: 0.250rem; }
.ui-page-title { font-size: clamp(1.500rem, 2.200vw, 1.750rem); line-height: 1.2; font-weight: 700; color: var(--ui-strong);
  letter-spacing: -0.012em; }
.ui-page-sub { color: var(--ui-muted); font-size: 0.9375rem; margin-top: 0.250rem; }

/* ---------- кнопки ---------- */
.ui-btn, .ui-app main :is(button, a)[class~="bg-blue-600"], .ui-app main :is(button, a)[class~="bg-green-600"],
.ui-app main :is(button, a)[class~="bg-red-600"], .ui-app main :is(button, a)[class~="bg-slate-800"],
.ui-app main button[class~="border-slate-300"], .ui-app main a[class~="border-slate-300"][class~="rounded-md"],
.admin-btn {
  padding: 0.5625rem 1rem; border-radius: var(--ui-radius); font-size: 0.9375rem; font-weight: 600; line-height: 1.25;
  text-decoration: none; cursor: pointer; touch-action: manipulation; border: 1px solid transparent;
  transition: filter 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease, background-color 0.16s ease,
    border-color 0.16s ease; }
/* Расположение содержимого кнопки. Элементы с классом hidden не трогаем: их показом управляют Tailwind и скрипты. */
.ui-btn, .admin-btn, .ui-app main :is(button, a)[class~="bg-blue-600"]:not(.hidden),
.ui-app main :is(button, a)[class~="bg-green-600"]:not(.hidden), .ui-app main :is(button, a)[class~="bg-red-600"]:not(.hidden),
.ui-app main :is(button, a)[class~="bg-slate-800"]:not(.hidden), .ui-app main button[class~="border-slate-300"]:not(.hidden),
.ui-app main a[class~="border-slate-300"][class~="rounded-md"]:not(.hidden) {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.500rem; }
.ui-btn:focus-visible, .ui-app main :is(button, a):focus-visible { outline: 3px solid rgba(47, 128, 237, 0.45); outline-offset: 2px; }
.ui-btn:active:not(:disabled), .ui-app main :is(button, a)[class~="rounded-md"]:active:not(:disabled) { transform: translateY(1px); }
.ui-btn:disabled, .ui-app main button:disabled { cursor: not-allowed; }

/* основное действие — синий */
.ui-btn-primary, .ui-app main :is(button, a)[class~="bg-blue-600"] { color: #fff;
  background: linear-gradient(180deg, var(--ui-blue-btn) 0%, var(--ui-blue-deep) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 1px 2px rgba(15, 52, 110, 0.28), 0 8px 18px -8px rgba(23, 98, 204, 0.6); }
.ui-btn-primary:hover:not(:disabled), .ui-app main :is(button, a)[class~="bg-blue-600"]:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--ui-blue-btn) 0%, var(--ui-blue-deep) 100%); filter: brightness(1.07); }
.ui-btn-primary:disabled, .ui-app main button[class~="bg-blue-600"]:disabled { filter: saturate(0.6); opacity: 0.6; box-shadow: none; }

/* подтверждение — зелёный */
.ui-btn-success, .ui-app main :is(button, a)[class~="bg-green-600"] { color: #fff;
  background: linear-gradient(180deg, #1aa35a 0%, var(--ui-green-btn) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 1px 2px rgba(10, 70, 38, 0.3), 0 8px 18px -8px rgba(22, 146, 79, 0.6); }
.ui-app main :is(button, a)[class~="bg-green-600"]:hover:not(:disabled) {
  background: linear-gradient(180deg, #1aa35a 0%, var(--ui-green-btn) 100%); filter: brightness(1.06); }
.ui-app main button[class~="bg-green-600"]:disabled { filter: saturate(0.5); opacity: 0.55; box-shadow: none; }

/* опасное действие — красный */
.ui-btn-danger, .ui-app main :is(button, a)[class~="bg-red-600"] { color: #fff;
  background: linear-gradient(180deg, #e5483b 0%, var(--ui-red-btn) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(120, 20, 12, 0.3), 0 8px 18px -8px rgba(217, 45, 32, 0.55); }
.ui-app main :is(button, a)[class~="bg-red-600"]:hover:not(:disabled) {
  background: linear-gradient(180deg, #e5483b 0%, var(--ui-red-btn) 100%); filter: brightness(1.06); }

/* второстепенное действие — светлая кнопка с рамкой (в шаблонах это тёмные и «контурные» кнопки) */
.ui-btn-secondary, .ui-app main :is(button, a)[class~="bg-slate-800"], .ui-app main button[class~="border-slate-300"],
.ui-app main a[class~="border-slate-300"][class~="rounded-md"], .admin-btn {
  color: #243247; background: #fff; border-color: var(--ui-border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); }
.ui-btn-secondary:hover:not(:disabled), .ui-app main :is(button, a)[class~="bg-slate-800"]:hover:not(:disabled),
.ui-app main button[class~="border-slate-300"]:hover:not(:disabled),
.ui-app main a[class~="border-slate-300"][class~="rounded-md"]:hover, .admin-btn:hover {
  background: #f3f7fc; border-color: #c2d0e0; color: var(--ui-strong); }
.ui-app main :is(button, a)[class~="bg-slate-800"] { color: var(--ui-blue-deep); border-color: #c9dcf6; background: #f4f9ff; }
.ui-app main :is(button, a)[class~="bg-slate-800"]:hover:not(:disabled) { background: var(--ui-blue-tint); border-color: #a9c8f5;
  color: #0f4fa8; }
.ui-app main button[class~="border-red-300"] { color: var(--ui-red-deep); border-color: #f6c4bf; background: #fff; }
.ui-app main button[class~="border-red-300"]:hover:not(:disabled) { background: #fef3f2; border-color: #f2a59c; }
.admin-btn { min-height: 2.125rem; padding: 0.3125rem 0.750rem; font-size: 0.875rem; }
.admin-btn.text-red-700 { color: var(--ui-red-deep); border-color: #f6c4bf; }
.admin-btn.text-red-700:hover { background: #fef3f2; border-color: #f2a59c; color: var(--ui-red-deep); }
.ui-btn-lg { min-height: 3rem; padding-inline: 1.500rem; font-size: 1rem; border-radius: 0.750rem; }
.ui-btn-sm { min-height: 2.125rem; padding: 0.250rem 0.750rem; font-size: 0.875rem; }
.ui-spinner { width: 1.125rem; height: 1.125rem; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff; animation: spin 0.75s linear infinite; }

/* ---------- поля ввода ---------- */
.ui-input, .ui-app main input[class~="border-slate-300"], .ui-app main select[class~="border-slate-300"],
.ui-app main textarea[class~="border-slate-300"], .sad-input, .admin-input, .diff-input {
  border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: #fff; color: var(--ui-strong);
  font-size: 0.9375rem; min-height: 2.500rem; padding: 0.375rem 0.750rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease; }
.ui-input:hover, .sad-input:hover, .admin-input:hover, .diff-input:hover,
.ui-app main :is(input, select, textarea)[class~="border-slate-300"]:hover { border-color: #c2d0e0; }
.ui-input:focus, .sad-input:focus, .sad-input:focus-visible, .admin-input:focus, .diff-input:focus,
.ui-app main :is(input, select, textarea)[class~="border-slate-300"]:focus {
  outline: none; border-color: var(--ui-blue); box-shadow: var(--ui-ring); }
.ui-app main select { cursor: pointer; }
.ui-app main input[type="checkbox"], .ui-app main input[type="radio"] { accent-color: var(--ui-blue-btn); width: 1.0625rem;
  height: 1.0625rem; cursor: pointer; flex: none; }
.ui-label { display: block; font-size: 0.9375rem; font-weight: 600; color: #243247; }
.ui-help { font-size: 0.8438rem; color: var(--ui-muted); line-height: 1.45; }
.admin-input { min-height: 2.250rem; }
.diff-input { min-height: 2.250rem; padding: 0.3125rem 0.625rem; background: rgba(255, 255, 255, 0.92); font-size: 0.9375rem; }
textarea.diff-input { min-height: 3.500rem; line-height: 1.4; }
.diff-input.diff-invalid { border-color: #d92d20; background: #fff5f4; }
.diff-input.diff-invalid:focus { box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.14); }

/* ---------- сообщения ---------- */
.ui-app main :is(p, div)[class~="bg-red-50"], .ui-app main :is(p, div)[class~="bg-green-50"],
.ui-app main :is(p, div)[class~="bg-amber-50"], .ui-app main :is(p, div)[class~="bg-slate-100"][class~="rounded"] {
  border-radius: 0.750rem; border: 1px solid transparent; padding: 0.625rem 0.875rem; }
.ui-app main :is(p, div)[class~="bg-red-50"] { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.ui-app main :is(p, div)[class~="bg-green-50"] { background: #edfbf3; border-color: #bfe9d1; color: #11663a; }
.ui-app main :is(p, div)[class~="bg-amber-50"] { background: #fffaeb; border-color: #fde5a8; }

/* ---------- значки состояния ---------- */
.status-badge { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; font-weight: 600;
  padding: 0.1875rem 0.625rem; border-radius: 999px; background: #eef2f7; color: #334155; white-space: nowrap; }
.status-badge::before { content: ""; width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: currentColor; opacity: 0.75; }
.status-processing { background: #e8f1fe; color: #1552a8; }
.status-review { background: #fff4d6; color: #8a4b0a; }
.status-approved, .status-exported { background: #e3f7ea; color: #11663a; }
.status-failed { background: #fee9e7; color: #a5271c; }
.status-canceled { background: #f1f5f9; color: #475569; }
.dev-badge { font-size: 0.7188rem; font-weight: 600; padding: 0.250rem 0.500rem; color: #8a4b0a; background: #fff4d6; border-color: #f9dc8c; }
.spinner { border-color: #d5e0ee; border-top-color: var(--ui-blue-btn); }

/* ---------- таблицы списков (задачи, шаблоны, словарь, админ-панель) ---------- */
.sad-table, .admin-table { font-size: 0.9375rem; }
.sad-table th, .admin-table th { font-size: 0.8125rem; font-weight: 600; color: #4b5a6e; letter-spacing: 0.01em;
  background: #f6f8fb; padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--ui-border); white-space: nowrap; }
.sad-table td, .admin-table td { padding: 0.625rem 0.875rem; border-bottom: 1px solid #eef2f7; }
.sad-table tbody tr:hover td, .admin-table tbody tr:hover td { background: #f8fbff; }
.sad-table th:first-child, .admin-table th:first-child { border-top-left-radius: 0.625rem; }
.sad-table th:last-child, .admin-table th:last-child { border-top-right-radius: 0.625rem; }
/* таблицы внутри вкладок бланка — плотнее */
.sad-panel .sad-table th, .sad-panel .sad-table td { padding: 0.4375rem 0.875rem 0.4375rem 0.625rem; }
.admin-dl { font-size: 0.9375rem; gap: 0.500rem 1.250rem; }
.admin-h2, .ui-app main h2.font-semibold { font-size: 1.125rem; font-weight: 700; color: var(--ui-strong); }
.admin-card-value { color: var(--ui-strong); }
.admin-card-label, .admin-card-hint { font-size: 0.8438rem; }

/* вкладки админ-панели — одной «таблеткой» */
.admin-tabs { gap: 0.125rem; padding: 0.250rem; background: #fff; border: 1px solid var(--ui-border-soft); border-radius: 0.875rem;
  box-shadow: var(--ui-shadow-card); }
.admin-tabs a { padding: 0.4375rem 0.875rem; border-radius: 0.625rem; font-size: 0.9375rem; font-weight: 500; color: #3b4a5e; }
.admin-tabs a:hover { background: #eef3f9; }
.admin-tabs a.is-active { background: var(--ui-blue-btn); color: #fff; font-weight: 600; }

/* ---------- зона загрузки файла ---------- */
.ui-drop { position: relative; display: flex; align-items: center; gap: 0.875rem; padding: 0.875rem 1rem; border-radius: 0.875rem;
  border: 1.5px dashed #c2d0e0; background: var(--ui-field);
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease; }
.ui-drop:hover { border-color: #8fbdfa; background: #f3f8ff; }
.ui-drop:focus-within { border-color: var(--ui-blue); box-shadow: var(--ui-ring); background: #fff; }
.ui-drop.is-over { border-color: var(--ui-blue); background: var(--ui-blue-tint); }
.ui-drop.has-files { border-style: solid; border-color: #a9d8bd; background: #f3fbf6; }
/* само поле файла растянуто на всю зону и прозрачно: щелчок и перетаскивание работают как у обычного поля */
.ui-drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ui-drop-icon { width: 2.750rem; height: 2.750rem; border-radius: 0.750rem; display: grid; place-items: center; flex: none;
  background: var(--ui-blue-tint); color: var(--ui-blue-deep); }
.ui-drop.has-files .ui-drop-icon { background: #dcf5e6; color: #12804a; }
.ui-drop-text { min-width: 0; font-size: 0.9375rem; color: #243247; }
.ui-drop-text b { font-weight: 600; color: var(--ui-blue-deep); }
.ui-drop-files { display: block; font-size: 0.875rem; color: #12663a; font-weight: 600; overflow-wrap: anywhere; }
.ui-drop-files:empty { display: none; }
.ui-drop.has-files .ui-drop-prompt { display: none; }
.ui-drop-formats { display: block; font-size: 0.8125rem; color: var(--ui-muted); margin-top: 0.125rem; }
/* зона с несколькими файлами: подсказка «добавить» остаётся, файлы — списком с кнопкой «×» над прозрачным полем */
.ui-drop-multi.has-files .ui-drop-prompt { display: block; }
.ui-drop-multi .ui-drop-files { position: relative; z-index: 2; pointer-events: none; margin: 0.375rem 0; }
.ui-drop-file { pointer-events: auto; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.1875rem 0.25rem 0.1875rem 0.625rem; border-radius: 0.5rem; background: #fff; border: 1px solid #cfe9da; }
.ui-drop-file + .ui-drop-file { margin-top: 0.25rem; }
.ui-drop-file-name { min-width: 0; overflow-wrap: anywhere; }
.ui-drop-remove { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 0.375rem; border: 0; background: transparent;
  color: #8a2f2f; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.ui-drop-remove:hover { background: #fdecec; }
.ui-drop-remove:focus-visible { outline: 2px solid var(--ui-blue); outline-offset: 1px; }

/* шаги формы новой декларации */
.ui-step { display: grid; grid-template-columns: 2.250rem minmax(0, 1fr); gap: 0.250rem 0.875rem; }
.ui-step-num { width: 2.250rem; height: 2.250rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  font-size: 0.9375rem; background: var(--ui-blue-tint); color: var(--ui-blue-deep); }
.ui-step-body { min-width: 0; }
.ui-step + .ui-step { padding-top: 1.375rem; border-top: 1px solid #eef2f7; }
.ui-step-title { font-size: 1.0625rem; font-weight: 700; color: var(--ui-strong); line-height: 1.3; padding-top: 0.3125rem; }
.ui-optional { font-weight: 500; color: var(--ui-muted); font-size: 0.875rem; }
/* выбор режима — карточки с переключателем */
.ui-choice { display: flex; align-items: flex-start; gap: 0.750rem; padding: 0.750rem 0.875rem; border-radius: 0.750rem;
  border: 1px solid var(--ui-border); background: #fff; cursor: pointer; font-size: 0.9375rem;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease; }
.ui-choice:hover { border-color: #a9c8f5; }
.ui-choice:has(input:checked) { border-color: var(--ui-blue); background: #f4f9ff; box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.10); }
.ui-choice input { margin-top: 0.1875rem; }

/* ---------- список задач в боковой карточке ---------- */
.ui-list > li { padding-block: 0.625rem; }
.ui-link { color: var(--ui-blue-deep); font-weight: 600; text-decoration: none; }
.ui-link:hover { text-decoration: underline; }
.ui-app main a[class~="text-blue-600"] { color: var(--ui-blue-deep); font-weight: 500; }

/* ---------- страница задачи: шапка, бланк, полоса подтверждения ---------- */
.ui-file-chip { display: inline-flex; align-items: center; gap: 0.375rem; max-width: 100%; padding: 0.250rem 0.625rem; border-radius: 999px;
  background: #f1f5f9; border: 1px solid var(--ui-border-soft); font-size: 0.8438rem; color: #334155; }
.ui-file-chip b { font-weight: 600; color: #4b5a6e; }
.ui-file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-toolbar { background: #fff; border: 1px solid var(--ui-border-soft);
  border-radius: 0.875rem; padding: 0.750rem 0.875rem; box-shadow: var(--ui-shadow-card); }
.sad-legend { font-size: 0.875rem; gap: 0.375rem 1.125rem; color: #334155; }
/* вкладки бланка — «таблетки» */
.sad-tabs { gap: 0.250rem; border-bottom: 0; padding: 0.250rem; background: #e9eef5; border-radius: 0.875rem; width: fit-content;
  max-width: 100%; margin-top: 0.875rem; }
.sad-tab { font-size: 0.9375rem; font-weight: 500; padding: 0.4375rem 0.875rem; border: 0; border-radius: 0.625rem; margin-bottom: 0;
  color: #3b4a5e; transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.sad-tab:hover { background: rgba(255, 255, 255, 0.6); }
.sad-tab[aria-selected="true"] { background: #fff; color: var(--ui-blue-deep); font-weight: 600; border: 0;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 4px 10px -6px rgba(23, 60, 120, 0.3); }
.sad-badge { font-weight: 600; }
.sad-panel:not(#panel-form) { border-color: var(--ui-border-soft); border-radius: var(--ui-radius-lg); padding: 1.250rem;
  box-shadow: var(--ui-shadow-card); }
/* лист бланка лежит на «столе»: сама сетка граф не меняется */
#panel-form { margin-top: 0.875rem; padding: clamp(0.500rem, 1.200vw, 1rem); background: #e9eef5; border-radius: var(--ui-radius-lg);
  border: 1px solid var(--ui-border-soft); }
#panel-form > .sad { margin-top: 0; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 14px 30px -16px rgba(15, 23, 42, 0.35); }
.sad-editor { border-color: var(--ui-blue); border-radius: 0.750rem; box-shadow: var(--ui-shadow-pop); padding: 0.750rem; }
.sad-editor-input { border-color: var(--ui-border); border-radius: 0.500rem; min-height: 2.375rem; }
.sad-editor-input:focus-visible { outline: none; border-color: var(--ui-blue); box-shadow: var(--ui-ring); }
.sad-editor-btn { border-color: var(--ui-border); border-radius: 0.500rem; font-weight: 600; min-height: 2.125rem; }
.sad-editor-save { background: var(--ui-blue-btn); border-color: var(--ui-blue-btn); }
.sad-editor-save:hover { background: var(--ui-blue-deep); }
/* размер текста в бланке: кнопки A− / A+ (ui.js) меняют только переменную --sad-scale, сетка граф остаётся прежней */
@media screen {
  .sad { font-size: calc(0.875rem * var(--sad-scale, 1)); }
  .sad .sad-l { font-size: 0.8215em; }
  .sad .sad-bad sup { font-size: 0.72em; }
  .sad .sad-item-title { font-size: 0.93em; padding: 0.250rem 0.500rem; }
  .sad .sad-docs { font-size: 0.93em; }
  .sad .sad-doc-state { font-size: 0.8215em; }
  .sad .sad-suggest { font-size: 1em; }
  .sad .sad-box { min-height: 3.200em; padding: 0.250em 0.500em 0.350em; }
  .sad .sad-tall { min-height: 6.400em; }
}
.ui-zoom { display: inline-flex; align-items: center; border: 1px solid var(--ui-border); border-radius: var(--ui-radius);
  background: #fff; overflow: hidden; }
.ui-zoom button { min-width: 2.375rem; min-height: 2.375rem; font-weight: 700; color: #243247; cursor: pointer; font-size: 0.9375rem;
  transition: background-color 0.15s ease; }
.ui-zoom button:hover:not(:disabled) { background: #f1f5f9; }
.ui-zoom button:disabled { opacity: 0.4; cursor: not-allowed; }
.ui-zoom button + button { border-left: 1px solid var(--ui-border); }
.ui-zoom output { min-width: 3.250rem; text-align: center; font-size: 0.8438rem; font-variant-numeric: tabular-nums; color: var(--ui-muted);
  border-left: 1px solid var(--ui-border); padding-inline: 0.375rem; }

/* заключение эксперта */
.expert-finding { border-radius: 0.750rem; padding: 0.750rem 0.875rem; }
.expert-badge { border-radius: 0.375rem; padding: 0.125rem 0.4375rem; font-weight: 700; }

/* полоса «Подтвердить данные» — плавающая карточка у нижнего края */
#confirm-bar { background: rgba(255, 255, 255, 0.92); border: 1px solid var(--ui-border-soft); border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -10px 30px -18px rgba(15, 23, 42, 0.35); padding: 0.750rem 1rem; margin-top: 1.500rem;
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); }
#approve-btn { min-height: 2.750rem; padding-inline: 1.375rem; font-size: 1rem; }
/* в одну строку: кнопка, пояснение (переносится внутри своего места), скачивание */
#confirm-valid:not(.hidden), #confirm-needed:not(.hidden) { flex: 1 1 18rem; min-width: 0; flex-wrap: nowrap; }
#confirm-needed > #approve-hint, #confirm-valid > [role="status"] { flex: 1 1 auto; min-width: 0; }
#confirm-bar :is(a, button) { flex: none; }
@media (max-width: 767px) { #confirm-valid:not(.hidden), #confirm-needed:not(.hidden) { flex-wrap: wrap; } }

/* ---------- таблица «было / стало» ---------- */
.diff-section { padding: 1.250rem; margin-bottom: 1.250rem; }
.diff-section-title { font-size: 1.125rem; font-weight: 700; color: var(--ui-strong); }
.diff-section-subtitle { font-size: 0.875rem; color: var(--ui-muted); }
.diff-table { font-size: 0.9375rem; border-collapse: separate; border-spacing: 0; }
.diff-table th { font-size: 0.8125rem; font-weight: 600; color: #4b5a6e; letter-spacing: 0.01em; background: #f6f8fb;
  padding: 0.625rem 0.750rem; border-bottom: 1px solid var(--ui-border); }
.diff-table th:first-child { border-top-left-radius: 0.625rem; }
.diff-table th:last-child { border-top-right-radius: 0.625rem; }
.diff-table td { padding: 0.5625rem 0.750rem; border-bottom: 1px solid #eef2f7; }
.diff-label { color: #3b4a5e; font-weight: 500; }
.diff-old { color: #334155; font-variant-numeric: tabular-nums; }
.diff-new { font-variant-numeric: tabular-nums; }
/* изменённые строки видны сразу: цветная полоса слева и подложка у нового значения */
.diff-row.diff-changed .diff-label { box-shadow: inset 3px 0 0 #f0b429; }
.diff-row.diff-added .diff-label { box-shadow: inset 3px 0 0 #22a565; }
.diff-row.diff-removed .diff-label { box-shadow: inset 3px 0 0 #e5483b; }
.diff-row.diff-unexpected .diff-label { box-shadow: inset 3px 0 0 #b42318; }
.diff-row.diff-has-error .diff-label { box-shadow: inset 3px 0 0 #dc2626; }
.diff-item-title td { background: #eef3f9; border-top: 0; padding: 0.750rem; font-weight: 600; color: var(--ui-strong); }
.diff-item-title:not(:first-child) td { border-top: 0.625rem solid #fff; }
.diff-source { font-weight: 400; }
.diff-issue { font-size: 0.8438rem; border-radius: 0.500rem; padding: 0.3125rem 0.5625rem; line-height: 1.4; }
.diff-delta { font-size: 0.8438rem; font-weight: 600; }
.diff-basis { font-size: 0.7813rem; padding: 0.0625rem 0.500rem; font-weight: 500; }
.diff-chip { font-size: 0.875rem; font-weight: 600; padding: 0.3125rem 0.750rem; }
.diff-legend { font-size: 0.8125rem; padding: 0.1875rem 0.5625rem; border-radius: 0.375rem; }
.diff-save-note { font-size: 0.8125rem; }

/* ---------- помощь ---------- */
.help { font-size: 1rem; line-height: 1.6; padding: clamp(1.250rem, 3vw, 2.250rem) !important; }
.help h1 { font-size: 1.625rem; font-weight: 700; color: var(--ui-strong); letter-spacing: -0.012em; }
.help h2 { font-size: 1.1875rem; font-weight: 700; color: var(--ui-strong); margin: 1.750rem 0 0.500rem; }
.help code { background: #eef3f9; border-radius: 0.3125rem; padding: 0.0625rem 0.3125rem; font-size: 0.9em; }
.help-table { font-size: 0.9375rem; }
.help a { color: var(--ui-blue-deep); }

/* ---------- узкий экран: ничто не должно выходить за край страницы ---------- */
.ui-app main .grid > *, .ui-app main .flex > * { min-width: 0; }
.ui-app main :is(input, select, textarea) { max-width: 100%; }
.ui-app main label { max-width: 100%; }
.admin-dl { grid-template-columns: max-content minmax(0, 1fr); }
.admin-dl > dd { min-width: 0; overflow-wrap: anywhere; }
.admin-panel { min-width: 0; }
@media (max-width: 639px) {
  .admin-dl { grid-template-columns: minmax(0, 1fr); gap: 0.125rem 0; }
  .admin-dl > dt { margin-top: 0.500rem; font-size: 0.8438rem; }
  .ui-main { padding-block: 1rem 1.500rem; }
  .ui-step { grid-template-columns: 1.875rem minmax(0, 1fr); gap: 0.250rem 0.625rem; }
  .ui-step-num { width: 1.875rem; height: 1.875rem; font-size: 0.875rem; }
  .ui-drop { padding: 0.750rem; gap: 0.625rem; }
  .sad-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .sad-tab { white-space: nowrap; }
  .sad-add label, .sad-add label > .sad-input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ui-btn, .ui-app main :is(button, a), .ui-nav-link, .ui-drop, .ui-choice, .sad-tab { transition: none; }
}
@media print {
  .ui-app { background: #fff !important; }
  #panel-form { padding: 0 !important; background: none !important; border: 0 !important; margin-top: 0 !important; }
  #panel-form > .sad { box-shadow: none !important; }
}

/* ---------- Вкладка «ТН ВЭД» (static/js/tnved.js) ---------- */
.tnved { display: grid; gap: 1rem; grid-template-columns: minmax(17rem, 28rem) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .tnved { grid-template-columns: minmax(0, 1fr); } }
.tnved-side { max-height: 78vh; overflow: auto; }
.tnved-card { min-height: 12rem; overflow-wrap: anywhere; }
.tnved-tree, .tnved-list { list-style: none; margin: 0; padding: 0; }
.tnved-tree .tnved-tree { margin-left: 0.7rem; padding-left: 0.5rem; border-left: 1px solid #e2e8f0; }
.tnved-row { display: flex; align-items: flex-start; gap: 0.125rem; }
.tnved-toggle { flex: none; width: 1.5rem; height: 1.75rem; border: 0; background: none; cursor: pointer; color: #475569; }
.tnved-toggle:disabled { cursor: default; color: #cbd5e1; }
.tnved-label, .tnved-result { display: flex; flex-wrap: wrap; gap: 0.125rem 0.5rem; width: 100%; text-align: left; border: 0;
  background: none; cursor: pointer; padding: 0.25rem 0.375rem; border-radius: 0.375rem; font: inherit; color: inherit; }
.tnved-label:hover, .tnved-result:hover { background: #eef4ff; }
.tnved-code { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: #1e3a8a; }
.tnved-name { color: #334155; font-size: 0.875rem; }
.tnved-path { flex-basis: 100%; font-size: 0.75rem; color: #64748b; }
.tnved-result { border-bottom: 1px solid #f1f5f9; border-radius: 0; }
.tnved-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; font-size: 0.8125rem; margin-bottom: 0.5rem; }
.tnved-crumb { border: 0; background: none; padding: 0.125rem 0.25rem; cursor: pointer; color: #1d4ed8; border-radius: 0.25rem; }
.tnved-crumb:hover { background: #eef4ff; }
.tnved-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; margin-bottom: 0.75rem; }
.tnved-title { font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums; color: #0f172a; }
.tnved-desc { flex-basis: 100%; font-size: 1rem; color: #1e293b; }
.tnved-sub { font-weight: 600; margin: 0.75rem 0 0.375rem; }
.tnved-details { border: 1px solid #e2e8f0; border-radius: 0.5rem; margin-top: 0.5rem; background: #f8fafc; }
.tnved-summary { cursor: pointer; padding: 0.5rem 0.75rem; font-weight: 600; }
.tnved-notes { padding: 0 0.75rem 0.75rem; display: grid; gap: 0.375rem; max-height: 28rem; overflow: auto; }
.tnved-note { font-size: 0.9375rem; line-height: 1.5; }
.tnved-note-head { font-weight: 600; margin-top: 0.375rem; }
.tnved-table { width: 100%; }
.tnved-cap { width: 22%; font-size: 0.8125rem; color: #475569; }
.tnved-val { width: 14%; font-weight: 600; }
.tnved-com { white-space: pre-wrap; font-size: 0.875rem; line-height: 1.45; }
