:root {
  /* Фирменный градиент Сбера: зелёный → бирюзовый */
  --green: #21a038;
  --green-2: #0fbf9f;
  --green-3: #00c2ff;
  --grad: linear-gradient(120deg, #21a038 0%, #1eb182 55%, #00c2ff 130%);
  --grad-soft: linear-gradient(160deg, #eafaf0 0%, #e7f7fb 100%);

  --bg: #eef3f1;
  --card: #ffffff;
  --text: #0c1f17;
  --muted: #6b7b76;
  --border: #e6ece9;
  --field: #f4f8f6;

  --error-bg: #fdeceb;
  --error: #c0392b;
  --notice-bg: #fff6e3;
  --notice: #8a6a14;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 12px 40px rgba(18, 80, 50, 0.10);
  --shadow-sm: 0 4px 16px rgba(18, 80, 50, 0.07);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

/* Фирменный шрифт Сбера для заголовка. Порядок поиска:
   1) шрифт, установленный на компьютере (на сберовских машинах он обычно есть);
   2) файл static/fonts/SBSansDisplay-Bold.woff2 (положить с брендпортала);
   3) если ничего нет — обычный Inter, страница не ломается. */
@font-face {
  font-family: "SB Sans Display";
  src: local("SB Sans Display Bold"), local("SBSansDisplay-Bold"),
       local("SB Sans Display"),
       url("fonts/SBSansDisplay-Bold.woff2") format("woff2");
  font-weight: 700 800;
  font-display: swap;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(980px 520px at 8% 6%, rgba(182, 247, 255, 0.64) 0%, rgba(182, 247, 255, 0) 64%),
    radial-gradient(900px 520px at 92% 7%, rgba(207, 255, 218, 0.76) 0%, rgba(207, 255, 218, 0) 68%),
    radial-gradient(1100px 480px at 50% -120px, #f8fffb 0%, rgba(248, 255, 251, 0) 70%),
    var(--bg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 20px 72px;
  position: relative;
  z-index: 1;
}

/* ---------- Шапка ---------- */
header { text-align: center; margin-bottom: 30px; }
.logo-dot {
  width: 52px; height: 52px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: var(--grad);
  box-shadow: 0 8px 22px rgba(33, 160, 56, 0.35);
  position: relative;
}
.logo-dot::after {
  content: "";
  position: absolute; inset: 0;
  margin: auto;
  width: 22px; height: 22px;
  border: 3px solid #fff;
  border-radius: 50%;
  border-right-color: transparent;
  transform: rotate(-45deg);
}
header h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-family: "SB Sans Display", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.sub {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Табы ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  background: #fff;
  padding: 5px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}
.tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  font-family: inherit;
  transition: all .18s ease;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 16px rgba(33, 160, 56, 0.30);
}

/* ---------- Карточки ---------- */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel.hidden, .hidden { display: none; }

.auth {
  max-width: 420px;
  margin: 0 auto 18px;
}
.auth .primary { margin-top: 14px; }
.auth .error { margin-top: 12px; margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 18px 0 8px;
}
.field-label:first-child { margin-top: 0; }

textarea, select, input[type="password"] {
  width: 100%;
  border: 1.5px solid transparent;
  background: var(--field);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}
textarea, select {
  resize: vertical;
  transition: border-color .15s, background .15s;
}
textarea::placeholder { color: #9aa8a3; }
textarea:focus, select:focus, input[type="password"]:focus {
  outline: none;
  background: #fff;
  border-color: var(--green-2);
}
.field-hint {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}
.scope-hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
}

.row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1.5px dashed #c7d7d0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
}
.file-btn:hover { border-color: var(--green-2); color: var(--green); }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  padding: 7px 8px 7px 12px;
  background: #eefaf5;
  border: 1px solid #d4eee4;
  border-radius: 999px;
}
.file-info.hidden { display: none; }
.file-name {
  min-width: 0;
  max-width: min(360px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}
.clear-file {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(33, 160, 56, 0.12);
  color: var(--green);
  cursor: pointer;
  font: 700 18px/1 Arial, sans-serif;
  transition: background .15s, color .15s;
}
.clear-file:hover {
  background: var(--green);
  color: #fff;
}
.file-hint {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3faf7;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.primary {
  margin-top: 22px;
  width: 100%;
  padding: 15px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(33, 160, 56, 0.28);
  transition: transform .12s ease, box-shadow .15s ease, opacity .15s;
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(33, 160, 56, 0.34); }
.primary:active { transform: translateY(0); }
.primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Состояния ---------- */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  padding: 16px 4px;
}
.loading.hidden { display: none; }
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid #d7e7e0;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  background: var(--error-bg);
  color: var(--error);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  margin-bottom: 18px;
}
.notice {
  background: var(--notice-bg);
  color: var(--notice);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  margin-bottom: 18px;
}

/* ---------- Результат ---------- */
.result {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.result:last-child { margin-bottom: 0; }

/* Исправленная версия — на белой подложке, как блок правок */
.result.corrected {
  background: var(--card);
}

.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.result-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.ghost {
  background: #fff;
  border: 1.5px solid var(--green-2);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--green);
  font-family: inherit;
  transition: all .15s;
}
.ghost:hover { background: var(--green); color: #fff; }

.rich {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  margin: 0;
  color: #1a2c25;
}
.rich strong { font-weight: 700; color: var(--text); }
/* Структурированный рендер результата (списки правок, разделы) */
.rich ol, .rich ul { margin: 0 0 12px; padding-left: 22px; white-space: normal; }
.rich li { margin-bottom: 10px; }
.rich h3 { margin: 16px 0 6px; font-size: 15.5px; white-space: normal; }
.rich p { margin: 6px 0; white-space: normal; }
.rich .note-muted { font-size: 13px; opacity: .75; }
.rich .result-section-title:first-child { margin-top: 0; }
.rich .review-title { color: #76591a; }
.rich .review-intro { margin: 0 0 10px; }
.rich .review-edits {
  border-left: 3px solid #e7c66b;
  padding-left: 25px;
}
.rich .edit-context {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
}
.corrected-note {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Подвал ---------- */
footer { margin-top: 30px; }
footer p { color: var(--muted); font-size: 12px; text-align: center; margin: 0; opacity: .85; }

@media (max-width: 520px) {
  .wrap { padding: 36px 16px 56px; }
  header h1 { font-size: 25px; }
  .panel, .result { padding: 20px; }
}
