/* STYLES 68*/

html {
  /* Плавный масштаб шрифтов/ремов под размер окна.
     - минимум 11px (чтобы не было слишком мелко на 1366/1440)
     - максимум 14px (как у тебя для 3440+)
     - середина растёт плавно от viewport (и по ширине, и по высоте) */
  font-size: clamp(11px, calc(9px + 0.22vw + 0.18vh), 14px);
  overflow-y: auto !important;
}

/* Страховка: на очень маленьких высотах не раздуваем интерфейс */
@media (max-height: 700px) {
  html { font-size: 11px; }
}

/* Страховка: на очень больших экранах (типа 4K) не делаем слишком крупно */
@media (min-width: 3000px) and (min-height: 1600px) {
  html { font-size: 14px; }
}

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: #f3f4f6;
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  padding-bottom: 14.29rem; /* 200px */
}

/* Унифицированные поля ввода */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  font-size: 0.9rem;
  line-height: 1.4;
  font-family: 'Segoe UI', sans-serif; /* избегаем среза букв в select */
  padding: 0.29rem 0.71rem; /* 4px 10px */
  box-sizing: border-box;
  min-height: 2.43rem; /* 34px */
  height: auto;
  border: 1px solid #ccc;
  border-radius: 0.43rem; /* 6px */
  background-color: #fff;
  vertical-align: middle;
  width: 100%;
}

select,
input[type="text"],
input[type="password"] {
  font-size: 0.9rem;
  padding: 0.36rem 0.57rem; /* 5px 8px */
  line-height: 1.4;
  font-family: 'Segoe UI', sans-serif;
  height: auto;
}

/* Select — доп. место под стрелку */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2rem; /* 28px */
}

.container {
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: #fff;
  border-radius: 0.71rem; /* 10px */
  box-shadow: 0 0 15px rgba(0,0,0,0.1); /* оставляем px для тени */
  padding: 2rem;
  margin-bottom: 2rem;
}

h2, h3 {
  margin-top: 0;
}

/*
input[type="text"],
input[type="number"],
select,
textarea {
  padding: 8px;
  font-size: 14px;
  border-radius: 5px;
  border: 1px solid #ccc;
}
*/

button {
  padding: 0.57rem 0.86rem; /* 8px 12px */
  background-color: #2c7be5;
  color: #fff;
  border: none;
  border-radius: 0.36rem; /* 5px */
  cursor: pointer;
}

/* Компакт для кнопки PRO опций */
button.pro-options-toggle {
  padding: .25em .6em;
  font-size: .875rem;
  line-height: 1.2;
  border-radius: .4rem;
  display: inline-flex;
  align-items: center;
  gap: .35em;
}

button.pro-options-toggle:hover { filter: brightness(.95); }

@media (max-width:480px) {
  button.pro-options-toggle { font-size: .82rem; padding: .2em .5em; }
}

button:hover {
  background-color: #1a5ed0;
}

.auth-popup button[aria-label="Показать пароль"] {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.auth-popup button[aria-label="Показать пароль"]:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #1e40af !important;
}

td:last-child {
  text-align: center;
  vertical-align: middle;
}

button.delete-btn {
  display: inline-block;
  margin: 0 auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  table-layout: fixed;
}

th,
td {
  padding: 0.71rem; /* 10px */
  border: 1px solid #ccc;
  text-align: left;
}

th {
  background-color: #f0f0f0;
}

tr:nth-child(even) {
  background-color: #fafafa;
}

textarea::placeholder {
  font-size: 0.79rem; /* 11px */
  color: #666;
}

textarea.dirty-values {
  width: 35.71rem;      /* 500px */
  min-height: 27.14rem; /* 380px */
  font-size: 1rem;      /* 14px */
  resize: vertical;
}

.btn {
  background-color: #2563eb;
  color: white;
  padding: 0.43rem 0.86rem; /* 6px 12px */
  border: none;
  border-radius: 0.43rem;   /* 6px */
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

.btn:hover {
  background-color: #1e40af;
}

.btn.secondary {
  background-color: #e2e8f0;
  color: #1f2937;
}

.btn.secondary:hover {
  background-color: #cbd5e1;
}

.btn.danger {
  background-color: #dc2626;
}

.btn.danger:hover {
  background-color: #b91c1c;
}

.btn-primary {
  background-color: #2563eb;
  color: white;
  padding: 1.14rem 2.29rem; /* 16px 32px */
  font-size: 1.29rem;       /* 18px */
  font-weight: bold;
  border: none;
  border-radius: 0.57rem;   /* 8px */
  cursor: pointer;
  display: block;
  margin: 2.36rem auto 7.86rem auto; /* 40px auto 0 auto */
  transition: background-color 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* px оставляем */
}

.btn-primary:hover {
  background-color: #1e40af;
}

.fb-admin-nav-btn {
  min-width: 220px;
  min-height: 80px;
  padding: 1.14rem 2.29rem;
  font-size: 1.29rem;
  font-weight: bold;
  border: 2px solid #2563eb;
  border-radius: 0.57rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  color: #ffffff;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.fb-admin-nav-btn:hover {
  background: #1e40af;
  border-color: #1e40af;
}

.fb-admin-nav-btn.is-active {
  background: #ffffff;
  color: #111827;
  border-color: #2563eb;
}

.btn-add {
  background-color: #10b981;
  color: white;
  padding: 0.57rem 0.86rem;       /* 8px 12px */
  border: none;
  border-radius: 0.43rem;         /* 6px */
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s ease;
  margin: 1.71rem 0 1.14rem 0;    /* 24px 0 16px 0 */
}

.btn-add:hover {
  background-color: #059669;
}

.btn-add:disabled {
  background-color: #d1d5db;
  color: #ffffff;
  cursor: not-allowed;
  opacity: 0.95;
}

.null-wrapper {
  position: relative;
  display: inline-block;
  width: 5rem;        /* 70px */
  margin-top: 0.36rem;/* 5px */
}


.null-input {
  width: 100%;
  padding-left: 1.43rem; /* 20px */
  box-sizing: border-box;
}

.null-percent-symbol {
  position: absolute;
  left: 2.43rem;          /* 34px */
  top: 45%;
  transform: translateY(-50%);
  font-size: 0.93rem;     /* 13px */
  color: #555;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.form-group {
  display: flex;
  align-items: center;
  margin-bottom: 0.57rem; /* 8px */
  max-width: 35.71rem;    /* 500px */
}

.top-bar-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}


.auth-captcha-row {
  display: flex;
  align-items: center;          /* ВАЖНО: выравнивание по вертикали */
  gap: 0.9rem;                  /* расстояние между картинкой и кнопкой */
  margin: 0.6rem 0 0.8rem;      /* аккуратные отступы */
}

.auth-captcha-img {
  height: 42px;                 /* фиксированная высота капчи */
  width: auto;
  display: block;
}

.auth-captcha-reload {
  width: 30px;   /* было 40 */
  height: 30px;  /* было 40 */

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;

  border: 1px solid rgba(37, 99, 235, 0.22);
  background: rgba(37, 99, 235, 0.06);
  color: rgba(37, 99, 235, 0.92);

  cursor: pointer;
  padding: 0;

  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.08);

  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}


/* SVG внутри кнопки */
.auth-captcha-icon {
  width: 18px;
  height: 18px;
  display: block;

  /* вращаем только иконку */
  transition: transform 0.18s ease;
}

.auth-captcha-reload:hover {
  background: rgba(37, 99, 235, 0.10);
  border-color: rgba(37, 99, 235, 0.30);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
}

.auth-captcha-reload:hover .auth-captcha-icon {
  transform: rotate(18deg);
}

.auth-captcha-reload:active {
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.10);
}

.auth-captcha-reload:active .auth-captcha-icon {
  transform: rotate(35deg) scale(0.98);
}




.top-bar-logo {
  display: flex;
  align-items: center;
  gap: 0.57rem;           /* 8px */
}

.top-bar-logo-img {
  height: 3.43rem;        /* 48px */
  width: 3.43rem;         /* 48px */
  display: block;
  margin-right: 1.14rem;  /* 16px */
}

.auth-btn {
  padding: 0.43rem 1rem;  /* 6px 14px */
  border-radius: 999px;
  border: 1px solid #4b5563;
  background-color: #111827;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 1rem;        /* 14px */
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}


.auth-btn:hover {
  background-color: #1f2937;
  color: #ffffff;
  border-color: #6b7280;
}

/* Двухслойная “кнопка” баланса:
   внешний слой — как соседние auth-btn,
   внутренний слой — белая вставка с отступом 2–3 мм */
