/* ============================================================================
   RANCH-SCHOOL «Qabul» — стили компонентов (v4: сервер, роли; база v3.1 — крупнее и тише: 16px, поля 48, карточки без рамок).
   Только токены из tokens.css; подключать после него. Цветовые литералы
   запрещены (кроме @media print). Светлая тема по умолчанию; тёмная — только
   :root[data-theme="dark"] (prefers-color-scheme не читается).
   Состояния: .is-error / .is-warn / .is-auto / [readonly] / .is-required /
   form[data-step] / .step[data-state] / #calc[data-calc-mode] / html[data-sidebar] / html[data-role] / .roster[data-scope] / html[data-drawer]
   ========================================================================== */

/* ---------- Сброс и база ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
table { border-collapse: collapse; border-spacing: 0; }
svg { flex: none; }
[hidden] { display: none !important; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
kbd {
  font-family: var(--font-mono); font-size: var(--fs-2xs); line-height: 1;
  padding: 3px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface-2); color: var(--text-2);
}

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.dot { color: var(--text-3); margin: 0 var(--sp-1); }
.opt { color: var(--text-3); font-weight: var(--fw-medium); }
.num { text-align: right; }
.link {
  background: none; border: 0; padding: 0; color: var(--primary-text);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: inherit; font-weight: var(--fw-medium);
}
.link:hover { color: var(--primary-dark); }

/* Иконки темы: луна/солнце */
.only-dark { display: none; }
:root[data-theme="dark"] .only-dark { display: inline; }
:root[data-theme="dark"] .only-light { display: none; }

/* Аватар-инициалы (реестр 36, «найден родитель» 40, дети в расчёте 32) */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: var(--avatar-size); height: var(--avatar-size); border-radius: 50%;
  background: var(--avatar-bg); color: var(--avatar-text);
  font-size: var(--fs-sm); font-weight: var(--fw-extrabold); letter-spacing: 0.02em; line-height: 1;
}
.avatar-lg { width: 40px; height: 40px; font-size: var(--fs-md); }
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.avatar.is-muted { background: var(--surface-2); color: var(--text-3); }

/* ============================================================================
   КАРКАС: aside слева (grid-column 1), контент справа. В DOM aside стоит после .content.
   ========================================================================== */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  transition: grid-template-columns var(--dur-base) var(--ease);
}
.content { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.content > .page { flex: 1 0 auto; width: 100%; }
.sidebar { grid-column: 1; grid-row: 1; }

/* ---------- Aside ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: var(--z-sidebar);
  display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-3);
  background: var(--sidebar-bg); color: var(--sidebar-text); box-shadow: var(--sidebar-shadow);
  transition: width var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--on-primary); text-decoration: none; white-space: nowrap; border-radius: 10px; min-width: 0; }
.sidebar .brand { padding: 6px 8px 18px; }
.brand .logo-sign { width: 26px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-school { font-size: var(--fs-lg); font-weight: var(--fw-extrabold); letter-spacing: 0.02em; }
.brand-app { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--sidebar-text-muted); letter-spacing: 0.04em; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: var(--sp-1); padding-top: var(--sp-3); border-top: 1px solid var(--sidebar-line); min-width: 0; }
.nav-label { font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--sidebar-text-muted); padding: 6px 12px 8px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  height: var(--sidebar-item-h); padding: 0 var(--sp-3); border: 0; border-radius: 10px;
  background: transparent; color: var(--sidebar-text); font-size: var(--fs-md); font-weight: var(--fw-semibold);
  text-align: left; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item svg { width: var(--sidebar-icon); height: var(--sidebar-icon); }
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item[aria-selected="true"] { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: var(--fw-bold); box-shadow: var(--shadow-1); }
.nav-text { overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  margin-left: auto; font-size: var(--fs-2xs); font-weight: var(--fw-bold); line-height: 20px; padding: 0 8px; border-radius: var(--r-pill);
  background: var(--sidebar-hover); color: var(--sidebar-text); font-family: var(--font-ui);
}
.nav-item[aria-selected="true"] .nav-count { background: var(--primary-tint-2); color: var(--primary-text); }
.nav-count:empty { display: none; }

.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-3); border-top: 1px solid var(--sidebar-line); }
/* Текущий пользователь внизу aside: аватар-инициалы (белый круг, красные буквы), имя, роль */
.sb-user { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; min-width: 0; }
.sb-avatar { width: 36px; height: 36px; background: var(--on-primary); color: var(--primary-text); font-size: var(--fs-sm); }
.sb-user-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sb-user-name { font-size: var(--fs-md); font-weight: var(--fw-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--sidebar-text-muted); white-space: nowrap; }
.nav-group { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--sidebar-line); }
/* Роли: элементы [data-role] видны только своей роли (html[data-role] ставит Auth); сервер проверяет права сам */
html:not([data-role="admin"]) [data-role="admin"] { display: none !important; }
html:not([data-role="operator"]) [data-role="operator"] { display: none !important; }
.btn-lock {
  position: relative; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 44px; padding: 0 var(--sp-3);
  border-radius: var(--r-pill); background: transparent; color: var(--on-primary);
  border: 1.5px solid color-mix(in srgb, var(--on-primary) 55%, transparent); font-size: var(--fs-md); font-weight: var(--fw-bold); white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn-lock:hover { background: var(--on-primary); color: var(--primary-text); border-color: var(--on-primary); }
.lock-kbd { font-size: var(--fs-xs); font-weight: var(--fw-medium); opacity: 0.75; border: 0; background: transparent; padding: 0; color: inherit; font-family: var(--font-ui); }
.btn-collapse {
  position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 var(--sp-3); border: 0; border-radius: 10px;
  background: transparent; color: var(--sidebar-text-muted); font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap;
}
.btn-collapse:hover { background: var(--sidebar-hover); color: var(--on-primary); }
.btn-collapse svg { transition: transform var(--dur-base) var(--ease); }

/* Свёрнутый aside (72 px): иконки по центру, подписи — в tooltip справа */
html[data-sidebar="collapsed"] .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
html[data-sidebar="collapsed"] .sidebar { padding-left: 10px; padding-right: 10px; }
html[data-sidebar="collapsed"] .sidebar .nav-text,
html[data-sidebar="collapsed"] .sidebar .brand-text,
html[data-sidebar="collapsed"] .sidebar .sb-user-text,
html[data-sidebar="collapsed"] .sidebar .nav-label { display: none; }
html[data-sidebar="collapsed"] .sidebar .brand { justify-content: center; padding: 6px 0 16px; }
html[data-sidebar="collapsed"] .sidebar .nav { padding-top: var(--sp-2); }
html[data-sidebar="collapsed"] .sidebar .nav-item { justify-content: center; padding: 0; width: 52px; margin: 0 auto; }
html[data-sidebar="collapsed"] .sidebar .nav-item[aria-selected="true"] { width: 52px; }
html[data-sidebar="collapsed"] .sidebar .nav-count { position: absolute; top: 9px; right: 9px; margin: 0; width: 8px; height: 8px; padding: 0; border-radius: 50%; font-size: 0; line-height: 0; background: var(--on-primary); box-shadow: 0 0 0 2px var(--primary-mid); }
html[data-sidebar="collapsed"] .sidebar .nav-item[aria-selected="true"] .nav-count { background: var(--primary); box-shadow: 0 0 0 2px var(--on-primary); }
html[data-sidebar="collapsed"] .sidebar .sb-user { justify-content: center; padding: 0 0 8px; }
html[data-sidebar="collapsed"] .sidebar .nav-group { padding-top: var(--sp-2); }
html[data-sidebar="collapsed"] .sidebar .btn-lock { width: 40px; padding: 0; margin: 0 auto; }
html[data-sidebar="collapsed"] .sidebar .btn-collapse { justify-content: center; padding: 0; width: 36px; margin: 0 auto; }
html[data-sidebar="collapsed"] .sidebar .btn-collapse svg { transform: scaleX(-1); }

/* Tooltip: [data-tip] → ::after (в aside — только в свёрнутом режиме; у кнопок-иконок — всегда) */
html[data-sidebar="collapsed"] .sidebar [data-tip]::after,
.btn-icon[data-tip]::after {
  content: attr(data-tip); position: absolute; z-index: var(--z-tooltip);
  padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap; pointer-events: none;
  background: var(--surface); color: var(--text); font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.3;
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
  display: none; opacity: 0;
}
html[data-sidebar="collapsed"] .sidebar [data-tip]::before,
.btn-icon[data-tip]::before {
  content: ""; position: absolute; z-index: calc(var(--z-tooltip) + 1); width: 8px; height: 8px; transform: rotate(45deg);
  background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); pointer-events: none;
  display: none; opacity: 0;
}
html[data-sidebar="collapsed"] .sidebar [data-tip]::after { left: calc(100% + 12px); top: 50%; transform: translateY(-50%); }
html[data-sidebar="collapsed"] .sidebar [data-tip]::before { left: calc(100% + 8px); top: 50%; margin-top: -4px; }
.btn-icon[data-tip]::after { left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); }
.btn-icon[data-tip]::before { left: 50%; bottom: calc(100% + 5px); margin-left: -4px; transform: rotate(-45deg); }
/* display:none в покое — невидимый tooltip не расширяет прокрутку таблицы/aside; появление 120 мс с задержкой 300 мс, по фокусу — сразу */
html[data-sidebar="collapsed"] .sidebar [data-tip]:hover::after, html[data-sidebar="collapsed"] .sidebar [data-tip]:hover::before,
.btn-icon[data-tip]:hover::after, .btn-icon[data-tip]:hover::before { display: block; animation: tip-in var(--dur-fast) var(--ease) 300ms forwards; }
html[data-sidebar="collapsed"] .sidebar [data-tip]:focus-visible::after, html[data-sidebar="collapsed"] .sidebar [data-tip]:focus-visible::before,
.btn-icon[data-tip]:focus-visible::after, .btn-icon[data-tip]:focus-visible::before { display: block; animation: tip-in var(--dur-fast) var(--ease) 0ms forwards; }
@keyframes tip-in { to { opacity: 1; } }

