:root {
  --bg: #f3f0eb;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --card: #fff;
  --accent: #0b6e4f;
  --warn: #b45309;
  --crit: #b91c1c;
  --ok: #047857;
  --line: #e0dbd3;
  --accent-soft: #dcece5;
  --track: #ebe6de;
  --shadow: 0 10px 28px rgba(26, 26, 26, 0.06), 0 2px 6px rgba(26, 26, 26, 0.04);
  --shadow-lg: 0 18px 48px rgba(26, 26, 26, 0.09), 0 4px 12px rgba(26, 26, 26, 0.05);
  --font: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dfece6 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #efe6d8 0%, transparent 50%),
    linear-gradient(180deg, #f7f4ef 0%, var(--bg) 40%);
  line-height: 1.45;
}
.surface {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.top {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 4px 18px rgba(26,26,26,0.04);
}
.brand { font-weight: 700; letter-spacing: -0.02em; }
.muted { color: var(--muted); font-size: 0.9rem; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 2rem clamp(1rem, 3vw, 1.75rem) 4rem; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -0.03em; margin: 0.2rem 0 1rem; }
.lead { color: var(--muted); max-width: 42rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.35rem 1.4rem;
  display: grid;
  gap: 0.95rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-lg);
}
label { display: grid; gap: 0.4rem; font-size: 0.9rem; font-weight: 600; }
input[type="text"], input[type="number"], input:not([type]) {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-weight: 400;
  background: #fbfaf8;
  box-shadow: inset 0 1px 2px rgba(26,26,26,0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
  background: #fff;
}
button {
  background: linear-gradient(180deg, #0d8060 0%, var(--accent) 100%);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.35rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(11, 110, 79, 0.28), inset 0 1px 0 rgba(255,255,255,0.2);
}
button:hover { filter: brightness(1.04); }
button:disabled { opacity: 0.55; cursor: wait; filter: none; }
.progress-panel { display: grid; gap: 0.85rem; margin-top: 0.35rem; }
.progress-hero {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 110px;
}
.progress-mascot {
  width: 92px;
  height: auto;
  flex: 0 0 auto;
  image-rendering: auto;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(26,26,26,0.12));
}
.speech-bubble {
  position: relative;
  align-self: flex-start;
  margin-top: 0.35rem;
  max-width: 14rem;
  padding: 0.65rem 0.85rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}
.speech-bubble::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 18px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
.speech-bubble.pop {
  animation: bubble-pop 0.35s ease;
}
@keyframes bubble-pop {
  0% { transform: scale(0.86); opacity: 0.35; }
  70% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.progress-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: var(--track);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d8060, #14a37c);
  transition: width 0.35s ease;
}
.progress-error {
  color: var(--crit);
  font-size: 0.9rem;
  white-space: pre-wrap;
  max-height: 12rem;
  overflow: auto;
}
.meta { color: var(--muted); padding-left: 1.1rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--muted); }
.exec { font-size: 1.05rem; max-width: 46rem; }
.verdict { color: var(--muted); max-width: 46rem; }
.block-lead { color: var(--muted); margin: 0 0 1rem; max-width: 40rem; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
  gap: clamp(0.75rem, 2vw, 1.25rem);
  align-items: stretch;
  margin: 1.5rem 0;
}
@media (max-width: 620px) { .hero-grid { grid-template-columns: 1fr; } }
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 22vw, 150px), 1fr));
  gap: clamp(0.5rem, 1.5vw, 0.85rem);
}
.kpi {
  border-radius: 16px;
  padding: 0.95rem 1rem;
  display: grid;
  gap: 0.15rem;
  align-content: center;
}
.kpi strong { font-size: clamp(1.05rem, 2.2vw, 1.3rem); letter-spacing: -0.02em; }
.lbl { display: block; color: var(--muted); font-size: 0.78rem; margin-bottom: 0.15rem; }

