:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --green: #22c55e;
  --green-ink: #15803d;
  --green-soft: #f0fdf4;
  --warn: #f59e0b;
  --warn-ink: #b45309;
  --warn-soft: #fffbeb;
  --danger: #ef4444;
  --danger-ink: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --tab: calc(84px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: clip; }
body {
  font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  color-scheme: light;
}
a, button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.hero :focus-visible,
.btn.primary:focus-visible,
.btn.danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink);
}

#install-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
#install-banner[hidden] { display: none; }
#install-banner button {
  border: 0;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius);
  min-height: 40px;
  padding: 8px 14px;
}

#app {
  max-width: 720px;
  min-width: 0;
  margin: 0 auto;
  padding: 20px 16px var(--tab);
}

.top { margin-bottom: 18px; }
.brand {
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}
.back {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}
h2, h3 { margin: 0 0 8px; letter-spacing: -0.02em; }
.sheet h3 { margin-top: 16px; }
h2 { font-size: 18px; }
.sub, .muted { color: var(--muted); margin: 8px 0 0; }
.lead { margin: 0 0 12px; font-size: 16px; }
.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}
.text-link {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.hero {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}
.hero h2 { margin: 0; color: #fff; font-size: 26px; line-height: 1.15; }
.hero p { margin: 8px 0 0; color: #cbd5e1; }
.hero .btn { margin-top: 18px; }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.metric {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 26px 0 10px;
}
.section-head h2 { margin: 0; }
.section-head a { color: var(--ink); font-size: 14px; font-weight: 700; text-decoration: none; }

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters button, .btn, select, input, textarea { font: inherit; }
.filters button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  min-height: 40px;
  padding: 8px 14px;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 700;
}
.filters button.on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.list, .stack { display: grid; gap: 12px; }
.list.after-hero { margin-top: 14px; }
.stack > .btn.danger { justify-self: start; width: auto; }
.sheet .text-link { display: inline-block; margin-top: 8px; }
h2, .hero h2 { overflow-wrap: anywhere; }
.card, .sheet, .empty {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card {
  display: block;
  padding: 16px;
  text-decoration: none;
  color: inherit;
}
a.card:hover { border-color: #cbd5e1; }
.card h2 { font-size: 17px; }
.card p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.card-top, .row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.card time, .muted, .note { color: var(--muted); font-size: 13px; }
.activity-list { padding: 4px 16px; }
.activity {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.activity .pill { flex-shrink: 0; }
.activity:first-child { border-top: 0; }
.activity strong, .activity em { display: block; }
.activity strong { font-size: 15px; overflow-wrap: anywhere; }
.activity em { color: var(--muted); font-style: normal; font-size: 12px; margin-top: 2px; }

.pill, .badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.new, .pill.sent { background: var(--surface); color: var(--ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.ok { background: var(--green-soft); color: var(--green-ink); }
.badge { background: var(--green); color: #fff; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.conf { font-size: 12px; font-weight: 700; }
.conf.high { color: var(--green-ink); }
.conf.mid, .conf.low { color: var(--warn-ink); }

.empty, .sheet, .pad { padding: 18px; }
.pad-top { display: flex; align-items: center; gap: 8px; padding: 0 2px 12px; }
.empty { text-align: center; }
.empty .btn { margin-top: 12px; }

label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 700;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 48px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}
textarea { min-height: 160px; resize: vertical; }
#email-draft { min-height: 220px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  min-height: 48px;
  padding: 12px 16px;
  text-decoration: none;
  font-weight: 700;
}
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.tiny { min-height: 40px; padding: 8px 12px; font-size: 13px; border-radius: 12px; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions.stack-actions { display: grid; }
.actions.stack-actions .btn { width: 100%; }

.original pre {
  white-space: pre-wrap;
  font: inherit;
  margin: 0;
  max-height: 220px;
  overflow: auto;
  color: var(--muted);
}

.timeline {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  overflow: hidden;
  padding: 2px 0 14px;
  margin: 0 -4px 8px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 5px;
  height: 2px;
  background: var(--line);
}
.step {
  position: relative;
  min-height: 48px;
  text-align: center;
  text-decoration: none;
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  background: none;
  border: 0;
  padding: 0 1px;
  white-space: nowrap;
}
.step .mark {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  margin: 0 auto 8px;
  background: #e2e8f0;
  box-shadow: 0 0 0 4px #fff;
}
.step.done { color: var(--ink); }
.step.done .mark { background: var(--green); }
.step.current { color: var(--ink); }
.step.current .mark { background: var(--ink); transform: scale(1.2); }

.lines { display: grid; gap: 14px; }
.line { border-top: 1px solid var(--line); padding-top: 14px; }
.line textarea { min-height: 72px; }
.line-meta {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.1fr;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.line-meta strong { grid-column: 1 / -1; text-align: right; }
.tag {
  display: inline-flex;
  margin-bottom: 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
}

.price-hero { margin-bottom: 8px; }
.price-hero span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.price-hero strong {
  display: block;
  margin-top: 2px;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.045em;
}
.totals { display: grid; gap: 8px; margin: 14px 0 0; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 700; }

.material-list, .questions { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.material-list li, .questions li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.material-list li:first-child, .questions li:first-child { border-top: 0; padding-top: 0; }
.material-list strong { white-space: nowrap; }
.questions li { display: list-item; list-style: disc; margin-left: 18px; border-top: 0; padding-top: 0; }

.meter { display: flex; gap: 6px; margin: 12px 0; }
.meter i {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: #e2e8f0;
  font-style: normal;
}
.meter.high i,
.meter.mid i:nth-child(-n+2),
.meter.low i:first-child { background: var(--warn); }
.meter.high i { background: var(--green); }

.flash { padding: 12px 14px; border-radius: var(--radius); font-weight: 700; }
.flash.warn { background: var(--warn-soft); color: var(--warn-ink); }
.flash.ok { background: var(--green-soft); color: var(--green-ink); }
.flash.danger { background: var(--danger-soft); color: var(--danger-ink); }
.success-note {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green-ink);
  font-weight: 700;
}

.quote-list { display: grid; gap: 12px; }
.quote {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}
.quote.best { border-color: var(--green); background: var(--green-soft); }
.quote.picked { box-shadow: 0 0 0 2px var(--ink), var(--shadow); }
.quote-price {
  margin: 10px 0 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.quote.best .quote-price { color: var(--green-ink); }
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.compare div { background: var(--surface); border-radius: 12px; padding: 8px; }
.quote.best .compare div { background: #fff; }
.compare span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.compare strong { display: block; margin-top: 2px; font-size: 13px; overflow-wrap: anywhere; }
.distributor { margin: 12px 0; gap: 12px; align-items: flex-start; }
.distributor span { overflow-wrap: anywhere; }
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
}
code { font-size: 12px; background: var(--surface); padding: 1px 5px; border-radius: 6px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(16px);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 52px;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--ink); background: var(--surface); }

@media (min-width: 700px) {
  .line-meta { grid-template-columns: 1.2fr 0.7fr 1fr auto; }
  .line-meta strong { grid-column: auto; }
}
@media (min-width: 800px) {
  #app { padding-top: 36px; }
  h1 { font-size: 36px; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
}