/* Оверлей под выезжающим aside (< 1000 px) */
.sidebar-overlay { position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1); background: var(--overlay); }

/* ---------- Верхняя панель контента ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--sp-4); height: var(--topbar-h); padding: 0 28px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--topbar-border); box-shadow: var(--topbar-shadow);
}
.topbar-title { font-size: var(--fs-xl); font-weight: var(--fw-extrabold); letter-spacing: var(--tracking-h1); color: var(--heading); white-space: nowrap; }
.topbar-sub { display: none !important; } /* хлебная крошка убрана; #topbar-sub остаётся для app.js */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.wizard-status { display: none !important; } /* статус «Qoralama · saqlanmagan» убран из панели; #wizard-status остаётся для app.js */
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn-border); flex: none; }
.wizard-status[data-state="saved"] .ws-dot { background: var(--ok-border); }
.wizard-status[data-state="editing"] .ws-dot { background: var(--info-border); }
.wizard-status[hidden] { display: none; }

/* Сегмент UZ | RU (на белой панели) */
.seg { display: inline-flex; height: 36px; padding: 3px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); }
.seg-btn {
  min-width: 38px; height: 28px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: transparent;
  color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-bold); letter-spacing: 0.04em; line-height: 28px;
}
.seg-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.icon-btn {
  width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: inline-grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-input); }

/* ---------- Мобильная красная панель (< 1000 px) ---------- */
.mobile-bar {
  display: none; position: sticky; top: 0; z-index: var(--z-header);
  align-items: center; gap: var(--sp-3); height: var(--topbar-h); padding: 0 var(--sp-4);
  background: var(--grad-header); color: var(--on-primary); box-shadow: var(--shadow-header);
}
.mb-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--on-primary); cursor: pointer; }
.mb-btn:hover { background: var(--sidebar-hover); }
.mb-lock { margin-left: auto; background: var(--on-primary); color: var(--primary-text); }
.mb-lock:hover { background: var(--primary-tint); }
.mb-brand .logo-sign { width: 22px; height: 30px; }
.mb-brand .brand-school { font-size: var(--fs-sm); }
.mb-title { text-transform: none; }

/* ============================================================================
   КНОПКИ — pill, как .btn-primary-theme сайта
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-5);
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: transparent; color: var(--text);
  font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: 1; white-space: nowrap;
  text-decoration: none; user-select: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.btn:disabled { cursor: not-allowed; }
.btn-primary { background: var(--grad-primary); color: var(--on-primary); border: 0; box-shadow: var(--shadow-1); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-primary); }
.btn-primary:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-1); }
.btn-primary:disabled { opacity: 0.45; transform: none; box-shadow: none; }
.btn-outline { border: 2px solid var(--primary); color: var(--primary-text); background: transparent; }
.btn-outline:hover:not(:disabled) { background: var(--primary); color: var(--on-primary); }
.btn-outline.btn-neutral { border-color: var(--border-input); color: var(--text); }
.btn-outline.btn-neutral:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-text { color: var(--primary-text); padding: 0 var(--sp-3); }
.btn-text:hover:not(:disabled) { background: var(--primary-tint); }
.btn-text.btn-muted { color: var(--text-2); }
.btn-text.btn-muted:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-text-danger { color: var(--error); }
.btn-text-danger:hover:not(:disabled) { background: var(--error-bg); }
.btn-danger { background: var(--error-border); border-color: var(--error-border); color: var(--on-primary); }
.btn-danger:hover:not(:disabled) { background: var(--error); border-color: var(--error); }
.btn-lg { height: var(--control-h-lg); padding: 0 var(--sp-6); font-size: var(--fs-md); font-weight: var(--fw-bold); }
.btn-sm { height: 40px; padding: 0 var(--sp-4); font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.btn-block { width: 100%; }
label.btn { cursor: pointer; }
/* Кнопка-иконка 36 px (действия строки реестра) */
.btn-icon {
  position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-icon:hover:not(:disabled) { background: var(--primary-tint); color: var(--primary-text); }
.btn-icon-danger:hover:not(:disabled) { background: var(--error-bg); color: var(--error); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }

/* ============================================================================
   БАННЕРЫ, ТОСТЫ
   ========================================================================== */
.banner {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-md); border-radius: var(--r-md);
  border: 1px solid transparent;
}
.banner-error { background: var(--error-bg); color: var(--error); border-color: var(--error-border); }
.banner-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
#template-alert { margin: var(--sp-4) 28px 0; }
.toast-area {
  position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: var(--z-tooltip);
  display: flex; flex-direction: column; gap: var(--sp-2); width: min(400px, calc(100vw - 32px)); pointer-events: none;
}
.toast-area > * { pointer-events: auto; }
.toast {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--ok-border);
  border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: var(--fs-md); animation: rise var(--dur-base) var(--ease);
}
.toast[data-level="warn"] { border-left-color: var(--warn-border); }
.toast[data-level="error"] { border-left-color: var(--error-border); }
.toast .btn-sm { margin-left: auto; padding: 0 var(--sp-2); height: 28px; }

/* ============================================================================
   СТРАНИЦА
   ========================================================================== */
.page { max-width: var(--container-w); margin: 0 auto; padding: var(--sp-5) 28px var(--sp-8); }
.panel[hidden] { display: none; }

/* Рабочая область мастера: stepper на обе колонки, карточка шага слева, расчёт справа */
.wizard { display: grid; grid-template-columns: minmax(0, var(--wizard-max-w)) var(--panel-w); gap: var(--sp-6); align-items: start; }
.contract-form { display: contents; }
.stepper { grid-column: 1 / -1; }
.step-card { grid-column: 1; min-width: 0; }
.calc { grid-column: 2; }

/* ============================================================================
   STEPPER
   ========================================================================== */