.rows-balance-pill {
  cursor: pointer;
  margin-right: 5.6rem; /* добавляем второй такой же отступ, как gap */

  /* внешний слой как .auth-btn */
  border-radius: 999px;
  border: 2px solid #4b5563;
  background-color: #111827;
  color: #e5e7eb;

  /* “кайма” толщиной ~2px вокруг белой вставки */
  padding: 4px;

  display: inline-flex;
  align-items: center;
}

.rows-balance-pill:hover {
  background-color: #1f2937;
  color: #ffffff;
  border-color: #6b7280;
}

/* внутренняя белая вставка */
.rows-balance-pill .rows-balance-inner {
  background-color: #ffffff;
  color: #111827;
  border-radius: 999px;

  /* такие же внутренние отступы как у .auth-btn */
  padding: 0.43rem 1rem; /* 6px 14px */

  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* пробел после ":" через margin */
.rows-balance-pill .rows-balance-value {
  margin-left: 0.25rem;
  font-weight: 700;
}

.rows-balance-pill .rows-balance-label {
  color: #111827;
}

/* < 10000 — красный (как "Удалить аккаунт") */
.rows-balance-pill .rows-balance-value.low {
  color: #ef4444;
}

/* >= 10000 — зелёный (как "+ Добавить поле") */
.rows-balance-pill .rows-balance-value.high {
  color: #16a34a;
}

/* ===== UI: подсветка ошибок по балансу/rows ===== */

@keyframes fsqlInputBlinkRed {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0); border-color: inherit; }
  25%  { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.40); border-color: #ef4444; }
  50%  { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18); border-color: #ef4444; }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0); border-color: inherit; }
}

.fsql-input-blink-red {
  animation: fsqlInputBlinkRed 0.35s ease-in-out 0s 2;
}

@keyframes fsqlBalanceFlash {
  0%   { border-color: #ef4444; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0); }
  20%  { border-color: #ef4444; box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.28); }
  100% { border-color: #4b5563; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0); }
}

.rows-balance-pill.fsql-balance-flash {
  animation: fsqlBalanceFlash 3s ease-out 0s 1;
}

@keyframes fsqlExpectedSizeFlash {
  0%   { background: rgba(239, 68, 68, 0.0); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0); }
  15%  { background: rgba(239, 68, 68, 0.22); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.22); }
  100% { background: rgba(239, 68, 68, 0.0); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0); }
}

#expected-table-info.fsql-expected-size-flash {
  border-radius: 6px;
  padding: 2px 6px;
  animation: fsqlExpectedSizeFlash 5s ease-out 0s 1;
}

.fsql-expected-size-toast {
  position: fixed;
  z-index: 20000;

  max-width: min(520px, calc(100vw - 20px));
  padding: 10px 12px;
  border-radius: 10px;

  background: rgba(17, 24, 39, 0.96);
  color: #ffffff;

  font-size: 0.95rem;
  line-height: 1.35;

  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
  transform: translateY(0);
  opacity: 1;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.fsql-expected-size-toast.hide {
  opacity: 0;
  transform: translateY(-6px);
}

/* === Relations modal: "Сохранено" по центру === */
.fsql-rel-saved-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;

  display: inline-flex;
  align-items: center;
  gap: 0.5rem;

  padding: 10px 14px;
  border-radius: 12px;

  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #16a34a;

  font-size: 0.95rem;
  font-weight: 700;

  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);

  pointer-events: none;
  opacity: 1;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.fsql-rel-saved-toast.hide {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(-6px);
}

.fsql-rel-saved-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.14);
  color: #16a34a;
  font-size: 14px;
  line-height: 1;
}

/* === Relations modal: "Ошибка лимита размера" (без кнопок), как в simple === */
.fsql-rel-error-toast{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20050; /* выше любых overlay (auth/diagram/relations) */

  max-width: min(520px, calc(100vw - 20px));
  padding: 10px 12px;
  border-radius: 10px;

  background: rgba(17, 24, 39, 0.96);
  color: #ffffff;

  font-size: 0.95rem;
  line-height: 1.35;

  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
  opacity: 1;

  pointer-events: none;

  transition: opacity 0.28s ease, transform 0.28s ease;
}

.fsql-rel-error-toast.hide{
  opacity: 0;
  transform: translate(-50%, -50%) translateY(-6px);
}





.auth-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  z-index: 1100;
}

.auth-popup {
  margin-top: 5rem;              /* ниже фиксированной шапки */
  margin-right: 1.71rem;         /* 24px */
  width: 22.86rem;               /* 320px */
  background: #ffffff;
  border-radius: 1rem;           /* 14px */
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  padding: 1.14rem 1.14rem 1rem; /* 16px 16px 14px */
  display: flex;
  flex-direction: column;
  gap: 0.57rem;                  /* 8px */
}

.auth-popup h3 {
  margin: 0 0 0.29rem 0;         /* 4px */
  font-size: 1.14rem;            /* 16px */
  font-weight: 600;
  color: #111827;
}

.auth-field-label {
  font-size: 0.86rem;            /* 12px */
  color: #6b7280;
  margin-bottom: 0.14rem;        /* 2px */
}

.auth-input {
  width: 100%;
  padding: 0.43rem 0.57rem;      /* 6px 8px */
  border-radius: 0.43rem;        /* 6px */
  border: 1px solid #d1d5db;
  font-size: 0.93rem;            /* 13px */
  box-sizing: border-box;
}

.auth-input:focus {
  outline: none;
  border-color: #2563eb;
}

.auth-btn-primary {
  width: 100%;
  padding: 0.5rem 0.71rem;       /* 7px 10px */
  border-radius: 0.57rem;        /* 8px */
  border: none;
  font-size: 1rem;               /* 14px */
  cursor: pointer;
  background-color: #22c55e;
  color: #ffffff;
  margin-top: 0.29rem;           /* 4px */
  transition: background-color 0.15s ease;
}

.auth-btn-primary[disabled] {
  background-color: #d1d5db;
  color: #6b7280;
  cursor: default;
}

.auth-btn-primary:not([disabled]):hover {
  background-color: #16a34a;
}

.auth-link {
  font-size: 0.86rem;            /* 12px */
  color: #2563eb;
  cursor: pointer;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-error {
  font-size: 0.79rem;            /* 11px */
  color: #dc2626;
  margin-top: 0.14rem;           /* 2px */
}

.auth-success {
  font-size: 0.86rem;            /* 12px */
  color: #16a34a;
  margin-top: 0.14rem;           /* 2px */
}

.auth-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.43rem;                  /* 6px */
  margin-top: 0.29rem;           /* 4px */
}

.auth-checkbox-row label {
  font-size: 0.79rem;            /* 11px */
  color: #4b5563;
}

.auth-password-hint {
  font-size: 0.71rem;            /* 10px */
  color: #6b7280;
  margin-top: 0.14rem;           /* 2px */
}

.footer-links {
  position: fixed;
  right: 1.14rem;      /* 16px */
  bottom: 0.86rem;     /* 12px */
  display: flex;
  align-items: baseline;
  gap: 1.25rem;        /* ФИКСИРОВАННЫЙ ОТСТУП МЕЖДУ ССЫЛКАМИ */
  z-index: 500;
}

.footer-links a {
  font-size: 0.79rem;  /* 11px */
  color: #6b7280;
  text-decoration: none;
  white-space: nowrap; /* НИКОГДА не переносить строки */
  line-height: 1.2;
}

.footer-links span {
  font-size: 0.86rem;  /* немного крупнее активный пункт */
  color: #111827;
  font-weight: 500;
  white-space: nowrap; /* НИКОГДА не переносить строки */
  cursor: default;
  line-height: 1.2;
}

.footer-links a:hover {
  color: #111827;
  text-decoration: underline;
}

.form-group label {
  width: 12.86rem;               /* 180px */
  font-weight: 500;
  margin-right: 0.71rem;         /* 10px */
}

