* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --text: #172a45;
  --muted: #5f6b7a;
  --line: #d7dde5;
  --primary: #172a45;
  --accent: #b8935c;
  --soft: #eef2f6;
  --danger: #b42318;
  --success: #0a7b18;
  --shadow: 0 8px 28px rgba(12, 30, 60, 0.10);
  --radius: 18px;
}

body {
  background: linear-gradient(180deg, #f3efe7 0%, #ece7df 100%);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
}

.app-header {
  padding: 8px 2px 18px;
}

.eyebrow {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

h1 {
  font-size: 1.65rem;
  line-height: 1.15;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.45;
}

.screen.hidden {
  display: none;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.intro-card h2,
.step-title,
.section-title,
.review-title {
  font-size: 1.1rem;
}

.intro-card p,
.step-indicator,
.help-text,
.field-hint,
.review-muted {
  color: var(--muted);
}

.quote-type-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.quote-type-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(23, 42, 69, 0.04);
}

.quote-type-btn:active {
  transform: scale(0.99);
}

.quote-type-label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.quote-type-desc {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.step-indicator {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.step-pill {
  display: inline-flex;
  align-self: flex-start;
  background: #f0e8dc;
  color: var(--primary);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.95rem;
  font-weight: 650;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 1rem;
  color: var(--text);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.segmented.three {
  grid-template-columns: repeat(3, 1fr);
}

.segment-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 10px;
  font-weight: 650;
  cursor: pointer;
}

.segment-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.counter-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.counter-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.counter-value {
  min-width: 36px;
  text-align: center;
  font-weight: 700;
}

.section-block {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.section-heading-row .mini-btn {
  flex-shrink: 0;
}

.line-item-row {
  display: grid;
  grid-template-columns: 1.5fr 108px 74px 40px;
  gap: 8px;
  align-items: center;
}

.line-desc,
.line-amount {
  font-size: 0.94rem;
  padding: 10px 11px;
}

.line-sst-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.icon-btn,
.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  color: var(--danger);
}

.mini-btn {
  padding: 9px 12px;
  font-weight: 650;
}

.discount-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.discount-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 10px 8px;
  font-weight: 700;
  cursor: pointer;
}

.discount-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.summary-card {
  background: var(--soft);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.summary-row,
.total-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.summary-row span:first-child,
.total-row span:first-child {
  color: var(--muted);
}

.total-row strong {
  font-size: 1.02rem;
}

.total-row.grand strong:last-child {
  color: var(--primary);
  font-size: 1.16rem;
}

.breakdown-table {
  display: grid;
  gap: 10px;
}

.breakdown-group {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.breakdown-group h3 {
  padding: 12px 14px;
  background: #f7f9fb;
  font-size: 0.98rem;
  border-bottom: 1px solid var(--line);
}

.breakdown-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f6;
  font-size: 0.93rem;
}

.breakdown-line:last-child {
  border-bottom: none;
}

.breakdown-line .sst-note {
  color: var(--muted);
  font-size: 0.84rem;
}

.review-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.disclaimer {
  background: #fff8ef;
  border: 1px solid #ecd9bc;
  color: #6b5b45;
  border-radius: 14px;
  padding: 14px;
  line-height: 1.5;
  font-size: 0.92rem;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(244, 241, 234, 0.96);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 14px 14px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
}

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

.secondary-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-btn {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--line);
}

.pdf-actions {
  display: grid;
  gap: 10px;
}

.print-sheet {
  background: #fff;
  color: #111;
  padding: 28px;
}

.print-sheet h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.print-sheet h2 {
  font-size: 1.05rem;
  margin: 18px 0 8px;
}

.print-meta {
  font-size: 0.95rem;
  color: #333;
  line-height: 1.5;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.92rem;
}

.print-table th,
.print-table td {
  border: 1px solid #c8c8c8;
  padding: 8px 10px;
  vertical-align: top;
}

.print-table th {
  background: #f4f4f4;
  text-align: left;
}

.print-note {
  margin-top: 16px;
  line-height: 1.55;
  font-size: 0.92rem;
}

@media (max-width: 520px) {
  .line-item-row {
    grid-template-columns: 1fr;
  }

  .discount-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bottom-bar {
    grid-template-columns: 100px 1fr;
  }

  .breakdown-line {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    display: none;
  }
}