.stepper {
  display: flex; align-items: center; height: var(--stepper-h); padding: 0 var(--sp-2);
  background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.step {
  display: flex; align-items: center; gap: 12px; height: 100%; padding: 0 var(--sp-3);
  background: none; border: 0; border-radius: var(--r-sm); font-size: var(--fs-md); font-weight: var(--fw-semibold); white-space: nowrap;
  color: var(--stepper-todo-text); cursor: default; text-align: left;
}
.step[data-state="done"], .step[data-state="error"] { cursor: pointer; color: var(--text); }
.step[data-state="done"]:hover, .step[data-state="error"]:hover { background: var(--surface-2); }
.step[data-state="current"] { color: var(--heading); font-weight: var(--fw-bold); }
.step[data-state="error"] { color: var(--error); }
.step:disabled { cursor: not-allowed; }
.step-dot {
  position: relative; display: grid; place-items: center; flex: none;
  width: var(--stepper-dot); height: var(--stepper-dot); border-radius: 50%;
  border: 2px solid var(--stepper-todo); color: var(--stepper-todo-text); font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: 1;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.step-check { display: none; }
.step[data-state="current"] .step-dot { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 0 0 4px var(--primary-tint-2); }
.step[data-state="done"] .step-dot { background: var(--stepper-done); border-color: var(--stepper-done); color: var(--on-primary); }
.step[data-state="done"] .step-num { display: none; }
.step[data-state="done"] .step-check { display: block; }
.step[data-state="error"] .step-dot { background: var(--surface); border-color: var(--error-border); color: var(--error); }
.step[data-state="error"] .step-dot::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--error-border); box-shadow: 0 0 0 2px var(--surface);
}
.step-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.step-line { flex: 1; height: var(--stepper-line); min-width: 20px; border-radius: 2px; background: var(--stepper-todo); }
.step-line.is-done { background: var(--stepper-done); }

/* ============================================================================
   КАРТОЧКА ШАГА: одна белая карточка, панели переключаются, подвал липкий
   ========================================================================== */
.card { background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.step-card { padding: var(--sp-6) 28px 0; position: relative; }
.step-card.is-shake { animation: shake var(--dur-base) var(--ease); }
.step-panel { animation: step-in var(--dur-fast) var(--ease); }
.step-panel > legend.card-head { float: left; width: 100%; display: flex; flex-direction: column; padding-bottom: var(--sp-4); margin-bottom: var(--sp-5); border-bottom: 1px solid var(--border); }
.step-panel > legend + * { clear: both; }
.step-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--tracking-h2); color: var(--heading); text-wrap: balance; }
.step-title::after { content: ""; display: block; width: var(--heading-line-w); height: var(--heading-line-h); background: var(--primary); border-radius: 2px; margin-top: var(--sp-2); }
.step-sub, .section-desc { font-size: var(--fs-md); color: var(--text-2); margin-top: 6px; line-height: var(--lh-snug); text-wrap: pretty; }

.card-foot {
  position: sticky; bottom: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  margin: var(--sp-6) -28px 0; padding: 14px 28px; border-top: 1px solid var(--border);
  background: var(--surface); border-radius: 0 0 var(--r-md) var(--r-md);
}
.foot-left, .foot-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.foot-right { flex: none; }
.foot-secondary { display: none; align-items: center; gap: 4px; padding-left: 10px; border-left: 1px solid var(--border); }
.foot-secondary .btn-icon { width: 36px; height: 36px; border-radius: 50%; }
.btn-back { padding: 0 var(--sp-3); color: var(--text-2); font-weight: var(--fw-semibold); }
.btn-back:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-back:disabled { color: var(--text-3); }
.foot-total { display: none; font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.foot-total strong { color: var(--heading); font-size: var(--fs-lg); font-weight: var(--fw-extrabold); }
.btn-save { display: none; }
.contract-form[data-step="4"] .btn-next { display: none; }
.contract-form[data-step="4"] .btn-save { display: inline-flex; }
.contract-form[data-step="4"] .foot-secondary { display: flex; }
/* Липкий подвал настроек */
.page-foot { position: sticky; bottom: 0; margin: 0; border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.page-foot .field-msg { margin: 0; }
.page-foot .field-msg:not(:empty) { color: var(--ok); }

@keyframes step-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes rise { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ============================================================================
   СЕТКА ПОЛЕЙ (12 колонок) И ПОЛЯ
   ========================================================================== */
.grid { display: grid; grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr)); column-gap: var(--grid-gap-x); row-gap: var(--grid-gap-y); }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; } .c12 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; min-width: 0; }
.field > label, .field-group > legend {
  display: block; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-2); line-height: 20px;
  margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field-group > legend { float: left; width: 100%; }
.field-group > legend + * { clear: both; }
/* Обязательность не помечается: она проверяется при переходе; необязательные подписаны «(ixtiyoriy)» */
.input {
  width: 100%; height: var(--control-h); padding: 0 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-input); border-radius: var(--r-sm);
  font-family: var(--font-ui); font-size: var(--fs-md); line-height: calc(var(--control-h) - 2px);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.input[data-kind], .input.mono { font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.input:hover:not([readonly]):not(:disabled) { border-color: var(--border-strong); }
.input:focus-visible { border-color: var(--focus-ring); }
.input-caps { text-transform: uppercase; }
.input-caps::placeholder { text-transform: none; }
.textarea { height: auto; min-height: 96px; padding: 12px 14px; line-height: var(--lh-base); resize: vertical; }
.select {
  padding-right: var(--sp-8); appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 21px, calc(100% - 14px) 21px; background-size: 5px 5px; background-repeat: no-repeat;
}
input[type="date"].input { padding-right: var(--sp-2); font-family: var(--font-ui); font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
input[type="number"].input { -moz-appearance: textfield; appearance: textfield; }
input[type="search"].input { -webkit-appearance: none; appearance: none; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { flex: 1; }
.input-suffix .input { padding-right: var(--sp-8); }
.input-suffix .suffix { position: absolute; right: 14px; color: var(--text-3); font-size: var(--fs-sm); pointer-events: none; }

/* Подсказка под полем скрыта; показывается, пока поле в фокусе или в состоянии ошибки/предупреждения.
   Исключение — подсказка с кнопкой (согласие: «matnni ko‘rish») — всегда видна. */
.field-hint { display: none; font-size: var(--fs-xs); color: var(--text-2); line-height: 18px; margin-top: 6px; }
.field:focus-within > .field-hint, .field.is-error > .field-hint, .field.is-warn > .field-hint,
.field-group:focus-within .field-hint, .field-group.is-error .field-hint, .field-group.is-warn .field-hint,
.field-hint:has(button) { display: block; }
.field-hint.mono { font-variant-numeric: tabular-nums; }
.field-msg { display: none; font-size: var(--fs-xs); line-height: 18px; margin-top: 6px; }
.field-msg:not(:empty) { display: flex; align-items: flex-start; gap: 5px; }
.field-msg:not(:empty)::before { content: "▲"; font-size: 9px; line-height: 18px; flex: none; }

/* Автозаполненное поле — только светлая подложка, без чипа «avto» */
.field.is-auto .input { background: var(--auto-bg); }

.field.is-error .input { border-color: var(--error-border); background: var(--error-bg); }
.field.is-error .field-msg, .field-group.is-error .field-msg { color: var(--error); }
.field.is-error > label, .field-group.is-error > legend { color: var(--error); }
.field.is-warn .input { border-color: var(--warn-border); background: var(--warn-bg); }
.field.is-warn .field-msg, .field-group.is-warn .field-msg { color: var(--warn); }
.field.is-warn > label, .field-group.is-warn > legend { color: var(--warn); }

.input[readonly] { background: var(--surface-ro); border-color: var(--border); color: var(--text-2); cursor: default; }
.field.is-auto .input[readonly] { background: var(--auto-bg); color: var(--text); }
.input:disabled { opacity: 0.55; cursor: not-allowed; }

/* Радио-группы — pill-сегменты 36 px; выбранная — розовая подложка, красная рамка, красный текст */
.radio-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); clear: both; }
.radio {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: var(--control-h-sm); padding: 0 var(--sp-4);
  border: 1px solid var(--border-input); border-radius: var(--r-pill); background: var(--surface);
  color: var(--text); font-size: var(--fs-md); font-weight: var(--fw-semibold);
  cursor: pointer; user-select: none; line-height: 1.2; white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.radio:hover { border-color: var(--primary); color: var(--primary-text); }
.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.radio:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-text); }
.radio:has(input:focus-visible) { outline: var(--focus-width) solid var(--focus-ring); outline-offset: var(--focus-offset); box-shadow: var(--focus-shadow); }
.radio .pct { color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.radio:has(input:checked) .pct { color: var(--primary-text); }
.field-group.is-error .radio:not(:has(input:checked)) { border-color: var(--error-border); }
.field-group.is-warn .radio:not(:has(input:checked)) { border-color: var(--warn-border); }

/* Чекбокс */
.check, .field > label.check {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  font-size: var(--fs-md); font-weight: var(--fw-regular); color: var(--text); line-height: var(--lh-base);
  white-space: normal; overflow: visible; text-overflow: clip; margin-bottom: 0;
}
.check input { margin: 3px 0 0; width: 18px; height: 18px; flex: none; }
.check-lg { font-size: var(--fs-md); }
.field.is-error .check { color: var(--error); }
.field-check-align { justify-content: flex-end; padding-bottom: 8px; }

/* Условная видимость по скидке: app.js ставит data-discount на форму */
.field[data-visible-for] { display: none; }
.contract-form[data-discount="ORDER"] .field[data-visible-for~="ORDER"],
.contract-form[data-discount="SIBLINGS"] .field[data-visible-for~="SIBLINGS"],
.contract-form[data-discount="CORPORATE"] .field[data-visible-for~="CORPORATE"],
.contract-form[data-discount="GRANT"] .field[data-visible-for~="GRANT"] { display: flex; }
.contract-form:not([data-discount="ORDER"]) .field[data-for="discount.note"] { grid-column: 1 / -1; }

/* ---------- Карточка «найден в базе» — результат поиска с аватаром ---------- */
.found-card {
  display: none; gap: 16px; align-items: flex-start; padding: 16px 18px;
  background: var(--ok-bg); border: 0; border-radius: var(--r-md);
  animation: rise var(--dur-base) var(--ease);
}
.found-card[data-state="found"], .found-card[data-state="rejected"] { display: flex; }
.found-card[data-state="rejected"] { background: var(--surface-2); }
.found-card[data-state="rejected"] .avatar { background: var(--surface); color: var(--text-3); }
.found-card[data-state="rejected"] .found-actions [data-action="found-apply"] { display: none; }
.found-body { flex: 1; min-width: 0; }
.found-card .avatar-lg { width: 44px; height: 44px; }
.found-name { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--heading); line-height: 1.25; overflow-wrap: anywhere; }
.found-meta { color: var(--text-2); font-size: var(--fs-md); margin-top: 4px; }
.found-meta:has([data-found="role"]:empty) .found-role-dot { display: none; }
.found-children { margin-top: 6px; font-size: var(--fs-md); }
.found-children:has([data-found="children"]:empty) { display: none; }
.found-child { display: inline; }
.found-child + .found-child::before { content: " · "; color: var(--text-3); }
.found-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.found-actions .btn-primary.btn-sm:hover:not(:disabled) { transform: translateY(-1px); }