.form-group input,
.form-group select {
  flex: 1;
  padding: 0.43rem 0.57rem;      /* 6px 8px */
  font-size: 1rem;               /* 14px */
  border: 1px solid #ccc;
  border-radius: 0.29rem;        /* 4px */
  width: 100%;
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

* {
  box-sizing: border-box;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%23444" height="14" viewBox="0 0 24 24" width="14" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.71rem center; /* 10px */
  background-size: 1.43rem 1.43rem;          /* 20px 20px */
  padding-right: 2.57rem;                    /* 36px */
  position: relative;
  z-index: 10;
  border: 1px solid #ccc;
  height: 2.57rem;                           /* 36px */
  line-height: 1.2;
}

/* Заголовок сверху - большой и стильный */
.page-title {
  font-size: 2.86rem;                        /* 40px */
  font-weight: 800;
  text-align: center;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 2.14rem;                    /* 30px */
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
  font-family: 'Segoe UI', sans-serif;
}

.logo-wrapper {
  text-align: center;
  margin-top: 2.14rem;                       /* 30px */
}

.logo-title {
  font-size: 3rem;                           /* 42px */
  font-weight: 900;
  font-family: 'Segoe UI', sans-serif;
  color: #1e3a8a;
  text-align: center;
  position: relative;
  margin: 1.43rem auto 0.71rem;              /* 20px auto 10px */
  display: inline-block;
  padding-bottom: 0.71rem;                   /* 10px */
  transform: translateY(-0.71rem);           /* -10px */
  margin-bottom: 3.57rem;                    /* 50px */
}

.logo-title::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 80%;
  height: 0.29rem;                           /* 4px */
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transform: translateX(-50%);
  border-radius: 0.14rem;                    /* 2px */
}

.top-bar {
  background-color: #1f2937;
  padding: 1.14rem 0;                        /* 16px 0 */
  width: 100%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.top-bar-inner {
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 0 1.14rem;                        /* 16px */
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.top-bar-title {
  color: #f9fafb;
  font-size: 1.43rem;                        /* 20px */
  font-weight: 700;
  letter-spacing: 0.04rem;                   /* 0.5px */
}

.top-bar-center-nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 1.43rem;
}

.top-bar-back-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.43rem;
  white-space: nowrap;
}

.top-bar-back-btn-icon {
  color: #f59e0b;
  font-size: 1.36rem;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-0.04rem);
}

.top-bar-back-btn-text {
  color: inherit;
}

.top-bar-auth {
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}


.columns-section {
  margin-top: 2.14rem;                       /* 30px */
}

.columns-section-header {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 1rem;
  margin-bottom: 0.86rem;
  flex-wrap: wrap;
}

.columns-section-header > h2 {
  margin: 0;
  flex: 0 0 auto;
  line-height: 1.15;
}

.loaded-template-badge {
  display: inline-flex;
  align-items: center;
  align-self: baseline;
  gap: 0.71rem;
  margin-left: 0;
  flex-wrap: nowrap;
}

.loaded-template-name {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  line-height: 1.15;
}

.loaded-template-reset-btn {
  padding: 0.43rem 0.86rem;
  font-size: 0.93rem;
  line-height: 1.2;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .columns-section-header {
    align-items: flex-start;
  }

  .loaded-template-badge {
    margin-left: 0;
    flex-wrap: wrap;
  }
}

/* верхний горизонтальный блок */
.main-wrapper {
  display: flex;
  gap: 0.71rem;                              /* 10px */
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
  margin-top: 1.43rem;                       /* 20px */
}

/* нижний блок структуры таблицы на всю ширину */
.columns-full {
  width: 100%;
  box-sizing: border-box;
  background-color: #fafafa;
  padding: 1.43rem;                          /* 20px */
  border-radius: 0.57rem;                    /* 8px */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  margin-top: 1.43rem;                       /* 20px */
}

.sidebar {
  background-color: #fff;
  padding: 1.43rem;                         /* ~20px */
  border-right: 0.071rem solid #eee;        /* 1px */
  border-radius: 0.57rem;                   /* 8px */
  box-sizing: border-box;
  overflow-y: auto;

  /* базовая ширина для очень широких экранов */
  width: 29.5rem;
  min-width: 29.5rem;
  max-width: 30rem;
}

/* заголовок блока сайдбара — как у раздела настроек БД */
.sidebar > h3 {
  margin: 0 0 0.86rem 0;                    /* отступ вниз */
  padding: 0.57rem 0.86rem;                 /* внутренние отступы */
  background: #f6f7f9;                      /* светлый фон «плашки» */
  border: 0.071rem solid #e5e7eb;           /* тонкая рамка */
  border-radius: 0.57rem;                   /* скругление углов */
  line-height: 1.25;
  font-weight: 700;
}

/* >= 3000px: чуть шире, чтобы не теряться на 32–34" */
@media (min-width: 3000px) {
  .sidebar {
    width: 30.5rem;                        /* ~270px при 14px */
    max-width: 30.5rem;
  }
}

/* 2560–2999px (WQHD/UWQHD) */
@media (min-width: 2560px) and (max-width: 2999.98px) {
  .sidebar {
    width: 31rem;                           /* ~260px при 13px */
  }
}

/* 2200–2559px (редкие промежуточные) */
@media (min-width: 2200px) and (max-width: 2559.98px) {
  .sidebar {
    width: 32.5rem;
  }
}

/* 1920–2199px (24–27", типичные десктопы) */
@media (min-width: 1920px) and (max-width: 2199.98px) {
  .sidebar {
    width: 32.5rem;                         /* ~258px при 12px */
  }
}

/* 1600–1919px */
@media (min-width: 1600px) and (max-width: 1919.98px) {
  .sidebar {
    width: 30rem;
  }
}

/* 1366–1599px (13–14" ноутбуки FHD/HD) */
@media (min-width: 1366px) and (max-width: 1599.98px) {
  .sidebar {
    width: 29rem;
  }
}

/* <= 1365px (узкие/старые ноутбуки) */
@media (max-width: 1365.98px) {
  .sidebar {
    width: 28rem;
  }
}





.main-content {
  flex: 1;
  padding: 1.43rem;                         /* 20px */
  box-sizing: border-box;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  border-radius: 0.57rem;                   /* 8px */
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: #fafafa;
}

@media (max-width: 1024px) {
  .sidebar {
    width: 14.29rem;                        /* 200px */
  }

  .main-content {
    padding: 1.07rem;                       /* 15px */
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    max-width: 100%;
    padding: 0.71rem;                       /* 10px */
  }
}

.page-container {
  max-width: 2400px;
  margin: 0 auto;
  padding-right: 2.86rem;                   /* 40px */
  padding-left: 2.86rem;                    /* 40px */
  box-sizing: border-box;
  overflow-x: hidden;
}

.sidebar h3 {
  font-size: 1rem;                          /* 14px */
  color: #5f7890;
  font-weight: normal;
  margin-bottom: 1.07rem;                   /* 15px */
}

.table-wrapper {
  padding-left: 0.71rem;                    /* 10px */
  padding-right: 0.71rem;                   /* 10px */
  box-sizing: border-box;
  overflow-x: auto;
  width: 100%;
}

.table-wrapper table {
  width: 100%;
  table-layout: fixed;
  box-sizing: border-box;
  border-collapse: collapse;
}

.table-wrapper table input:not([type="checkbox"]),
.table-wrapper table select,
.table-wrapper table textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.29rem 0.43rem;                 /* 4px 6px */
  font-size: 0.9rem;
  line-height: 1.4;
}

.tooltip-icon {
  cursor: pointer;
  color: #e91e63;
  background-color: #f2f6fb;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.8em;
  height: 0.8em;
  font-size: 1rem;
  line-height: 1;
  position: relative;
  top: 0;
  padding: 0;
  margin-top: 0.29rem;                      /* 4px */
  margin-left: 0.43rem;                     /* 6px */
  transition: background-color 0.2s ease, color 0.2s ease, top 0.2s ease;
}

.tooltip-text {
  position: absolute;
  top: 0;
  left: auto;
  right: 100%;
  margin-right: 0.86rem;                    /* 12px */
  background-color: #fff;
  color: #333;
  border: 1px solid #ccc;
  padding: 0.71rem 1.07rem 1.07rem 1.07rem; /* 10px 15px 15px 15px */
  border-radius: 0.57rem;                   /* 8px */
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);

  min-width: 22.86rem;                      /* 320px */
  max-width: 42.86rem;                      /* 600px */
  width: max-content;

  font-size: 0.93rem;                       /* 13px */
  z-index: 999;
  white-space: normal;
}

.tooltip-text code {
  background: #f5f5f5;
  padding: 0.14rem 0.43rem;                 /* 2px 6px */
  border-radius: 0.29rem;                   /* 4px */
  margin: 0.14rem;                          /* 2px */
  display: inline-block;
}

