/**
 * NextFin — UI-компоненты (формы, модалки, кнопки, таблицы).
 * Единственный слой совместимости для существующих шаблонов без styles.css.
 */

/* ── Экран приложения (как data-rscreen в макете) ── */
.nf-screen {
  padding: 6px 0 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: nfFadeUp .42s ease both;
}
.nf-screen--grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.nf-kpi--brand { background: linear-gradient(155deg, var(--brand-deep), var(--brand-deep2)); color: #fff; border: 0; }
.nf-kpi--brand .nf-kpi__label { color: rgba(255, 255, 255, .5); }
.nf-kpi__label--caps {
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text2);
}

/* ── Модалки (старые id/hooks сохранены) ── */
.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(8, 12, 10, .45);
  backdrop-filter: blur(2px);
}
.modal-backdrop-custom.show {
  display: flex;
  animation: nfFade .2s ease;
}
.modal-backdrop-custom > .nf-budget-modal,
.modal-backdrop-custom > .modal-dialog-custom,
.modal-backdrop-custom > .modal-panel,
.modal-backdrop-custom > .modal-panel-wide {
  margin: auto;
  flex-shrink: 0;
  box-sizing: border-box;
  width: fit-content;
  max-width: calc(100vw - max(20px, env(safe-area-inset-left, 0px)) - max(20px, env(safe-area-inset-right, 0px)));
  max-height: calc(100dvh - max(20px, env(safe-area-inset-top, 0px)) - max(20px, env(safe-area-inset-bottom, 0px)));
  height: auto;
  min-height: 0;
}
@media (max-width: 640px) {
  .modal-backdrop-custom {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .modal-backdrop-custom > .nf-budget-modal,
  .modal-backdrop-custom > .nf-budget-modal--wide,
  .modal-backdrop-custom > .nf-budget-modal--pay,
  .modal-backdrop-custom > .modal-dialog-custom,
  .modal-backdrop-custom > .modal-panel,
  .modal-backdrop-custom > .modal-panel-wide {
    width: fit-content;
    max-width: calc(100vw - max(12px, env(safe-area-inset-left, 0px)) - max(12px, env(safe-area-inset-right, 0px)));
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top, 0px)) - max(12px, env(safe-area-inset-bottom, 0px)));
    min-height: 0;
    margin: auto;
    border-radius: 18px;
  }
}
.modal-dialog-custom {
  min-width: min(300px, calc(100vw - 40px));
  max-width: min(720px, calc(100vw - 40px));
  overflow-y: auto;
}
.debt-new-modal-dialog { max-width: min(920px, calc(100vw - 40px)); }
.modal-panel { min-width: min(280px, calc(100vw - 40px)); max-width: min(560px, calc(100vw - 40px)); }
.modal-panel-wide { min-width: min(300px, calc(100vw - 40px)); max-width: min(720px, calc(100vw - 40px)); }
.modal-content-custom, .modal-panel {
  width: 100%;
  box-sizing: border-box;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, .18);
}
.modal-header-custom {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 18px;
}
.modal-header-custom h5 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer; width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 9px;
}
.modal-close-btn:hover { color: var(--text); background: var(--hover); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions.justify-content-between { justify-content: space-between; }
body.modal-open { overflow: hidden; }

/* ── Формы ── */
.form-label, label.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text3); margin-bottom: 6px;
}
.form-control, .form-select, textarea.form-control,
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], select, textarea {
  width: 100%; box-sizing: border-box; font-family: inherit; font-size: 16px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-alt); color: var(--text);
}
.form-control:focus, .form-select:focus, textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--accent); background: var(--card);
}
.form-control-sm, .form-select-sm { padding: 7px 10px; font-size: 16px; }
.form-text { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Toggle-switch (чекбоксы) ── */
.nf-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.nf-switch--between {
  justify-content: space-between;
  width: 100%;
}
.nf-switch__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}
.nf-switch__ui {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--track);
  position: relative;
  flex: none;
  cursor: pointer;
  transition: background .22s ease;
}
.nf-switch__ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .22s ease;
}
.nf-switch__input:checked + .nf-switch__ui { background: var(--accent); }
.nf-switch__input:checked + .nf-switch__ui::after { transform: translateX(18px); }
.nf-switch__input:focus-visible + .nf-switch__ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.nf-switch__input:disabled + .nf-switch__ui {
  opacity: .5;
  cursor: not-allowed;
}
.nf-switch:has(.nf-switch__input:disabled) { cursor: not-allowed; }
.nf-switch__text {
  font-size: 13.5px;
  color: var(--text3);
  line-height: 1.4;
}
.nf-switch--between .nf-switch__text {
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  cursor: pointer;
}
.form-check-label { font-size: 13.5px; color: var(--text3); }
/* Radio — обычный вид */
.form-check-input[type="radio"] { margin-top: 0; accent-color: var(--accent); flex-shrink: 0; }
.input-group { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.input-group .nf-date-today-btn { margin-left: 6px; }
.nf-date-field {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.nf-date-field input[type="date"] {
  flex: 1 1 auto;
  min-width: 140px;
  width: auto;
}
.input-group-text {
  display: inline-flex; align-items: center; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--fill); color: var(--muted);
}
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 14px !important; }
.mb-4 { margin-bottom: 18px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 14px !important; }
.mt-4 { margin-top: 18px !important; }
.my-4 { margin-top: 18px !important; margin-bottom: 18px !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 14px !important; }
.p-4 { padding: 18px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.d-none { display: none !important; }
.d-inline { display: inline !important; }
.d-flex { display: flex !important; }
.flex-wrap { flex-wrap: wrap !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.align-items-baseline { align-items: baseline !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-muted, .small.text-muted { color: var(--muted) !important; }
.text-success { color: var(--pos) !important; }
.text-danger { color: var(--neg) !important; }
.text-primary { color: var(--accent) !important; }
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }
.fw-bold { font-weight: 700 !important; }
.fs-6 { font-size: 14px !important; }
.position-relative { position: relative !important; }
.vstack { display: flex; flex-direction: column; }
.ps-3 { padding-left: 14px !important; }
.border-top { border-top: 1px solid var(--border) !important; }

/* ── Кнопки (bootstrap-совместимые классы → nf) ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 18px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  text-decoration: none; transition: background .18s, border-color .18s, transform .12s;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-press); color: #fff; }
.btn-secondary, .btn-outline-secondary, .btn-outline-light {
  background: var(--fill); border-color: var(--border); color: var(--text3);
}
.btn-secondary:hover, .btn-outline-secondary:hover, .btn-outline-light:hover {
  background: var(--hover); color: var(--text);
}
.btn-success { background: var(--pos); border-color: var(--pos); color: #fff; }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-warning { background: var(--amber-text); border-color: var(--amber-text); color: #fff; }
.btn-info { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-icon { padding: 7px 9px; }

/* ── Таблицы ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .03em;
}
.table td { padding: 12px; border-bottom: 1px solid var(--track); color: var(--text3); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: var(--hover); }
.table-sm th, .table-sm td { padding: 8px 10px; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Алерты / бейджи ── */
.alert {
  padding: 12px 14px; border-radius: 11px; margin-bottom: 14px;
  border: 1px solid var(--border); background: var(--fill); color: var(--text3);
}
.alert-info { background: var(--accent-soft); border-color: var(--accent-soft-border); }
.alert-success { background: var(--accent-soft); border-color: var(--accent-soft-border); color: var(--tag-text); }
.alert-danger, .alert-error { background: var(--red-bg); border-color: var(--red-text); color: var(--red-text); }
.badge, .nav-tier-badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: var(--tag-bg); color: var(--tag-text);
}
.bg-success, .badge.bg-success { background: var(--accent-soft) !important; color: var(--pos) !important; }
.bg-secondary, .badge.bg-secondary { background: var(--fill) !important; color: var(--muted) !important; }
.bg-info, .badge.bg-info { background: var(--tag-bg) !important; color: var(--tag-text) !important; }
.text-bg-secondary { background: var(--fill); color: var(--muted); padding: 2px 8px; border-radius: 6px; }

/* ── Меню действий портфеля ── */
.action-menu-wrap { position: relative; display: inline-block; }
.action-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
}
.action-menu.is-open { display: block; }
.action-menu-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── ИИ оверлей ── */
.ai-loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(8, 12, 10, .45); backdrop-filter: blur(2px);
}
.ai-loading-overlay[hidden] { display: none !important; }
.ai-loading-overlay-card {
  max-width: 360px; text-align: center; background: var(--card);
  border: 1px solid var(--border); border-radius: 18px; padding: 28px 24px;
}
.ai-loading-overlay-title { font-size: 15px; font-weight: 600; margin: 14px 0 6px; }
.preloader-spinner {
  width: 36px; height: 36px; margin: 0 auto;
  border: 3px solid var(--track); border-top-color: var(--accent);
  border-radius: 50%; animation: nfSpin .8s linear infinite;
}
@keyframes nfSpin { to { transform: rotate(360deg); } }
.ai-response-text { line-height: 1.55; white-space: pre-wrap; font-size: 14px; color: var(--text3); }
.nf-budget-modal__body--ai {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-analysis-main-stack {
  position: relative;
  flex: 1 1 auto;
  min-height: 160px;
}
.nf-ai-disclaimer--modal {
  flex-shrink: 0;
  margin-top: 0;
  position: relative;
  z-index: 4;
}
.ai-modal-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  border-radius: 12px;
  background: rgba(8, 12, 10, .45);
  backdrop-filter: blur(2px);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.ai-modal-loading[hidden] {
  display: none !important;
}

/* ── Таблица активов (макет data-atable) ── */
.nf-adaptive-table {
  container-type: inline-size;
  min-width: 0;
  width: 100%;
}
.nf-adaptive-table .nf-atable-head,
.nf-adaptive-table .nf-atable-row {
  gap: clamp(4px, 1.2cqi, 8px);
}
.nf-adaptive-table .nf-atable-head {
  font-size: clamp(9px, 2.3cqi, 11px);
}
.nf-adaptive-table .nf-atable-row {
  font-size: clamp(10px, 2.8cqi, 13px);
}
.nf-adaptive-table .nf-atable-row > div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-adaptive-table .nf-atable-row__label {
  font-size: clamp(10px, 2.6cqi, 13.5px);
  color: var(--text3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-adaptive-table--compact .nf-atable-head,
.nf-adaptive-table--compact .nf-atable-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, auto);
}

.nf-atable-head, .nf-atable-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 64px) minmax(0, 96px) minmax(0, 104px) minmax(0, 72px);
  gap: clamp(4px, 1.2cqi, 8px); align-items: center;
  min-width: 0;
}
.nf-atable-head {
  font-size: clamp(9px, 2.3cqi, 11px); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  padding: 0 4px 8px; border-bottom: 1px solid var(--track);
}
.nf-atable-head > div:not(:first-child),
.nf-atable-row > div:not(:first-child) { text-align: right; }
.nf-atable-row {
  padding: 11px 4px; border-radius: 8px;
  font-size: clamp(10px, 2.8cqi, 13px);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
.nf-atable-row > div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-atable-row:hover { background: var(--hover); }
.nf-ticker-tag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 4px 8px; border-radius: 7px;
  background: var(--tag-bg); color: var(--tag-text);
  font-size: clamp(9px, 2.2cqi, 12px); font-weight: 700; font-family: var(--nf-font-mono);
  flex-shrink: 0;
}

