:root {
  --surface: #f8f9fc;
  --surface-low: #f1f4f8;
  --surface-card: #ffffff;
  --surface-high: #e2e9ef;
  --text: #2b3439;
  --text-muted: #576066;
  --accent: #005db5;
  --accent-dim: #0052a0;
  --accent-soft: #d6e3ff;
  --warning: #8a5400;
  --error: #9f403d;
  --outline: #aab3ba;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--surface);
}

h1, h2, h3 { font-family: "Manrope", "Inter", sans-serif; }

.page {
  max-width: 1360px;
  margin: 1.2rem auto;
  padding: 0 1.2rem 2.2rem;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
  background: rgba(255,255,255,.86);
  border-radius: 14px;
  padding: .9rem 1rem;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgba(43,52,57,.06);
}

.brand-lockup { display: flex; align-items: center; gap: .8rem; }

.brand-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(120deg,var(--accent),var(--accent-dim));
  color: #f6f7ff; display: inline-flex; align-items: center; justify-content: center;
}

.brand-icon .material-symbols-outlined { font-size: 22px; }

h1 { margin: 0; font-size: 1.35rem; color: var(--accent); }

.kicker {
  margin: .08rem 0 0;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .62rem;
  font-weight: 700;
  color: var(--text-muted);
}

.surface-card {
  background: var(--surface-card);
  border: 0;
  border-radius: 14px;
  padding: 1.05rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 28px rgba(43,52,57,.05);
}

.input-card h2 { margin-top: 0; }

.vehicle-form { display: flex; flex-direction: column; gap: .85rem; }

.vehicle-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.input-group {
  background: var(--surface-card);
  border-radius: 12px;
  padding: .95rem;
  border: 1px solid rgba(170,179,186,.16);
}

.input-group h3 {
  margin: 0 0 .45rem;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .38rem;
}

.input-group h3::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
}

.vehicle-panel { grid-column: span 5; }
.range-panel { grid-column: span 4; }
.specs-panel { grid-column: span 3; }

.input-stack {
  display: flex;
  flex-direction: column;
  gap: .72rem;
}

.split-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .72rem;
}

.input-grid { display: grid; gap: .72rem; }
.input-grid-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.input-grid-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }

.field-block {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.field-label {
  margin-left: .1rem;
  font-size: .64rem;
  font-weight: 700;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: .08em;
}

input, select, button {
  padding: .55rem;
  border-radius: 8px;
  border: 1px solid transparent;
}

input, select { background: var(--surface-low); color: var(--text); }
input::placeholder { color: var(--outline); }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,93,181,.15);
}

.field-control {
  width: 100%;
  min-height: 42px;
  font-size: .92rem;
}

.field-shell,
.range-shell {
  display: flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  background: var(--surface-low);
  border: 1px solid transparent;
}

.field-shell:focus-within,
.range-shell:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,93,181,.15);
}

.currency-shell {
  gap: .15rem;
  padding-left: .7rem;
}

.field-prefix {
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-muted);
}

.field-control-plain {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.field-control-plain:focus {
  border-color: transparent;
  box-shadow: none;
}

.range-shell {
  gap: .55rem;
  padding: 0 .35rem;
}

.year-shell {
  padding-right: .25rem;
  gap: .28rem;
}

.year-operator {
  position: relative;
  flex: 0 0 auto;
}

.year-operator-trigger {
  min-width: 46px;
  height: 34px;
  padding: 0 .45rem;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(170,179,186,.2);
}

.year-operator-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 184px;
  display: none;
  flex-direction: column;
  gap: .2rem;
  padding: .35rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(170,179,186,.28);
  box-shadow: 0 12px 28px rgba(43,52,57,.12);
  z-index: 20;
}

.year-operator.is-open .year-operator-menu {
  display: flex;
}

.year-operator-option {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: .52rem .6rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .55rem;
  text-align: left;
}

.year-operator-option strong {
  min-width: 14px;
  font-size: 1rem;
  font-weight: 800;
}

.year-operator-option span {
  font-size: .84rem;
  color: var(--text-muted);
}

.year-operator-option:hover,
.year-operator-option.is-selected {
  background: var(--accent-soft);
}

.year-operator-option.is-selected span {
  color: var(--accent-dim);
}

.range-input { text-align: center; }

.range-separator {
  color: var(--outline);
  font-weight: 600;
}