.tooltip-close {
  position: absolute;
  top: 0.43rem;                             /* 6px */
  right: 0.43rem;                           /* 6px */
  background: transparent;
  border: none;
  color: #999;
  font-size: 0.93rem;                       /* 13px */
  line-height: 1;
  cursor: pointer;
  padding: 0.43rem;                         /* 6px */
  border-radius: 0.43rem;                   /* 6px */
  transition: color 0.2s ease, background-color 0.2s ease;
}

.tooltip-close:hover {
  color: #fff;
  background-color: #dc2626;
}

.field-lock {
  position: relative;
  display: inline-block;
}

.field-lock.disabled select,
.field-lock.disabled input,
.field-lock.disabled textarea {
  pointer-events: none;
  opacity: 0.5;
  cursor: not-allowed;
}

.flash-border {
  border: 2px solid red !important;
  animation: flashBorder 0.6s ease-in-out;
}

@keyframes flashBorder {
  0% {
    box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.6);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
  }
}

.fake-disabled {
  pointer-events: none;
  opacity: 0.5;
}

.type-select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.29rem 0.43rem;                 /* 4px 6px */
  font-size: 1rem;                          /* 14px */
}

select.type-select {
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box;
}

.select-wrapper {
  display: block;
  width: 100%;
}

.select-wrapper select {
  width: 100%;
  box-sizing: border-box;
}

.click-catcher-wrapper {
  position: relative;
  display: inline-block;
  min-height: 2.14rem;                      /* 30px */
  width: 100%;
}

.click-catcher-wrapper.fake-disabled,
.click-catcher-wrapper.disabled {
  cursor: not-allowed;
}

.click-catcher-wrapper::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 0, 0, 0.00);
  z-index: 1;
  pointer-events: none;
}

.dirty-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: 50;
  pointer-events: auto;
  cursor: not-allowed;
}

.textarea-with-tooltip {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.43rem;                             /* 6px */
  width: 100%;
}

.textarea-with-tooltip textarea {
  width: 80%;
  box-sizing: border-box;
  min-height: 4.29rem;                      /* 60px */
}

.click-catcher-wrapper,
.field-wrapper {
  width: 100%;
  display: block;
}

.remove-btn {
  width: auto;
  height: 2.29rem;                          /* 32px */
  min-width: 2.29rem;                       /* 32px */
  padding: 0.29rem 0.71rem;                 /* 4px 10px */
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  cursor: pointer;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 0.43rem;                   /* 6px */
  transition: background-color 0.2s ease;
}

.remove-btn:hover {
  background-color: #ff3b3b !important;
}

.remove-icon {
  display: none;
  font-size: 1.29rem;                       /* 18px */
}

@media (max-width: 1920px) {
  .remove-text {
    display: none;
  }

  .remove-btn {
    width: 2.29rem;                         /* 32px */
    height: 2.29rem;                        /* 32px */
    padding: 0;
  }

  .remove-icon {
    display: inline-block;
    width: 100%;
    height: 100%;
    line-height: 2.29rem;                   /* 32px */
    text-align: center;
  }
}


.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 0.43rem;                  /* 6px */
  font-size: 0.93rem;            /* 13px */
  line-height: 1;
}

.inline-checkbox input[type="checkbox"] {
  margin: 0;
  transform: translateY(1px);
}

.table-wrapper input[type="checkbox"] {
  vertical-align: middle;
  transform: scale(1);
  margin: 0;
  font-size: 1rem;
}

.table-wrapper label {
  font-size: 0.93rem;            /* 13px */
  line-height: 1;
  margin: 0;
}

.clear-template-btn {
  background: none;
  border: 1px solid #ccc;
  padding: 0.21rem 0.57rem;      /* 3px 8px */
  border-radius: 0.43rem;        /* 6px */
  cursor: pointer;
  font-size: 0.86rem;            /* 12px */
}

.clear-template-btn:hover {
  background: #f0f0f0;
}

.clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.43rem;                  /* 6px */
  padding: 0.29rem 0.57rem;      /* 4px 8px */
  font-size: 0.86rem;            /* 12px */
  border: 1px solid #ccc;
  background-color: #f8f8f8;
  color: #333;
  border-radius: 0.29rem;        /* 4px */
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.clear-btn:hover {
  background-color: #eaeaea;
}

.clear-icon {
  font-size: 1.14rem;            /* 16px */
  line-height: 1;
  transform: translateY(1px);
}

.clear-label {
  font-size: 0.86rem;            /* 12px */
}

.invalid-format {
  border: 2px solid #e74c3c !important;
  background-color: #fff5f5;
}

.format-error-text {
  color: #e74c3c;
  font-size: 0.86rem;            /* 12px */
  margin-top: 0.14rem;           /* 2px */
  display: none;
}

.format-error-text.visible {
  display: block;
}

.invalid-flash {
  box-shadow: 0 0 5px 2px red;
  transition: box-shadow 0.2s ease;
}

.pro-entry {
  display: inline-flex;
  align-items: center;
  gap: 0.29rem;                  /* 4px */
  margin: 0.14rem 0.29rem;       /* 2px 4px */
  width: 6.43rem;                /* 90px */
  justify-content: space-between;
  box-sizing: border-box;
}

.pro-entry input[type="checkbox"] {
  margin-right: 0.21rem;         /* 3px */
}

.input-error {
  border: 1px solid red !important;
  background-color: #ffe6e6;
}

.pro-entry input.pro-percent {
  width: 1.93rem !important;     /* 27px */
  height: 1.43rem !important;    /* 20px */
  min-height: 0 !important;
  font-size: 0.79rem !important; /* 11px */
  padding: 0.14rem 0.14rem !important; /* 2px 2px */
  text-align: right !important;
  line-height: 1.14rem !important;     /* 16px */
  background-color: #fff;
  box-sizing: border-box;
  margin-left: 0.14rem;          /* 2px */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.pro-entry .pro-percent-sign {
  font-size: 0.79rem;            /* 11px */
  margin-left: 0.14rem;          /* 2px */
  color: #666;
}

.pro-entry input.pro-percent::placeholder {
  text-align: center;
  color: #999;
  line-height: 1.43rem;          /* 20px */
}

.pro-entry input.pro-percent::-webkit-inner-spin-button,
.pro-entry input.pro-percent::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pro-year-fixed::-webkit-inner-spin-button,
.pro-year-fixed::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pro-year-fixed {
  -moz-appearance: textfield;
}

.pro-options label {
  display: inline-block;
  margin-bottom: 0.29rem;        /* 4px */
  font-weight: 500;
}

.pro-options select {
  margin-bottom: 0.57rem;        /* 8px */
}

/* только для текстовой области "Шаблоны" */
.tpl-wrap {
  position: relative;
}

.tpl-wrap textarea {
  line-height: 1.43rem;          /* 20px */
  font-size: 1rem;               /* 14px */
}

.tpl-gutter {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2rem;                   /* 28px */
  overflow: hidden;
  pointer-events: none;
}

.tpl-gutter .btn {
  height: 1.43rem;               /* 20px */
  line-height: 1.43rem;          /* 20px */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.modal-overlay {
  backdrop-filter: blur(1px);
}

.modal.array-editor .btn-primary,
.modal.array-editor .btn-secondary,
.modal.array-editor .btn-close,
.modal.array-editor .btn-add,
.modal.array-editor .btn-del {
  border: 1px solid #d0d7de;
  background: #fff;
  border-radius: 0.57rem;        /* 8px */
  padding: 0.43rem 0.71rem;      /* 6px 10px */
  cursor: pointer;
}

.modal.array-editor .btn-primary {
  background: #1e66f5;
  color: #fff;
  border-color: #1e66f5;
}

.modal.array-editor .btn-add {
  width: 2rem;                   /* 28px */
}

.modal.array-editor .btn-del {
  width: 2rem;                   /* 28px */
}

.pro-badge {
  vertical-align: middle;
}

.array-nesting-wrap {
  margin-top: 0.43rem;           /* 6px */
}

/* первая подпись уходит на отдельную строку */
.pro-json-options label:first-of-type {
  display: block;
  margin-bottom: 0.29rem;        /* 4px */
}

/* радиокнопки выстраиваются в одну линию под подписью */
.pro-json-options label:not(:first-of-type) {
  display: inline-block;
  margin-right: 0.86rem;         /* 12px */
  white-space: nowrap;
}

.ddbtn-label {
  color: #000 !important;
  font-size: 0.86rem !important; /* 12px */
  line-height: 1.4;
  visibility: visible !important;
}

.info-icon {
  display: inline-block;
  margin-left: 0.43rem;          /* 6px */
  width: 1.6em;
  height: 1.6em;
  line-height: 1.6em;
  border-radius: 50%;
  background: #007bff;
  color: #fff;
  text-align: center;
  font-size: 0.9em;
  font-weight: bold;
  cursor: help;
}

.info-icon {
  display: inline-block;
  margin-left: 0.07rem;          /* 1px */
  width: 1.3em;
  height: 1.3em;
  line-height: 1.3em;
  border-radius: 50%;
  background: #007bff;
  color: #fff;
  text-align: center;
  font-size: 0.8em;
  font-weight: bold;
  cursor: help;
}

/* PRO: сворачивание больших списков */
.pro-toggle-wrap {
  margin-top: 0.43rem;           /* 6px */
}

.pro-toggle-btn {
  background: #e2e8f0;
  color: #1f2937;
  border: 1px solid #cbd5e1;
  border-radius: 0.29rem;        /* 4px */
  font-size: 0.86rem;            /* 12px */
  padding: 0.21rem 0.57rem;      /* 3px 8px */
  cursor: pointer;
  margin-bottom: 0.43rem;        /* 6px */
}

.pro-toggle-btn:hover {
  background: #cbd5e1;
}

.pro-toggle-body.hidden {
  display: none !important;
}

.pro-del-btn--compact {
  padding: 0 .35em;
  min-width: 1.6em;
  height: 1.6em;
  font-size: .85em;
}

.pro-add-btn--compact {
  padding: 0 .35em;
  min-width: 1.6em;
  height: 1.6em;
  font-size: .85em;
}

.disabled-field {
  background-color: #eee;
  color: #666;
}

#schema:disabled {
  background-color: #eee !important;
  color: #666 !important;
  cursor: not-allowed !important;
}

.sql-mini-checkbox {
  width: 0.99rem;
  height: 0.99rem;
  margin: 0;
  transform: translateY(1px);
}

/* === Templates panel === */
.tpl-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tpl-item {
  display: flex;
  flex-direction: column;
  border-bottom: 0.071rem solid #eee;      /* 1px */
  padding: 0.429rem 0.286rem;              /* 6px 4px */
  font-size: 0.93rem;                      /* чуть меньше базового на сверхшироких */
}

/* <= 2560px: ещё немного уменьшаем */
@media (max-width: 2560px) {
  .tpl-item {
    font-size: 0.9rem;
  }
}

/* <= 1920px: ещё компактнее */
@media (max-width: 1920px) {
  .tpl-item {
    font-size: 0.85rem;
  }
}

/* переключатель "Развернуть все / Свернуть все" */
.tpl-toggle-all-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.571rem;                 /* 8px */
  margin-bottom: 0.429rem;       /* 6px */
}