/* ---------- Сводка шага 4 ---------- */
.review { display: flex; flex-direction: column; gap: var(--sp-5); }
.review-title {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-2);
  padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-1);
}
.review-edit { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); letter-spacing: 0; text-transform: none; color: var(--primary-text); text-decoration: none; border-radius: var(--r-sm); padding: 2px 6px; }
.review-edit:hover { background: var(--primary-tint); }
.review-rows { display: flex; flex-direction: column; }
.review-row { display: grid; grid-template-columns: 40% minmax(0, 1fr); gap: var(--sp-3); align-items: baseline; min-height: 44px; padding: 10px 10px; margin: 0 -10px; border-radius: var(--r-sm); border-bottom: 1px solid var(--border); }
.review-row:last-child { border-bottom: 0; }
.review-row dt { font-size: var(--fs-sm); color: var(--text-2); }
.review-row dd { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--text); overflow-wrap: anywhere; }
.review-row dd.mono { font-size: var(--fs-md); }
.review-row dd.is-empty { color: var(--text-3); font-weight: var(--fw-regular); }
.review-row-total dd { font-weight: var(--fw-extrabold); color: var(--heading); font-size: var(--fs-lg); }
.review-row.is-error { background: var(--error-bg); }
.review-row.is-error dd { color: var(--error); }
.review-err { display: block; font-size: var(--fs-sm); font-weight: var(--fw-regular); color: var(--error); margin-top: 2px; }
.review-err a { color: var(--error); font-weight: var(--fw-semibold); }

/* Согласие: подсекция с левой полосой (жёлтая → зелёная после отметки) */
.review-consent { margin-top: var(--sp-6); padding: var(--sp-4) 0 0 var(--sp-4); border-top: 1px solid var(--border); box-shadow: inset 3px 0 0 var(--warn-border); }
.review-consent.is-consented { box-shadow: inset 3px 0 0 var(--ok-border); }
.review-consent .subsection-title { margin-bottom: var(--sp-3); }
.consent-grid { margin-top: var(--sp-4); }
.consent-text { margin-top: var(--sp-4); border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.consent-text > summary { cursor: pointer; font-size: var(--fs-md); color: var(--primary-text); font-weight: var(--fw-semibold); }
.consent-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); margin-top: var(--sp-3); }
.consent-doc { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; }
.consent-doc h4 { font-size: var(--fs-sm); color: var(--heading); margin-bottom: var(--sp-2); letter-spacing: 0.02em; }
.consent-doc p { margin-bottom: var(--sp-2); }
.consent-doc b { color: var(--text); font-weight: var(--fw-semibold); }

/* ---------- Список ошибок текущего шага ---------- */
.issues {
  display: none; margin: var(--sp-5) 0 0; padding: var(--sp-3) var(--sp-4);
  background: var(--error-bg); border: 1px solid color-mix(in srgb, var(--error-border) 35%, transparent); border-left: 4px solid var(--error-border);
  border-radius: var(--r-sm);
}
.issues:not([data-errors="0"]), .issues:not([data-warns="0"]) { display: block; }
.issues[data-errors="0"]:not([data-warns="0"]) { border-left-color: var(--warn-border); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-border) 35%, transparent); }
.issues-title { font-size: var(--fs-md); font-weight: var(--fw-bold); margin-bottom: var(--sp-1); color: var(--error); }
.issues[data-errors="0"] .issues-title { color: var(--warn); }
.issues-list { display: flex; flex-direction: column; gap: 2px; }
.issue { display: flex; align-items: center; gap: var(--sp-2); }
.issue-btn {
  flex: 1; display: flex; align-items: flex-start; gap: var(--sp-2); text-align: left;
  padding: var(--sp-1) var(--sp-2); margin-left: calc(-1 * var(--sp-2));
  background: none; border: 0; border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-md); line-height: 1.4;
}
.issue-btn:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); text-decoration: underline; text-underline-offset: 2px; }
.issue-icon { margin-top: 1px; color: var(--error); }
.issue[data-level="warn"] .issue-icon { color: var(--warn); }
.issue-field { color: var(--text-2); white-space: nowrap; }
.issue-field:not(:empty)::after { content: ":"; }
.issue-fix { height: 32px; font-size: var(--fs-sm); }

/* ============================================================================
   КАРТОЧКА РАСЧЁТА — белая, красная полоса сверху; compact (шаги 1–2) / full (3–4)
   ========================================================================== */
.calc {
  position: sticky; top: calc(var(--topbar-h) + var(--sp-5));
  /* Помещается целиком на 1366×768 без прокрутки страницы: под топбаром и stepper; иначе прокручивается .calc-body, Jami всегда виден */
  max-height: calc(100vh - var(--topbar-h) - var(--stepper-h) - var(--sp-5) - var(--sp-6) - var(--sp-4));
  display: flex; flex-direction: column;
  background: var(--surface); border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden;
}
.calc::before { content: ""; display: block; flex: none; height: var(--calc-stripe-h); background: var(--grad-primary); }
.calc-head { flex: none; padding: 14px var(--sp-5) 12px; border-bottom: 1px solid var(--border); }
.calc-title { font-size: var(--fs-lg); font-weight: var(--fw-extrabold); line-height: var(--lh-tight); letter-spacing: 0; color: var(--heading); }
.calc-title .mono { font-weight: var(--fw-bold); }
.calc-brief { display: none; flex-direction: column; }
.calc[data-calc-mode="compact"] .calc-brief { display: flex; }
.calc[data-calc-mode="compact"] .calc-full { display: none; }
.kv-list { padding: var(--sp-2) var(--sp-5) 0; display: flex; flex-direction: column; }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); font-size: var(--fs-md); padding: 10px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--text-2); font-size: var(--fs-sm); }
.kv dd { font-weight: var(--fw-semibold); color: var(--text); text-align: right; white-space: nowrap; }
.kv-accent dd { color: var(--primary-text); }
.kv-step2 { display: none; }
.calc[data-step="2"] .kv-step2 { display: flex; }
.calc-kids { display: flex; flex-direction: column; gap: 6px; padding: 0 var(--sp-5); }
.calc-kids:not(:empty) { padding-top: var(--sp-3); }
.calc-brief { padding-bottom: var(--sp-4); }
.kid { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.kid .avatar { width: 36px; height: 36px; font-size: var(--fs-sm); }
.kid-lines { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.kid-name { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kid-meta { font-size: var(--fs-sm); color: var(--text-2); }

.calc-full { display: flex; flex-direction: column; min-height: 0; }
.calc-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--sp-3) var(--sp-5) var(--sp-2); }
.calc-sub { font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.calc-rows { display: flex; flex-direction: column; gap: 0; margin-bottom: 10px; }
.calc-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-md); line-height: 25px; }
.calc-row dt { color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; }
.calc-row dd { white-space: nowrap; color: var(--text); font-weight: var(--fw-medium); }
.calc-row-lg dd { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--heading); }