.insight-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(220px, 36vw, 320px), 1fr));
  gap: clamp(0.6rem, 1.5vw, 0.9rem);
  margin: 1rem 0 2rem;
}
.insight-card {
  border-radius: 18px;
  padding: 1.15rem 1.2rem;
  display: grid;
  gap: 0.7rem;
  min-height: 140px;
}
.insight-card strong {
  display: block;
  font-size: clamp(1.15rem, 2.5vw, 1.55rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.insight-card p { margin: 0; color: var(--muted); font-size: 0.84rem; }
.money-risk { background: linear-gradient(145deg, #fff 20%, #fff4f2 100%); }
.money-risk strong { color: var(--crit); }
.risk-meter {
  height: 12px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(26,26,26,0.06);
}
.risk-fill {
  display: block;
  min-width: 2px;
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f59e0b, var(--crit));
}
.insight-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
}
.compare-bars { display: grid; gap: 0.45rem; }
.compare {
  display: block;
  min-width: 54px;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.32rem 0.6rem;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 10px rgba(26,26,26,0.08);
}
.compare.winner { background: var(--accent); }
.compare.waste { background: var(--warn); }

.gauge-card {
  border-radius: 18px;
  padding: 1.1rem;
  display: grid;
  gap: 0.6rem;
  align-content: center;
  justify-items: center;
  text-align: center;
}
.gauge { width: clamp(120px, 40vw, 168px); height: auto; }
.gauge-track { fill: none; stroke: var(--track); stroke-width: 12; }
.gauge-arc { fill: none; stroke-width: 12; stroke-linecap: round; }
.gauge-num { font-size: 34px; font-weight: 700; text-anchor: middle; fill: var(--ink); letter-spacing: -0.03em; }
.gauge-cap { font-size: 11px; text-anchor: middle; fill: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.gauge-ok .gauge-arc { stroke: var(--ok); }
.gauge-warn .gauge-arc { stroke: var(--warn); }
.gauge-crit .gauge-arc { stroke: var(--crit); }
.gauge-verdict { margin: 0; font-weight: 600; font-size: 0.95rem; }
.gauge-ok .gauge-verdict { color: var(--ok); }
.gauge-warn .gauge-verdict { color: var(--warn); }
.gauge-crit .gauge-verdict { color: var(--crit); }
.gauge-meta { display: grid; gap: 0.15rem; }

.block {
  margin: 2.2rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(220px, 30vw, 280px), 1fr));
  gap: clamp(0.7rem, 1.5vw, 1rem);
}
.chart-card {
  border-radius: 16px;
  padding: 1.15rem 1.2rem;
  display: grid;
  gap: 0.7rem;
  align-content: start;
}
.chart-card h3 { margin: 0; font-size: 0.98rem; letter-spacing: -0.01em; }
.chart-note { margin: 0; color: var(--muted); font-size: 0.82rem; }
.slot-explain { margin-top: 1rem; }
.slot-meta { display: grid; gap: 0.1rem; min-width: 0; }
.slot-tip { color: var(--muted); font-size: 0.72rem; line-height: 1.3; }

.stacked {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--track);
  box-shadow: inset 0 1px 2px rgba(26,26,26,0.05);
}
.stacked .seg { display: block; height: 100%; }
.stacked .seg.ok { background: var(--ok); }
.stacked .seg.warn { background: var(--warn); }
.stacked .seg.crit { background: var(--crit); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.65rem; margin: 0; padding: 0; font-size: 0.82rem; color: var(--muted); }
.legend-total { margin-left: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.3rem; vertical-align: baseline; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }
.dot.accent { background: var(--accent); }
.dot.ink { background: var(--ink); }

.track {
  display: block;
  height: 9px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(26,26,26,0.05);
}
.fill { display: block; height: 100%; border-radius: 999px; }
.fill.accent { background: var(--accent); }
.fill.warn-fill { background: var(--warn); }
.fill.muted-fill { background: #c9c2b7; }
.dual-bar, .slot-bars { display: grid; gap: 0.65rem; }
.dual-row, .slot-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) 1fr auto;
  gap: 0.65rem;
  align-items: center;
  font-size: 0.84rem;
}
.dual-lbl, .slot-lbl { color: var(--ink); font-weight: 600; font-size: 0.82rem; }
.dual-val, .slot-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-gauge { display: flex; align-items: center; gap: 0.75rem; }
.mini-gauge .track { flex: 1; }
.mini-gauge-val { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.trend-card { margin-top: clamp(0.7rem, 1.5vw, 1rem); }
.trend-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: baseline; justify-content: space-between; }
.trend-legend { display: flex; flex-wrap: wrap; gap: 0.9rem; font-size: 0.82rem; color: var(--muted); }
.trend { width: 100%; height: clamp(140px, 26vw, 190px); display: block; }
.trend-area { fill: var(--accent-soft); opacity: 0.6; stroke: none; }
.trend-cost { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-clicks { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 4 3; opacity: 0.55; stroke-linejoin: round; }
.trend-dot { fill: var(--accent); }
.trend-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75rem; margin-top: 0.25rem; }