.tpl-toggle-all-label {
  font-size: 0.85rem;
  color: #111827;
}

/* синий слайдер */
.tpl-switch {
  position: relative;
  display: inline-block;
  width: 2.857rem;               /* 40px */
  height: 1.429rem;              /* 20px */
}

.tpl-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tpl-switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #e5e7eb;
  border-radius: 999px;
  transition: 0.2s;
}

.tpl-switch-slider::before {
  content: "";
  position: absolute;
  width: 1.143rem;               /* 16px */
  height: 1.143rem;
  left: 0.143rem;
  top: 0.143rem;
  background-color: #fff;
  border-radius: 999px;
  box-shadow: 0 0 0.071rem rgba(0,0,0,0.3);
  transition: 0.2s;
}

/* включено: синий, круг вправо */
.tpl-switch input:checked + .tpl-switch-slider {
  background-color: #2563eb;
}

.tpl-switch input:checked + .tpl-switch-slider::before {
  transform: translateX(1.286rem); /* 18px */
}

.tpl-row {
  display: flex;
  align-items: center;
  gap: 0.571rem;                           /* 8px */
}

.tpl-toggle {
  cursor: pointer;
  width: 1.714rem;
  height: 1.714rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0.071rem solid #dbe2f0;
  border-radius: 0.429rem;
  background: #fff;
  user-select: none;
  font-size: 0;               /* Иконка только через SVG */
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.tpl-toggle .ico{
  width: 0.95rem;
  height: 0.95rem;
  display:block;
  fill:#1f6feb;               /* единый синий */
}

.tpl-toggle:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  box-shadow: 0 0 0 0.071rem rgba(59,130,246,.15);
}

.tpl-toggle:active {
  background: #e5f0ff;
}

.tpl-title {
  flex: 1 1 auto;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* имя шаблона кликабельно */
.tpl-title-link {
  cursor: pointer;
}

.tpl-title-link:hover {
  text-decoration: underline;
}

/* активный шаблон в сайдбаре */
.tpl-item-active .tpl-row {
  background-color: #fff7e6;        /* светло-оранжевый фон */
  border-radius: 0.285rem;         /* ~4px */
}

.tpl-item-active .tpl-title-link {
  color: #b45309;                  /* чуть более тёмный текст */
}



/* контейнер для кнопок действий */
.tpl-actions {
  display: inline-flex;
  gap: 0.429rem;                           /* 6px */
}

/* сами кнопки-иконки */
.tpl-btn {
  width: 1.714rem;                         /* 24px */
  height: 1.714rem;                        /* 24px */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0.071rem solid #ccc;             /* 1px */
  border-radius: 0.429rem;                 /* 6px */
  background: #fff;
  cursor: pointer;
  font-size: 0.857rem;                     /* ~12px */
  line-height: 1;
  color: #111;                             /* чтобы иконки не были белыми */
  font-family: "Segoe UI Symbol","Noto Color Emoji",
               "Apple Color Emoji",system-ui,sans-serif;
}

/* символы через ::before */
.tpl-btn-edit::before { content: "✎"; }
.tpl-btn-run::before  { content: "▶"; }
.tpl-btn-link::before { content: "⛓"; }
.tpl-btn-del::before  { content: "✕"; }

.tpl-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.tpl-meta {
  font-size: 0.9em;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  margin-top: 0.143rem;      /* 2px */
  padding-left: 0;
  display: inline-flex;      /* аккуратное выравнивание стрелки и текста */
  align-items: center;
  gap: 0.286rem;             /* ~4px между маркером и текстом */
}

/* плавное затухание справа — без изменений */
.tpl-meta.fade-right {
  -webkit-mask-image: linear-gradient(
    to right,
    black 0%,
    black calc(100% - 2.714rem),
    rgba(0,0,0,0) calc(100% - 0.571rem)
  );
          mask-image: linear-gradient(
    to right,
    black 0%,
    black calc(100% - 2.714rem),
    rgba(0,0,0,0) calc(100% - 0.571rem)
  );
}

.tpl-rel-edge-line {
  padding-left: 0;
  margin-left: 0;
}

/* === Relations sidebar === */
.tpl-rel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: default;
  transition: background 0.2s ease;
}
.tpl-rel:hover {
  background: #f1f5f9;
}
.tpl-rel-name {
  font-weight: 600;
  color: #1e3a8a;
}
.tpl-rel-controls {
  display: flex;
  gap: 6px;
}
.tpl-rel-controls button {
  border: none;
  background: #e2e8f0;
  color: #1f2937;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.tpl-rel-controls button:hover {
  background: #cbd5e1;
}
.tpl-rel-expanded {
  margin-left: 20px;
  padding-left: 8px;
  border-left: 2px solid #93c5fd;
  color: #374151;
  font-size: 0.9rem;
}

/* плавающая круглая "+" — оставляем, но без px */
.tpl-btn-add-icon {
  position: absolute;
  right: 0.75rem;         /* 12px */
  bottom: 0.5rem;         /* 8px  */
  width: 1.75rem;         /* 28px */
  height: 1.75rem;        /* 28px */
  border-radius: 50%;
  border: 0;
  background: #2563eb;
  color: #fff;
  font-size: 1.25rem;     /* 20px */
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}
.tpl-btn-add-icon:hover  { background: #1d4ed8; }
.tpl-btn-add-icon:active { background: #1e40af; }

/* В САЙДБАРЕ (#rel-list) рендерим кнопку строкой — без абсолютного позиционирования */
#rel-list .tpl-btn-add-icon {
  position: static;
  width: auto;
  height: auto;
  border-radius: 0.5rem;          /* 8px */
  border: 0.071rem solid #9ca3af; /* 1px */
  background: #f8fafc;
  color: #111827;
  font-size: 0.95rem;
  padding: 0.429rem 0.857rem;     /* 6px 12px */
}
#rel-list .tpl-btn-add-icon:hover  { background: #e2e8f0; }
#rel-list .tpl-btn-add-icon:active { background: #dbeafe; }




/* === Relations Diagram Modal === */
.relation-diagram-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.relation-diagram-modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);

  /* фиксируем окно в пределах экрана */
  width: min(1100px, 94vw);
  max-height: 88vh;
  height: 88vh;

  /* чтобы заголовок+крестик были всегда видны */
  display: flex;
  flex-direction: column;

  padding: 16px 18px 18px;
  position: relative;
  text-align: center;
  font-family: 'Segoe UI', sans-serif;

  overflow: hidden; /* важно: контент не должен раздувать модалку */
}