.schedule { width: 100%; font-size: var(--fs-table); border-top: 1px solid var(--border); }
.schedule th {
  text-align: left; font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--text-2); padding: 6px var(--sp-1) 4px; border-bottom: 1px solid var(--border);
}
.schedule td { padding: 0 var(--sp-1); height: 26px; border-bottom: 1px solid var(--border-light); vertical-align: middle; white-space: nowrap; }
.schedule tbody tr:last-child td { border-bottom: 0; }
.schedule .note { display: block; font-size: var(--fs-2xs); color: var(--primary-text); line-height: 1.1; }
.schedule .note:empty { display: none; }
.schedule tr.is-prorated td { background: var(--primary-tint); height: 38px; }
.schedule tr.is-prorated td:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.schedule tr.is-prorated td:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.schedule tr.is-zero td { color: var(--text-3); }
.schedule .mono { color: var(--text-2); font-size: var(--fs-sm); }
.schedule .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums ; }

.calc-foot { flex: none; padding: 10px var(--sp-5) 14px; border-top: 2px solid var(--heading); background: var(--surface); }
.calc-total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.calc-total-label { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-2); }
.calc-total-value { font-size: var(--fs-3xl); font-weight: var(--fw-extrabold); line-height: 1; letter-spacing: 0; white-space: nowrap; color: var(--heading); }
.calc-total-value .cur { font-size: var(--fs-md); font-weight: var(--fw-regular); color: var(--text-2); font-family: var(--font-ui); letter-spacing: 0; }

/* ============================================================================
   РЕЕСТР
   ========================================================================== */
.toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "search search" "filters actions"; gap: var(--sp-3) var(--sp-4); align-items: center;
  padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4);
  background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.search { grid-area: search; position: relative; display: flex; align-items: center; min-width: 0; color: var(--text-3); }
.search svg { position: absolute; left: 14px; pointer-events: none; }
.search .input { padding-left: 44px; color: var(--text); border-radius: var(--r-pill); }
.filters { grid-area: filters; display: flex; flex-wrap: wrap; gap: var(--sp-2); min-width: 0; }
.filter .select {
  width: auto; min-width: 0; height: var(--control-h-sm); line-height: 38px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); border-radius: var(--r-pill);
  background-color: var(--surface-2); border-color: transparent; color: var(--text-2); padding-left: var(--sp-4); padding-right: 32px;
  background-position: calc(100% - 19px) 17px, calc(100% - 14px) 17px;
}
/* select с width:auto растёт до самой длинной опции — ограничиваем, чтобы 4 фильтра + 3 кнопки умещались в одну строку на 1366 */
.filter .select[data-filter="grade"] { max-width: 152px; }
.filter .select[data-filter="status"] { max-width: 160px; }
.filter .select[data-filter="discount"] { max-width: 182px; }
.filter .select[data-filter="lang"] { max-width: 146px; }
.filter .select:hover { border-color: var(--border-input); }
.filter .select:not(:has(option[value=""]:checked)) { background-color: var(--primary-tint); color: var(--primary-text); border-color: var(--primary); }
.toolbar-actions { grid-area: actions; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); justify-content: flex-end; }
.toolbar-actions .btn { height: var(--control-h-sm); font-size: var(--fs-sm); padding: 0 var(--sp-4); }
/* Меню «⋯» (details без JS): Zaxira / Tiklash */
.menu { position: relative; }
.menu > summary { list-style: none; width: 44px; padding: 0; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--surface-2); border-color: var(--border-strong); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-dropdown); min-width: 230px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-2);
}
.menu-item {
  display: flex; align-items: center; height: 44px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--text); font-size: var(--fs-md); font-weight: var(--fw-semibold); text-align: left; white-space: nowrap; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.stat {
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 14px 18px; min-width: 0;
  background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.stat-wide { grid-column: span 2; }
.stat-label { font-size: var(--fs-2xs); font-weight: var(--fw-bold); color: var(--text-2); text-transform: uppercase; letter-spacing: var(--tracking-caps); line-height: 1.25; }
.stat-value { font-size: var(--fs-2xl); font-weight: var(--fw-extrabold); line-height: 1.1; color: var(--heading); white-space: nowrap; }
.stat-muted { border-style: dashed; box-shadow: none; }
.stat-muted .stat-value { color: var(--text-2); font-weight: var(--fw-medium); }

.import-report { margin-bottom: var(--sp-4); background: var(--surface); border: 0; border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-md); box-shadow: var(--shadow-1); }
.import-report > summary { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-weight: var(--fw-bold); color: var(--heading); }
.import-legend { display: flex; gap: var(--sp-2); margin: var(--sp-2) 0; }
.import-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; }
.import-item { display: flex; gap: var(--sp-2); padding: 2px 0; }
.import-item[data-level="error"] .import-row { color: var(--error); }
.import-item[data-level="warn"] .import-row { color: var(--warn); }
.import-row { min-width: 56px; }

