/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary:  #3b6ef8;
  --c-danger:   #e53e3e;
  --c-success:  #38a169;
  --c-warn:     #d97706;
  --c-bg:       #f7f8fa;
  --c-surface:  #ffffff;
  --c-border:   #e2e8f0;
  --c-text:     #1a202c;
  --c-muted:    #718096;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,.08);

  /* Фоны бейджей/алертов — отдельно от цвета текста, чтобы менять яркость
     независимо в тёмной теме (просто затемнить --c-success и т.п. для фона
     давало нечитаемый низкий контраст). */
  --c-info-bg:    #ebf4ff;
  --c-success-bg: #f0fff4;
  --c-danger-bg:  #fff5f5;
  --c-danger-border: #feb2b2;
  --c-warn-bg:    #fffff0;
  --c-warn-banner-bg: #fef3c7;
  --c-chip-bg:    #eef1f6;
}

/* Тёмная тема: следует системной настройке, а <html data-theme> её переопределяет
   в обе стороны (переключатель в шапке). Значения — те же токены, только тёмные. */
@media (prefers-color-scheme: dark) {
  :root {
    --c-primary:  #6d93ff;
    --c-danger:   #ef6b6b;
    --c-success:  #3fbf8a;
    --c-warn:     #e0a13a;
    --c-bg:       #14161f;
    --c-surface:  #1b1e29;
    --c-border:   #2b2f3d;
    --c-text:     #e6e8f0;
    --c-muted:    #9aa2b6;
    --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --c-info-bg:    #1b2740;
    --c-success-bg: #12271f;
    --c-danger-bg:  #2c1717;
    --c-danger-border: #4a2a2a;
    --c-warn-bg:    #2b220f;
    --c-warn-banner-bg: #2b220f;
    --c-chip-bg:    #232735;
  }
}
:root[data-theme="dark"] {
  --c-primary:  #6d93ff;
  --c-danger:   #ef6b6b;
  --c-success:  #3fbf8a;
  --c-warn:     #e0a13a;
  --c-bg:       #14161f;
  --c-surface:  #1b1e29;
  --c-border:   #2b2f3d;
  --c-text:     #e6e8f0;
  --c-muted:    #9aa2b6;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --c-info-bg:    #1b2740;
  --c-success-bg: #12271f;
  --c-danger-bg:  #2c1717;
  --c-danger-border: #4a2a2a;
  --c-warn-bg:    #2b220f;
  --c-warn-banner-bg: #2b220f;
  --c-chip-bg:    #232735;
}
:root[data-theme="light"] {
  --c-primary:  #3b6ef8;
  --c-danger:   #e53e3e;
  --c-success:  #38a169;
  --c-warn:     #d97706;
  --c-bg:       #f7f8fa;
  --c-surface:  #ffffff;
  --c-border:   #e2e8f0;
  --c-text:     #1a202c;
  --c-muted:    #718096;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
  --c-info-bg:    #ebf4ff;
  --c-success-bg: #f0fff4;
  --c-danger-bg:  #fff5f5;
  --c-danger-border: #feb2b2;
  --c-warn-bg:    #fffff0;
  --c-warn-banner-bg: #fef3c7;
  --c-chip-bg:    #eef1f6;
}