/* viewport под диаграмму — теперь СКРОЛЛ (без масштабирования) */
.diagram-viewport{
  flex: 1;
  min-height: 0;          /* чтобы flex нормально ужимал */
  overflow: auto;         /* скролл вместо scale */
  position: relative;
  display: block;

  /* “недоступные поля” сверху/снизу + боковые отступы */
  padding: 0.75rem 1.1rem 1.6rem 1.1rem; /* top right bottom left */
}

/* чтобы внизу был гарантированный “воздух”, даже если контент упирается */
.diagram-wrap{
  padding-bottom: 1.2rem;
}

.relation-diagram-modal h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.4rem;
  color: #1e3a8a;
}

.relation-diagram-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: none;
  font-size: 1.5rem;
  color: #666;
  cursor: pointer;
}
.relation-diagram-close:hover { color: #000; }

:root { --diag-gray: #cbd5e1; }

/* контейнер диаграммы: группы идут вертикально друг за другом */
.diagram-wrap{
  position: relative;
  display: grid;
  row-gap: clamp(1rem, 2.4vw, 1.6rem); /* расстояние между блоками parent->children */
}

/* один блок (parent слева, его children справа) */
.diag-group{
  position: relative;
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) minmax(13rem, 1fr);
  column-gap: clamp(2rem, 7vw, 5rem); /* ДАЛЬШЕ друг от друга — линии длиннее */
  align-items: start;
}

/* колонки внутри группы */
.diagram-col-left{  display: grid; }
.diagram-col-right{ display: grid; gap: clamp(.6rem,1.4vw,.9rem); }

/* заголовок таблицы в боксе */
.table-title{
  font-weight: 700;
  margin-bottom: .35rem;
}

/* бокс родителя/ребёнка: делаем чуть уже, прижимаем к краям треков */
.diagram-parent, .diagram-child{
  width: 100%;
  max-width: clamp(14rem, 34vw, 22rem); /* уже, чем было */
  justify-self: stretch;
}

/* список колонок и сами строки-«якоря» */
.col-list{ display: grid; gap: .25rem; }
.col-item{
  font-size: .95rem;
  line-height: 1.25rem;
  padding: .15rem .35rem;
  background: rgba(0,0,0,.02);
  border-radius: .35rem;
}

/* единый SVG поверх всех групп */
.diagram-svg-global{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;   /* стрелка не обрезается по краю svg */
  z-index: 5;         /* svg поверх parent/child боксов */
}

.diagram-path{
  stroke: var(--diag-gray);
  stroke-width: .125rem;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}





.diagram-parent {
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

.diagram-child {
  background: #dcfce7;
  color: #166534;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

/* ===== Feedback popup ===== */

.feedback-popup-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;        /* немодальное окно: без затемнения */
  z-index: 1100;                 /* выше auth-popup */
  pointer-events: none;          /* клики проходят к основной форме */
}

.feedback-popup {
  position: fixed;               /* позицию задаёт JS под кнопками */
  width: min(28.75vw, 644px);    /* +15% от 25vw/560px */
  height: min(38vh, 598px);      /* +15% от 33vh/520px */
  min-width: 368px;              /* +15% от 320px */
  min-height: 368px;             /* +15% от 320px */
  background: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  padding: 1rem 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;          /* окно кликабельно */
}

.feedback-popup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.feedback-popup-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
  line-height: 1.2;
}

/* Billing modal: заголовок = "Текущий баланс: <SUM> строк" */
.billing-popup-title {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.billing-popup-title .billing-balance-amount {
  font-size: 1.45rem;     /* чуть больше */
  font-weight: 750;
  color: #1f2937;         /* зелёный как "+ Добавить поле" */
  letter-spacing: 0.01em;
}

/* ===== Billing modal: История (покупок | списаний) в одном месте ===== */

.billing-history-row {
  margin-top: 0.85rem;        /* пустая строка от "Действует до" */
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.billing-history-label {
  font-weight: 650;
  font-size: 0.95rem;
  color: #111827;
}

.billing-history-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.billing-history-sep {
  color: #9ca3af;
  font-size: 0.95rem;
  line-height: 1;
}

.billing-history-tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 0.18rem 0.50rem;
  border-radius: 0.43rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-align: left;

  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

/* БАЗА (всегда): фиксируем метрики, чтобы не было сдвигов при hover */
.billing-history-tab-text {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  color: #111827;
}

.billing-history-tab-icon {
  font-size: 0.92rem;
  line-height: 1;
  color: #6b7280;
}

/* неактивное состояние (цвета) */
.billing-history-tab:not(:hover):not(.active) .billing-history-tab-text {
  color: #111827;
}

.billing-history-tab:not(:hover):not(.active) .billing-history-tab-icon {
  color: #6b7280;
}


/* hover: инверсия текста (белый) + правильный “общий” синий */
.billing-history-tab:hover {
  background: rgba(37, 99, 235, 0.92);
  border-color: rgba(37, 99, 235, 0.30);
}

.billing-history-tab:hover .billing-history-tab-text,
.billing-history-tab:hover .billing-history-tab-icon {
  color: #fff;
}

/* active: как у капчи — полупрозрачный фон + “общий” синий текст/иконка */
.billing-history-tab.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
}

.billing-history-tab.active .billing-history-tab-text {
  font-weight: 700;
  color: #2563eb;
}

.billing-history-tab.active .billing-history-tab-icon {
  color: #2563eb;
  line-height: 1;
}



.billing-history-list {
  margin-top: 0.45rem;
}

.billing-history-item {
  font-size: 0.85rem;     /* чуть меньше */
  line-height: 1.35;
}




.feedback-popup-close {
  border: 1px solid #d0d7de;
  background: #fff;
  color: #111827;               /* фикс: видимый крестик */
  border-radius: 0.57rem;
  width: 1.8rem;                /* -15% от 2.1rem */
  height: 1.8rem;               /* -15% от 2.1rem */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
}

.feedback-popup-close:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.feedback-popup-body {
  flex: 1;
  overflow: auto;
  padding-right: 0.25rem;
}

.feedback-field {
  margin-bottom: 0.65rem;
}

.feedback-label {
  font-size: 0.86rem;
  color: #6b7280;
  margin-bottom: 0.14rem;
  display: block;
}

.feedback-input,
.feedback-select,
.feedback-textarea {
  width: 100%;
  padding: 0.57rem 0.71rem;
  border: 1px solid #d0d7de;
  border-radius: 0.57rem;
  font-size: 0.95rem;
  outline: none;
}

.feedback-textarea {
  resize: none;
  min-height: 10.0rem;
  font-size: 1.0rem;
}

.feedback-hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.feedback-actions {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.feedback-error {
  color: #b91c1c;
  font-size: 0.9rem;
  margin: 0.25rem 0 0.5rem;
}

.feedback-ok {
  color: #166534;
  font-size: 0.9rem;
  margin: 0.25rem 0 0.5rem;
}

/* ошибка капчи — прямо под лейблом "Капча: ..." */
.feedback-captcha-error {
  color: #b91c1c;
  font-size: 0.9rem;
  margin: 0.2rem 0 0.4rem;
  display: none;
}

.feedback-captcha-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.feedback-captcha-img {
  height: 2.2rem;
  border-radius: 0.57rem;
  border: 1px solid #d0d7de;
}

/* FIX: текст кнопок больше не белый на белом */
.feedback-btn {
  border: 1px solid #d0d7de;
  background: #fff;
  color: #111827;
  border-radius: 0.57rem;
  padding: 0.57rem 0.85rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.feedback-btn:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.feedback-btn-primary {
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  border-radius: 0.57rem;
  padding: 0.6rem 0.95rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.feedback-btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

/* SEO clouds (ниже кнопки "Сгенерировать") */

:root {
  /* Сдвиг ВНУТРИ подложки: двигаем облака вниз, подложка остаётся на месте */
  --seo-clouds-inner-top-offset: clamp(1.2rem, 1.2vw + 0.8rem, 2.2rem);
  --seo-clouds-inner-bottom-offset: clamp(1.2rem, 1.2vw + 0.8rem, 2.2rem);
  
    /* Раздельные расстояния между облаками */
  --seo-clouds-gap-x: clamp(3.4rem, 2.4vw + 1rem, 4.8rem); /* 👈 горизонталь (сделал заметнее) */
  --seo-clouds-gap-y: clamp(1.8rem, 1.2vw + 0.6rem, 2.6rem); /* вертикаль как было */
}

.seo-clouds {
  /* Подложка остаётся как сейчас (НЕ трогаем её позицию) */
  margin-top: clamp(1.2rem, 1.2vw + 0.8rem, 2.2rem);
  padding: 1.25rem 1.25rem 1.35rem;
  border: 1px solid #e5e7eb;
  border-radius: 1.15rem;
  background: #fafafa;
}

/* Вводный текст над SEO-облаками (SEO-intro) */
.seo-clouds-intro {
  max-width: 72rem;                  /* чтобы не растягивался в простыню */
  margin: 0 auto 1.8rem auto;        /* по центру + отступ до облаков */
  margin-top: 2.8rem;

  text-align: center;
  font-size: clamp(1.8rem, 1.3vw + 1rem, 2.15rem);
  font-weight: 500;                  /* НЕ жирный, не заголовок */
  line-height: 1.55;
  color: #1f2937;                    /* тёмно-серый, не кричащий */

  letter-spacing: 0.01em;
}

.seo-clouds-grid {
  /* Двигаем вниз только содержимое (облака) */
  padding-top: var(--seo-clouds-inner-top-offset);
  padding-bottom: var(--seo-clouds-inner-bottom-offset);

  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;

  /* Надёжно для flex: gap (row column) */
  gap: var(--seo-clouds-gap-y) var(--seo-clouds-gap-x);
}



/* Большие облака, но текст чуть менее жирный */
.seo-cloud {
  /*
    Всегда 2 в ряд:
    - flex-basis = 50% - gap/2 (через calc)
    - max-width ограничиваем, чтобы на ультрашироких не были “простынями”
    - размеры и шрифт масштабируем clamp'ом (выглядит одинаково на разных экранах)
  */
  flex: 0 1 calc(50% - (var(--seo-clouds-gap-x) / 2));
  max-width: clamp(38rem, 46vw, 52rem);

  display: flex;
  flex-direction: column;

  padding: clamp(2.2rem, 1.1vw + 1.4rem, 3rem) clamp(2.1rem, 1vw + 1.2rem, 2.8rem);
  border-radius: clamp(2.1rem, 1vw + 1.2rem, 2.8rem);
  border: 1px solid #c7ddff;
  background: linear-gradient(180deg, #f8fcff 0%, #eef6ff 100%);
  color: #0b2b6a;

  font-size: clamp(1.14rem, 0.35vw + 1.02rem, 1.36rem);
  font-weight: 650; /* менее жирный, чем 800 */
  line-height: 1.55;

  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;

  min-height: clamp(11.2rem, 2.2vw + 9.2rem, 13.8rem);
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

/* Заголовок и описание внутри облака */
.seo-cloud-title {
  font-size: clamp(1.18rem, 0.45vw + 1.05rem, 1.46rem);
  font-weight: 750;
  line-height: 1.25;
  margin: 0 0 0.9rem 0;
  color: #0b2b6a;
}

.seo-cloud-desc {
  font-size: clamp(0.98rem, 0.25vw + 0.92rem, 1.12rem);
  font-weight: 500;
  line-height: 1.55;
  margin: 0;
  color: rgba(11, 43, 106, 0.78);
}

.seo-cloud:hover {
  transform: translateY(-4px);
  box-shadow: 0 26px 64px rgba(16, 24, 40, 0.18);
  filter: saturate(1.08);
}

/* На узких экранах — 1 облако на строку (и оно автоматически по центру) */
@media (max-width: 980px) {
  .seo-cloud {
    flex-basis: 100%;
    max-width: clamp(38rem, 92vw, 56rem);
    min-height: auto;
  }
}

/* ---------- тарифные планы в "облаках" (страница /tplans) ---------- */

.tplans-title {
  text-align: center;
  margin-top: 1.8rem;
  margin-bottom: 0.6rem;
  font-size: clamp(1.35rem, 1.0vw + 1.05rem, 1.9rem);
  font-weight: 650;
  color: #111827;
}

.tplans-subtitle {
  text-align: center;
  margin: 0 auto 1.6rem auto;
  max-width: 62rem;
  font-size: 0.98rem;
  line-height: 1.55;
  color: #4b5563;
}

.plan-cloud {
  cursor: pointer;
  user-select: none;
}

.plan-cloud:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 3px;
}

.plan-price {
  font-size: clamp(1.02rem, 0.35vw + 0.95rem, 1.18rem);
  font-weight: 750;
  margin: 0 0 0.65rem 0;
  color: rgba(11, 43, 106, 0.95);
}

.plan-price-num {
  font-size: clamp(1.20rem, 0.55vw + 1.05rem, 1.46rem);
  font-weight: 850;
  color: #19b663; /* как активная кнопка "Далее" */
}

.plan-price-cur {
  font-size: clamp(1.10rem, 0.45vw + 1.00rem, 1.32rem);
  font-weight: 850;
  color: #19b663;
}


.plan-meta {
  font-size: 0.92rem;
  margin: 0 0 0.9rem 0;
  color: rgba(11, 43, 106, 0.75);
}

.plan-features {
  margin: 0.2rem 0 0 1.1rem;
  padding: 0;
  color: rgba(11, 43, 106, 0.78);
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.55;
}

.plan-features li {
  margin: 0.28rem 0;
}

/* Баннер согласий */
.plan-consent {
  display: none;
  margin: 1.2rem auto 1.5rem auto;
  max-width: 62rem;
  padding: 1.05rem 1.15rem 1.0rem;
  border-radius: 1.0rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.06);
}

.plan-consent-title {
  margin: 0 0 0.55rem 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}

.plan-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0.55rem 0;
  color: #111827;
  font-size: 0.95rem;
  line-height: 1.45;
}

.plan-consent-row input[type="checkbox"] {
  margin-top: 0.2rem;
  transform: scale(1.05);
}

.plan-consent-row a {
  color: #2563eb;
  text-decoration: none;
}

.plan-consent-row a:hover {
  text-decoration: underline;
}

.plan-pay-logos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.65rem 0 0.1rem 1.95rem; /* визуально под текстом чекбоксов */
}

.plan-pay-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.6rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #111827;
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
  user-select: none;
}

.plan-consent-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 0.85rem;
}


.plan-selected-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.10);
  color: #1d4ed8;
  font-size: 0.85rem;
  font-weight: 650;
}

