:root {
  --ink: #071c24;
  --ink-soft: #1d3c46;
  --teal: #0f6d7a;
  --teal-deep: #0a4d57;
  --mint: #1aa3a1;
  --ice: #e7f5f6;
  --sand: #f6f1e8;
  --paper: #fffcf7;
  --coral: #dd6b3a;
  --gold: #c9a227;
  --line: rgba(7, 28, 36, 0.08);
  --shadow: 0 18px 50px rgba(7, 28, 36, 0.12);
  --radius: 22px;
  --nav-h: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(26, 163, 161, 0.16), transparent 50%),
    radial-gradient(900px 400px at -10% 20%, rgba(221, 107, 58, 0.08), transparent 45%),
    var(--sand);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(255, 252, 247, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  max-width: 100vw;
  overflow: hidden;
  direction: ltr;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.02em;
  margin: 0;
  flex: 0 0 auto;
  direction: ltr;
  unicode-bidi: isolate;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex: 0 0 auto;
  display: block;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(15, 109, 122, 0.22);
}
.brand-name {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.top-links {
  display: none;
  gap: 8px;
  margin-left: auto;
  direction: rtl;
}
.top-links a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 14px;
}
.top-links a.active, .top-links a:hover { background: var(--ice); color: var(--teal-deep); }

.hero {
  position: relative;
  margin: 14px 16px 0;
  border-radius: 26px;
  overflow: hidden;
  min-height: 240px;
  color: white;
  box-shadow: var(--shadow);
}
.hero img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.04) brightness(1.05);
}
.hero-copy {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(7,28,36,0.55) 0%, rgba(7,28,36,0.22) 48%, rgba(7,28,36,0.08) 100%);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
}
.hero-panel {
  max-width: min(520px, 100%);
  background: rgba(4, 18, 24, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 20px;
  padding: 16px 16px 14px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.35);
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 5vw, 34px);
  line-height: 1.3;
  max-width: none;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.hero p {
  margin: 0 0 14px;
  max-width: none;
  opacity: 0.95;
  font-size: 14px;
  color: rgba(255,255,255,0.92);
}
.badge {
  display: inline-flex;
  width: fit-content;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  margin-bottom: 8px;
  color: #fff;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.hero-actions .btn {
  padding: 11px 16px;
  font-size: 14px;
}
.btn-hero-secondary {
  background: #fff !important;
  color: var(--ink) !important;
  border: 0 !important;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
}
.btn-hero-secondary:hover {
  background: var(--ice) !important;
}
.hero-links {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px 0;
  margin: 0 0 4px;
  scrollbar-width: none;
}
.hero-links::-webkit-scrollbar { display: none; }
.hero-links a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px 7px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  box-shadow: 0 4px 14px rgba(7,28,36,0.05);
}
.hero-links a img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.hero-links a:active { transform: scale(0.98); }

.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 28px 0 14px; }
.section-title h2 { margin: 0; font-size: 22px; }
.section-title p { margin: 0; color: var(--ink-soft); font-size: 14px; }

.grid { display: grid; gap: 14px; }
.products { grid-template-columns: 1fr; }
.product-card {
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(7,28,36,0.06);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: transform .18s ease, box-shadow .18s ease;
}
.product-card:active { transform: scale(0.985); }
.product-card img { height: 168px; width: 100%; object-fit: cover; background: #dfe9ec; }
.product-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-card h3 { margin: 0; font-size: 18px; }
.product-card p { margin: 0; color: var(--ink-soft); font-size: 13.5px; line-height: 1.7; flex: 1; }
.chip {
  display: inline-flex;
  width: fit-content;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--ice);
  color: var(--teal-deep);
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 15px;
}
.btn-primary { background: var(--ink); color: white; }
.btn-accent { background: linear-gradient(135deg, var(--teal), var(--mint)); color: white; }
.btn-ghost { background: var(--ice); color: var(--teal-deep); }
.btn-wide { width: 100%; }
.btn:disabled { opacity: 0.55; }

