:root {
  --bg: #f3f6f5;
  --panel: #ffffff;
  --panel-2: #f8faf9;
  --ink: #121716;
  --muted: #6d7773;
  --line: #e1e7e3;
  --line-strong: #cdd7d1;
  --accent: #c7362f;
  --accent-dark: #a72822;
  --steel: #2f3a3a;
  --blue: #256f91;
  --green: #16845a;
  --amber: #b87513;
  --shadow: 0 1px 2px rgba(18, 28, 24, 0.04);
  --shadow-soft: 0 16px 40px rgba(18, 28, 24, 0.06);
  --radius-xl: 28px;
  --radius-lg: 16px;
  --radius-md: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(201, 34, 29, 0.06), transparent 260px),
    var(--bg);
  color: var(--ink);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

.page-shell {
  width: min(1760px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 20px;
}

.hidden {
  display: none !important;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}

.hero {
  padding: 24px 28px;
  margin-bottom: 18px;
  background:
    linear-gradient(135deg, #b9322c, #202b29);
  color: #fff;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1,
.section-head h2,
.section-head h3 {
  margin: 0;
  font-weight: 700;
}

.hero h1 {
  margin-top: 8px;
  font-size: clamp(36px, 4vw, 58px);
  line-height: 1.02;
}

.hero-copy {
  max-width: 760px;
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 18px;
  line-height: 1.45;
}

.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-points span {
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  font-weight: 700;
}

.mode-switch {
  display: inline-flex;
  gap: 8px;
  padding: 8px;
  margin-bottom: 20px;
  border-radius: 999px;
}

.mode-tab {
  min-height: 46px;
  padding: 0 18px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  box-shadow: none;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow:
    0 10px 24px rgba(199, 54, 47, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.form-card,
.results-card {
  padding: 22px;
}

.simple-layout {
  display: block;
}

.simple-card {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.simple-card > .section-head {
  margin-bottom: 14px;
}

.simple-card > .section-head h2 {
  font-size: 26px;
}

.request-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(260px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.export-action {
  min-height: 52px;
  padding: 0 20px;
  white-space: nowrap;
}

.export-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.secondary-action {
  background: var(--steel);
  box-shadow:
    0 10px 24px rgba(47, 58, 58, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.secondary-action:hover {
  background: #1f2828;
  box-shadow:
    0 14px 30px rgba(47, 58, 58, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.simple-controls {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(320px, 1fr);
  gap: 14px;
}

.simple-workspace {
  display: grid;
  grid-template-columns: minmax(1080px, 1fr) 280px;
  gap: 12px;
  align-items: start;
  margin-top: 18px;
}

.simple-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.simple-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.simple-table th,
.simple-table td {
  padding: 15px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.simple-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #f4f8f6;
}

.simple-table tbody tr:hover td {
  background: #fbfdfc;
}

.simple-table td strong {
  color: var(--steel);
}

.simple-table th:first-child,
.simple-table td:first-child {
  min-width: 360px;
  white-space: nowrap;
}

.simple-table td:nth-child(2) {
  color: var(--steel);
  font-weight: 700;
}

.weight-cell {
  color: var(--ink);
  font-weight: 900;
  white-space: nowrap;
}

.simple-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.empty-table-message {
  padding: 28px !important;
  color: var(--muted);
  text-align: center !important;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quantity-input {
  width: 74px;
  min-height: 38px;
  padding: 0 10px;
  text-align: center;
  font-weight: 800;
}

.inline-action {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.add-cart-action {
  min-width: 108px;
}

.inline-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.cart-panel {
  position: sticky;
  top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow);
}

.cart-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.cart-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}

.cart-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.cart-items {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 440px;
  overflow: auto;
}

.cart-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
}

.cart-item {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}

.cart-item-main strong {
  font-size: 14px;
}

.cart-item-main strong,
.cart-item-main span {
  display: block;
}

.cart-item-main span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.cart-item-controls {
  display: grid;
  grid-template-columns: 62px minmax(74px, 1fr);
  gap: 8px;
  align-items: center;
}

.cart-item-controls > strong {
  color: var(--steel);
}

.cart-item-controls .remove-cart-action {
  grid-column: 1 / -1;
  min-height: 34px;
}

.cart-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.cart-total span {
  color: var(--muted);
}

.cart-total strong {
  color: var(--accent);
  font-size: 24px;
}

.inline-action:disabled:hover {
  background: linear-gradient(180deg, #ffffff, #f5f8f6);
  border-color: var(--line);
  box-shadow:
    0 8px 20px rgba(18, 28, 24, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
  color: var(--steel);
  transform: none;
}

.section-head {
  margin-bottom: 16px;
}

.section-head p,
.material-note,
.formula-box p,
.status-message {
  margin: 8px 0 0;
  line-height: 1.55;
  color: var(--muted);
}

.section-head.compact {
  margin-top: 20px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span,
.formula-title {
  color: var(--muted);
  font-size: 14px;
}

.field-wide {
  grid-column: 1 / -1;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ffffff, #f7faf8);
  color: var(--ink);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 1px 2px rgba(18, 28, 24, 0.03);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

input:focus,
select:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(37, 111, 145, 0.12),
    0 10px 24px rgba(37, 111, 145, 0.08);
  transform: translateY(-1px);
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #f1f4f2;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 48px;
  background-image:
    linear-gradient(180deg, #ffffff, #f7faf8),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%232f3a3a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, right 14px center;
  background-size: auto, 18px;
  font-weight: 700;
}

select:hover,
input:hover:not(:disabled) {
  border-color: var(--line-strong);
}

.density-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  margin-top: 14px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 2px;
  color: var(--ink);
}

.checkbox input {
  width: 18px;
  min-height: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

button {
  min-height: 50px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 10px 24px rgba(199, 54, 47, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
  box-shadow:
    0 14px 30px rgba(199, 54, 47, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

button:active {
  transform: translateY(0);
  box-shadow:
    0 6px 14px rgba(199, 54, 47, 0.14),
    inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

button.ghost {
  background: linear-gradient(180deg, #ffffff, #f5f8f6);
  border-color: var(--line);
  color: var(--steel);
  box-shadow:
    0 8px 20px rgba(18, 28, 24, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

button.ghost:hover {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow:
    0 12px 24px rgba(18, 28, 24, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.mode-switch .mode-tab {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  box-shadow: none;
}

.mode-switch .mode-tab:hover {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.mode-switch .mode-tab.active,
.mode-switch .mode-tab.active:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow:
    0 10px 24px rgba(199, 54, 47, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.status-message {
  min-height: 24px;
}

.status-message.ok {
  color: var(--green);
}

.status-message.error {
  color: var(--accent);
}

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

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--steel);
  font-size: clamp(24px, 2vw, 30px);
  line-height: 1.1;
}

.accent-copper {
  background: #fff7f6;
  border-color: rgba(199, 54, 47, 0.18);
}

.accent-amber {
  background: #fff8ee;
  border-color: rgba(184, 117, 19, 0.2);
}

.accent-teal {
  background: #f5fbfa;
  border-color: rgba(22, 132, 90, 0.16);
}

.accent-indigo {
  background: #f6f8fb;
  border-color: rgba(37, 111, 145, 0.16);
}

.accent-berry {
  background: #fff7f7;
  border-color: rgba(167, 40, 34, 0.14);
}

.accent-lime {
  background: #f7fbf8;
  border-color: rgba(22, 132, 90, 0.14);
}

.formula-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-2);
}

.formula-box p {
  margin-top: 6px;
}

.note-box {
  background: #fbfcfb;
}

.seo-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
  padding: 18px;
  border: 1px solid rgba(205, 215, 209, 0.7);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(248, 250, 249, 0.84)),
    rgba(255, 255, 255, 0.5);
}

.seo-section article {
  padding: 14px 16px;
  border: 1px solid rgba(225, 231, 227, 0.72);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: none;
}

.seo-section h2 {
  margin: 0 0 7px;
  color: #27302e;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.seo-section p {
  margin: 0;
  color: #76817d;
  font-size: 14px;
  line-height: 1.55;
}

.faq-block {
  grid-column: 1 / -1;
}

.faq-block details {
  padding: 10px 0;
  border-top: 1px solid rgba(225, 231, 227, 0.8);
}

.faq-block details:first-of-type {
  border-top: 0;
}

.faq-block summary {
  cursor: pointer;
  color: #4d5955;
  font-size: 14px;
  font-weight: 750;
}

.faq-block details p {
  margin-top: 8px;
}

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

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

  .export-action,
  .export-actions {
    grid-column: 1 / -1;
  }

  .export-actions {
    display: grid;
  }

  .simple-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .cart-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--bg);
  }

  .page-shell {
    width: min(100vw - 12px, 1320px);
    padding: max(8px, env(safe-area-inset-top)) 0 22px;
  }

  .hero,
  .form-card,
  .results-card {
    padding: 14px;
    border-radius: 18px;
  }

  .hero {
    margin-bottom: 12px;
  }

  .hero h1 {
    font-size: 30px;
    line-height: 1.06;
  }

  .hero-copy {
    font-size: 15px;
  }

  .hero-points {
    gap: 7px;
    margin-top: 14px;
  }

  .hero-points span {
    padding: 7px 10px;
    font-size: 13px;
  }

  .form-grid,
  .metrics-grid,
  .density-row,
  .simple-controls,
  .request-panel,
  .seo-section {
    grid-template-columns: 1fr;
  }

  .simple-card {
    padding: 0;
  }

  .simple-card > .section-head h2 {
    font-size: 22px;
    line-height: 1.15;
  }

  .simple-card > .section-head p {
    display: none;
  }

  .request-panel {
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
  }

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

  .export-action {
    min-height: 48px;
    padding: 0 12px;
  }

  .simple-controls {
    gap: 8px;
  }

  .simple-controls input,
  .simple-controls select {
    min-height: 48px;
    font-size: 16px;
  }

  .field {
    gap: 5px;
  }

  .field span,
  .formula-title {
    font-size: 13px;
  }

  .simple-workspace {
    gap: 10px;
    margin-top: 12px;
  }

  .simple-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .simple-table,
  .simple-table tbody,
  .simple-table tr,
  .simple-table td {
    display: block;
    width: 100%;
  }

  .simple-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 8px;
  }

  .simple-table thead {
    display: none;
  }

  .simple-table tr {
    padding: 13px 12px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .mode-switch {
    display: grid;
    width: 100%;
    gap: 6px;
    padding: 6px;
    margin-bottom: 14px;
  }

  .simple-table th,
  .simple-table td {
    padding: 0;
    border-bottom: 0;
  }

  .simple-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 26px;
    padding-top: 6px;
    color: var(--ink);
    font-size: 15px;
  }

  .simple-table td::before {
    content: "";
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .simple-table td:nth-child(1) {
    display: block;
    min-width: 0;
    padding-top: 0;
    white-space: normal;
  }

  .simple-table td:nth-child(1)::before {
    display: none;
  }

  .simple-table td:nth-child(1) strong {
    display: block;
    color: var(--ink);
    font-size: 17px;
    line-height: 1.22;
  }

  .simple-table td:nth-child(2)::before {
    content: "ГОСТ";
  }

  .simple-table td:nth-child(3)::before {
    content: "Длина";
  }

  .simple-table td:nth-child(4)::before {
    content: "Теор. вес";
  }

  .simple-table td:nth-child(5)::before {
    content: "Вес 1 шт";
  }

  .simple-table td:nth-child(6)::before {
    content: "Кол-во";
  }

  .simple-table td:nth-child(7) {
    display: block;
    padding-top: 10px;
  }

  .simple-table td:nth-child(7)::before {
    display: none;
  }

  .weight-cell {
    font-size: 17px;
  }

  .simple-table td:last-child {
    width: 100%;
    white-space: normal;
  }

  .row-actions,
  .cart-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cart-item-controls {
    grid-template-columns: 1fr;
  }

  .quantity-input {
    width: 100%;
    min-height: 42px;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .inline-action,
  .add-cart-action {
    width: 100%;
    min-height: 44px;
    border-radius: 999px;
  }

  .cart-panel {
    padding: 14px;
    border-radius: 18px;
  }

  .cart-items {
    max-height: none;
  }

  .cart-total strong {
    font-size: 22px;
  }

  .seo-section {
    gap: 8px;
    margin-top: 22px;
    padding: 12px;
    border-radius: 18px;
  }

  .seo-section article {
    padding: 12px;
  }

  .seo-section h2 {
    font-size: 16px;
  }

  .seo-section p {
    font-size: 13px;
  }
}

@media (max-width: 430px) {
  .page-shell {
    width: min(100vw - 8px, 1320px);
  }

  .hero {
    padding: 12px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .hero-copy,
  .eyebrow,
  .hero-points {
    display: none;
  }

  .mode-switch {
    margin-bottom: 10px;
  }

  .mode-tab {
    min-height: 42px;
  }

  .request-panel {
    padding: 10px;
  }

  .request-panel .field {
    display: none;
  }

  .export-actions {
    grid-column: auto;
  }

  .simple-table tr {
    padding: 12px 10px 10px;
  }

  .simple-table td:nth-child(1) strong {
    font-size: 16px;
  }

  .simple-table td {
    min-height: 24px;
    padding-top: 5px;
    font-size: 14px;
  }

  .simple-table td::before {
    font-size: 10px;
  }

  .simple-table td:nth-child(6) {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
  }

  .simple-table td:nth-child(6)::before {
    align-self: center;
  }

  .quantity-input {
    min-height: 38px;
  }

  .inline-action,
  .add-cart-action {
    min-height: 42px;
    font-size: 14px;
  }

  .cart-panel {
    padding: 12px;
  }
}