/* Таблица активов на странице портфеля */
#portfolio-table .nf-atable-head,
#portfolio-table .nf-atable-row {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 58px) minmax(0, 92px) minmax(0, 100px) minmax(0, 68px);
}
#portfolio-table .nf-atable-row > .nf-atable-cell-num {
  font-weight: 600;
  text-overflow: clip;
}
@container (max-width: 560px) {
  #portfolio-table .nf-atable-col--moex {
    display: none !important;
  }
  #portfolio-table .nf-atable-head,
  #portfolio-table .nf-atable-row {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 50px) minmax(0, 92px) minmax(0, 62px);
  }
  #portfolio-table .nf-atable-row__label {
    display: none;
  }
}
@container (max-width: 400px) {
  #portfolio-table .nf-ticker-tag {
    min-width: 34px;
    padding: 3px 5px;
    font-size: 10px;
  }
}

.nf-table-wrap {
  container-type: inline-size;
  min-width: 0;
  width: 100%;
  overflow-x: auto;
}

/* ── Аккордеон бюджета ── */
.nf-acc { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.nf-acc__head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  cursor: pointer; background: var(--card-alt);
  user-select: none;
  flex-wrap: nowrap;
  overflow: hidden;
  container-type: inline-size;
}
.nf-acc__head-title {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
}
.nf-acc__head-totals {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.5cqi, 8px);
  font-size: clamp(8.5px, 3.1cqi, 12.5px);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.nf-acc__head .month-income-value,
