.mobile-wizard-heading,
.mobile-wizard-actions,
.system-choice-grid {
  display: none;
}

.config-flow > button {
  transition: background-color 160ms ease, color 160ms ease;
}

.config-flow > button:hover,
.config-flow > button:focus-visible {
  background: #f1f7ee;
}

.config-flow > button.active {
  background: #edf7e9;
}

.item-note-field {
  grid-column: 1 / -1;
}

@media (max-width: 680px) {
  body.calculator-mobile-wizard {
    --calc-green: #64cc3f;
    --calc-navy: #0a2733;
    --calc-surface: #ffffff;
    --calc-bg: #f1f5f2;
    --calc-muted: #6a7e86;
    --calc-line: #dce6e2;
    background: var(--calc-bg);
    padding-bottom: calc(108px + env(safe-area-inset-bottom));
    overscroll-behavior-y: contain;
  }

  body.calculator-mobile-wizard.pwa-has-app-nav {
    padding-bottom: calc(180px + env(safe-area-inset-bottom));
  }

  .calculator-mobile-wizard .calc-page-hero,
  .calculator-mobile-wizard [data-footer] {
    display: none;
  }

  .calculator-mobile-wizard .order-section {
    padding: calc(86px + env(safe-area-inset-top)) 0 28px;
    background: var(--calc-bg);
  }

  .calculator-mobile-wizard .order-section > .container {
    width: min(100% - 24px, 680px);
    padding-bottom: 18px;
  }

  .mobile-wizard-heading {
    display: block;
    padding: 8px 4px 19px;
    scroll-margin-top: calc(138px + env(safe-area-inset-top));
  }

  .mobile-wizard-heading > span {
    display: block;
    margin-bottom: 8px;
    color: #3d9430;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
  }

  .mobile-wizard-heading h1 {
    margin: 0;
    color: var(--calc-navy);
    font-size: clamp(29px, 8.5vw, 38px);
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.045em;
  }

  .mobile-wizard-heading p {
    margin: 10px 0 0;
    color: var(--calc-muted);
    font-size: 13px;
    line-height: 1.45;
  }

  .calculator-mobile-wizard .config-flow {
    position: sticky;
    z-index: 42;
    top: calc(64px + env(safe-area-inset-top));
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 -12px 18px;
    border: 0;
    border-top: 1px solid var(--calc-line);
    border-bottom: 1px solid var(--calc-line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 24px rgba(7, 28, 38, 0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .calculator-mobile-wizard .config-flow > button {
    min-width: 0;
    min-height: 58px;
    padding: 8px 3px 7px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    border-right: 1px solid var(--calc-line);
    border-bottom: 0;
    background: transparent;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .calculator-mobile-wizard .config-flow > button:last-child {
    border-right: 0;
  }

  .calculator-mobile-wizard .config-flow span {
    color: #7e9097;
    font-size: 9px;
    line-height: 1;
    letter-spacing: 0.08em;
  }

  .calculator-mobile-wizard .config-flow strong {
    max-width: 100%;
    overflow: hidden;
    color: #657981;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .calculator-mobile-wizard .config-flow small {
    display: none;
  }

  .calculator-mobile-wizard .config-flow > button.active {
    background: #eaf6e5;
  }

  .calculator-mobile-wizard .config-flow > button.active span,
  .calculator-mobile-wizard .config-flow > button.active strong,
  .calculator-mobile-wizard .config-flow > button.complete span {
    color: #2c7a27;
  }

  .calculator-mobile-wizard .order-layout {
    display: block;
  }

  .calculator-mobile-wizard .order-heading {
    padding: 4px 2px 0;
  }

  .calculator-mobile-wizard .order-heading h2 {
    font-size: 21px;
  }

  .calculator-mobile-wizard .order-heading p {
    margin-bottom: 16px;
    font-size: 12px;
    line-height: 1.5;
  }

  .calculator-mobile-wizard .order-item {
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid var(--calc-line);
    border-radius: 17px;
    background: var(--calc-surface);
    box-shadow: 0 10px 30px rgba(7, 28, 38, 0.055);
  }

  .calculator-mobile-wizard .order-item summary {
    min-height: 54px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    color: #36525e;
    font-size: 12px;
    line-height: 1.35;
  }

  .calculator-mobile-wizard .order-item summary::before {
    margin-right: 9px;
  }

  .calculator-mobile-wizard .item-body {
    padding: 16px;
  }

  .calculator-mobile-wizard .config-primary,
  .calculator-mobile-wizard .item-meta-fields {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .calculator-mobile-wizard .config-primary {
    margin-bottom: 0;
  }

  .calculator-mobile-wizard .field {
    min-width: 0;
  }

  .calculator-mobile-wizard .field label {
    margin-bottom: 7px;
    display: block;
    color: #526b74;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .calculator-mobile-wizard .field input,
  .calculator-mobile-wizard .field select,
  .calculator-mobile-wizard .field textarea {
    width: 100%;
    min-width: 0;
    min-height: 50px;
    padding: 11px 13px;
    border: 1px solid #c8d5d2;
    border-radius: 11px;
    background: #fff;
    color: var(--calc-navy);
    font-size: 16px;
    line-height: 1.45;
    scroll-margin-top: calc(148px + env(safe-area-inset-top));
    scroll-margin-bottom: calc(184px + env(safe-area-inset-bottom));
  }

  .calculator-mobile-wizard .field input:focus,
  .calculator-mobile-wizard .field select:focus,
  .calculator-mobile-wizard .field textarea:focus {
    border-color: var(--calc-green);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(100, 204, 63, 0.18);
  }

  .calculator-mobile-wizard .system-field > select {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
  }

  .system-choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .system-choice-grid button {
    min-height: 88px;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 9px;
    border: 1px solid #cad7d4;
    border-radius: 13px;
    color: var(--calc-navy);
    background: #f8faf9;
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .system-choice-grid button strong {
    font-size: 14px;
    font-weight: 500;
  }

  .system-choice-grid button span {
    color: var(--calc-muted);
    font-size: 10px;
    line-height: 1.3;
  }

  .system-choice-grid button.active {
    border-color: var(--calc-green);
    color: #1e5922;
    background: #eaf6e5;
    box-shadow: inset 0 0 0 1px var(--calc-green);
  }

  .system-missing .system-choice-grid {
    padding: 3px;
    outline: 2px solid #b94b3d;
    outline-offset: 2px;
    border-radius: 14px;
  }

  .system-missing .system-field::after {
    content: "Выберите систему";
    display: block;
    margin-top: 8px;
    color: #a33a2e;
    font-size: 11px;
  }

  .calculator-mobile-wizard .construction-builder {
    overflow: hidden;
    border: 1px solid var(--calc-line);
    border-radius: 14px;
    background: #eef3f1;
  }

  .calculator-mobile-wizard .builder-toolbar {
    padding: 16px;
    gap: 15px;
  }

  .calculator-mobile-wizard .builder-toolbar h3 {
    font-size: 18px;
  }

  .calculator-mobile-wizard .grid-counters {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .calculator-mobile-wizard .grid-counter {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) 40px 28px 40px;
    border-radius: 10px;
    overflow: hidden;
  }

  .calculator-mobile-wizard .grid-counter > span {
    padding: 0 8px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .calculator-mobile-wizard .grid-counter button {
    width: 40px;
    height: 44px;
  }

  .calculator-mobile-wizard .grid-visual {
    padding: 14px 8px 16px;
  }

  .calculator-mobile-wizard .view-badge {
    margin: 0 4px 13px;
    padding-bottom: 10px;
    flex-direction: row;
    align-items: center;
  }

  .calculator-mobile-wizard .dimension-top {
    margin-left: 58px;
  }

  .calculator-mobile-wizard .dimension-and-grid {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 5px;
  }

  .calculator-mobile-wizard .dimension-top input,
  .calculator-mobile-wizard .dimension-side input {
    min-height: 38px;
    height: 38px;
    padding: 2px;
    border-radius: 7px;
    font-size: 11px;
  }

  .calculator-mobile-wizard .dimension-side input {
    width: 49px;
  }

  .calculator-mobile-wizard .construction-grid {
    border-width: 4px;
  }

  .calculator-mobile-wizard .construction-cell {
    border-width: 1px;
  }

  .calculator-mobile-wizard .cell-id {
    left: 5px;
    top: 5px;
    min-width: 24px;
    height: 21px;
    font-size: 9px;
  }

  .calculator-mobile-wizard .cell-type {
    left: 5px;
    right: 5px;
    bottom: 5px;
    font-size: 8px;
  }

  .calculator-mobile-wizard .cell-inspector {
    padding: 17px 14px;
  }

  .calculator-mobile-wizard .cell-kinds {
    gap: 8px;
  }

  .calculator-mobile-wizard .cell-kind {
    min-height: 88px;
    border-radius: 11px;
    font-size: 11px;
  }

  .calculator-mobile-wizard .item-meta-fields {
    margin-top: 14px;
    padding: 16px;
    border: 1px solid var(--calc-line);
    border-radius: 14px;
    background: #fff;
  }

  .calculator-mobile-wizard .item-note-field {
    grid-column: auto;
  }

  .calculator-mobile-wizard .item-note-field textarea {
    min-height: 104px;
    resize: vertical;
  }

  .calculator-mobile-wizard .item-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
  }

  .calculator-mobile-wizard .item-actions button {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 8px 10px;
    border: 1px solid var(--calc-line);
    border-radius: 9px;
    font-size: 11px;
    line-height: 1.25;
    overflow-wrap: anywhere;
    touch-action: manipulation;
  }

  .calculator-mobile-wizard .item-actions [data-download] {
    grid-column: 1 / -1;
  }

  .calculator-mobile-wizard .add-item {
    min-height: 52px;
    margin-top: 2px;
    border-radius: 12px;
  }

  .calculator-mobile-wizard .order-documents,
  .calculator-mobile-wizard .order-sidebar {
    margin-top: 0;
    padding: 17px;
    border: 1px solid var(--calc-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(7, 28, 38, 0.05);
  }

  .calculator-mobile-wizard .order-sidebar {
    display: grid;
    gap: 15px;
  }

  .calculator-mobile-wizard .order-sidebar > div:first-child h2 {
    font-size: 23px;
  }

  .calculator-mobile-wizard .order-sidebar #sendCalc {
    display: none;
  }

  .calculator-mobile-wizard .order-documents {
    margin-bottom: 12px;
    gap: 18px;
  }

  .calculator-mobile-wizard .attachments input {
    font-size: 12px;
  }

  .calculator-mobile-wizard .mobile-wizard-actions {
    position: fixed;
    z-index: 88;
    left: 50%;
    bottom: env(safe-area-inset-bottom);
    transform: translateX(-50%);
    width: min(100%, 680px);
    min-height: 68px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr) 104px;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--calc-line);
    box-shadow: 0 -12px 32px rgba(7, 28, 38, 0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: opacity 150ms ease, transform 180ms ease;
  }

  .pwa-has-app-nav .mobile-wizard-actions {
    bottom: calc(68px + env(safe-area-inset-bottom));
    padding-bottom: 8px;
  }

  .mobile-wizard-actions > span {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .mobile-wizard-actions small,
  .mobile-wizard-actions strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-wizard-actions small {
    color: var(--calc-muted);
    font-size: 9px;
  }

  .mobile-wizard-actions strong {
    margin-top: 2px;
    color: var(--calc-navy);
    font-size: 11px;
    font-weight: 500;
  }

  .mobile-wizard-actions button {
    min-height: 48px;
    border-radius: 12px;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
  }

  .calculator-mobile-wizard.calc-field-focus .mobile-wizard-actions {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, calc(100% + 20px));
  }

  .mobile-wizard-back {
    border: 1px solid #cbd7d4;
    color: #526b74;
    background: #fff;
  }

  .mobile-wizard-back:disabled {
    opacity: 0.35;
  }

  .mobile-wizard-next {
    border: 1px solid var(--calc-green);
    color: var(--calc-navy);
    background: var(--calc-green);
  }

  .calculator-mobile-wizard[data-calc-step="1"] .construction-builder,
  .calculator-mobile-wizard[data-calc-step="1"] .item-meta-fields,
  .calculator-mobile-wizard[data-calc-step="1"] .item-actions,
  .calculator-mobile-wizard[data-calc-step="1"] .wizard-step-delivery,
  .calculator-mobile-wizard[data-calc-step="2"] .wizard-step-system,
  .calculator-mobile-wizard[data-calc-step="2"] .item-meta-fields,
  .calculator-mobile-wizard[data-calc-step="2"] .item-actions,
  .calculator-mobile-wizard[data-calc-step="2"] .wizard-step-delivery,
  .calculator-mobile-wizard[data-calc-step="3"] .wizard-step-system,
  .calculator-mobile-wizard[data-calc-step="3"] .wizard-step-delivery,
  .calculator-mobile-wizard[data-calc-step="4"] .order-main > :not(.order-documents) {
    display: none !important;
  }

  .calculator-mobile-wizard[data-calc-step="2"] .cell-inspector {
    display: none;
  }

  .calculator-mobile-wizard[data-calc-step="2"] .construction-cell {
    pointer-events: none;
  }

  .calculator-mobile-wizard[data-calc-step="2"] .grid-help {
    font-size: 0;
  }

  .calculator-mobile-wizard[data-calc-step="2"] .grid-help::after {
    content: "Укажите количество рядов и колонок, затем введите размеры каждой ячейки.";
    font-size: 11px;
  }

  .calculator-mobile-wizard[data-calc-step="3"] .builder-toolbar {
    display: none;
  }

  .calculator-mobile-wizard[data-calc-step="3"] .grid-help {
    margin-top: 12px;
  }

  .calculator-mobile-wizard[data-calc-step="4"] .order-main {
    display: block;
  }

  .calculator-mobile-wizard[data-calc-step="4"] .order-documents,
  .calculator-mobile-wizard[data-calc-step="4"] .order-sidebar {
    display: grid;
  }
}

@media (max-width: 370px) {
  .system-choice-grid {
    grid-template-columns: 1fr;
  }

  .calculator-mobile-wizard .grid-counters {
    grid-template-columns: 1fr;
  }

  .mobile-wizard-actions {
    grid-template-columns: 72px minmax(0, 1fr) 94px;
    padding-inline: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .config-flow > button,
  .mobile-wizard-actions {
    transition: none;
  }
}

@media (max-width: 680px) {
  .calculator-mobile-wizard .construction-grid {
    border: 0;
  }

  .calculator-mobile-wizard .construction-frame-path {
    stroke-width: 7;
  }

  .calculator-mobile-wizard .construction-mullion-path {
    stroke-width: 5;
  }

  .calculator-mobile-wizard .cell-kinds {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .calculator-mobile-wizard .profile-mode-toggle {
    min-height: 68px;
    padding: 11px 12px;
    touch-action: manipulation;
  }

  .calculator-mobile-wizard .profile-editor {
    margin-top: 18px;
  }
}
