:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --line: #d8dee9;
  --text: #111827;
  --muted: #6b7280;
  --blue: #2563eb;
  --green: #047857;
  --red: #b91c1c;
  --dark: #111827;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1500px;
  margin: 0 auto;
}

.topbar {
  margin: 16px;
  padding: 16px 20px;
  background: var(--dark);
  color: white;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.subtitle {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 16px;
  padding: 0 16px 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.label {
  display: block;
  margin-top: 10px;
  margin-bottom: 5px;
  font-weight: 700;
  font-size: 13px;
}

input, select {
  width: 100%;
  padding: 9px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
}

.btn {
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  background: var(--blue);
  color: white;
  padding: 11px 15px;
  font-size: 14px;
  font-weight: 700;
}

.btn-secondary {
  background: #4b5563;
}

.btn.full {
  width: 100%;
  margin-top: 14px;
}

.btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.ok { color: var(--green); font-weight: 700; }
.bad { color: var(--red); font-weight: 700; }

.status {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.progress {
  height: 20px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.progress > div {
  height: 100%;
  width: 0%;
  background: var(--blue);
  transition: width 0.3s;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #f8fafc;
}

.metric-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 6px;
}

.files a {
  display: inline-block;
  margin: 6px 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.map-frame {
  width: 100%;
  height: 620px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

pre {
  background: #111827;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
  max-height: 260px;
  font-size: 12px;
}

details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .map-frame {
    height: 480px;
  }
}


.btn.is-running {
  background: var(--red);
  color: white;
  cursor: pointer;
}


.metric-sub {
  display: inline-block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}


/* ---- UI polish v0.5.14 ---- */

h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-num {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  flex: 0 0 auto;
}

.run-zone {
  min-height: 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 0 12px;
}

.run-orb {
  width: 128px;
  height: 128px;
  border-radius: 999px;
  border: 7px solid #e8eef8;
  background: radial-gradient(circle at 35% 30%, #2f7cf6 0%, #1057d7 55%, #073eab 100%);
  color: white;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
  cursor: pointer;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.run-orb:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.34);
}

.run-orb:active:not(:disabled) {
  transform: translateY(1px);
}

.run-orb:disabled {
  cursor: not-allowed;
  filter: grayscale(0.65);
  opacity: 0.7;
}

.run-orb .run-icon {
  font-size: 34px;
  line-height: 1;
  margin-left: 4px;
}

.run-orb .run-label {
  font-size: 19px;
  line-height: 1;
  letter-spacing: 0.4px;
}

.run-orb.is-running {
  background: radial-gradient(circle at 35% 30%, #ef4444 0%, #b91c1c 58%, #7f1d1d 100%);
  box-shadow: 0 10px 22px rgba(185, 28, 28, 0.28);
}

.job-note {
  margin-top: 0;
}

.file-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.file-card,
.files a.file-card {
  min-height: 78px;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.file-card:hover {
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.file-icon {
  grid-row: 1 / span 2;
  font-size: 28px;
  line-height: 1;
  text-align: center;
}

.file-title {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
}

.file-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  margin-top: 2px;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.map-actions a {
  margin: 0;
}

.debug-panel.hidden {
  display: none !important;
}

@media (max-width: 1000px) {
  .run-zone {
    min-height: 140px;
  }

  .run-orb {
    width: 112px;
    height: 112px;
  }

  .file-actions {
    grid-template-columns: 1fr 1fr;
  }
}


/* ---- UI final polish v0.5.15 ---- */

.choice-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: start;
  column-gap: 8px;
  margin: 10px 0;
  line-height: 1.25;
  cursor: pointer;
}

.choice-row input[type="radio"],
.choice-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 1px 0 0 0;
  accent-color: var(--blue);
}

.sub-options {
  margin-top: 14px;
  padding-left: 18px;
  border-left: 2px solid #e5e7eb;
}

.sub-options-nested {
  margin-left: 18px;
  margin-top: 8px;
}

.metrics {
  gap: 16px;
}

.metric {
  min-height: 96px;
}

.run-zone {
  min-height: 178px;
  padding: 26px 0 14px;
}

.run-orb {
  width: 136px;
  height: 136px;
  border-width: 8px;
  box-shadow:
    0 12px 28px rgba(37, 99, 235, 0.30),
    0 0 0 7px rgba(37, 99, 235, 0.08);
}

.run-orb:hover:not(:disabled) {
  transform: scale(1.03);
  box-shadow:
    0 16px 34px rgba(37, 99, 235, 0.36),
    0 0 0 8px rgba(37, 99, 235, 0.10);
}

.run-orb.is-running {
  box-shadow:
    0 12px 28px rgba(185, 28, 28, 0.30),
    0 0 0 7px rgba(185, 28, 28, 0.09);
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 12px;
}

.map-actions a,
.map-card-action {
  margin: 0 !important;
  min-width: 132px;
  min-height: 48px;
  display: grid !important;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 8px;
  padding: 9px 12px !important;
  border: 1px solid #bfdbfe;
  border-radius: 10px !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  text-decoration: none;
  font-size: 13px !important;
  font-weight: 800 !important;
}

.map-action-icon {
  grid-row: 1 / span 2;
  font-size: 20px;
  text-align: center;
}

.map-card-action small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.file-actions {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
}

.file-card,
.files a.file-card {
  min-height: 92px;
  grid-template-columns: 42px 1fr;
  padding: 14px 16px;
  overflow: hidden;
}

.file-icon {
  font-size: 32px;
}

.file-icon-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 900;
  color: #7c3aed;
  font-size: 24px;
}

.file-title {
  font-size: 13px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.file-title-compact {
  font-size: 12px;
  line-height: 1.08;
}

.file-sub {
  font-size: 12px;
}

@media (max-width: 1000px) {
  .run-orb {
    width: 118px;
    height: 118px;
  }

  .file-actions {
    grid-template-columns: 1fr 1fr;
  }
}


/* ---- UI compact files fix v0.5.17 ---- */

/* Пункт 2: без лишней подписи, радиокнопка на уровне текста */
.choice-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: start;
  column-gap: 8px;
  margin: 10px 0;
  line-height: 1.25;
}

.choice-row input[type="radio"],
.choice-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 1px 0 0 0;
  accent-color: var(--blue);
}

/* Блок файлов: все действия — одинаковые компактные карточки */
.file-actions {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)) !important;
  gap: 12px !important;
  margin-top: 10px !important;
}

.file-card,
.files a.file-card,
.files button.file-card {
  width: 100%;
  min-height: 82px !important;
  height: 82px;
  display: grid !important;
  grid-template-columns: 38px 1fr;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  margin: 0 !important;
  padding: 11px 12px !important;
  border: 1px solid var(--line);
  border-radius: 12px !important;
  background: #fff !important;
  color: var(--text) !important;
  text-decoration: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  overflow: hidden;
}

.file-card:hover {
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.file-icon {
  grid-row: 1 / span 2;
  font-size: 28px !important;
  line-height: 1;
  text-align: center;
}

.file-title {
  font-size: 12.5px !important;
  font-weight: 800;
  line-height: 1.12 !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
}

.file-sub {
  color: var(--muted);
  font-size: 11.5px !important;
  line-height: 1.15;
}

.file-card-shahmatka {
  min-width: 178px;
}

.file-card-shahmatka .file-title {
  font-size: 12px !important;
  line-height: 1.05 !important;
}

.file-card-package .file-title {
  font-size: 12px !important;
}

/* Откат крупного отдельного стиля кнопок карты */
.map-actions,
.map-card-action,
.map-action-icon {
  all: unset;
}

@media (max-width: 1300px) {
  .file-actions {
    grid-template-columns: repeat(3, minmax(150px, 1fr)) !important;
  }
}

@media (max-width: 1000px) {
  .file-actions {
    grid-template-columns: 1fr 1fr !important;
  }
}


/* ---- Scheme controls restored v0.5.19 ---- */
.scheme-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.scheme-row select,
.scheme-row input {
  width: 100%;
}

@media (max-width: 1000px) {
  .scheme-row {
    grid-template-columns: 1fr;
  }
}


/* ---- UI fixes v0.5.21: scheme list + file cards ---- */

/* Карточка "Предварительный расчет куста" без иконки, чтобы текст не ломался */
.file-card.no-icon {
  grid-template-columns: 1fr !important;
  justify-content: center;
}

.file-card.no-icon .file-title {
  display: block;
  font-size: 13px !important;
  line-height: 1.15 !important;
  text-align: center;
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
}

.file-card.no-icon .file-sub {
  display: block;
  grid-column: 1;
  text-align: center;
  margin-top: 4px;
}

/* Чуть шире минимальная карточка, чтобы длинные подписи не дробились */
.file-actions {
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)) !important;
}

/* Для широких экранов оставляем аккуратную строку без чрезмерного растягивания */
@media (min-width: 1301px) {
  .file-actions {
    grid-template-columns: repeat(6, minmax(168px, 1fr)) !important;
  }
}

.metric-main{
  font-size:22px;
  font-weight:800;
}

.metric[data-state="ok"] .metric-main{ color:#111827; }
.metric[data-state="warning"] .metric-main{ color:#d97706; }
.metric[data-state="danger"] .metric-main{ color:#b91c1c; }
