:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d2622;
  background: #f2f4f1;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f2f4f1;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  background: #1f5b46;
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

button.secondary {
  background: #e7ece8;
  color: #1d3b31;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input {
  width: 100%;
  border: 1px solid #c8d1cb;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  color: inherit;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid #a5c7b8;
  outline-offset: 2px;
}

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.page-header,
.section-heading {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.page-header {
  margin-bottom: 1rem;
  align-items: center;
}

.logo-mark {
  margin: 0;
  display: block;
  height: 28px;
  width: auto;
  max-width: 100%;
  flex: none;
  object-fit: contain;
}

.header-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* LIVE SMOKE FIX PASS #01 (Blocker 3): a small, always-present in-project
   nav row (Обзор/Результат/Скачать файлы/КП), repeated identically on
   every in-project screen -- so a reopened project is never just one
   "Назад" button away from getting lost. */
.project-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.project-nav-btn {
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
}

h2 {
  margin-bottom: 0.75rem;
}

h3 {
  margin-top: 1.2rem;
  margin-bottom: 0.6rem;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: #1f5b46;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  color: #64716b;
}

.small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
}

.card {
  margin-top: 1rem;
  padding: 1.25rem;
  border: 1px solid #dce2dd;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 24px rgb(20 40 30 / 0.05);
}

.notice,
.message,
.empty {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.notice {
  background: #f5f0df;
  color: #5e5127;
}

.message {
  margin-top: 1rem;
  background: #edf2ef;
}

.message.success {
  background: #e7f4ea;
  color: #225d31;
}

.message.error {
  background: #fbe9e8;
  color: #8c2f29;
}

/* STEP WEB — TIMEOUT RECOVERY + USER WAITING UX V1: a plain indeterminate
   spinner -- never a percentage/progress value, since real progress is
   genuinely unknown (task section 4: "Не показывать выдуманный процент
   готовности"). */
#analysis-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.spinner {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 3px solid #d7e3da;
  border-top-color: #225d31;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  background: #dcebe4;
  color: #1d4e3d;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill[data-status="done"] {
  background: #e8edf6;
  color: #2f4f78;
}

.status-pill[data-status="calculating"] {
  background: #fff0d8;
  color: #7a5015;
}

.row-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.5fr) minmax(220px, 2fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.stack-form {
  display: grid;
  gap: 0.7rem;
}

.project-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.project-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 0;
  border-top: 1px solid #edf0ed;
}

.empty {
  margin-top: 1rem;
  background: #f6f7f6;
  color: #64716b;
}

.step-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* SOURCE SELECTION -- compact 2x2 by default (also reads fine at 375px
   mobile width without a separate breakpoint override: four short cards). */
.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.source-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  min-height: 6.5rem;
  padding: 1rem;
  border: 1px solid #dce2dd;
  border-radius: 14px;
  background: #f6f8f6;
  color: #1d2622;
  text-align: left;
  font-weight: 400;
}

.source-option strong {
  font-size: 1.05rem;
}

.source-option.active {
  border-color: #1f5b46;
  background: #fff;
  box-shadow: 0 4px 16px rgb(31 91 70 / 0.12);
}

.source-option:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.source-status-ready {
  background: #1f5b46;
  color: #fff;
}

.source-status-soon {
  background: #e7ece8;
  color: #64716b;
}

/* LIVE SMOKE FIX-PASS #02: real byte-progress for the STEP upload
   (bot/api/web/app.js's xhr.upload.onprogress) -- never a fake timer. */
.upload-progress {
  display: grid;
  gap: 0.35rem;
}

.upload-progress progress {
  width: 100%;
  height: 0.6rem;
  accent-color: #1f5b46;
}

/* DRAWING V1 REVIEW: a real table, not a spreadsheet editor (task section
   8) -- plain input cells, no drag/drop, no bulk edit. Horizontal scroll
   on narrow viewports is the deliberately accepted mobile answer instead
   of a second responsive layout (task section 23). */
.table-scroll {
  overflow-x: auto;
  margin: 1rem 0;
}

.drawing-review-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.drawing-review-table th,
.drawing-review-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #edf0ed;
  text-align: left;
}

.drawing-review-table input {
  width: 100%;
  min-width: 72px;
  box-sizing: border-box;
}

.drawing-review-table input[type="text"] {
  min-width: 110px;
}

.action-box {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem;
  border-radius: 12px;
  background: #f6f8f6;
}

.summary-item {
  min-width: 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: #f6f8f6;
}

.summary-item strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 0.2rem;
}

.result-summary {
  font-size: 1.4rem;
  font-weight: 700;
}

.screen-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.commercial-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.multiplier-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.multiplier-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.multiplier-button {
  min-width: 3.2rem;
}

.multiplier-button.active {
  background: #1f5b46;
  color: #fff;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 1rem, 1100px);
    padding-top: 1rem;
  }

  .page-header,
  .section-heading,
  .project-row {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
  }

  .logo-mark {
    height: 24px;
  }

  .header-nav button {
    padding: 0.6rem;
    font-size: 0.875rem;
  }

  .row-form,
  .step-controls,
  .commercial-body {
    grid-template-columns: 1fr;
  }

  .row-form {
    align-items: stretch;
  }

  .card {
    padding: 1rem;
    border-radius: 12px;
  }

  .badge,
  .status-pill {
    align-self: flex-start;
  }

  .screen-nav {
    flex-direction: column-reverse;
  }
}
