:root {
  --bg: #eef3f1;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --text: #102019;
  --muted: #5f7268;
  --border: rgba(16, 32, 25, 0.09);
  --teal: #0b8f77;
  --teal-dark: #0b6b59;
  --teal-soft: rgba(11, 143, 119, 0.11);
  --red: #ba3652;
  --red-soft: rgba(186, 54, 82, 0.11);
  --amber: #b06a13;
  --amber-soft: rgba(176, 106, 19, 0.12);
  --shadow: 0 22px 60px rgba(9, 28, 21, 0.10);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Onest", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(11, 143, 119, 0.17), transparent 28%),
    radial-gradient(circle at top right, rgba(176, 106, 19, 0.08), transparent 22%),
    linear-gradient(180deg, #f6fbf8 0%, var(--bg) 100%);
}

.shell {
  max-width: 1560px;
  margin: 0 auto;
  padding: 28px 28px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 700;
  color: var(--teal-dark);
}

h1, h2 {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.lead {
  margin: 12px 0 0;
  max-width: 780px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 20px;
}

.panel--sticky {
  position: sticky;
  top: 24px;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.panel__header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.banner-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.banner-card,
.metric-card {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: 0 18px 40px rgba(9, 28, 21, 0.06);
}

.banner-card__label,
.metric-card__label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.banner-card__value,
.metric-card__value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.banner-card__meta,
.metric-card__meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.info-strip {
  margin-bottom: 22px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(16, 32, 25, 0.05);
  border: 1px solid rgba(16, 32, 25, 0.06);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.field__hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.input {
  width: 100%;
  border: 1px solid rgba(16, 32, 25, 0.12);
  background: rgba(255, 255, 255, 0.86);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
}

.input:focus {
  outline: 2px solid rgba(11, 143, 119, 0.18);
  border-color: rgba(11, 143, 119, 0.28);
}

.input--compact {
  width: auto;
  min-width: 84px;
  padding: 10px 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.field-grid--inputs {
  align-items: start;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(16, 32, 25, 0.08);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text);
}

.checkbox input {
  margin: 0;
}

.auto-refresh {
  min-height: 44px;
}

.quick-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip,
.btn,
.pill {
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
}

.chip {
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: 8px 12px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  padding: 11px 16px;
  transition: transform 0.14s ease, opacity 0.14s ease, background 0.14s ease;
}

.btn:hover,
.chip:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--teal) 0%, #0d7562 100%);
  color: #fff;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(16, 32, 25, 0.10);
  color: var(--text);
}

.btn--danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(186, 54, 82, 0.18);
}

.estimate-box,
.result-box {
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(16, 32, 25, 0.08);
}

.estimate-box + .result-box {
  margin-top: 14px;
}

.estimate-box__title,
.result-box__title {
  font-weight: 700;
  margin-bottom: 10px;
}

.estimate-box__empty,
.result-box__empty {
  color: var(--muted);
  line-height: 1.5;
}

.estimate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.estimate-stat {
  border-radius: 12px;
  background: rgba(11, 143, 119, 0.08);
  padding: 12px;
}

.estimate-stat__label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.estimate-stat__value {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 18px;
}

.result-box pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.pill {
  padding: 8px 12px;
  background: rgba(11, 143, 119, 0.11);
  color: var(--teal-dark);
}

.table-wrap {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(16, 32, 25, 0.08);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
  background: rgba(255, 255, 255, 0.55);
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(16, 32, 25, 0.08);
  vertical-align: top;
  font-size: 13px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(244, 249, 247, 0.96);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mono {
  font-family: "JetBrains Mono", monospace;
}

.muted {
  color: var(--muted);
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 18px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.status-dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 6px rgba(176, 106, 19, 0.10);
}

.status-dot--ok::before {
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(11, 143, 119, 0.10);
}

.status-dot--bad::before {
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(186, 54, 82, 0.10);
}

.tiny-action {
  background: var(--red-soft);
  color: var(--red);
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.code-block {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

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

  .panel--sticky {
    position: static;
  }

  .cards-grid,
  .banner-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 18px 16px 26px;
  }

  .topbar,
  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cards-grid,
  .banner-grid,
  .field-grid,
  .estimate-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Embed mode (когда открыт внутри основного приложения через iframe) ───
   Цель: уместить всю функциональность на одной странице без вертикального скролла. */
html.embed, body.embed { background: var(--bg); }
body.embed .shell { max-width: 100%; padding: 10px 14px 14px; }
body.embed .topbar { margin-bottom: 10px; gap: 12px; align-items: center; }
body.embed .topbar > div:first-child .eyebrow,
body.embed .topbar > div:first-child h1,
body.embed .topbar > div:first-child .lead { display: none; }
body.embed .topbar > div:first-child::before {
    content: "Контроль моделей";
    font-weight: 700; font-size: 15px; color: var(--teal-dark);
}
body.embed .topbar-actions { gap: 6px; }
body.embed .topbar-actions .btn { padding: 6px 10px; font-size: 12px; }
body.embed .info-strip { display: none; }
body.embed .banner-grid { gap: 8px; margin-bottom: 10px; }
body.embed .banner-card { padding: 8px 12px; border-radius: 10px; }
body.embed .banner-card__label { font-size: 10px; }
body.embed .banner-card__value { font-size: 13px; margin: 2px 0 1px; }
body.embed .banner-card__meta { font-size: 11px; }

body.embed .layout { gap: 10px; grid-template-columns: 280px minmax(0, 1fr); }
body.embed .panel { padding: 10px; border-radius: 10px; box-shadow: none; }
body.embed .panel--sticky { top: 10px; }
body.embed .panel__header { margin-bottom: 8px; gap: 8px; }
body.embed .panel__header h2 { font-size: 14px; }
body.embed .panel__header p { display: none; }

body.embed .field { margin-bottom: 8px; }
body.embed .field label { font-size: 11px; }
body.embed .field__hint { font-size: 11px; margin-top: 2px; }
body.embed .input { padding: 6px 8px; font-size: 12px; }
body.embed .input--compact { padding: 4px 6px; }

body.embed .quick-row { gap: 4px; margin: 4px 0 8px; }
body.embed .chip { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
body.embed .field-grid { gap: 6px; margin-bottom: 8px; }
body.embed .checkbox { font-size: 12px; }
body.embed .action-row { gap: 6px; margin-top: 8px; }
body.embed .action-row .btn { padding: 6px 10px; font-size: 12px; }

body.embed .estimate-box, body.embed .result-box {
    padding: 8px; margin-top: 8px; font-size: 12px; border-radius: 8px;
}
body.embed .estimate-box__title, body.embed .result-box__title { font-size: 12px; margin-bottom: 4px; }

body.embed .cards-grid { gap: 6px; margin-bottom: 10px; }
body.embed .cards-grid > * { padding: 8px; border-radius: 8px; }

body.embed .table { font-size: 12px; }
body.embed .table th { padding: 6px 8px; font-size: 11px; }
body.embed .table td { padding: 6px 8px; }
body.embed .empty-row { padding: 12px; font-size: 12px; }
body.embed .pill { padding: 2px 8px; font-size: 11px; border-radius: 6px; }

body.embed .panel + .panel { margin-top: 8px; }

/* Topbar action: ссылка "Основное приложение" не нужна когда мы внутри */
body.embed .topbar-actions a.btn { display: none; }