.table-wrap { overflow: auto; background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.roster-table { width: 100%; font-size: var(--fs-table); }
.roster-table th {
  position: sticky; top: 0; z-index: 1; text-align: left; height: 44px; padding: 0 var(--sp-3);
  background: var(--surface-2); color: var(--text-2); font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.roster-table th.num { text-align: right; }
.roster-table th[data-sort] { cursor: pointer; }
.roster-table th[aria-sort]::after { content: " ↑"; color: var(--text-3); }
.roster-table th[aria-sort="descending"]::after { content: " ↓"; }
.roster-table td { height: var(--row-h); padding: 0 10px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.roster-table td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums ; }
.roster-table td[data-col="monthly"] { font-weight: var(--fw-bold); font-size: var(--fs-md); }
.roster-table td[data-col="no"] { color: var(--text-2); }
.roster-table tbody tr:hover td { background: var(--bg); }
.roster-table tbody tr[data-status="CANCELLED"] td { color: var(--text-3); }
.roster-table tbody tr[data-status="CANCELLED"] .cell-main { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.roster-table tbody tr[data-status="CANCELLED"] .avatar { background: var(--surface-2); color: var(--text-3); }
.roster-table tbody tr:last-child td { border-bottom: 0; }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-lines { display: flex; flex-direction: column; min-width: 0; }
.cell-main { display: block; line-height: 1.25; font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--heading); }
.roster-table td[data-col="parent"] .cell-main { font-size: var(--fs-table); font-weight: var(--fw-medium); color: var(--text); }
.cell-sub { display: block; font-size: var(--fs-xs); color: var(--text-2); line-height: 1.25; margin-top: 2px; }
/* Под ФИО родителя маскированный ЖШШИР не показываем (элемент остаётся для app.js); скидка — только процент чипом */
.roster-table td[data-col="parent"] [data-col="parentPinfl"] { display: none; }
.roster-table td[data-col="discount"] [data-col="discountName"] { display: none; }
.roster-table td[data-col="discount"] [data-col="discountPct"]:not(:empty) {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--r-pill); margin: 0;
  background: var(--primary-tint); color: var(--primary-text); font-size: var(--fs-2xs); font-weight: var(--fw-bold); line-height: 1;
}
/* Имена и название скидки переносятся на 2 строки, остальные колонки — без переноса */
.roster-table td[data-col="student"], .roster-table td[data-col="parent"] { white-space: normal; padding-top: 6px; padding-bottom: 6px; }
.roster-table td[data-col="student"] { width: 25%; min-width: 190px; }
.roster-table td[data-col="parent"] { width: 19%; min-width: 150px; }
.roster-table td[data-col="discount"] { width: 1%; }
.roster-table th:first-child, .roster-table td:first-child { padding-left: var(--sp-4); }
.roster-table td.mono { font-size: var(--fs-table); }
.masked { color: var(--text-2); cursor: default; }
.masked[tabindex]:focus-visible { color: var(--text); }
.actions-col { text-align: right; width: 1%; }
.roster-table .actions-col { white-space: nowrap; padding-right: var(--sp-2); }
.roster-table .actions-col .btn-icon + .btn-icon { margin-left: 2px; }

.roster:has(#roster-body:empty) .table-wrap { display: none; }
/* «Kim tuzgan» и фильтр по оператору — только в «Barcha shartnomalar» (admin); чтобы 9 колонок умещались на 1366, статус и автор переносятся */
.roster:not([data-scope="all"]) [data-col="createdBy"], .roster:not([data-scope="all"]) [data-scope="all"] { display: none; }
.roster[data-scope="all"] .roster-table td[data-col="createdBy"] { white-space: normal; min-width: 140px; max-width: 190px; padding-top: 6px; padding-bottom: 6px; }
.roster[data-scope="all"] .roster-table td[data-col="status"] { white-space: normal; max-width: 130px; }
.roster[data-scope="all"] .roster-table td[data-col="status"] .chip + .chip { margin-top: 4px; }
.roster[data-scope="all"] .roster-table td[data-col="student"] { width: 22%; min-width: 170px; }
.roster[data-scope="all"] .roster-table td[data-col="parent"] { width: 17%; min-width: 140px; }
.roster-table tbody tr[data-id] { cursor: pointer; }
.roster-table tbody tr[data-id]:focus-visible { outline-offset: -2px; }
.roster-table td[data-col="createdBy"] .cell-main { font-size: var(--fs-table); font-weight: var(--fw-medium); color: var(--text); }
/* Пагинация */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-3); padding: 0 var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.pager-btns { display: flex; gap: var(--sp-2); }
.pager .btn-sm { height: 36px; font-size: var(--fs-sm); }
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center;
  padding: var(--sp-12) var(--sp-4); color: var(--text-2);
  background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.empty-icon { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); margin-bottom: var(--sp-2); }
.empty-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--heading); }
.empty-text { font-size: var(--fs-md); color: var(--text-2); max-width: 420px; }
.empty-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); flex-wrap: wrap; justify-content: center; }
.empty-inline { color: var(--text-3); font-size: var(--fs-md); padding: var(--sp-2) 0; }

/* Сканы документов (мастер: .doc-field на шагах 1–2; карточка договора: #dr-files-group). Тихий блок: пунктирная рамка, pill-кнопка, строка файла */
.doc-box {
  display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  border: 1px dashed var(--border-input); border-radius: var(--r-md); background: var(--surface);
}
.doc-box[data-state="filled"] { border-style: solid; border-color: var(--border); }
.doc-empty { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.doc-hint { font-size: var(--fs-sm); color: var(--text-2); }
.doc-box[data-state="filled"] .doc-hint { display: none; }
.doc-field[data-busy="1"] .doc-pick { opacity: 0.6; pointer-events: none; }
.doc-list { display: flex; flex-direction: column; list-style: none; margin: 0; padding: 0; }
.doc-list:empty { display: none; }
.doc-item { display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: 0; }
.doc-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); }
.doc-lines { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.doc-name { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--heading); line-height: 1.25; overflow-wrap: anywhere; }
.doc-meta { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.3; margin-top: 2px; }
.doc-actions { display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.doc-actions .btn-sm { height: 36px; padding: 0 var(--sp-3); }
.field.is-warn .doc-box { border-color: var(--warn-border); }
/* Карточка договора: список + строка загрузки (тип + pill) */
#dr-files-group .doc-list { margin-top: var(--sp-1); }
.doc-add { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.doc-add .input { flex: 1 1 auto; min-width: 0; height: 40px; font-size: var(--fs-sm); }
.doc-add .btn { flex: none; }
/* Скрепка в реестре: есть прикреплённые файлы */
.roster-table .cell-main { display: flex; align-items: center; gap: 6px; }
.clip { display: inline-flex; flex: none; color: var(--text-2); }
.clip[hidden] { display: none; }

/* Чипы статусов / счётчики */
.chip {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.chip-ok, .chip[data-status="ACTIVE"] { background: var(--ok-bg); color: var(--ok); }
.chip-error, .chip[data-status="CANCELLED"] { background: var(--error-bg); color: var(--error); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-auto { background: var(--auto-bg); color: var(--auto); }
.chip-accent { background: var(--primary-tint); color: var(--primary-text); }
.chip.mono { text-transform: none; }

/* ============================================================================
   НАСТРОЙКИ / О ПРОГРАММЕ — карточки с заголовком и описанием
   ========================================================================== */
.settings, .about { display: flex; flex-direction: column; gap: var(--sp-4); max-width: 1000px; }
.card-plain { background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1); padding: var(--sp-6) 28px; }
.card-plain > legend.card-head { float: left; width: 100%; display: flex; flex-direction: column; margin-bottom: var(--sp-5); }
.card-plain > legend + * { clear: both; }
.card-plain .step-title::after { margin-top: var(--sp-2); }
.card-plain > .grid + .subsection { clear: both; }
.card-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--tracking-h2); color: var(--heading); }
.card-title::after { content: ""; display: block; width: var(--heading-line-w); height: var(--heading-line-h); background: var(--primary); border-radius: 2px; margin-top: var(--sp-2); }
.card-title + .section-desc { margin: 6px 0 var(--sp-4); }
.subsection { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.subsection-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--heading); }
.subsection-warn { box-shadow: inset 3px 0 0 var(--warn-border); padding-left: var(--sp-4); }
.subsection .section-desc { margin: 4px 0 var(--sp-4); }
.subsection .grid { margin-bottom: var(--sp-4); }
.subsection .check { margin-bottom: var(--sp-3); }
.subsection .field-msg { margin-bottom: var(--sp-2); }
.subsection .field-msg:not(:empty) { color: var(--ok); }
.about-grid { align-items: start; }
.about-grid > .section { min-width: 0; }
.kv-about, .about .kv { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-md); }
.about .kv > div { display: grid; grid-template-columns: minmax(110px, 150px) minmax(0, 1fr); gap: var(--sp-3); align-items: baseline; padding: 0; border: 0; }
.about .kv dt { color: var(--text-2); }
.about .kv dd { min-width: 0; overflow-wrap: anywhere; word-break: break-word; white-space: normal; font-weight: var(--fw-medium); text-align: left; }
.hash { font-size: var(--fs-xs); word-break: break-all; overflow-wrap: anywhere; }
.template-status { margin-bottom: var(--sp-3); }
.template-status[data-state="mismatch"] .chip { background: var(--error-bg); color: var(--error); }
.template-status[data-state="checking"] .chip { background: var(--surface-2); color: var(--text-2); }
.about .subsection-title { margin: var(--sp-4) 0 var(--sp-2); }
.rules { display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-md); color: var(--text-2); list-style: disc; padding-left: var(--sp-5); }
.log-table td { height: 48px; }
.about-logo { display: flex; align-items: center; gap: var(--sp-3); color: var(--primary); margin-bottom: var(--sp-4); }
.about-logo .logo-full { height: 40px; }

/* ============================================================================
   КАРТОЧКА ДОГОВОРА — панель справа 520 px (html[data-drawer="open"]), поверх оверлея
   ========================================================================== */
