:root {
  color-scheme: light;
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-2: #e7f3f1;
  --text: #12201f;
  --muted: #60716e;
  --line: #d7e5e2;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --danger: #b42318;
  --shadow: 0 10px 26px rgba(15, 76, 72, 0.1);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.05rem;
}

.topbar {
  align-items: center;
  background: #0f766e;
  color: #fff;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  color: inherit;
  display: block;
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  opacity: 0.72;
  text-transform: uppercase;
}

.badge {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  color: #fff;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 850;
  padding: 7px 10px;
  white-space: nowrap;
}

.layout {
  display: grid;
  gap: 12px;
  margin: 0 auto;
  max-width: 980px;
  padding: 12px;
}

.quote-panel,
.results-panel,
.catalog-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.actions {
  display: flex;
  gap: 8px;
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.82rem;
  font-weight: 800;
  gap: 6px;
}

.field-card {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

input,
select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 750;
  min-height: 50px;
  padding: 10px 12px;
  width: 100%;
}

select {
  appearance: auto;
}

input:focus,
select:focus,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 2px;
}

.input-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  overflow: hidden;
}

.input-row input {
  border: 0;
  border-radius: 0;
  min-width: 0;
}

.input-row span {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 900;
  padding: 0 11px;
}

button,
.file-action {
  align-items: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 48px;
  padding: 10px 14px;
}

.compact {
  min-height: 40px;
  padding: 8px 12px;
}

.primary {
  background: var(--brand);
  color: #fff;
}

.primary:active {
  background: var(--brand-strong);
}

.ghost {
  background: var(--surface-2);
  color: var(--brand-strong);
}

.file-action input {
  display: none;
}

.advanced {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

summary {
  cursor: pointer;
  font-weight: 900;
  list-style-position: inside;
  min-height: 48px;
  padding: 14px;
}

.advanced-grid,
.catalog-form {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

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

.metrics div,
.result-card,
.catalog-item {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
}

.metrics span,
.result-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.metrics strong {
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.results {
  display: grid;
  gap: 10px;
}

.result-card {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr auto;
  padding: 12px;
}

.result-card h3 {
  font-size: 0.98rem;
  margin: 0 0 4px;
}

.result-price {
  color: var(--brand-strong);
  font-size: 1.35rem;
  font-weight: 950;
  text-align: right;
  white-space: nowrap;
}

.catalog-panel > details > summary {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.catalog-panel strong {
  display: block;
}

.catalog-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 12px 12px;
}

.catalog-list {
  display: grid;
  gap: 9px;
  padding: 0 12px 12px;
}

.catalog-item {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  padding: 12px;
}

.catalog-item strong {
  color: var(--text);
}

.catalog-item span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.danger {
  background: #fff1f0;
  color: var(--danger);
}

.empty {
  color: var(--muted);
  padding: 14px 0;
}

.bottom-quote {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  bottom: 0;
  box-shadow: 0 -10px 24px rgba(15, 76, 72, 0.12);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  left: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  z-index: 10;
}

.bottom-quote span {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
  font-weight: 850;
}

.bottom-quote strong {
  color: var(--brand-strong);
  display: block;
  font-size: 1.45rem;
  font-weight: 950;
  line-height: 1;
}

.bottom-quote button {
  min-width: 124px;
}

.toast {
  background: #13201f;
  border-radius: 8px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  color: #fff;
  left: 50%;
  max-width: calc(100vw - 32px);
  opacity: 0;
  padding: 12px 14px;
  position: fixed;
  transform: translate(-50%, 20px);
  transition: 180ms ease;
  visibility: hidden;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}

@media (min-width: 720px) {
  body {
    padding-bottom: 28px;
  }

  h1 {
    font-size: 1.7rem;
  }

  .topbar {
    padding-left: 24px;
    padding-right: 24px;
  }

  .layout {
    gap: 18px;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    padding: 20px;
  }

  .quote-panel,
  .results-panel,
  .catalog-panel {
    padding: 18px;
  }

  .catalog-panel {
    grid-column: 1 / -1;
  }

  .advanced-grid,
  .catalog-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .catalog-form {
    align-items: end;
  }

  .bottom-quote {
    display: none;
  }

  .toast {
    bottom: 16px;
  }
}

@media (max-width: 390px) {
  .form-grid,
  .metrics,
  .result-card,
  .catalog-item {
    grid-template-columns: 1fr;
  }

  .result-price {
    text-align: left;
  }
}
