:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #15171a;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #1f6feb;
  --accent-soft: #eaf2ff;
  --positive: #137333;
  --negative: #b3261e;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

body.dark {
  --bg: #111315;
  --card: #191c20;
  --text: #f2f4f7;
  --muted: #a1a7b0;
  --border: #2b3036;
  --accent: #6ea8fe;
  --accent-soft: #18263b;
  --positive: #55c878;
  --negative: #ff7b72;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #ffffff 0, #f8fbff 180px, var(--bg) 560px);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.container { width: min(1180px, calc(100% - 28px)); margin: 0 auto; }
.site-header { border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.92); position: sticky; top: 0; z-index: 20;  }
.header-inner { min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { font-size: 20px; font-weight: 800; }
.tagline { font-size: 12px; color: var(--muted); margin-top: 3px; }
.page-shell { padding: 26px 0 56px; }
.hero { display: grid; grid-template-columns: 1fr auto; gap: 22px; align-items: end; margin-bottom: 20px; }
.hero h1 { margin: 8px 0 10px; font-size: clamp(30px, 5vw, 54px); line-height: 1.02; max-width: 860px; }
.hero p { margin: 0; max-width: 760px; color: var(--muted); line-height: 1.55; }
.eyebrow { display: inline-block; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 700; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); }
.brand, .kpi .value, .metric-row strong, .compare-card-value strong { font-variant-numeric: tabular-nums; }
.primary-btn, .secondary-btn, .ghost-btn { min-height: 44px; border-radius: 12px; padding: 0 16px; border: 1px solid var(--border); }
.primary-btn { background: var(--accent); color: white; border-color: var(--accent); font-weight: 700; }
.secondary-btn, .ghost-btn { background: var(--card); color: var(--text); }
.mode-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 16px; margin-bottom: 20px; }
.mode-label { font-weight: 700; }
.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segment { border: 1px solid var(--border); background: transparent; color: var(--text); padding: 9px 12px; border-radius: 10px; }
.segment.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); font-weight: 700; }
.objects-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.objects-grid.compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.object-card { padding: 20px; min-width: 0; }
.object-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.object-head input[type="text"] { border: 0; background: transparent; color: var(--text); font-size: 22px; font-weight: 800; width: 100%; min-width: 0; padding: 0; }
.object-head input[type="text"]:focus { outline: 2px solid var(--accent); border-radius: 6px; }
.object-sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { min-width: 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input-wrap { display: flex; align-items: center; gap: 8px; min-height: 46px; border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; background: var(--card); }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.input-wrap input, .field select { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 16px; }
.input-wrap span { color: var(--muted); white-space: nowrap; font-size: 13px; }
.field select { border: 1px solid var(--border); border-radius: 12px; min-height: 46px; padding: 0 10px; }
.subsection { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 18px; }
.subsection h3 { margin: 0 0 12px; font-size: 15px; }
.advanced { margin-top: 12px; }
.advanced summary { color: var(--accent); cursor: pointer; font-weight: 700; }
.results { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.kpi { border: 1px solid var(--border); border-radius: 14px; padding: 14px; min-width: 0; }
.kpi.primary { background: var(--accent-soft); border-color: transparent; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { margin-top: 5px; font-size: 21px; font-weight: 800; overflow-wrap: anywhere; }
.kpi .value.negative { color: var(--negative); }
.kpi .value.positive { color: var(--positive); }
.metrics-list { margin-top: 12px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.metric-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
.metric-row:last-child { border-bottom: 0; }
.metric-row span:first-child { color: var(--muted); }
.metric-row strong { text-align: right; overflow-wrap: anywhere; }
.comparison { margin-top: 22px; padding: 20px; }
.section-title-row h2, .info-card h2 { margin: 0 0 6px; }
.section-title-row p { margin: 0; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--border); text-align: right; }
th:first-child, td:first-child { text-align: left; color: var(--muted); }
th { color: var(--text); }
.winner-box { margin-top: 16px; padding: 14px; border-radius: 14px; background: var(--accent-soft); }
/* Contextual help */
.term-help { position: relative; display: inline-flex; align-items: center; gap: 5px; max-width: 100%; vertical-align: middle; }
.term-help-text { min-width: 0; }
.info-btn {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--muted) 45%, var(--border));
  background: transparent; color: var(--muted); display: inline-grid; place-items: center; padding: 0; font-size: 12px; font-weight: 800; line-height: 1;
}
.info-btn:hover, .info-btn:focus-visible, .term-help.open .info-btn { color: var(--accent); border-color: var(--accent); outline: none; }
.tooltip {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 60; width: min(310px, calc(100vw - 44px));
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); box-shadow: 0 12px 34px rgba(0,0,0,.14);
  font-size: 12px; font-weight: 500; line-height: 1.45; text-align: left; opacity: 0; visibility: hidden; transform: translateY(-3px); pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
.term-help.open .tooltip, .info-btn:focus-visible + .tooltip { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; }
.mini-info { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--border); border-radius: 50%; font-size: 11px; font-weight: 800; color: var(--muted); vertical-align: -1px; }