.drawer-overlay { position: fixed; inset: 0; z-index: calc(var(--z-lock) - 2); background: var(--overlay); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-lock) - 1); width: var(--drawer-w); max-width: 100vw;
  display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-3); animation: drawer-in var(--dur-base) var(--ease);
}
.drawer::before { content: ""; display: block; flex: none; height: var(--calc-stripe-h); background: var(--grad-primary); }
.drawer-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-4); border-bottom: 1px solid var(--border); }
.drawer-titles { min-width: 0; }
.drawer-kicker { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-2); }
.drawer-kicker .mono { color: var(--text); font-weight: var(--fw-bold); }
.drawer-title { font-size: var(--fs-xl); font-weight: var(--fw-extrabold); letter-spacing: var(--tracking-h1); color: var(--heading); margin-top: 4px; overflow-wrap: anywhere; }
.drawer-sub { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.drawer-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--sp-4) var(--sp-6) var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-5); }
.drawer-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.dr-group .review-title { margin-bottom: 0; }
.dr-group .review-row { min-height: 40px; padding: 8px 10px; }
.dr-group .schedule { margin-top: var(--sp-2); border-top: 0; }
.dr-total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 2px solid var(--heading); font-size: var(--fs-md); color: var(--text-2); }
.dr-total strong { font-size: var(--fs-2xl); font-weight: var(--fw-extrabold); color: var(--heading); margin-left: auto; }
.dr-total .cur { font-size: var(--fs-sm); }
.history { display: flex; flex-direction: column; margin-top: var(--sp-2); }
.history-item { display: grid; grid-template-columns: 118px minmax(0, 1fr); column-gap: var(--sp-3); row-gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.history-item:last-child { border-bottom: 0; }
.history-time { color: var(--text-2); grid-row: 1 / span 3; }
.history-who { font-weight: var(--fw-semibold); color: var(--heading); }
.history-what { color: var(--text); }
.history-details { color: var(--text-2); font-size: var(--fs-xs); overflow-wrap: anywhere; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================================
   DASHBOARD (admin): KPI-плитки + графики inline-SVG (тихие столбцы, красный — только акцент)
   ========================================================================== */
.dash { display: flex; flex-direction: column; gap: var(--sp-4); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; min-width: 0; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.kpi-label { font-size: var(--fs-2xs); font-weight: var(--fw-bold); color: var(--text-2); text-transform: uppercase; letter-spacing: var(--tracking-caps); line-height: 1.25; }
.kpi-value { font-size: var(--fs-2xl); font-weight: var(--fw-extrabold); line-height: 1.1; color: var(--heading); white-space: nowrap; font-variant-numeric: proportional-nums; }
.kpi-money .kpi-value { font-size: var(--fs-xl); }
.kpis .kpi:nth-child(n+5) { grid-column: span 1; }
.kpis .kpi-money:nth-child(5) { grid-column: 1 / span 2; }
.dash-grid { align-items: start; row-gap: var(--sp-4); }
.dash-card { min-width: 0; padding: var(--sp-5) 28px var(--sp-5); }
.dash-card .card-title { font-size: var(--fs-lg); }
.dash-card .card-title::after { display: none; }
.dash-card .card-title + .section-desc { margin: 2px 0 var(--sp-3); font-size: var(--fs-sm); }
.chart { width: 100%; min-height: 200px; }
.chart-h { min-height: 120px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-ui); }
.ch-bar { fill: var(--chart-bar); }
.ch-bar-g:hover .ch-bar { fill: var(--chart-bar-hover); }
.ch-bar-accent { fill: var(--primary); }
.ch-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.ch-axis { stroke: var(--border-input); stroke-width: 1; shape-rendering: crispEdges; }
.ch-tick { fill: var(--text-2); font-size: 13px; }
.ch-label { fill: var(--text); font-size: 13px; font-weight: var(--fw-medium); }
.ch-value { fill: var(--heading); font-size: 13px; font-weight: var(--fw-bold); }
.ch-muted { fill: var(--text-3); font-weight: var(--fw-regular); }
.dash-table { width: 100%; }
.dash-table th { height: 40px; }
.dash-table td { height: 44px; }
.dash-table td.mono { color: var(--text-2); font-size: var(--fs-sm); }
.dash-table tbody tr.is-link { cursor: default; }
.meter { display: inline-block; vertical-align: middle; width: 140px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-right: 10px; }
.meter-fill { display: block; height: 100%; border-radius: 4px; background: var(--chart-bar); }
.meter-pct { font-size: var(--fs-sm); color: var(--text-2); }
.attention { display: flex; flex-direction: column; }
.attention-item { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--border); }
.attention-item:last-child { border-bottom: 0; }
.dash:has(#dash-attention:empty) #dash-attention-empty { display: block; }

/* ============================================================================
   ОПЕРАТОРЫ / ЖУРНАЛ (admin)
   ========================================================================== */
.users, .audit { display: flex; flex-direction: column; gap: var(--sp-4); }
.toolbar-simple { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "text actions"; }
.toolbar-text { grid-area: text; font-size: var(--fs-md); color: var(--text-2); }
.toolbar-filters { grid-template-columns: minmax(0, 1fr); grid-template-areas: "filters"; }
.filter-date .input { width: 160px; height: var(--control-h-sm); line-height: 38px; font-size: var(--fs-sm); border-radius: var(--r-pill); background-color: var(--surface-2); border-color: transparent; color: var(--text-2); padding: 0 var(--sp-4); }
.filter .select[data-afilter="user"] { max-width: 260px; }
.filter .select[data-afilter="action"] { max-width: 240px; }
.users-table td, .audit-table td { height: 52px; }
.users-table .actions-col .btn-icon + .btn-icon { margin-left: 2px; }
.audit-table td.audit-details { white-space: normal; max-width: 520px; font-size: var(--fs-sm); color: var(--text-2); }
.users-table tr[data-active="0"] .cell-main, .users-table tr[data-active="0"] td[data-col="login"] { color: var(--text-3); }
.input-actions .input { padding-right: 84px; }
.input-actions .btn-icon { position: absolute; top: 6px; }
.input-actions [data-action="gen-pass"] { right: 42px; }
.input-actions [data-action="copy-pass"] { right: 6px; }
.secret { display: flex; align-items: center; gap: var(--sp-3); padding: 12px 14px; background: var(--surface-2); border-radius: var(--r-sm); }
.secret-value { flex: 1; font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: 0.06em; color: var(--heading); overflow-wrap: anywhere; }
.settings-readonly { font-size: var(--fs-md); color: var(--text-2); padding: 0 var(--sp-2); }
#export-pass-field { margin-top: var(--sp-1); }

/* ============================================================================
   ДИАЛОГИ
   ========================================================================== */
.dialog {
  width: 480px; max-width: calc(100vw - var(--sp-8)); padding: 0; border: 0;
  border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3);
}
.dialog::backdrop { background: var(--overlay); }
.dialog-form { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-6); }
.dialog-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--tracking-h2); color: var(--heading); }
.dialog-title::after { content: ""; display: block; width: 40px; height: var(--heading-line-h); background: var(--primary); border-radius: 2px; margin-top: var(--sp-2); }
.dialog-text, .dialog-note { font-size: var(--fs-md); color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-2); }
.dialog .radio-col { display: flex; flex-direction: column; gap: var(--sp-2); clear: both; }
.dialog .radio-col .radio { align-self: flex-start; height: auto; min-height: var(--control-h-sm); padding: 6px var(--sp-4); white-space: normal; }

/* ============================================================================
   ЭКРАН БЛОКИРОВКИ — светлая страница, белая карточка по центру
   ========================================================================== */
.lock {
  position: fixed; inset: 0; z-index: var(--z-lock);
  display: grid; grid-template-rows: 1fr auto; background: var(--bg); overflow: auto;
}
.lock-center { display: grid; place-items: center; padding: var(--sp-8) var(--sp-4); }
.lock-card {
  width: 400px; max-width: 100%; padding: var(--sp-8);
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); border: 0;
}
.lock-brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); color: var(--primary); }
.lock-brand .logo-sign { width: 48px; height: 64px; }
.lock-brand .brand-text { line-height: 1.15; }
.lock-brand .brand-school { color: var(--heading); font-size: var(--fs-lg); font-weight: var(--fw-extrabold); letter-spacing: 0.02em; }
.lock-brand .brand-app { color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: 0; }
.lock-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.lock[data-mode="setup"] #lock-unlock { display: none; }
.lock[data-mode="unlock"] #lock-setup { display: none; }
.lock-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--tracking-h2); color: var(--heading); }
.lock-text { font-size: var(--fs-md); color: var(--text-2); }
.lock-form .btn-primary { height: var(--control-h-lg); margin-top: var(--sp-1); font-size: var(--fs-md); font-weight: var(--fw-bold); }
.lock-forgot { margin: var(--sp-3) 0 0; text-align: center; }
.lock-forgot .btn-text { font-size: var(--fs-sm); color: var(--text-3); white-space: normal; height: auto; padding: 6px var(--sp-3); }
.lock-forgot .btn-text:hover { color: var(--error); }
.lock-msg { display: none; font-size: var(--fs-md); color: var(--error); }
.lock-msg:not(:empty) { display: flex; gap: 6px; align-items: flex-start; }
.lock-msg:not(:empty)::before { content: "▲"; font-size: 9px; line-height: 20px; flex: none; }
.lock.is-shake .lock-card { animation: shake var(--dur-base) var(--ease); }
.lock-foot { display: flex; align-items: flex-start; gap: 6px; margin-top: var(--sp-5); font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; }
.lock-foot svg { margin-top: 1px; }

