:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1a2233;
  --muted: #66738a;
  --line: #dde3ec;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --good: #0d8a4f;
  --danger: #c0392b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.brand span { color: var(--accent); }
.brand .tag {
  font-style: normal; font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#dealSelect { max-width: 260px; }

main { max-width: 980px; margin: 0 auto; padding: 20px 16px 60px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
h2 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 small { font-weight: 400; color: var(--muted); font-size: 13px; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 700; flex: none;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
label small { font-weight: 400; }
.span2 { grid-column: span 2; }
input, select {
  font: inherit; color: var(--ink);
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
output { color: var(--ink); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 6px; padding: 7px 14px; border: 1px solid transparent;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }

table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
th.num, td.num { text-align: right; }
td input { width: 100%; }
td input[type="checkbox"] { width: auto; }
.col-use { width: 40px; }
.col-del { width: 34px; }
.del-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.del-btn:hover { color: var(--danger); }
tr.excluded td { opacity: 0.45; }
td.ppsf { font-weight: 700; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.arv-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: stretch; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.stat-value.big { color: var(--accent); }
.stat.override { justify-content: flex-start; }

.offer-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.offer-box { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; }
.offer-label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.offer-value { font-size: 26px; font-weight: 800; margin: 4px 0; color: var(--good); }
.offer-formula { font-size: 12px; color: var(--muted); }

.disclaimer { color: var(--muted); font-size: 12px; text-align: center; }

/* ---- print report ---- */
#report { display: none; }
@media print {
  body * { visibility: visible; }
  header.topbar, main { display: none; }
  #report { display: block; padding: 0 8px; }
  #report h1 { font-size: 22px; margin: 0 0 2px; }
  #report .report-sub { color: #555; font-size: 11px; margin: 0 0 14px; }
  #report h2 { font-size: 17px; margin: 0 0 4px; display: block; }
  #report h3 { font-size: 14px; margin: 18px 0 6px; }
  #report table { font-size: 12px; }
  #report th, #report td { padding: 4px 6px; }
  .report-stats { display: flex; gap: 24px; margin: 10px 0; }
  .report-stats div { font-size: 12px; }
  .report-stats b { display: block; font-size: 16px; }
  .report-disclaimer { font-size: 10px; color: #777; margin-top: 24px; }
}
