/* ChoiceGrid — стили веб-клиента.
   Цвета — токены на :root; тёмная тема — отдельно подобранные ступени тех же шкал.
   Категориальная палитра серий (критериев) — проверенная на дальтонизм, в фиксированном порядке. */

:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e7e6e1;
  --border: rgba(11, 11, 11, 0.1);
  --border-strong: rgba(11, 11, 11, 0.2);
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #6b6a65;
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  --accent: #1c5cab;
  --accent-hover: #184f95;
  --on-accent: #ffffff;
  --accent-soft: #e6effb;
  --focus: #2a78d6;

  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warning-text: #7a4f00;
  --warning-soft: #fff4d6;
  --warning-mark: #fab219;
  --success-text: #006300;
  --success-soft: #e6f4e6;
  --info-soft: #eef3fa;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 2px 8px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2e2e2b;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #a3a198;
    --grid: #2c2c2a;
    --axis: #383835;

    --accent: #6da7ec;
    --accent-hover: #86b6ef;
    --on-accent: #0b0b0b;
    --accent-soft: #1b2a3d;
    --focus: #86b6ef;

    --danger: #f08b85;
    --danger-soft: #3a1d1b;
    --warning-text: #f5c96a;
    --warning-soft: #33290f;
    --success-text: #5cc95c;
    --success-soft: #16291a;
    --info-soft: #1c2533;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}


/* --- Шапка ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-mark { width: 22px; height: 22px; fill: var(--text-2); }
.brand-mark .brand-mark-accent { fill: var(--series-1); }
.topbar-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40vw;
}
a.account-chip { text-decoration: none; padding: 6px 8px; border-radius: var(--radius-sm); }
a.account-chip:hover { background: var(--surface-2); color: var(--text); }
.account-chip svg { width: 16px; height: 16px; flex: none; }

/* --- Страница ---------------------------------------------------------------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  outline: none;
}
.loading, .empty-note { color: var(--text-3); }
.loading { padding: 40px 0; text-align: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.section-title {
  font-size: 17px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-num {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 650;
  flex: none;
}
.section-lead { color: var(--text-2); font-size: 14px; margin-bottom: 16px; }
.counter { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Кнопки и поля ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 560;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn-lg { min-height: 48px; padding: 10px 20px; font-size: 16px; }
.btn svg { width: 16px; height: 16px; flex: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn svg { width: 17px; height: 17px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 560; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--text-3); }
.field-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 0;
}
.field-error:empty { display: none; }

.input, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 0.85; }
.input:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}
.textarea { resize: vertical; line-height: 1.45; }

.inline-form { display: flex; gap: 8px; align-items: flex-start; }
.inline-form .field { flex: 1; }

/* Сегментированный переключатель (radio) */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.segmented label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.segmented label:has(input:checked) {
  background: var(--surface);
  color: var(--text);
  font-weight: 560;
  box-shadow: 0 0 0 1px var(--border);
}
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.segmented svg { width: 14px; height: 14px; }

/* --- Главная --------------------------------------------------------------------- */

.hero {
  padding: 28px 0 8px;
  display: grid;
  gap: 16px;
  max-width: 760px;
}
.hero h1 { font-size: clamp(26px, 4.4vw, 40px); letter-spacing: -0.02em; font-weight: 700; }
.hero p { color: var(--text-2); font-size: 17px; max-width: 640px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.hero-compact { padding-top: 4px; }
.hero-compact h1 { font-size: 26px; }

.how-it-works {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 28px;
  padding: 0;
  list-style: none;
}
.how-it-works li { display: grid; gap: 4px; }
.how-it-works strong { font-size: 15px; }
.how-it-works span { color: var(--text-2); font-size: 14px; }

.create-card { margin-top: 20px; max-width: 760px; }
.create-card form { display: grid; gap: 14px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-gap { margin-top: 32px; }
.list-title { font-size: 19px; font-weight: 650; margin-bottom: 12px; }

.decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.decision-card {
  display: grid;
  gap: 8px;
  height: 100%;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}
.decision-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.decision-card h3 { font-size: 16px; font-weight: 620; overflow-wrap: anywhere; }
.decision-card p {
  color: var(--text-2);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.decision-meta { color: var(--text-3); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: auto; }

.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--text);
  font-size: 14px;
}
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--text-2); }
.banner-body { flex: 1; display: grid; gap: 8px; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.banner-warning { background: var(--warning-soft); }
.banner-warning svg { color: var(--warning-text); }
.banner-error { background: var(--danger-soft); }
.banner-error svg { color: var(--danger); }

/* --- Аккаунт -------------------------------------------------------------------- */

.auth-wrap { max-width: 440px; margin: 24px auto 0; }
.auth-wrap h1 { font-size: 24px; margin-bottom: 6px; }
.auth-wrap .section-lead { margin-bottom: 18px; }
.auth-tabs { margin-bottom: 18px; }
.auth-form { display: grid; gap: 14px; }

/* --- Редактор --------------------------------------------------------------------- */

.editor-head { display: grid; gap: 8px; margin-bottom: 16px; }
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 0;
}
.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.save-status { font-size: 13px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.save-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success-text);
}
.save-status[data-state="saving"]::before { background: var(--warning-mark); }
.save-status[data-state="error"] { color: var(--danger); }
.save-status[data-state="error"]::before { background: var(--danger); }