/* billing stub */
.billing-wrap {
  max-width: 980px;
  margin: 40px auto;
  padding: 24px 24px 32px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15,23,42,0.06);
  color: #111827;
}

.billing-ok {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(16,185,129,0.12);
  color: #047857;
  font-weight: 750;
  font-size: 0.9rem;
}

/* Шапка основного блока (заголовок + кнопка инструкции) */
.main-content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.main-content-header h2 {
  margin: 0;
}

/* Кнопка "Пошаговая инструкция" */
.howto-btn {
  border-radius: 999px;
  border: 1px solid #111827; /* цвет, как фон auth-btn */
  background-color: transparent;
  color: #111827;
  font-size: 0.9rem;
  padding: 0.36rem 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  gap: 0.35rem;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.howto-btn:hover {
  background-color: #111827;
  color: #f9fafb;
  box-shadow: 0 6px 14px rgba(15,23,42,0.16);
}

.howto-btn:active {
  transform: translateY(1px) scale(0.99);
}

/* Блок с инструкцией внизу страницы */
.howto-guide {
  margin-top: 2.5rem;
  margin-bottom: 1.5rem;
  padding: 1.4rem 1.6rem 1.7rem;
  border-radius: 1.15rem;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 0.95rem;
  line-height: 1.6;
}

.howto-guide h2 {
  margin: 0 0 0.9rem;
  font-size: 1.65rem;
  font-weight: 600;
  color: #111827;
}

.howto-guide h3 {
  margin: 0.7rem 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: #111827;
}

.howto-intro {
  margin: 0 0 1.8rem;
  max-width: 68rem;
  color: #374151;
}

.howto-list {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.howto-list > li {
  margin-bottom: 1.8rem;
  font-size: 1.15rem;
}

.howto-list > li > ul {
  margin: 0.35rem 0 0.35rem 1.4rem;
  padding-left: 1.1rem;
  list-style: disc;
}

.howto-list > li > ul > li {
  margin-bottom: 0.25rem;
  color: #4b5563;
}

/* Адаптив для узких экранов */
@media (max-width: 768px) {
  .main-content-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .howto-btn {
    align-self: flex-start;
  }

  .howto-guide {
    padding: 1.2rem 1.1rem 1.4rem;
    margin-top: 2rem;
  }
}

/* Блок mini-FAQ внизу страницы */
.faq-block {
  margin-top: 2rem;
  margin-bottom: 1.8rem;
  padding: 1.3rem 1.6rem 1.5rem;
  border-radius: 1.15rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 0.95rem;
  line-height: 1.6;
}

.faq-block h2 {
  margin: 0 0 0.8rem;
  font-size: 1.3rem;
  font-weight: 600;
  color: #111827;
}

.faq-item {
  border-radius: 0.9rem;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.55rem;
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "▼";
  font-size: 0.75rem;
  margin-left: 0.6rem;
  color: #6b7280;
  transition: transform 0.15s ease;
}

.faq-item[open] summary::after {
  transform: rotate(-180deg);
}

.faq-item > div {
  margin-top: 0.45rem;
  color: #4b5563;
}

@media (max-width: 768px) {
  .faq-block {
    padding: 1.1rem 1.1rem 1.3rem;
    margin-top: 1.8rem;
  }
}

/* --- Progress line (simple + relations) --- */
.fsql-progress-host {
  width: 100%;
  margin-top: 6px;
}

/* только для simple: чтобы было место под процентами */
.fsql-progress-host--simple {
  padding-bottom: 18px;
}

.fsql-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  margin-bottom: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.fsql-progress-box {
  width: 100%;
  height: 4px;
  background: rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  overflow: visible;            /* чтобы проценты не обрезались */
  position: relative;
}

.fsql-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
  background: linear-gradient(90deg, #2563eb 0%, #2563eb 100%);
  background-image: repeating-linear-gradient(
    90deg,
    rgba(37,99,235,0.00) 0px,
    rgba(37,99,235,0.00) 8px,
    rgba(255,255,255,0.55) 12px,   /* ярче белая вспышка */
    rgba(37,99,235,0.55) 16px,     /* добавляем СИНИЙ в “волну” */
    rgba(37,99,235,0.00) 26px
  );
  background-size: 180px 100%;
  animation: fsql-progress-wave 2s linear infinite;
  box-shadow: 0 0 0 1px rgba(37,99,235,0.20) inset, 0 0 10px rgba(37,99,235,0.25); /* сделать “живее/ярче” */
}

@keyframes fsql-progress-wave {
  0%   { background-position: 0 0; }
  100% { background-position: 180px 0; }
}

.fsql-progress-pct {
  position: absolute;
  top: -16px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #2563eb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  z-index: 5;                   /* гарантированно поверх */
  text-shadow: 0 1px 0 rgba(255,255,255,0.9);
}

/* только для simple: проценты ПОД баром */
.fsql-progress-pct--below {
  top: 10px;
}


/* relations: проценты ПОД линией (чтобы не наезжали на имя таблицы) */
.fsql-progress-host-rel .fsql-progress-box {
  margin-bottom: 16px;          /* место под процент */
}

.fsql-progress-host-rel .fsql-progress-pct {
  top: 10px;                    /* ниже линии (4px) */
}

/* SIMPLE FINISHED: "Отменить" как красный квадрат с белым крестиком */
.fsql-cancel-square {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border: none !important;
  border-radius: 6px;
  background: #dc2626;          /* как danger-hover */
  color: #fff;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.fsql-cancel-square:hover {
  background: #b91c1c;          /* как danger hover darker */
}


/* Плавающая кнопка "Наверх" */
.fsql-scrolltop {
  position: fixed;

  /* адаптивные отступы от краёв (масштабируются вместе с UI) */
  right: 3.25rem;
  bottom: 3.25rem;

  /* адаптивный размер кнопки */
  width: 2.875rem;
  height: 2.875rem;

  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(31, 41, 55, 0.45);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 0.625rem 1.875rem rgba(0,0,0,0.22);
  backdrop-filter: blur(0.375rem);
  -webkit-backdrop-filter: blur(0.375rem);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  z-index: 999999;

  opacity: 0;
  pointer-events: none;
  transform: translateY(0.625rem);
  transition: opacity .18s ease, transform .18s ease, background-color .18s ease, box-shadow .18s ease;

  /* размер стрелки */
  font-size: 1.375rem;
  line-height: 1;

  /* чуть “плотнее” визуально */
  font-weight: 800;
  text-shadow: 0 0 0 rgba(255,255,255,0.92);
}

.fsql-scrolltop.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.fsql-scrolltop:hover {
  background: rgba(31, 41, 55, 0.62);
  box-shadow: 0 0.75rem 2.125rem rgba(0,0,0,0.28);
}

.fsql-scrolltop:active {
  transform: translateY(0.0625rem);
}

@media (prefers-reduced-motion: reduce) {
  .fsql-scrolltop {
    transition: none;
  }
}

.fb-mail-folder-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.fb-mail-folder-btn {
  padding: 0.45rem 0.8rem;
  border: 1px solid #2563eb;
  border-radius: 0.5rem;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.fb-mail-folder-btn.is-active {
  background: #ffffff;
  color: #111827;
}

.fb-admin-thread-card {
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  border: 1px solid #d0d7de;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
}

.fb-admin-thread-card.is-read .fb-admin-thread-main {
  color: #9ca3af;
}

.fb-admin-thread-card.is-unread .fb-admin-thread-main {
  color: #111827;
}

.fb-admin-thread-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.fb-admin-thread-main {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.fb-admin-thread-main:hover {
  background: transparent;
}

.fb-admin-thread-meta {
  font-size: 12px;
  color: #6b7280;
}

.tpl-save-btn-orange {
  background: #f59e0b !important;
  border-color: #d97706 !important;
  color: #ffffff !important;
}

.tpl-save-btn-orange:hover {
  background: #ea580c !important;
  border-color: #c2410c !important;
  color: #ffffff !important;
}

.tpl-save-btn-floating {
  position: fixed !important;
  z-index: 1200 !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18) !important;
}

.api-page-container {
  padding-top: 7.25rem;
}

.api-tool-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0 64px;
}

.api-tool-hero {
  margin-top: 0;
  margin-bottom: 20px;
}

.api-tool-hero h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  line-height: 1.15;
  color: #111827;
}

.api-tool-subtitle {
  color: #4b5563;
  margin-top: 8px;
  margin-bottom: 0;
}

.api-tool-layout {
  display: block;
}

.api-tool-main {
  display: grid;
  gap: 20px;
}

.api-tool-card {
  padding: 20px;
}

.api-tool-card h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  line-height: 1.2;
  color: #111827;
}