.nf-acc__head .month-expense-value,
.nf-acc__head .month-balance-value {
  white-space: nowrap;
}
.nf-acc__head .month-balance-value {
  padding-left: clamp(4px, 1.5cqi, 10px);
  margin-left: clamp(1px, 0.5cqi, 2px);
}
.nf-acc__head .month-balance-value::before {
  content: '|';
  margin-right: clamp(4px, 1.5cqi, 10px);
  color: var(--muted);
  font-weight: 400;
}
@container (max-width: 420px) {
  .nf-acc__head-totals { gap: 5px; }
  .nf-acc__head-title { font-size: 14px; }
}
@container (max-width: 340px) {
  .nf-acc__head-totals { gap: 4px; }
  .nf-acc__head-title { font-size: 13px; }
}
.nf-acc__head:hover { background: var(--hover); }
.nf-acc__head svg {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.nf-acc:not(.is-open) .nf-acc__head svg {
  transform: rotate(-90deg);
}
.nf-acc:not(.is-open) .nf-acc__body {
  display: none;
}
.nf-acc__body { padding: 6px 12px 12px; container-type: inline-size; min-width: 0; }
.nf-acc-month { border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: var(--card); margin-bottom: 8px; }
.nf-acc-month__head {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px; cursor: pointer;
}
.nf-acc-month__head:hover { background: var(--hover); }
.nf-op-row {
  display: flex; align-items: center; gap: clamp(6px, 1.8cqi, 13px); padding: 10px 0;
  border-top: 1px solid var(--track);
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}
.nf-op-row__main {
  flex: 1 1 0;
  min-width: 0;
}
.nf-op-row__title {
  font-size: clamp(11px, 3.2cqi, 13.5px);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-op-row__meta {
  font-size: clamp(10px, 2.6cqi, 12px);
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-op-row__amount {
  flex: 0 0 auto;
  font-size: clamp(9px, 2.8cqi, 14px);
  font-weight: 600;
  min-width: clamp(68px, 16cqi, 104px);
  max-width: 42%;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Категория уже в meta строки — тег на узком экране ломает вёрстку */
@media (max-width: 768px) {
  .nf-op-row > .nf-tag,
  .budget-row > .nf-tag {
    display: none;
  }
}

body.ui-variant-mobile .nf-op-row > .nf-tag,
body.ui-variant-mobile .budget-row > .nf-tag {
  display: none;
}

#budget-recurring-list,
#nf-recurring-income-list,
#nf-recurring-expense-list,
.nf-recurring-list {
  container-type: inline-size;
  min-width: 0;
}
.nf-recurring-row {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.8cqi, 13px);
  min-width: 0;
  overflow: hidden;
}
.nf-recurring-row__main {
  flex: 1 1 0;
  min-width: 0;
}
.nf-recurring-row__title {
  font-size: clamp(11px, 3.2cqi, 13.5px);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-recurring-row__meta {
  font-size: clamp(10px, 2.6cqi, 12px);
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-recurring-row__amount {
  flex: 0 0 auto;
  font-size: clamp(9px, 2.8cqi, 14px);
  font-weight: 600;
  min-width: clamp(68px, 16cqi, 104px);
  max-width: 42%;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.nf-recurring-row__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Карточки обучения ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nf-skip-link:focus,
.nf-skip-link:focus-visible {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10000;
  width: auto;
  height: auto;
  margin: 0;
  padding: 10px 16px;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 8px 0;
}

.nf-course-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
  min-width: 0;
}
.nf-course-card:hover { box-shadow: 0 10px 26px rgba(15, 42, 24, .1); border-color: var(--accent); }
.nf-course-card--active { border: 2px solid var(--accent); }
.nf-course-card--locked {
  display: grid;
  padding: 0;
  cursor: pointer;
  user-select: none;
  line-height: 0;
}
.nf-course-card--locked:hover {
  border-color: var(--muted);
  box-shadow: 0 6px 18px rgba(15, 42, 24, .08);
}
.nf-course-card--locked:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.nf-course-card--locked > .nf-lesson-infographic,
.nf-course-card--locked > .nf-course-card__body {
  grid-area: 1 / 1;
  width: 100%;
  min-width: 0;
}
.nf-course-card--locked > .nf-course-card__body {
  line-height: 1.35;
  min-height: 180px;
  padding: 16px 18px;
}
.nf-course-card--locked > .nf-lesson-infographic {
  margin: 0;
}
.nf-course-card--locked .nf-lesson-infographic__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  object-position: center;
}
.nf-course-card--locked > .nf-course-card__lock {
  grid-area: 1 / 1;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 16px;
  background: rgba(0, 0, 0, .42);
  color: #fff;
  text-align: center;
  line-height: 1.35;
  align-self: stretch;
  justify-self: stretch;
}
.nf-course-card__cover {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  background: #eef4fb;
  line-height: 0;
}
.nf-course-card__cover .nf-lesson-infographic {
  margin: 0;
  width: 100%;
}
.nf-course-card__cover .nf-lesson-infographic__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  object-position: center;
}
.nf-course-card__lock-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  flex-shrink: 0;
}
.nf-course-card__lock-icon svg {
  display: block;
}
.nf-course-card__lock-text {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  max-width: 88%;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .4);
}
.nf-course-card__body { padding: 16px 18px 0; }
.nf-course-card__footer {
  padding: 10px 14px 14px;
  margin-top: auto;
}
.nf-course-card__meta {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.nf-course-card__meta:empty { display: none; }
.nf-course-card__test {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}
.nf-course-card__progress {
  height: 6px;
  border-radius: 4px;
  background: var(--track);
  overflow: hidden;
}
.nf-course-card__title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.nf-course-card__excerpt {
  font-size: 12.5px;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

/* ── Инфографика урока ── */
.nf-lesson-infographic {
  margin: 0;
  width: 100%;
  overflow: hidden;
  background: #eef4fb;
}
.nf-lesson-infographic__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
}
.nf-lesson-infographic--compact .nf-lesson-infographic__img {
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

/* ── Сетка карточек уроков (каталог обучения) ── */
.nf-learning-cards-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1024px) {
  .nf-learning-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .nf-learning-cards-grid {
    grid-template-columns: 1fr;
  }
}

.nf-learning-section-title {
  margin: 4px 0 0;
}
.nf-learning-completed {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.nf-learning-completed__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.nf-learning-completed__title {
  margin: 0;
}
.nf-learning-completed__count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--fill);
  border: 1px solid var(--border);
}
.nf-learning-cards-grid--completed .nf-course-card {
  opacity: 0.92;
}
.nf-learning-cards-grid--completed .nf-course-card:hover {
  opacity: 1;
}

/* ── Доска идей / пожелания ── */
.nf-wishes-widget__head {
  margin-bottom: 20px;
}
.nf-wishes-widget__kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.nf-wishes-widget__title {
  margin: 0 0 10px;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}
.nf-wishes-widget__lead {
  margin: 0;
  max-width: 62ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text2);
}
.nf-wishes-widget--compact .nf-wishes-widget__title {
  font-size: 20px;
}
.nf-wishes-widget--compact .nf-wishes-widget__lead {
  font-size: 14px;
}
.nf-wishes-widget__compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.nf-wishes-widget__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 20px;
  align-items: start;
}
.nf-wishes-widget__form-card,
.nf-wishes-widget__list-card {
  border-radius: 18px;
  padding: 22px 24px;
}
.nf-wishes-widget__card-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.nf-wishes-widget__card-hint {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text2);
}
.nf-wishes-widget__sent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 12px;
  padding: 11px 13px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--tag-text);
}
.nf-wishes-widget__form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.nf-wishes-widget__lock-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}
.nf-wishes-widget__list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.nf-wishes-widget__count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.nf-wishes-widget__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nf-wishes-empty {
  font-size: 13px;
  color: var(--muted);
}
.nf-wishes-item {
  display: flex;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--card-alt);
}
.nf-wishes-item__avatar { flex: none; }
.nf-wishes-item__body { flex: 1; min-width: 0; }
.nf-wishes-item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.nf-wishes-item__author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.nf-wishes-item__text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text3);
}
.nf-wishes-item__vote,
.nf-wishes-item__votes-static {
  margin-top: 9px;
  font-size: 12px;
}
.nf-wishes-item__votes-static {
  font-weight: 600;
  color: var(--accent);
}
.nf-wishes-item__vote {
  padding: 5px 12px;
}
.nf-wishes-page .nf-wishes-widget__head {
  text-align: center;
}
.nf-wishes-page .nf-wishes-widget__lead {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}
@media (max-width: 900px) {
  .nf-wishes-widget__grid {
    grid-template-columns: 1fr;
  }
}