body { transition: background-color .15s, color .15s; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.5;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.container--narrow { max-width: 680px; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 52px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow);
}
.topbar-logo { font-weight: 700; font-size: 18px; color: var(--c-primary); }
.topbar-user { margin-left: auto; color: var(--c-muted); }
.topbar-logout { color: var(--c-muted); font-size: 13px; }
.topbar-logout:hover { color: var(--c-danger); text-decoration: none; }
.topbar-theme-btn {
  background: none; border: 1px solid var(--c-border); border-radius: 7px;
  width: 30px; height: 30px; font-size: 14px; cursor: pointer; color: var(--c-text);
}
.topbar-theme-btn:hover { background: var(--c-bg); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  /* <button> не наследует font-family/line-height от body так, как <a> —
     без явного font:inherit кнопка-<button> в одном ряду с <a class="btn">
     рендерится другой высоты при одинаковых padding/font-size. */
  font: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary  { background: var(--c-primary); color: #fff; }
.btn-outline  { background: transparent; border-color: var(--c-border); color: var(--c-text); }
.btn-outline:hover { background: var(--c-bg); }
.btn-danger   { background: var(--c-danger); color: #fff; }
.btn-ghost    { background: transparent; color: var(--c-muted); border-color: transparent; }
.btn-ghost:hover { color: var(--c-text); background: var(--c-bg); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; }

/* Одинаковая форма (обводка), разный только акцентный цвет — для рядов
   разнородных действий (карточка бизнеса: перейти/изменить/удалить), где
   заливка вперемешку с обводкой и сплошной красной кнопкой выглядела разнобоем. */
.btn-outline-primary { background: transparent; border-color: var(--c-primary); color: var(--c-primary); }
.btn-outline-primary:hover { background: var(--c-info-bg); }
.btn-outline-danger { background: transparent; border-color: var(--c-danger-border); color: var(--c-danger); }
.btn-outline-danger:hover { background: var(--c-danger-bg); }

/* ── Auth page ───────────────────────────────────────────────── */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.auth-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.auth-logo { font-size: 28px; color: var(--c-primary); text-align: center; margin-bottom: 4px; }
.auth-sub  { color: var(--c-muted); font-size: 13px; text-align: center; margin-bottom: 24px; }
.auth-link { margin-top: 20px; text-align: center; font-size: 13px; color: var(--c-muted); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--c-text); }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

input[type=text], input[type=email], input[type=password],
input[type=tel], input[type=url], textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: var(--c-surface);
  color: var(--c-text);
}
input:focus, textarea:focus { border-color: var(--c-primary); }
textarea { resize: vertical; }

fieldset  { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; }
legend    { font-weight: 600; font-size: 13px; color: var(--c-muted); padding: 0 6px; }
.biz-form { display: flex; flex-direction: column; gap: 4px; }
.form-actions { display: flex; gap: 12px; align-items: center; padding-top: 4px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: var(--c-danger-bg); border: 1px solid var(--c-danger-border); color: var(--c-danger); }
.alert-success { background: var(--c-success-bg); border: 1px solid var(--c-success); color: var(--c-success); }

/* ── Page head ───────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-head h1 { font-size: 22px; }
.page-sub  { color: var(--c-muted); font-size: 13px; margin-top: 4px; }
.breadcrumb { font-size: 13px; color: var(--c-muted); display: block; margin-bottom: 4px; }
.breadcrumb:hover { color: var(--c-text); text-decoration: none; }

/* ── Сводные тайлы ───────────────────────────────────────────── */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-tile {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat-tile__num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-tile__label { font-size: 12px; color: var(--c-muted); margin-top: 2px; }

/* ── Business grid ───────────────────────────────────────────── */
.biz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.biz-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.biz-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.biz-card__name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.biz-card__city { color: var(--c-muted); font-size: 13px; }
.biz-card__dot {
  flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 6px;
  background: var(--c-muted);
}
.biz-card__dot--ok   { background: var(--c-success); }
.biz-card__dot--warn { background: var(--c-primary); }
.biz-card__dot--err  { background: var(--c-danger); }
.biz-card__progress { margin-bottom: 16px; }
/* Кнопки прибиты к низу карточки: у бизнесов без заявок нет блока прогресса,
   и без margin-top:auto ряд карточек в гриде получался неровным по высоте кнопок. */
.biz-card__actions { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.biz-card__actions .btn { flex: 1 1 auto; justify-content: center; min-width: 0; }
/* display:contents убирает form как коробку из раскладки — кнопка внутри
   становится обычным flex-элементом наравне с соседними <a>, а не блочным
   потомком формы со своим выравниванием (отсюда была "выше других" кнопка). */
.biz-card__delete-form { margin: 0; display: contents; }

/* ── Progress summary ────────────────────────────────────────── */
.progress-summary { margin-bottom: 24px; }
.summary-bar {
  height: 8px;
  background: var(--c-border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.summary-bar__fill { height: 100%; background: var(--c-success); transition: width .4s; }
.summary-nums { display: flex; gap: 16px; font-size: 13px; }
.sn-done      { color: var(--c-success); font-weight: 600; }
.sn-submitted { color: #4a5568; font-weight: 600; }
.sn-total     { color: var(--c-muted); }
.sn-running   { color: var(--c-primary); }
.sn-fail      { color: var(--c-danger); }

/* ── Submission rows ─────────────────────────────────────────── */
.sub-list { display: flex; flex-direction: column; gap: 8px; }
.sub-row {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
}
.sub-row__name   { font-weight: 500; }
.sub-row__status { }
.sub-row__actions { display: flex; gap: 6px; }

/* Логи */
.sub-logs {
  grid-column: 1 / -1;
  background: #0d1117;
  border-radius: 6px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 12px;
  margin-top: 4px;
}
.log-line          { padding: 2px 0; line-height: 1.4; }
.log-line--info    { color: #c9d1d9; }
.log-line--warn    { color: #d97706; }
.log-line--error   { color: #e53e3e; }
.log-line--success { color: #38a169; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge--pending  { background: var(--c-chip-bg); color: var(--c-muted); }
.badge--running  { background: var(--c-info-bg); color: var(--c-primary); }
.badge--success  { background: var(--c-success-bg); color: var(--c-success); }
/* Форма ушла, но подтверждения нет — это не успех и не ошибка. Намеренно
   нейтрально-серый, чтобы не читался как зелёный success. */
.badge--submitted { background: var(--c-chip-bg); color: var(--c-muted); border: 1px solid var(--c-border); }
.badge--failed   { background: var(--c-danger-bg); color: var(--c-danger); }
.badge--skipped  { background: var(--c-warn-bg); color: var(--c-warn); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--c-muted);
}
.empty-state p { margin-bottom: 16px; }

/* ── Hint text ───────────────────────────────────────────────── */
.form-hint { font-size: 12px; color: var(--c-muted); margin-top: 4px; display: block; }

/* ── Поле пароля с показать/скопировать ─────────────────────── */
.pw-field { display: flex; gap: 6px; align-items: center; }
.pw-field input { flex: 1; min-width: 0; }
.pw-field button {
  flex: none;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  cursor: pointer;
  font-size: 15px;
  transition: background .15s;
}
.pw-field button:hover { background: var(--c-bg); }

/* ── Тосты (RB.toast) ────────────────────────────────────────── */
#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast {
  background: var(--c-surface); border: 1px solid var(--c-border); border-left: 3px solid var(--c-muted);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 11px 15px; font-size: 13px; color: var(--c-text);
  display: flex; align-items: flex-start; gap: 9px;
  animation: toast-in .18s ease-out;
}
.toast.is-ok   { border-left-color: var(--c-success); }
.toast.is-err  { border-left-color: var(--c-danger); }
.toast.is-warn { border-left-color: var(--c-warn); }
.toast .x { margin-left: auto; cursor: pointer; color: var(--c-muted); background: none; border: none; font-size: 15px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ── Модальное окно (RB.modal/RB.confirm) ─────────────────────── */
.modal-back {
  position: fixed; inset: 0; z-index: 400; background: rgba(8,10,15,.62);
  display: flex; align-items: center; justify-content: center; padding: 22px;
}
.modal {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 12px;
  box-shadow: var(--shadow); width: 100%; max-width: 560px;
  max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--c-border);
  font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 10px;
}
.modal-head .x { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--c-muted); font-size: 20px; line-height: 1; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--c-border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Busy-состояние кнопки (RB.busy) ───────────────────────────── */
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .form-row  { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }

  /* sub-row на мобильном — карточка */
  .sub-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .sub-row__name {
    font-size: 15px;
  }
  .sub-row__actions {
    flex-wrap: wrap;
  }
  .sub-row__actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 80px;
  }

  /* summary nums вертикально */
  .summary-nums { flex-wrap: wrap; gap: 8px; }

  /* biz-grid одна колонка */
  .biz-grid { grid-template-columns: 1fr; }
}
