:root {
  --bg: #e4e2dd;
  --card: #f5f3ef;
  --text: #003f5c;
  --muted: #456478;
  --line: #c5cec9;
  --accent: #003f5c;
  --accent-soft: #53758a;
  --danger: #9b3d31;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "TT Firs Neue", "Futura", "Segoe UI", "Helvetica Neue", sans-serif;
  background: radial-gradient(circle at 16% 12%, #f2f0ec, var(--bg));
  color: var(--text);
}

.container {
  width: min(1200px, 95vw);
  margin: 24px auto 34px;
}

.market-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.market-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #afbcc6;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  background: #f6f7f8;
  color: #335a70;
  text-decoration: none;
  font-weight: 600;
}

.market-tab.active {
  background: #003f5c;
  color: #e4e2dd;
  border-color: #003f5c;
}

.market-tab.disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.market-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}

h1 { margin: 0 0 8px 0; font-family: "Futura", "TT Firs Neue", sans-serif; }
h2 { margin: 0 0 12px 0; font-family: "Futura", "TT Firs Neue", sans-serif; }
p { margin-top: 0; color: var(--muted); }
.hint { margin-bottom: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin: 14px 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px 18px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  position: relative;
}

input, select {
  width: 100%;
  border: 1px solid #aab8c3;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.field-hint {
  margin-top: 6px;
  color: #7a4a17;
  font-size: 12px;
  font-weight: 600;
}

.category-autocomplete {
  position: relative;
  width: 100%;
}

.category-meta {
  margin-top: 6px;
  color: #335a70;
  font-size: 12px;
  font-weight: 600;
}

.category-suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  border: 1px solid #aab8c3;
  border-radius: 10px;
  background: #fff;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0, 39, 58, 0.14);
  position: absolute;
  left: 0;
  right: 0;
  z-index: 8;
}

.suggestion-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.suggestion-btn .label {
  white-space: normal;
  line-height: 1.35;
}

.suggestion-btn .meta {
  color: #335a70;
  font-size: 11px;
  white-space: nowrap;
}

.suggestion-btn:hover,
.suggestion-btn.active {
  background: #eaf0f4;
}

.actions { grid-column: 1 / -1; }
button {
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #f4f1ed;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 700;
}

.secondary-btn {
  background: #b9c8d1;
  color: #003f5c;
}

.category-suggestions .suggestion-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.category-suggestions .suggestion-btn:hover,
.category-suggestions .suggestion-btn.active {
  background: #eaf0f4;
}

.alert {
  background: #fceceb;
  color: var(--danger);
  border: 1px solid #e2b1ae;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
  margin: 12px 0;
}

.kpi-card {
  background: linear-gradient(135deg, #003f5c, #1a5a79);
  color: #f4f7f9;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 8px 22px rgba(0, 63, 92, 0.25);
}

.kpi-title {
  color: #cfe0eb;
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.kpi-value {
  margin: 6px 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
  color: #fff;
}

.kpi-sub {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #d8ebf7;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.right { text-align: right; }

.matrix-wrap {
  width: 100%;
  overflow-x: auto;
}

.matrix {
  min-width: 860px;
}

.matrix th,
.matrix td {
  text-align: center;
  border: 1px solid #b8c6cf;
  padding: 7px 8px;
  font-size: 13px;
}

.matrix tbody th {
  text-align: right;
  background: #edf1f3;
}

.mid-row th {
  font-weight: 800;
  color: #003f5c;
}

.funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.funnel-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0 10px;
  border-bottom: 1px dashed #b9c8d1;
}

.funnel-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 170px;
  gap: 10px;
  font-size: 14px;
  align-items: center;
}

.impact {
  font-weight: 700;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.impact.neg { color: #9b3d31; }
.impact.pos, .impact.final, .impact.neutral { color: #356278; }

.funnel-row:last-child .funnel-head strong {
  font-size: 16px;
}

.funnel-head strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.funnel-formula {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.funnel-track {
  position: relative;
  height: 16px;
  background: #d9ddd8;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.funnel-track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 2px;
  width: 1px;
  background: rgba(0, 63, 92, 0.25);
}

.funnel-bar {
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
  position: relative;
  z-index: 1;
}

.funnel-bar.pos {
  background: linear-gradient(90deg, #5d8aa3, #3f6f8a);
}

.funnel-bar.neg {
  background: linear-gradient(90deg, #d48a82, #b6584e);
}

.funnel-bar.neutral {
  background: linear-gradient(90deg, #003f5c, #236082);
}

.funnel-bar.final {
  background: linear-gradient(90deg, #0c577a, #003f5c);
}

.comparison-section {
  background: linear-gradient(180deg, #f5f3ef 0%, #ece8e1 100%);
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.scenario-card {
  border: 1px solid #b7c4cd;
  border-radius: 12px;
  background: #f8f9f7;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 44, 70, 0.08);
}

.scenario-card.selected {
  border-color: #003f5c;
  box-shadow: 0 0 0 2px rgba(0, 63, 92, 0.2), 0 8px 18px rgba(0, 63, 92, 0.12);
  background: linear-gradient(180deg, #f7fbff 0%, #eef4f8 100%);
}

.scenario-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.scenario-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #adc0cd;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  color: #2f556a;
  background: #edf3f7;
}

.scenario-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  background: #ffffff;
  border: 1px solid #d0d9de;
  border-radius: 10px;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 11px;
  color: #5f7686;
}

.metric-value {
  font-size: 16px;
  color: #003f5c;
  line-height: 1.1;
}

.metric-sub {
  font-size: 11px;
  color: #53758a;
}

.margin-pos {
  color: #285f3f;
}

.margin-neg {
  color: #9b3d31;
}

.product-data summary {
  cursor: pointer;
  font-family: "Futura", "TT Firs Neue", sans-serif;
  font-weight: 700;
  margin-bottom: 10px;
}

.label-help {
  position: absolute;
  right: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #003f5c;
  color: #e4e2dd;
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  line-height: 1;
}

.help-tip {
  position: absolute;
  right: 0;
  top: -6px;
  transform: translateY(-100%);
  background: #003f5c;
  color: #e4e2dd;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 12px;
  min-width: 260px;
  opacity: 0;
  visibility: hidden;
  transition: 120ms ease;
  z-index: 5;
}

.label-help:hover .help-tip,
.label-help:focus-within .help-tip {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  width: min(460px, 95vw);
  background: #fff;
  border-radius: 12px;
  border: 1px solid #c5cec9;
  padding: 18px;
}

.modal-card h3 {
  margin: 0 0 8px 0;
  font-family: "Futura", "TT Firs Neue", sans-serif;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.site-footer {
  width: min(1200px, 95vw);
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.consent-line {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.consent-line input {
  margin-top: 2px;
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .grid { grid-template-columns: 1fr; }
  .scenario-grid { grid-template-columns: 1fr; }
  .scenario-metrics { grid-template-columns: 1fr; }
  .funnel-head {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .impact,
  .funnel-head strong,
  .funnel-formula {
    text-align: left;
  }
}