/* Compact explainer */
.compact-info .info-lead { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.info-strip { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.info-strip strong { color: var(--text); }

/* Mobile comparison cards */
.comparison-cards { display: none; margin-top: 14px; gap: 10px; }
.compare-card-row { border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.compare-card-title { color: var(--muted); font-size: 12px; margin-bottom: 9px; }
.compare-card-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.compare-card-value { min-width: 0; }
.compare-card-value span { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compare-card-value strong { display: block; margin-top: 3px; font-size: 15px; overflow-wrap: anywhere; }

.info-card { margin-top: 22px; padding: 20px; }
.info-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 16px; }
.info-grid > div { border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: grid; gap: 5px; }
.info-grid span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.disclaimer { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 16px 0 0; }
.site-footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-actions { justify-content: flex-start; }
  .objects-grid.compare { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .container { width: min(100% - 18px, 1180px); }
  .page-shell { padding-top: 22px; }
  .hero h1 { font-size: 34px; }
  .mode-bar { align-items: flex-start; flex-direction: column; }
  .form-grid, .info-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .object-card, .comparison, .info-card { padding: 15px; border-radius: 16px; }
  .object-head { flex-direction: column; }
  .field select { font-size: 16px; }
  .comparison-table { display: none; }
  .comparison-cards { display: grid; }
  .metric-row { align-items: flex-start; }
  .metric-row strong { max-width: 56%; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 19px; }
  .tooltip { position: fixed; left: 14px; right: 14px; top: auto; bottom: 18px; width: auto; max-width: none; font-size: 13px; padding: 13px 14px; }
  .info-strip { display: grid; gap: 8px; }
}
@media (max-width: 360px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .compare-card-values { grid-template-columns: 1fr; }
}

/* v1.3 polish */
.hero { margin-bottom: 18px; }
.hero h1 { margin-top: 0; max-width: 760px; font-size: clamp(30px, 4.4vw, 48px); line-height: 1.04; }
.hero p { max-width: 740px; line-height: 1.5; }
.reset-btn { background: transparent; border-color: transparent; color: var(--muted); font-weight: 600; padding-inline: 10px; }
.reset-btn:hover, .reset-btn:focus-visible { color: var(--text); background: color-mix(in srgb, var(--card) 65%, var(--bg)); border-color: var(--border); outline: none; }
.tooltip { padding-right: 38px; max-height: 180px; overflow: auto; }
.tooltip-text { display: block; }
.tooltip-close { position: absolute; top: 6px; right: 7px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; font-size: 20px; line-height: 1; }
.tooltip-close:hover, .tooltip-close:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.metric-row, .compare-card-row, .compare-card-value { min-width: 0; }
.metric-row > span, .metric-row strong, .compare-card-title, .compare-card-value span, .compare-card-value strong { overflow-wrap: anywhere; word-break: normal; }
.comparison th, .comparison td { max-width: 320px; overflow-wrap: anywhere; }

@media (hover: hover) and (pointer: fine) {
  .term-help:hover .tooltip { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; }
  .tooltip-close { display: none; }
  .tooltip { padding-right: 12px; }
}

@media (max-width: 640px) {
  .page-shell { padding-top: 18px; }
  .hero { gap: 14px; margin-bottom: 16px; }
  .hero h1 { font-size: 30px; line-height: 1.06; margin-bottom: 8px; }
  .hero p { font-size: 15px; line-height: 1.48; }
  .hero-actions { gap: 6px; }
  .hero-actions .primary-btn { min-height: 42px; padding-inline: 14px; }
  .hero-actions .reset-btn { min-height: 42px; }
  .mode-bar { margin-bottom: 16px; }
  .tooltip {
    left: 50%; right: auto; bottom: 12px; width: min(calc(100% - 24px), 520px); max-width: calc(100% - 24px);
    max-height: min(30vh, 190px); transform: translate(-50%, 8px); padding: 13px 42px 13px 14px; font-size: 13px;
  }
  .term-help.open .tooltip, .info-btn:focus-visible + .tooltip { transform: translate(-50%, 0); }
  .metric-row { gap: 10px; }
  .metric-row > span { min-width: 0; }
  .metric-row strong { max-width: 52%; }
  .compare-card-value span { white-space: normal; text-overflow: clip; }
}


.input-wrap input[data-number="1"] { font-variant-numeric: tabular-nums; }
.site-footer { background: transparent; }
@media (max-width: 640px) {
  .site-header { position: sticky; }
  .header-inner { min-height: 68px; }
  .hero p { max-width: 100%; }
}