.title-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-left: -8px;
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  resize: none;
  overflow: hidden;
  display: block;
}
.desc-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-left: -8px;
  color: var(--text-2);
  resize: none;
  overflow: hidden;
  line-height: 1.5;
}
.title-input:hover, .desc-input:hover { border-color: var(--border); }
.title-input:focus, .desc-input:focus {
  outline: none;
  border-color: var(--focus);
  background: var(--surface);
}
.title-input[aria-invalid="true"] { border-color: var(--danger); }

.editor-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.editor-main { display: grid; gap: 16px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.editor-main > * { min-width: 0; }
.editor-main > .card + .card { margin-top: 0; }

@media (min-width: 1080px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr) 420px; align-items: start; }
  .editor-aside { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; border-radius: var(--radius); }
}

/* Варианты */
.option-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.option-row { display: flex; gap: 8px; align-items: flex-start; }
.option-row .field { flex: 1; }
.option-index {
  flex: none;
  width: 28px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Критерии */
.criteria-list { display: grid; gap: 12px; margin-bottom: 14px; }
@media (min-width: 720px) {
  .criteria-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.criterion-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
  background: var(--surface);
}
.criterion-top { display: flex; gap: 8px; align-items: flex-start; }
.criterion-top .field { flex: 1; }
.swatch {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.criterion-top .swatch { margin-top: 14px; }
.criterion-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.unit-input { width: 96px; min-height: 34px; padding: 5px 10px; }
.kind-hint { font-size: 13px; color: var(--text-3); }

.weight-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.weight-label { font-size: 13.5px; color: var(--text-2); font-weight: 560; }
.weight-value { font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--text-2); min-width: 92px; text-align: right; }
.weight-value b { color: var(--text); font-weight: 650; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; height: 24px; }

.add-criterion { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.add-criterion .inline-form { flex-wrap: wrap; }

/* Матрица */
.matrix-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; min-width: max-content; }
.matrix th, .matrix td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.matrix tr:last-child th, .matrix tr:last-child td { border-bottom: 0; }
.matrix thead th {
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 128px;
}
.matrix .col-sub { display: block; font-weight: 400; color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.matrix .col-name { display: inline-flex; align-items: center; gap: 6px; }
.matrix tbody th { font-weight: 560; font-size: 14px; }
.matrix .sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 140px;
  max-width: 220px;
  overflow-wrap: anywhere;
}
.matrix thead .sticky-col { background: var(--surface-2); z-index: 2; }
.row-progress { display: block; font-weight: 400; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.row-progress.is-complete { color: var(--success-text); }
.cell { display: grid; gap: 3px; width: 128px; }
.cell-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell-input:placeholder-shown { border-style: dashed; }
.cell-input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.cell-input[aria-invalid="true"] { border-color: var(--danger); border-style: solid; }
.cell-input[data-state="saving"] { border-color: var(--warning-mark); }
.cell-hint { font-size: 12px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; min-height: 18px; }
.cell .field-error { font-size: 12px; }

/* --- Результаты ------------------------------------------------------------------- */

.results { display: grid; gap: 14px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill[data-status="ready"] { background: var(--success-soft); color: var(--success-text); }
.status-pill[data-status="incomplete"] { background: var(--warning-soft); color: var(--warning-text); }
.status-pill[data-status="blocked"] { background: var(--danger-soft); color: var(--danger); }

.messages { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.messages .banner { padding: 10px 12px; font-size: 13.5px; }

.leader-card {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.leader-card .leader-label { font-size: 13px; color: var(--text-2); }
.leader-card .leader-name { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.leader-card .leader-score { font-size: 14px; color: var(--text-2); }

.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank-item { border-radius: var(--radius-sm); }
.rank-head {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 56px 16px;
  gap: 4px 10px;
  align-items: center;
  padding: 10px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.rank-head:hover { background: var(--surface-2); }
.rank-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.rank-item.is-leader .rank-badge { background: var(--accent); color: var(--on-accent); }
.rank-name { font-weight: 600; overflow-wrap: anywhere; }
.rank-total { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; text-align: right; }
.rank-item.is-incomplete .rank-total { color: var(--text-2); font-weight: 600; }
.rank-chevron { width: 16px; height: 16px; color: var(--text-3); transition: transform 0.15s; }
.rank-head[aria-expanded="true"] .rank-chevron { transform: rotate(180deg); }
.rank-bar-wrap { grid-column: 2 / 4; display: grid; gap: 4px; }
.rank-meta { font-size: 12.5px; color: var(--text-3); }
.rank-item.is-incomplete .rank-meta { color: var(--warning-text); }

/* Горизонтальная шкала 0–10: линии сетки — волосяные, фон — на ступень от поверхности */
.bar-track {
  position: relative;
  height: 14px;
  border-radius: 0 4px 4px 0;
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px);
  background-size: 20% 100%;
  background-repeat: repeat-x;
}
.bar-fill { display: flex; gap: 2px; height: 100%; min-width: 0; }
.seg { height: 100%; min-width: 2px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.bar-scale {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 56px 16px;
  gap: 0 10px;
  padding: 0 8px;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.bar-scale-ticks { grid-column: 2 / 4; position: relative; height: 16px; }
.bar-scale-ticks span { position: absolute; top: 0; transform: translateX(-50%); }
.bar-scale-ticks span:first-child { transform: none; }
.bar-scale-ticks span:last-child { transform: translateX(-100%); }

.sw-1 { background: var(--series-1); }
.sw-2 { background: var(--series-2); }
.sw-3 { background: var(--series-3); }
.sw-4 { background: var(--series-4); }
.sw-5 { background: var(--series-5); }
.sw-6 { background: var(--series-6); }
.sw-7 { background: var(--series-7); }
.sw-8 { background: var(--series-8); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 0; list-style: none; font-size: 13px; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.breakdown-wrap { padding: 4px 8px 12px 46px; overflow-x: auto; }
.breakdown { width: 100%; border-collapse: collapse; font-size: 13px; }
.breakdown th, .breakdown td { padding: 6px 6px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.breakdown th:first-child, .breakdown td:first-child { text-align: left; white-space: normal; }
.breakdown thead th { color: var(--text-3); font-weight: 500; }
.breakdown td { font-variant-numeric: tabular-nums; }
.breakdown tfoot td { font-weight: 650; border-bottom: 0; }
.breakdown .crit-name { display: inline-flex; align-items: center; gap: 6px; }
.breakdown .muted { color: var(--text-3); }

.method {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 13.5px;
  color: var(--text-2);
}
.method summary { cursor: pointer; color: var(--text); font-weight: 560; }
.method-body { display: grid; gap: 8px; margin-top: 10px; }
.formula {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
}
.disclaimer { font-size: 12.5px; color: var(--text-3); }

/* --- Всплывающие элементы ------------------------------------------------------------ */

.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.tooltip b { font-weight: 650; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 60;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
.toast-error { background: var(--danger); color: #fff; }

dialog.confirm {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
dialog.confirm::backdrop { background: rgba(11, 11, 11, 0.4); }
dialog.confirm h2 { font-size: 18px; margin-bottom: 8px; }
dialog.confirm p { color: var(--text-2); font-size: 14.5px; }
dialog.confirm .form-actions { justify-content: flex-end; margin-top: 18px; }

@media (max-width: 560px) {
  .page { padding-top: 16px; }
  .card { padding: 16px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { flex: 1; }
  .rank-head, .bar-scale { grid-template-columns: 26px minmax(0, 1fr) 52px 16px; gap: 4px 8px; padding-left: 4px; padding-right: 4px; }
  .breakdown-wrap { padding-left: 4px; }
  .account-chip.is-guest { display: none; }
  .matrix .sticky-col { min-width: 104px; max-width: 128px; font-size: 13px; }
  .matrix th, .matrix td { padding: 8px; }
  .cell { width: 108px; }
  .weight-row { grid-template-columns: minmax(0, 1fr) auto; }
  .weight-row .weight-label { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (forced-colors: active) {
  .seg { border: 1px solid CanvasText; }
}