.nf-card--lesson {
  padding: 0;
  overflow: hidden;
}
.nf-card--lesson .nf-lesson-infographic {
  border-radius: 16px 16px 0 0;
}
.nf-card--lesson .nf-lesson-lead,
.nf-card--lesson .nf-learning-content {
  padding-left: 22px;
  padding-right: 22px;
}
.nf-card--lesson .nf-lesson-lead {
  margin: 0;
  padding-top: 18px;
  padding-bottom: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text2);
}
.nf-card--lesson .nf-learning-content {
  padding-top: 16px;
  padding-bottom: 22px;
}

.nf-learning-continue {
  background: linear-gradient(135deg, var(--brand-deep), var(--brand-deep2));
  border-radius: 18px;
  padding: 18px 20px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.nf-learning-continue__thumb {
  flex: 0 0 168px;
  max-width: 42%;
  min-width: 120px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.nf-learning-continue__thumb .nf-lesson-infographic {
  background: transparent;
}
.nf-learning-continue__body { flex: 1; min-width: 0; }
.nf-learning-continue__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-bright);
}
.nf-learning-continue__title {
  font-size: 21px;
  font-weight: 600;
  margin-top: 8px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.nf-learning-continue__btn {
  background: #fff;
  color: var(--brand-deep);
  border: none;
  padding: 13px 24px;
  flex-shrink: 0;
  white-space: nowrap;
}
@media (max-width: 768px) {
  .nf-learning-continue { padding: 16px; gap: 14px; }
  .nf-learning-continue__thumb {
    flex: 1 1 100%;
    max-width: 100%;
  }
  .nf-learning-continue__btn { width: 100%; text-align: center; }
  .nf-course-card__footer { padding: 8px 12px 12px; }
  .nf-card--lesson .nf-lesson-lead,
  .nf-card--lesson .nf-learning-content {
    padding-left: 16px;
    padding-right: 16px;
  }
}
.nf-learning-content {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text3);
}
.nf-learning-content p { margin: 0 0 14px; }
.nf-learning-content p:last-child { margin-bottom: 0; }
.nf-lesson-list {
  margin: 0 0 14px;
  padding-left: 1.2em;
}
.nf-lesson-list li { margin-bottom: 6px; }
.nf-lesson-callout {
  display: flex;
  align-items: stretch;
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0;
  border: 1px solid var(--border);
}
.nf-lesson-callout__accent {
  flex: 0 0 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.nf-lesson-callout--tip .nf-lesson-callout__accent { background: #BA7517; }
.nf-lesson-callout--tip .nf-lesson-callout__content { background: #FAEEDA; }
.nf-lesson-callout--key .nf-lesson-callout__accent { background: #0F6E56; }
.nf-lesson-callout--key .nf-lesson-callout__content { background: #E1F5EE; }
.nf-lesson-callout--note .nf-lesson-callout__accent { background: #185FA5; }
.nf-lesson-callout--note .nf-lesson-callout__content { background: #E6F1FB; }
html[data-theme="dark"] .nf-lesson-callout--tip .nf-lesson-callout__content { background: rgba(186, 117, 23, .14); }
html[data-theme="dark"] .nf-lesson-callout--key .nf-lesson-callout__content { background: rgba(15, 110, 86, .16); }
html[data-theme="dark"] .nf-lesson-callout--note .nf-lesson-callout__content { background: rgba(24, 95, 165, .16); }
.nf-lesson-callout__content {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
}
.nf-lesson-callout__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.nf-lesson-callout__body {
  margin-top: 6px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text2);
}
.nf-lesson-table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.nf-lesson-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.nf-lesson-table th,
.nf-lesson-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.nf-lesson-table th {
  background: var(--tag-bg);
  font-weight: 600;
  color: var(--text);
}
.nf-lesson-table tr:last-child td { border-bottom: none; }
.nf-lesson-nav {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  align-items: center;
}
.nf-lesson-nav__btn {
  flex: 0 0 auto;
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}
.nf-lesson-nav__btn--next {
  margin-left: auto;
}
@media (max-width: 768px) {
  .nf-lesson-preview__text { font-size: 13px; padding: 10px 12px; }
  .nf-lesson-callout__accent { flex-basis: 30px; font-size: 14px; }
  .nf-lesson-callout__content { padding: 10px 12px; }
  .nf-lesson-table { font-size: 12px; }
  .nf-lesson-table th, .nf-lesson-table td { padding: 8px 10px; }
}