.primary-btn {
  background: linear-gradient(120deg,var(--accent),var(--accent-dim));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.action-cluster {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: .55rem;
}

.inline-warning {
  position: relative;
  color: #bf6a00;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.inline-warning::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  max-width: 360px;
  padding: .45rem .55rem;
  border-radius: 6px;
  border: 1px solid #d9b06f;
  background: #fff7e6;
  color: #7a4a00;
  font-size: .8rem;
  line-height: 1.35;
  box-shadow: 0 3px 12px rgba(0,0,0,.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity .15s ease, transform .15s ease;
  z-index: 15;
}

.inline-warning:hover::after,
.inline-warning:focus-visible::after { opacity: 1; transform: translateY(0); }

.icon-actions { display: inline-flex; gap: .5rem; }
.icon-actions { margin-left: auto; }

.icon-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(120deg,var(--accent),var(--accent-dim));
  color: #fff;
  cursor: pointer;
}

.icon-btn:hover { filter: brightness(.95); }

.status-card.warning { background: #fff7e6; }
.status-card.error { background: #fff1f0; }

.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.bento { margin-bottom: 0; }
.bento-scenario { grid-column: span 12; }
.bento-market { grid-column: span 12; }
.bento-charts { grid-column: span 12; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

@media (min-width: 1100px) {
  .bento-scenario { grid-column: span 4; }
  .bento-market { grid-column: span 8; }
}

.scenario-main {
  padding-bottom: .8rem;
  border-bottom: 1px solid rgba(170,179,186,.24);
  margin-bottom: .7rem;
}

.scenario-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .25rem;
}

.scenario-head h2 {
  margin: 0;
}

.scenario-alert {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff1f0;
  color: var(--error);
  cursor: pointer;
}

.scenario-alert .material-symbols-outlined {
  font-size: 18px;
}

.metric-label {
  margin: 0;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.metric-big {
  margin: .12rem 0 .42rem;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.metric-big-muted {
  color: var(--text-muted);
}

.chip {
  display: inline-block;
  margin: 0;
  padding: .18rem .5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dim);
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chip-muted {
  background: var(--surface-low);
  color: var(--text-muted);
}

.scenario-empty-note {
  margin: .8rem 0 0;
  color: var(--text-muted);
  font-size: .88rem;
  line-height: 1.4;
}

.scenario-lines { display: grid; gap: .45rem; }

.scenario-lines div {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  background: var(--surface-low);
  border-radius: 9px;
  padding: .45rem .55rem;
}

.scenario-lines span { color: var(--text-muted); font-size: .86rem; }
.scenario-lines strong { font-variant-numeric: tabular-nums; font-size: .92rem; }

.scenario-lines-muted strong {
  color: var(--outline);
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2.35rem;
}

@media (min-width: 900px) {
  .market-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: .32rem;
  min-width: 0;
}

.metric-item-primary strong {
  color: var(--accent-dim);
}

.metric-head {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.metric-head span:first-child {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-item strong {
  font-size: 1.56rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric-info {
  color: var(--outline);
}

.metric-info .material-symbols-outlined {
  font-size: 16px;
}

.metric-item:nth-child(3) strong,
.metric-item:nth-child(4) strong {
  font-size: 1.34rem;
  font-weight: 700;
}

.price-pair {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0;
}

.price-inline {
  white-space: nowrap;
}

.price-separator {
  padding: 0 .12rem;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(248, 249, 252, 0.84);
  backdrop-filter: blur(4px);
  z-index: 100;
}

.loading-overlay.is-visible {
  display: flex;
}

.loading-stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.loader {
  position: relative;
  width: 48px;
  height: 48px;
  color: var(--accent);
}

.loader-ring,
.loader-double-ring {
  border-radius: 999px;
  border: 4px solid rgba(0,93,181,.16);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.loader-double-ring {
  border-width: 3px;
}

.loader-double-ring::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 999px;
  border: 3px solid rgba(0,93,181,.12);
  border-bottom-color: var(--accent-dim);
  animation: spinReverse .9s linear infinite;
}

.loader-pulse-dots,
.loader-bars,
.loader-eq,
.loader-rotator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.loader-pulse-dots span,
.loader-rotator span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.loader-pulse-dots span:nth-child(2),
.loader-rotator span:nth-child(2) { animation-delay: .15s; }
.loader-pulse-dots span:nth-child(3),
.loader-rotator span:nth-child(3) { animation-delay: .3s; }

.loader-bars span,
.loader-eq span {
  width: 6px;
  border-radius: 999px;
  background: var(--accent);
  animation: bars 1s ease-in-out infinite;
}

.loader-bars span { height: 30px; }
.loader-eq span { height: 24px; }
.loader-bars span:nth-child(2),
.loader-eq span:nth-child(2) { animation-delay: .1s; }
.loader-bars span:nth-child(3),
.loader-eq span:nth-child(3) { animation-delay: .2s; }
.loader-bars span:nth-child(4),
.loader-eq span:nth-child(4) { animation-delay: .3s; }
.loader-eq span:nth-child(5) { animation-delay: .4s; }

.loader-orbit {
  border-radius: 999px;
  border: 2px solid rgba(0,93,181,.18);
}

.loader-orbit span,
.loader-radar span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  top: -1px;
  left: 19px;
  transform-origin: 5px 25px;
  animation: spin 1.15s linear infinite;
}

.loader-scan {
  overflow: hidden;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(0,93,181,.04), rgba(0,93,181,.12)),
    linear-gradient(90deg, rgba(0,93,181,.08) 1px, transparent 1px),
    linear-gradient(rgba(0,93,181,.08) 1px, transparent 1px);
  background-size: 100% 100%, 12px 12px, 12px 12px;
}

.loader-scan::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 1.2s ease-in-out infinite;
}

.loader-radar {
  border-radius: 999px;
  background:
    radial-gradient(circle at center, rgba(0,93,181,.12) 0 10%, transparent 10% 100%),
    conic-gradient(from 180deg, rgba(0,93,181,.02), rgba(0,93,181,.28), rgba(0,93,181,.02));
  overflow: hidden;
}

.loader-radar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 2px solid rgba(0,93,181,.16);
}

.loader-ripples span {
  position: absolute;
  inset: 10px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: ripple 1.6s ease-out infinite;
}

.loader-ripples span:nth-child(2) { animation-delay: .8s; }

.loader-ripples-lg {
  width: 132px;
  height: 132px;
}

.loader-ripples-lg span {
  inset: 20px;
  border-width: 3px;
}

.loader-rotator span {
  width: 9px;
  height: 9px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes spinReverse {
  to { transform: rotate(-360deg); }
}

@keyframes pulse {
  0%, 80%, 100% { transform: scale(.55); opacity: .45; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes bars {
  0%, 100% { transform: scaleY(.45); opacity: .55; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes scan {
  0% { top: 6px; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: calc(100% - 10px); opacity: 0; }
}

@keyframes ripple {
  0% { transform: scale(.35); opacity: .9; }
  100% { transform: scale(1.25); opacity: 0; }
}

.insight-list {
  margin: .4rem 0 .8rem;
  padding-left: 1.1rem;
  line-height: 1.4;
}

.dossier-shell {
  position: relative;
  margin-top: 1rem;
}

.dossier-tabs {
  display: flex;
  gap: .28rem;
  align-items: flex-end;
  margin-left: 1rem;
  margin-bottom: -1px;
  position: relative;
  z-index: 4;
}

.dossier-tab {
  border: 0;
  padding: .78rem 1.15rem;
  min-width: 180px;
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface-high);
  clip-path: polygon(0 100%, 10% 0, 90% 0, 100% 100%);
  transition: background .2s ease, color .2s ease, transform .2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
}

.dossier-tab .material-symbols-outlined {
  font-size: 18px;
}

.dossier-tab.is-active {
  background: var(--surface-card);
  color: var(--accent);
  transform: translateY(1px);
}

.dossier-stack {
  display: grid;
}

.results-panel {
  grid-area: 1 / 1;
}

.dossier-panel {
  background: var(--surface-card);
  border-radius: 14px;
  padding: 1.05rem;
  border: 1px solid rgba(170,179,186,.2);
  box-shadow: 0 10px 28px rgba(43,52,57,.05);
}

/* Only the active tab contributes to layout; otherwise the hidden Marktaanbod list stretches the page. */
.dossier-stack .results-panel:not(.is-active) {
  display: none;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .85rem;
}

@media (min-width: 1100px) {
  .charts-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.chart-card {
  border: 0;
  border-radius: 10px;
  background: var(--surface-low);
  padding: .65rem;
}

.chart-card h3 {
  margin: 0 0 .45rem;
  font-size: .95rem;
}

.chart-note {
  margin: 0 0 .45rem;
  font-size: .84rem;
  color: var(--text-muted);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 300px;
}

.chart-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 8px;
}

.listings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .75rem;
}

.listing {
  border: 0;
  border-radius: 10px;
  padding: .75rem;
  background: var(--surface-low);
}

.listing h3 { margin-top: 0; font-size: 1rem; }

@media (max-width: 900px) {
  .vehicle-panel,
  .range-panel,
  .specs-panel { grid-column: span 12; }

  .split-fields,
  .input-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .page { margin-top: 1rem; padding: 0 .8rem 1.8rem; }

  .vehicle-layout,
  .input-grid-2,
  .input-grid-3,
  .split-fields,
  .market-grid,
  .scenario-lines div {
    grid-template-columns: 1fr;
    display: grid;
  }

  .form-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .icon-actions {
    margin-left: 0;
  }

  .dossier-tabs {
    margin-left: 0;
    gap: .18rem;
  }

  .dossier-tab {
    min-width: 0;
    flex: 1;
    padding: .72rem .5rem;
    font-size: .68rem;
    text-align: center;
  }

  .range-shell {
    flex-direction: column;
    align-items: stretch;
    padding: .35rem;
  }

  .year-shell {
    padding-right: .35rem;
  }

  .year-operator-menu {
    left: auto;
    right: 0;
    min-width: 180px;
  }

  .range-separator {
    text-align: center;
    line-height: 1;
  }

  .chart-wrap { height: 260px; }
}
