:root {
  --bg: #ffffff;
  --bg-alt: #f7f9fc;
  --card: #f4f8fc;
  --blue-soft: #dcebfa;
  --blue: #8bb9e8;
  --blue-2: #b8d4f1;
  --text: #202b38;
  --muted: #7c8795;
  --border: #e8edf3;
  --blue-deep: #2c5b87;
  --warn-bg: #fdf3e7;
  --warn-text: #8a5a22;
  --danger-bg: #fcedef;
  --danger-text: #9b3a45;
  --radius: 22px;
  --shadow: 0 1px 2px rgba(32, 43, 56, 0.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg-alt); }
body {
  margin: 0;
  background: var(--bg-alt);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  box-shadow: 0 0 40px rgba(32, 43, 56, 0.05);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 15px; background: var(--blue-soft);
  display: grid; place-items: center; flex: 0 0 auto;
}
.brand-text h1 { font-size: 19px; font-weight: 750; letter-spacing: -0.3px; }
.brand-text h1 .author { font-size: 11px; font-weight: 600; color: var(--blue-deep); letter-spacing: 0; margin-left: 3px; }
.brand-text p { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 2px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  color: var(--muted);
}
.icon-btn:active { background: var(--bg-alt); }
.icon-btn.back { margin-left: -8px; color: var(--text); }

main { padding: 0 20px; }
.screen { display: none; padding: 12px 0 28px; animation: fade 0.22s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.section-head h2 { font-size: 16px; font-weight: 680; }
.section-head p { font-size: 12px; color: var(--muted); margin-top: 3px; }

.budget-card { padding-bottom: 16px; }
.budget-field {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 16px; padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.budget-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(139, 185, 232, 0.14); }
.budget-field input {
  border: 0; outline: 0; background: transparent; flex: 1; min-width: 0;
  font-size: 34px; font-weight: 720; letter-spacing: -1px;
}
.budget-field span { color: var(--muted); font-weight: 600; }

.chips { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips.scroll { overflow-x: auto; margin: 2px 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 50px; padding: 9px 13px; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; transition: all 0.18s ease;
}
.chip.selected { background: var(--blue-soft); border-color: var(--blue-2); color: var(--blue-deep); }
.chip:active { transform: scale(0.97); }

.city-row { margin-top: 14px; }
.city-field {
  display: flex; align-items: center; gap: 8px; background: var(--bg-alt);
  border-radius: 14px; padding: 10px 12px; color: var(--blue);
}
.city-field select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  flex: 1; outline: 0; font-size: 14px; color: var(--text);
}
.branch-line { font-size: 12px; color: var(--muted); margin-top: 9px; }

.toggle-card { display: flex; align-items: center; gap: 12px; }
.toggle-icon {
  width: 36px; height: 36px; border-radius: 12px; background: var(--bg-alt);
  display: grid; place-items: center; color: var(--blue);
}
.toggle-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.toggle-text strong { font-size: 15px; font-weight: 650; }
.toggle-text span { font-size: 12px; color: var(--muted); }
.switch { position: relative; width: 48px; height: 29px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 50px; background: var(--border);
  transition: background 0.2s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18);
  transition: transform 0.2s;
}
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(19px); }

.primary-btn {
  width: 100%; height: 56px; border-radius: 18px; background: var(--blue);
  color: #17324d; font-size: 16px; font-weight: 700; margin-top: 4px;
  transition: transform 0.12s, filter 0.2s;
}
.primary-btn:active { transform: scale(0.985); filter: brightness(0.97); }
.primary-btn:disabled { opacity: 0.5; }