.api-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

.api-form-field {
  display: grid;
  gap: 6px;
}

.api-form-field span {
  font-weight: 600;
  color: #111827;
}

.api-form-field input,
.api-form-field select,
.api-form-field textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  line-height: 1.35;
  box-sizing: border-box;
  min-height: 2.75rem;
}

.api-form-field select {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.api-form-field textarea {
  min-height: 10rem;
  resize: vertical;
}

.api-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.api-checkbox-grid label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #111827;
  font-size: 0.98rem;
}

.api-checkbox-grid input[type="checkbox"] {
  margin: 0;
  transform: translateY(1px);
}

.api-actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  align-items: center;
}

.api-actions-row .btn {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 13rem;
}

.api-action-btn {
  padding: 0.75rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.57rem;
}

.api-action-btn-primary {
  font-weight: 700;
}

.api-hidden {
  display: none !important;
}

.api-tool-examples {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.api-tool-example {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 10px;
  padding: 8px 12px;
}

.api-note {
  color: #6b7280;
}

.api-status-box {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.api-subcard {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 12px;
}

.api-subcard-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.api-pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
}

.api-base-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #1d4ed8;
  word-break: break-all;
}

.api-stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.api-stat-chip {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 8px 12px;
}

.api-form-help {
  display: block;
  color: #6b7280;
  font-size: 0.86rem;
  line-height: 1.4;
}

.api-source-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
}

.api-source-status.is-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

@media (max-width: 900px) {
  .api-page-container {
    padding-top: 6.75rem;
  }

  .api-actions-row .btn {
    min-width: 0;
    width: 100%;
  }
}