/* ============================================================================
   ФУТЕР — тёмный, как на сайте (внутри .content, не под aside)
   ========================================================================== */
.site-footer { background: var(--footer-bg); color: var(--footer-text); font-size: var(--fs-sm); }
.site-footer .footer-inner {
  max-width: var(--container-w); margin: 0 auto; min-height: 44px; padding: var(--sp-2) 28px;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
}
.footer-brand { display: inline-flex; align-items: center; gap: var(--sp-2); }
.footer-brand .logo-sign { width: 12px; height: 16px; color: var(--footer-text); }

/* ---------- Печать: скрыто на экране ---------- */
.print-root { display: none; }

/* ============================================================================
   АДАПТИВ
   ========================================================================== */
@media (max-width: 1240px) {
  .page { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .topbar { padding: 0 var(--sp-5); }
  #template-alert { margin-left: var(--sp-5); margin-right: var(--sp-5); }
}
/* ≤ 1180 px: aside сворачивается автоматически (Sidebar.js), карточка расчёта уже */
@media (max-width: 1180px) {
  .wizard { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-4); }
}
/* ≤ 1000 px: aside — выезжающая панель, сверху красная мобильная панель */
@media (max-width: 1000px) {
  .app, html[data-sidebar="collapsed"] .app { grid-template-columns: minmax(0, 1fr); }
  .content { grid-column: 1; }
  .sidebar, html[data-sidebar="collapsed"] .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; height: 100vh; padding: var(--sp-4) var(--sp-3);
    transform: translateX(-100%); box-shadow: none;
  }
  html[data-sidebar="collapsed"] .sidebar .nav-text, html[data-sidebar="collapsed"] .sidebar .brand-text, html[data-sidebar="collapsed"] .sidebar .nav-label { display: initial; }
  html[data-sidebar="collapsed"] .sidebar .sb-user-text { display: flex; }
  html[data-sidebar="collapsed"] .sidebar .nav-item { justify-content: flex-start; padding: 0 var(--sp-3); width: 100%; }
  html[data-sidebar="collapsed"] .sidebar .nav-count { position: static; width: auto; height: auto; padding: 0 7px; border-radius: var(--r-pill); font-size: var(--fs-2xs); line-height: 18px; background: var(--sidebar-hover); box-shadow: none; }
  html[data-sidebar="collapsed"] .sidebar .sb-user { justify-content: flex-start; padding: 6px 8px 10px; }
  html[data-sidebar="collapsed"] .sidebar .btn-lock { width: auto; padding: 0 var(--sp-3); }
  html[data-sidebar="collapsed"] .sidebar [data-tip]::after, html[data-sidebar="collapsed"] .sidebar [data-tip]::before { display: none; }
  html[data-sidebar="open"] .sidebar { transform: translateX(0); box-shadow: var(--sidebar-shadow); }
  .sidebar .btn-collapse { display: none; }
  .mobile-bar { display: flex; }
  .topbar { top: var(--topbar-h); height: 48px; padding: 0 var(--sp-4); }
  .topbar-title { display: none; }
  .topbar-sub { padding-left: 0; border-left: 0; }
  .wizard { grid-template-columns: minmax(0, 1fr); }
  .stepper, .step-card, .calc { grid-column: 1; }
  .calc { position: static; max-height: none; }
  .calc-body { overflow: visible; }
  .contract-form[data-step="3"] .foot-total, .contract-form[data-step="4"] .foot-total { display: inline-flex; gap: 6px; align-items: baseline; }
  .toast-area { right: var(--sp-4); bottom: 84px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings, .about { max-width: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi-money:nth-child(5) { grid-column: span 1; }
  .dash-grid .c6 { grid-column: 1 / -1; }
  .drawer { width: 100vw; }
  .history-item { grid-template-columns: minmax(0, 1fr); }
  .history-time { grid-row: auto; }
  .toolbar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "search" "filters" "actions"; }
  .toolbar-actions { justify-content: flex-start; }
}
@media (max-width: 720px) {
  .page { padding: var(--sp-4); }
  .c3, .c4, .c6, .c8 { grid-column: 1 / -1; }
  .consent-cols, .about-grid { grid-template-columns: minmax(0, 1fr); }
  .field > label, .field-group > legend { white-space: normal; }
  .stepper { height: 56px; padding: 0 var(--sp-3); }
  .step-txt { display: none; }
  .step[data-state="current"] .step-txt { display: flex; }
  .step { padding: 0 var(--sp-2); }
  .card-foot { flex-wrap: wrap; padding: 12px var(--sp-4); margin-left: calc(-1 * var(--sp-4)); margin-right: calc(-1 * var(--sp-4)); }
  .step-card { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .foot-secondary { display: none !important; }
  .btn-next, .btn-save { padding: 0 var(--sp-4); }
  .review-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .filter .select { max-width: none; width: 100%; }
  .filter { flex: 1 1 45%; min-width: 0; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
  .stat { padding: 12px 14px; }
  .lock-card { width: 100%; padding: var(--sp-6); }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .dash-card, .drawer-head, .drawer-body { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .toolbar-simple { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "actions"; }
  .card-plain { padding: var(--sp-5) var(--sp-4); }
  .site-footer .footer-inner { justify-content: center; text-align: center; }
  .mb-brand .brand-app { display: none; }
}

/* ---------- Движение ---------- */
@media (prefers-reduced-motion: reduce) {
  .found-card, .lock.is-shake .lock-card, .step-panel, .step-card.is-shake, .toast, .drawer { animation: none; }
  .nav-item, .btn, .input, .radio, .app, .sidebar { transition: none; }
  .btn-primary:hover:not(:disabled) { transform: none; }
}

/* ============================================================================
   Печать: только .print-root (tokens.css уже скрывает body > *:not(.print-root))
   ========================================================================== */
@media print {
  @page { size: A4; margin: 20mm; }
  html, body { background: #fff; color: #000; }
  .print-root {
    display: block; font-family: "Times New Roman", Times, serif; font-size: 11pt; line-height: 1.35; color: #000;
    max-width: none;
  }
  .doc-head { text-align: center; margin-bottom: 8mm; }
  .doc-org { font-size: 10pt; letter-spacing: 0.06em; }
  .doc-title { font-size: 12pt; font-weight: bold; margin: 2mm 0; color: #000; }
  .doc-place { font-size: 11pt; }
  .doc-h { font-size: 11pt; font-weight: bold; margin: 5mm 0 2mm; text-align: center; page-break-after: avoid; color: #000; }
  .doc-p { margin: 0 0 2mm; text-align: justify; }
  .doc-small { font-size: 9.5pt; }
  .doc-cb { display: inline-block; margin: 0 2mm; white-space: nowrap; }
  .doc-id { letter-spacing: 0.1em; font-weight: bold; }
  .doc-table { width: 100%; border-collapse: collapse; margin: 2mm 0 3mm; font-size: 10.5pt; page-break-inside: avoid; }
  .doc-table th, .doc-table td { border: 0.5pt solid #000; padding: 1mm 2mm; }
  .doc-table th { font-weight: bold; text-align: center; }
  .doc-table .num { text-align: right; font-family: inherit; font-variant-numeric: tabular-nums; }
  .doc-table tfoot td { font-weight: bold; }
  .doc-cols { display: flex; gap: 10mm; page-break-inside: avoid; }
  .doc-col { flex: 1; }
  .toast-area, .lock, .dialog, .sidebar, .topbar, .mobile-bar, .site-footer, .drawer, .drawer-overlay { display: none !important; }
}