.sync-line { margin-top: 12px; }
.sync-line p { font-size: 12px; color: var(--muted); margin-top: 6px; }
.progress { height: 8px; border-radius: 50px; background: var(--blue-soft); overflow: hidden; }
.progress span {
  display: block; height: 100%; width: 40%; border-radius: 50px; background: var(--blue);
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

.status-block {
  display: flex; align-items: flex-start; gap: 10px; justify-content: space-between;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.status-block p { font-size: 12px; color: var(--muted); }
.text-btn { color: var(--blue-deep); font-size: 13px; font-weight: 650; padding: 8px 4px; flex: 0 0 auto; }
.fineprint { font-size: 11.5px; color: var(--muted); margin-top: 10px; }

.notice {
  display: flex; gap: 8px; align-items: flex-start; background: var(--warn-bg);
  color: var(--warn-text); border: 1px solid #f3e1c8; border-radius: 16px;
  padding: 12px; font-size: 12px; margin-bottom: 12px;
}
.notice strong { letter-spacing: .4px; }
.install-hint { background: var(--blue-soft); color: var(--blue-deep); border-color: var(--blue-2); }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  max-width: 560px; margin: 0 auto;
  display: flex; background: rgba(255,255,255,.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600; padding: 7px 0; border-radius: 14px;
  transition: color .15s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.selected { color: var(--blue-deep); }
.nav-item.selected svg { stroke-width: 2; }

.screen-head { display: flex; align-items: center; gap: 6px; padding: 6px 0 14px; }
.screen-head > div { flex: 1; }
.screen-head h2 { font-size: 19px; font-weight: 700; }
.screen-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plain-head { padding: 8px 0 14px; }
.plain-head h2 { font-size: 23px; font-weight: 740; letter-spacing: -0.4px; }
.plain-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plain-head.with-action { display: flex; justify-content: space-between; align-items: flex-start; }

.result-card {
  border: 1px solid var(--border); background: #fff; border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px;
}
.result-card.best { background: var(--card); border-color: var(--blue-2); border-width: 1.5px; }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.result-head h3 { font-size: 16px; font-weight: 700; }
.result-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge {
  display: inline-block; background: var(--blue-soft); color: var(--blue-deep);
  font-size: 11px; font-weight: 700; border-radius: 50px; padding: 5px 9px; white-space: nowrap;
}
.badge.gray { background: var(--bg-alt); color: var(--muted); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }

.product-row {
  display: flex; align-items: center; gap: 11px; padding: 8px 0; width: 100%; text-align: left;
}
.product-row + .product-row { border-top: 1px solid var(--border); }
.thumb {
  width: 56px; height: 56px; border-radius: 15px; background: var(--bg-alt);
  display: grid; place-items: center; flex: 0 0 auto; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.thumb svg { width: 24px; height: 24px; color: var(--blue-2); }
.product-info { flex: 1; min-width: 0; }
.product-info strong { display: block; font-size: 13.5px; font-weight: 550; line-height: 1.3; }
.product-info span { font-size: 11.5px; color: var(--muted); }
.price-col { text-align: right; flex: 0 0 auto; }
.price-col .now { font-size: 15px; font-weight: 750; white-space: nowrap; }
.price-col .old { font-size: 11px; color: var(--muted); text-decoration: line-through; }
.price-col .off { display: inline-block; font-size: 10px; color: var(--blue-deep); background: var(--blue-soft); border-radius: 50px; padding: 2px 5px; margin-top: 2px; }

.result-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 12px; }
.result-foot .left { font-size: 11.5px; color: var(--muted); }
.result-foot .total { font-size: 20px; font-weight: 780; letter-spacing: -0.3px; }
.result-foot .rem { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.result-foot .rem.good { color: var(--blue-deep); font-weight: 650; }

.summary-card { background: var(--bg-alt); border: 0; }
.summary-grid { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.summary-grid div { display: flex; flex-direction: column; gap: 3px; }
.summary-grid span { font-size: 11px; color: var(--muted); }
.summary-grid strong { font-size: 18px; font-weight: 750; }
.summary-grid strong.good { color: var(--blue-deep); }
.usage { height: 8px; border-radius: 50px; background: var(--blue-soft); margin-top: 12px; overflow: hidden; }
.usage i { display: block; height: 100%; background: var(--blue); border-radius: 50px; transition: width .4s; }
.savings { font-size: 12px; color: var(--blue-deep); margin-top: 9px; }

.action-row { display: grid; gap: 8px; margin-top: 16px; }
.soft-btn, .outline-btn {
  height: 54px; border-radius: 18px; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.soft-btn { background: var(--blue-soft); color: var(--blue-deep); }
.soft-btn:disabled { background: var(--bg-alt); color: var(--muted); }
.outline-btn { border: 1px solid var(--border); background: #fff; color: var(--text); }
.small-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; }

.empty { text-align: center; padding: 34px 16px; }
.empty .round { width: 64px; height: 64px; border-radius: 50%; background: var(--card); display: grid; place-items: center; margin: 0 auto 14px; }
.empty svg { width: 28px; height: 28px; color: var(--blue); }
.empty h3 { font-size: 16px; font-weight: 680; }
.empty p { font-size: 13px; color: var(--muted); margin-top: 6px; }

.list { display: flex; flex-direction: column; gap: 9px; }
.list-card { background: #fff; border-radius: 20px; padding: 13px; }
.list-card .meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.list-card .meta span { font-size: 11px; color: var(--muted); }
.meta-badge { display: inline-block; font-size: 10.5px; font-weight: 700; background: var(--blue-soft); color: var(--blue-deep); border-radius: 50px; padding: 3px 8px; }
.fav-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--blue); }
.fav-btn svg { width: 21px; height: 21px; }
.history-card p.names { font-size: 13.5px; line-height: 1.45; }
.history-card .numbers { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.history-card .numbers b { color: var(--text); font-weight: 650; }

.install-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 16px; }
.install-card h3 { font-size: 15px; font-weight: 680; }
.install-card p { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.install-card .steps { margin: 9px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text); }
.install-card .steps li { margin: 4px 0; }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(32,43,56,.34); z-index: 60;
  animation: fade .18s ease;
}
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 70;
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: #fff; border-radius: 28px 28px 0 0;
  padding: 12px 22px calc(26px + env(safe-area-inset-bottom));
  animation: sheetUp .24s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetUp { from { transform: translate(-50%, 30px); opacity: .6; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 16px; }
.sheet-head { display: flex; gap: 14px; }
.sheet-head .thumb { width: 84px; height: 84px; border-radius: 18px; }
.sheet-head h3 { font-size: 16px; font-weight: 680; line-height: 1.35; }
.sheet-head .brand { font-size: 12px; color: var(--muted); margin-top: 3px; }
.sheet-price { margin: 16px 0; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.sheet-price .now { font-size: 24px; font-weight: 780; }
.sheet-price .old { font-size: 14px; color: var(--muted); text-decoration: line-through; }
.sheet-info { background: var(--bg-alt); border-radius: 16px; padding: 14px; display: grid; gap: 8px; margin: 14px 0; }
.info-line { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.info-line span { color: var(--muted); }
.info-line b { font-weight: 600; text-align: right; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.sheet-actions button { height: 50px; border-radius: 15px; font-size: 13.5px; font-weight: 650; display: flex; align-items: center; justify-content: center; gap: 6px; }
.sheet-actions .fav { background: var(--blue); color: #17324d; }
.sheet-actions .fav.on { background: var(--blue-soft); color: var(--blue-deep); }
.sheet-actions .exclude { border: 1px solid var(--border); background: #fff; }
.source-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; color: var(--blue-deep); font-size: 12.5px; font-weight: 600; text-decoration: none; background: var(--bg-alt); border-radius: 12px; padding: 9px 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 90; max-width: 90%; background: rgba(32,43,56,.94); color: #fff;
  border-radius: 14px; padding: 11px 15px; font-size: 12.5px; text-align: center;
  animation: fade .18s ease;
}

@media (min-width: 620px) {
  body { padding: 20px 0; }
  .app-shell { border-radius: 26px; overflow: hidden; min-height: calc(100dvh - 40px); }
  .bottom-nav { bottom: 20px; border-radius: 0 0 26px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
