:root {
  --espresso: #241711;
  --terracotta: #9b3b1a;
  --warm: #f8f4ef;
  --blush: #f3e6df;
  --paper: #fffaf6;
  --line: rgba(36, 23, 17, 0.13);
  --muted: #75645c;
  --success: #257a51;
  --warning: #9b5e13;
  --danger: #a33124;
  --shadow: 0 24px 70px rgba(36, 23, 17, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  color: var(--espresso);
  background:
    radial-gradient(circle at top left, rgba(155, 59, 26, 0.16), transparent 32rem),
    linear-gradient(135deg, #fffaf7 0%, var(--warm) 48%, #efe1da 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  display: grid;
  gap: 26px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 246, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-logo {
  width: min(360px, 100%);
  height: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--terracotta);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1.04;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 8px;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--espresso);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 4px rgba(155, 59, 26, 0.1);
}

.login-form button,
.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--terracotta);
  color: white;
  padding: 0 18px;
  font-weight: 800;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1540px;
  margin: 0 auto 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 246, 0.9);
  box-shadow: 0 14px 35px rgba(36, 23, 17, 0.08);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-lockup img {
  width: 220px;
  max-width: 38vw;
  height: auto;
}

.brand-lockup span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.brand-lockup strong {
  display: block;
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 0 12px;
  color: var(--espresso);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill.soft {
  background: var(--blush);
  color: var(--terracotta);
}

.ghost-button,
.copy-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--espresso);
  padding: 0 14px;
  font-weight: 800;
}

.calculations-panel {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 246, 0.94);
  box-shadow: 0 14px 38px rgba(36, 23, 17, 0.07);
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.calc-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.calc-form .primary-button {
  justify-self: start;
}

.calc-result {
  margin-top: 14px;
}

.calc-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.calc-result-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(243, 230, 223, 0.28);
  padding: 10px;
}

.calc-result-grid span,
.calc-result-grid strong {
  display: block;
}

.calc-result-grid span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.calc-result-grid strong {
  overflow-wrap: anywhere;
}

.workspace {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.sidebar,
.config-panel,
.result-panel {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 246, 0.92);
  box-shadow: 0 14px 38px rgba(36, 23, 17, 0.07);
}

.sidebar,
.config-panel {
  padding: 18px;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: auto;
}

.panel-title,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-title span {
  color: var(--muted);
}

.panel-title strong {
  font-size: 1.25rem;
}

.field-label,
.field span {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.sidebar select,
.sidebar input {
  margin-bottom: 12px;
}

.product-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding-right: 4px;
}

.product-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--espresso);
  padding: 11px;
  text-align: left;
}

.product-item.active {
  border-color: var(--terracotta);
  background: #fff1eb;
}

.product-item strong {
  font-size: 0.94rem;
}

.product-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(243, 230, 223, 0.32);
  text-align: center;
  padding: 26px;
}

.empty-state img {
  width: 86px;
  opacity: 0.88;
}

.empty-state p {
  max-width: 420px;
}

.quote-form {
  display: grid;
  gap: 26px;
}

.product-image-wrap {
  width: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  aspect-ratio: 16 / 8;
}

.product-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.image-notice {
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(243, 230, 223, 0.35);
  color: var(--muted);
  padding: 12px;
  text-align: center;
  font-weight: 700;
}

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

.field {
  min-width: 0;
}

.field small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.derived-field {
  display: block;
  margin-top: 10px;
}

.derived-field > span {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.option-group {
  min-width: 0;
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.option-group > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.check-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.check-field input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.check-field strong,
.check-field small {
  display: block;
}

.check-field small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.warning-list {
  display: grid;
  gap: 8px;
}

.warning-item {
  border: 1px solid rgba(155, 94, 19, 0.22);
  border-radius: 8px;
  background: #fff7ea;
  color: #71420b;
  padding: 10px 12px;
  line-height: 1.45;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.result-card,
.detail-card {
  container-type: inline-size;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 16px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 16px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 900;
}

.status-badge.idle {
  background: var(--blush);
  color: var(--terracotta);
}

.status-badge.ok {
  background: #e4f4ea;
  color: var(--success);
}

.status-badge.consult {
  background: #fff2d9;
  color: var(--warning);
}

.status-badge.error {
  background: #ffe5e0;
  color: var(--danger);
}

.price {
  display: block;
  margin-bottom: 10px;
  max-width: 100%;
  font-size: clamp(1.45rem, 10cqw, 2.55rem);
  line-height: 1.04;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  word-break: normal;
  font-variant-numeric: tabular-nums;
}

.price.wrap-price {
  white-space: normal;
  overflow-wrap: anywhere;
}

.price-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 132px), 1fr));
  gap: 8px;
  margin-top: 14px;
}

.price-breakdown div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(243, 230, 223, 0.28);
  padding: 10px;
}

.price-breakdown .extra-breakdown {
  background: #fff7ea;
  border-color: rgba(155, 94, 19, 0.24);
}

.price-breakdown span,
.price-breakdown strong {
  display: block;
}

.price-breakdown span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.price-breakdown strong {
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.price-breakdown small {
  display: block;
  margin-top: 6px;
  color: var(--warning);
  font-size: 0.74rem;
  line-height: 1.35;
}

@container (max-width: 320px) {
  .price {
    font-size: clamp(1.3rem, 9.2cqw, 1.9rem);
  }

  .price-breakdown {
    grid-template-columns: 1fr;
  }
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: minmax(84px, 110px) minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 0.84rem;
}

dd {
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.message-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.copy-button {
  width: 100%;
  min-width: 0;
}

.copy-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 1120px) {
  .calc-result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .result-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .copy-button {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1121px) {
  .result-panel {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 36px);
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 8px;
  }

  .topbar,
  .calculations-panel,
  .workspace,
  .result-panel {
    grid-template-columns: 1fr;
  }

  .topbar,
  .calculations-panel,
  .sidebar,
  .config-panel,
  .result-panel {
    border-radius: 12px;
  }

  .sidebar,
  .config-panel,
  .result-panel {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup img {
    max-width: 240px;
  }

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

  .calc-grid,
  .calc-result-grid {
    grid-template-columns: 1fr;
  }

  .result-card,
  .detail-card {
    padding: 16px;
  }

  .product-image-wrap {
    aspect-ratio: 16 / 9;
  }

  .price {
    font-size: clamp(1.4rem, 9.5cqw, 2.2rem);
    letter-spacing: 0;
  }

  .price-breakdown {
    grid-template-columns: 1fr;
  }

  dl {
    gap: 14px;
  }

  dl div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .product-list {
    max-height: 360px;
  }

  .password-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding: 6px;
  }

  .result-panel {
    padding: 10px;
    gap: 12px;
  }

  .result-card,
  .detail-card {
    padding: 14px;
    border-radius: 10px;
  }

  .price {
    font-size: clamp(1.3rem, 9cqw, 1.95rem);
  }

  .message-list {
    padding-left: 16px;
  }
}