.quick {
  margin-top: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(7, 28, 36, 0.08);
}
.quick .section-title {
  margin-top: 0;
}
.quick .section-title h2 {
  font-size: 18px;
}
.quick .section-title p {
  font-size: 13px;
}
.form-grid { display: grid; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
input, select, textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 12px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--mint); box-shadow: 0 0 0 4px rgba(26,163,161,0.12); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  background: var(--ice);
  border-radius: 18px;
  padding: 12px;
}
.kpi.heat { background: #fbece3; }
.kpi b, .kpi-val {
  display: inline-flex;
  flex-direction: row;
  align-items: baseline;
  gap: 0.35em;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 20px;
}
.kpi-num { font-variant-numeric: tabular-nums; }
.kpi-unit {
  font-size: 0.68em;
  font-weight: 600;
  color: var(--ink-soft);
}
.kpi > span:first-child { font-size: 12px; color: var(--ink-soft); display: block; }

.space-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.space-title { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.space-remove {
  border: 0;
  background: #f8e8e4;
  color: #a33b22;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.space-remove:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.layout-calc {
  display: grid;
  gap: 16px;
  margin: 16px auto 24px;
  width: min(1120px, calc(100% - 24px));
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
}
.card h1 { margin: 0 0 6px; font-size: 24px; }
.lede { margin: 0 0 16px; color: var(--ink-soft); font-size: 14px; line-height: 1.8; }
.result-card { position: relative; }
.result-card.result-revealed,
#p4.result-revealed,
#qResult.result-revealed {
  animation: result-reveal 0.85s ease;
}
@keyframes result-reveal {
  0% { box-shadow: 0 0 0 3px rgba(26, 163, 161, 0.45); }
  100% { box-shadow: 0 0 0 0 rgba(26, 163, 161, 0); }
}
.model-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  margin-top: 10px;
}
.model-card img { width: 92px; height: 72px; object-fit: cover; border-radius: 12px; }
.model-card-body { min-width: 0; }
.model-card-title {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
  line-height: 1.35;
}
.model-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
}
.model-spec {
  background: var(--ice);
  border-radius: 12px;
  padding: 6px 8px;
}
.model-spec-label {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 2px;
}
.model-spec-value {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.notice {
  background: #fff6dd;
  border: 1px solid rgba(201, 162, 39, 0.35);
  color: #6d5410;
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-top: 12px;
}

.range-band {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(15, 109, 122, 0.08), rgba(26, 163, 161, 0.06));
  border: 1px solid rgba(15, 109, 122, 0.18);
}
.range-band-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.range-band-top strong {
  font-size: 13px;
  color: var(--teal-deep);
}
.range-band-tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--teal);
  background: rgba(255,255,255,0.75);
  border-radius: 999px;
  padding: 3px 8px;
}
.range-band-values {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.range-sep {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.range-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.range-band-track {
  position: relative;
  height: 8px;
  margin: 10px 0 8px;
  border-radius: 999px;
  background: rgba(7, 28, 36, 0.08);
  overflow: visible;
}
.range-band-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(26, 163, 161, 0.35), rgba(15, 109, 122, 0.7), rgba(26, 163, 161, 0.35));
}
.range-band-mid {
  position: absolute;
  top: -3px;
  left: 50%;
  width: 3px;
  height: 14px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 3px rgba(255,252,247,0.9);
}
.range-band-meta {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.range-band-meta b { color: var(--ink); font-weight: 700; }

.scale-hint {
  background: var(--ice);
  border: 1px solid rgba(15, 109, 122, 0.16);
  color: var(--teal-deep);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
}
.scale-hint b { color: var(--ink); }
.space-item {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}
.kind-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind-pick label {
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  padding: 0;
  background: #fff;
  cursor: pointer;
}
.kind-pick img { height: 84px; width: 100%; object-fit: cover; }
.kind-pick span { padding: 8px 10px 10px; }
.kind-pick input { display: none; }
.kind-pick label:has(input:checked) { border-color: var(--mint); box-shadow: 0 0 0 4px rgba(26,163,161,0.12); }

.table-wrap { overflow: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-soft); font-weight: 600; }

.quick-split {
  display: grid;
  gap: 12px;
}

.bottomnav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: rgba(255,252,247,0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  box-sizing: border-box;
}
.bottomnav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 6px 2px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottomnav a.active { color: var(--teal-deep); font-weight: 800; }
.bottomnav svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.brand-name {
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kind-pick label span {
  display: block;
  padding: 8px 8px 10px;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}
.kind-pick label {
  min-width: 0;
}

.hero-actions .btn {
  max-width: 100%;
}
.hero h1 { max-width: 100%; }

@media (max-width: 759px) {
  .wrap { width: min(1120px, calc(100% - 24px)); }
  .hero { margin: 12px 12px 0; min-height: 220px; }
  .hero img { height: 220px; }
  .hero-copy { padding: 16px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 auto; text-align: center; justify-content: center; }
  .row-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .layout-calc { width: min(1120px, calc(100% - 20px)); margin: 12px auto 24px; }
  .kind-pick { grid-template-columns: 1fr 1fr; }
  .steps { margin-inline: -4px; padding-inline: 4px; }
  .section-title { flex-direction: column; align-items: start; }
  .model-card { grid-template-columns: 72px 1fr; }
  .product-card img { height: 148px; }
}

.steps { display: flex; gap: 8px; overflow: auto; padding-bottom: 8px; margin-bottom: 8px; }
.step {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
}
.step.on { background: var(--ink); color: white; }

details.formula { margin-top: 12px; color: var(--ink-soft); font-size: 13px; }
details.formula pre { white-space: pre-wrap; background: #fff; padding: 10px; border-radius: 12px; }

.conditional-block {
  display: none;
  gap: 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fff;
}
.conditional-block.open {
  display: grid;
}
.hidden { display: none !important; }
.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  padding-top: 4px;
}
.form-actions .btn-wide {
  width: 100%;
}
.sticky-cta {
  position: static;
  margin-top: 4px;
}

@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .top-links { display: flex; flex-wrap: wrap; justify-content: flex-end; max-width: 70%; margin-left: auto; }
  .products { grid-template-columns: repeat(3, 1fr); }
  .layout-calc { grid-template-columns: 1.05fr 0.95fr; align-items: start; }
  .result-card { position: sticky; top: 88px; }
  .hero { min-height: 280px; }
  .hero img { height: 280px; }
  .hero-links { justify-content: center; overflow: visible; }
  .kind-pick { grid-template-columns: repeat(4, 1fr); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
  .row-2 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
  .products { grid-template-columns: repeat(3, 1fr); }
}