.conclusions { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.85rem; }
.conclusion-card { padding: 1rem 1.15rem; display: grid; gap: 0.55rem; }
.conclusion-head { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; align-items: center; }
.conclusion-head strong { font-size: 1.05rem; }
.now, .should { margin: 0; }
.should {
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 8%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}
.should .lbl { color: var(--accent); font-weight: 700; }
.sev {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: lowercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-right: 0.2rem;
}
.sev.ok { background: #d1fae5; color: var(--ok); }
.sev.warn { background: #ffedd5; color: var(--warn); }
.sev.crit { background: #fee2e2; color: var(--crit); }
.hz { color: var(--muted); font-size: 0.85rem; margin-right: 0.4rem; }
.impact { color: var(--accent); margin: 0; font-weight: 600; }

.findings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 42vw, 420px), 1fr));
  gap: clamp(0.7rem, 1.5vw, 1rem);
  margin-top: 0.75rem;
}
.finding {
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin: 0;
}
.finding.crit { background: #fff9f8; }
.finding.warn { background: #fffbf5; }
.finding.ok { background: #f8fbf9; }
.finding h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.detail {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.92rem;
  margin: 0;
  color: #333;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.75rem 0 1.25rem;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
th, td { border-bottom: 1px solid var(--line); padding: 0.55rem 0.5rem; text-align: left; vertical-align: top; }
th { background: #faf8f5; font-size: 0.78rem; color: var(--muted); }
.kill-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.kill-overview div { padding: 0.85rem 0.95rem; border-radius: 14px; }
.kill-overview strong {
  display: block;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.badge {
  display: inline-block;
  background: #eee;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

/* Ads spoiler + before/after */
.ads-spoiler {
  margin-top: 1rem;
  padding: 0;
  overflow: hidden;
}
.ads-spoiler > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem;
}
.ads-spoiler > summary::-webkit-details-marker { display: none; }
.ads-spoiler > summary::before {
  content: "";
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.16s ease;
}
.ads-spoiler[open] > summary::before { transform: rotate(45deg); }
.summary-title { margin-right: auto; font-weight: 700; font-size: 1.05rem; }
.ads-list { padding: 0 1rem 1.1rem; display: grid; gap: 0.9rem; }
.ad-pair {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem 1rem;
  background: #fbfaf8;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}
.ad-pair.needs-fix { border-color: color-mix(in srgb, var(--warn) 28%, var(--line)); }
.ad-pair-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.ad-issues { margin: 0 0 0.65rem; padding-left: 1.1rem; color: var(--warn); font-size: 0.86rem; }
.ad-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}
.ad-col {
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.ad-col.better {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: color-mix(in srgb, var(--accent) 6%, #fff);
}
.ad-col p { margin: 0.25rem 0; font-size: 0.9rem; }
.ad-why { color: var(--accent); font-size: 0.84rem !important; margin-top: 0.45rem !important; }
.pattern-list { color: var(--muted); }

.foot { margin-top: 3rem; color: var(--muted); font-size: 0.85rem; }
.actions a { color: var(--accent); }

/* Buddy sidekick */
.buddy-dock {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  max-width: min(240px, calc(100vw - 2rem));
  pointer-events: none;
}
.buddy-dock > * { pointer-events: auto; }
.buddy-dock.drawer-open .buddy-fab-bubble { opacity: 0; pointer-events: none; }
.buddy-fab-bubble {
  position: relative;
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.3;
  color: var(--ink);
}
.buddy-fab-bubble::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
.buddy-fab {
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.15s ease;
}
.buddy-fab:hover { transform: translateY(-2px); }
.buddy-fab img { width: 44px; height: auto; display: block; }
.buddy-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 94vw);
  height: 100vh;
  z-index: 80;
  transform: translateX(105%);
  transition: transform 0.28s ease;
  pointer-events: none;
}
.buddy-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}
.buddy-drawer-inner {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(26,26,26,0.12);
}
.buddy-head {
  position: relative;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(420px 180px at 10% 0%, #dfece6 0%, transparent 60%),
    #fbfaf8;
}
.buddy-close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  padding: 0;
}
.buddy-hero {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding-right: 2rem;
}
.buddy-mascot {
  width: 84px;
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 3px 6px rgba(26,26,26,0.12));
}
.buddy-bubble {
  margin-top: 0.45rem;
  max-width: 15rem;
  font-size: 0.86rem;
}
.buddy-chat {
  overflow: auto;
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.65rem;
  align-content: start;
  background: linear-gradient(180deg, #fff 0%, #f7f4ef 100%);
}
.buddy-msg {
  max-width: 92%;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
}
.buddy-msg.user {
  justify-self: end;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
}
.buddy-msg.assistant {
  justify-self: start;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.buddy-compose {
  display: grid;
  gap: 0.55rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--line);
  background: #fff;
}
.buddy-compose textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: #fbfaf8;
}
.buddy-compose button {
  border-radius: 12px;
}
@media (max-width: 520px) {
  .buddy-drawer { width: 100vw; }
  .buddy-dock { right: 0.85rem; bottom: 0.85rem; max-width: calc(100vw - 1.7rem); }
}
.buddy-compose-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: -0.25rem;
}
