/*
 * Design tokens lifted from lease-e.nl: the theme's primary-1 through
 * primary-5. Flat surfaces, hard offset shadows, no gradients, no rounding.
 * The numbers carry the screen.
 */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #0b2621;
  --lime: #acff86;
  --wash: #eaffe0;
  --orange: #ed4800;
  --line: #cccccc;
  --paper: #ffffff;

  --ui: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --gap: 24px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/*
 * The browser's own [hidden] rule is display:none, but any author rule that
 * sets display wins over it. Several elements here are flex containers that
 * are toggled with the hidden attribute, so without this they never actually
 * disappear. Keep this above the component styles.
 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 18px 32px;
  border-bottom: 1px solid var(--ink);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 20;
}

.brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand span {
  font-weight: 400;
  color: #4d6660;
}

.views {
  display: flex;
  gap: -1px;
  margin-left: 8px;
}

.views button {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 8px 18px;
  cursor: pointer;
  font-weight: 500;
  margin-right: -1px;
}

.views button[aria-selected='true'] {
  background: var(--ink);
  color: var(--paper);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ------------------------------------------------------------ global bar */

main {
  padding: 28px 32px 96px;
  max-width: 1560px;
  margin: 0 auto;
}

.globals {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 28px;
  padding-bottom: 22px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label,
.legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #4d6660;
  font-weight: 600;
}

select,
input[type='number'],
input[type='text'] {
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 8px 10px;
  min-width: 150px;
}

select:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 1px;
}

.segmented {
  display: flex;
}

.segmented button {
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 8px 16px;
  cursor: pointer;
  margin-right: -1px;
  font-weight: 500;
  white-space: nowrap;
}

.segmented button[aria-pressed='true'] {
  background: var(--lime);
}

/* ----------------------------------------------------------- config grid */

.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  align-items: start;
}

/* One vehicle: a single generous panel, left-aligned rather than stretched.
   Centring it leaves a wide empty gutter that reads as a missing panel. */
.columns.single {
  grid-template-columns: minmax(0, 780px);
  justify-content: start;
}

@media (max-width: 1080px) {
  .columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.add-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.add-row .hint {
  font-size: 13px;
  color: #4d6660;
}

.columns:not(.single) + .add-row {
  display: none;
}

.panel-close {
  margin-left: auto;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 6px 11px;
  cursor: pointer;
  font-size: 12.5px;
}

.panel-close:hover {
  background: var(--ink);
  color: var(--paper);
}

.config-product {
  margin-bottom: 18px;
}

.segmented.small button {
  padding: 6px 13px;
  font-size: 13px;
}

/* --------------------------------------------------------------- sync */

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
}

.toggle .toggle-box {
  width: 13px;
  height: 13px;
  border: 1px solid var(--ink);
  background: var(--paper);
}

.toggle[aria-pressed='true'] {
  background: var(--wash);
}

.toggle[aria-pressed='true'] .toggle-box {
  background: var(--lime);
}

/* Subtle marker for conditions that differ between the two panels. */
.diff {
  font-style: normal;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--orange);
  border: 1px solid var(--orange);
  padding: 1px 5px;
  margin-left: 7px;
  vertical-align: 1px;
}

.chip.differs {
  border-color: var(--orange);
  box-shadow: inset 0 -3px 0 var(--orange);
}

.config {
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  background: var(--paper);
  padding: 24px;
}

.config-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.slot-tag {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--ink);
  padding: 2px 7px;
  font-weight: 500;
}

.config-head select {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.vehicle-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: #4d6660;
}

.vehicle-facts b {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink);
}

/* --------------------------------------------------------------- the sum */

.hero {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-amount {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(46px, 5.2vw, 72px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
}

.hero-unit {
  font-size: 14px;
  color: #4d6660;
}

.hero.recalc .hero-amount {
  animation: settle 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes settle {
  0% {
    opacity: 0.35;
    transform: translateY(-3px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

.hero-sub {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: #4d6660;
}

.hero-sub b {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink);
}

/* --------------------------------------------------------------- sliders */

.sliders {
  padding: 20px 0;
  display: grid;
  gap: 18px;
}

.slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 12px;
}

.slider-row .legend {
  grid-column: 1;
}

.slider-value {
  grid-column: 2;
  grid-row: 1;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
}

.slider-row input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  margin: 4px 0 0;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--ink);
}

input[type='range']::-moz-range-track {
  height: 3px;
  background: var(--ink);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 22px;
  margin-top: -10px;
  background: var(--lime);
  border: 1px solid var(--ink);
}

input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 22px;
  border-radius: 0;
  background: var(--lime);
  border: 1px solid var(--ink);
}

/* ------------------------------------------------------------ components */

.strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 0 20px;
  border-top: 1px solid var(--line);
}

.chip {
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 7px 12px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-weight: 500;
}

.chip[aria-pressed='true'] {
  background: var(--lime);
}

.chip[data-fixed='true'] {
  background: var(--ink);
  color: var(--paper);
  cursor: help;
}

/* Toelichting bij een component. Eén element, tegen het scherm geklemd. */
.tip {
  position: absolute;
  z-index: 60;
  width: min(320px, calc(100vw - 24px));
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 5px 5px 0 var(--lime);
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  pointer-events: none;
}

.chip .chip-amount {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 400;
}

/* --------------------------------------------------------------- potjes */

details.potjes {
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

details.potjes > summary {
  cursor: pointer;
  padding: 12px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: #4d6660;
  list-style: none;
}

details.potjes > summary::-webkit-details-marker {
  display: none;
}

details.potjes > summary::before {
  content: '+ ';
  font-family: var(--mono);
}

details.potjes[open] > summary::before {
  content: '- ';
}

table.pots {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.pots th {
  text-align: right;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: #4d6660;
  padding: 0 0 10px;
  font-weight: 600;
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}

table.pots th:first-child {
  text-align: left;
}

/* --- componentregel: naam links, bedragen rechts, geen scheidslijn ------- */

table.pots tr.line td {
  padding: 13px 0 4px 22px;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  border: none;
}

table.pots tr.line td:first-child {
  text-align: left;
  padding-left: 0;
  font-family: var(--ui);
  font-weight: 500;
  font-size: 13.5px;
}

table.pots th + th {
  padding-left: 22px;
}

/* De uitkomst is waar het oog naartoe moet. */
table.pots tr.line td:last-child {
  font-weight: 600;
}

/* Regels zonder formule eronder sluiten zelf af. */
table.pots tr.line.solo td {
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

table.pots tr.off td {
  color: #9aa8a5;
  font-weight: 400;
}

/* --- formule: hoort bij de regel erboven, dus duidelijk ondergeschikt ---- */

table.pots tr.formula td {
  padding: 0 0 13px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid var(--lime);
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.55;
  color: #7c908b;
  font-weight: 400;
}

/* --- totalen: eigen blok, weg van de componenten ------------------------ */

table.pots tr.sum td {
  background: var(--wash);
  border: none;
  padding: 11px 0;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

table.pots tr.sum td:first-child {
  text-align: left;
  font-family: var(--ui);
  padding-left: 12px;
}

table.pots tr.sum td:last-child {
  padding-right: 12px;
}

/* Alleen de eerste totaalregel; :first-of-type zou de eerste <tr> van de hele
   tabel pakken, want dat kijkt naar het element en niet naar de klasse. */
table.pots tr.sum:not(.vat):not(.grand) td {
  border-top: 2px solid var(--ink);
}

table.pots tr.sum.vat td {
  font-weight: 400;
  color: #4d6660;
  padding-top: 0;
  padding-bottom: 6px;
}

table.pots tr.sum.grand td {
  border-top: 1px solid var(--ink);
  padding-top: 10px;
  padding-bottom: 13px;
  font-size: 15px;
}

/* --- eenmalige posten: nadrukkelijk buiten de maandstapel ---------------- */

table.pots tr.apart td {
  border: none;
  padding: 20px 0 6px;
  text-align: left;
  font-family: var(--ui);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-weight: 600;
  color: #4d6660;
}

table.pots tr.once td {
  border-bottom: none;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

/* ------------------------------------------------------------------- FL */

.fl-fields {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.fl-fields input {
  min-width: 120px;
}

.schedule-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
}

table.schedule {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

table.schedule th {
  position: sticky;
  top: 0;
  background: var(--wash);
  text-align: right;
  padding: 7px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--ink);
  font-family: var(--ui);
  font-weight: 600;
}

table.schedule td {
  text-align: right;
  padding: 5px 10px;
  border-bottom: 1px solid #eef1f0;
}

table.schedule tbody tr:nth-child(even) {
  background: #fafcfa;
}

/* ------------------------------------------------------------ the stamp */

.stamp {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.stamp button {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #4d6660;
  background: none;
  border: none;
  border-bottom: 1px dotted #9aa8a5;
  padding: 0 0 1px;
  cursor: pointer;
  text-align: left;
}

.stamp button:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* --------------------------------------------------------------- compare */

.compare {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 34px 0 0;
  padding: 18px;
  background: var(--wash);
  border: 1px solid var(--ink);
  font-size: 14px;
}

.compare .delta {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
}

.delta.up {
  color: var(--orange);
}

/* ---------------------------------------------------------------- action */

.actionbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--ink);
}

.btn {
  border: 1px solid var(--ink);
  background: var(--lime);
  box-shadow: var(--shadow-sm);
  padding: 13px 24px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 90ms ease,
    box-shadow 90ms ease;
}

.btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}

.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn:disabled {
  background: var(--line);
  box-shadow: none;
  cursor: progress;
}

.btn.secondary {
  background: var(--paper);
}

.record-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.record-links:empty {
  display: none;
}

.record-link {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  font-family: var(--mono);
  font-size: 13px;
}

.record-link a {
  color: var(--lime);
}

.record-link small {
  color: #9fb5af;
  font-size: 11px;
}

.callout {
  border: 1px solid var(--orange);
  border-left-width: 4px;
  background: #fff5f0;
  padding: 13px 17px;
  margin-top: 18px;
  font-size: 13.5px;
  max-width: 76ch;
}

.api-badge {
  cursor: pointer;
  background: var(--paper);
  font-family: var(--mono);
}

.api-badge:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.api-badge.pulse {
  animation: pulse 340ms ease;
}

@keyframes pulse {
  0% { background: var(--lime); }
  100% { background: var(--paper); }
}

@media (prefers-reduced-motion: reduce) {
  .api-badge.pulse { animation: none; }
  .hero.recalc .hero-amount { animation: none; }
}

/* -------------------------------------------------------------- mutation */

.mutation-open {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.mutation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

@media (max-width: 1080px) {
  .mutation-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.panel {
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel.was {
  box-shadow: none;
  background: #fafcfa;
}

.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #4d6660;
  margin-bottom: 14px;
}

.timeline {
  margin: 22px 0 6px;
}

.timeline-bar {
  display: flex;
  height: 34px;
  border: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 11px;
}

.timeline-past {
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--ink);
  white-space: nowrap;
  overflow: hidden;
}

.timeline-future {
  background: var(--lime);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
}

.settlement {
  border: 1px solid var(--ink);
  background: var(--wash);
  padding: 18px;
  margin-top: 22px;
}

.settlement-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  font-size: 13px;
}

.settlement-row b {
  font-family: var(--mono);
  font-weight: 500;
}

.settlement-row.total {
  border-top: 1px solid var(--ink);
  margin-top: 8px;
  padding-top: 10px;
  font-weight: 600;
}

.settlement-row.total b {
  font-size: 18px;
  font-weight: 600;
}

.empty {
  color: #4d6660;
  padding: 40px 0;
  font-size: 14px;
}

/* ---------------------------------------------------------------- dialog */

dialog {
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
  max-width: min(900px, 92vw);
  width: 900px;
}

dialog::backdrop {
  background: rgba(11, 38, 33, 0.4);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--ink);
}

.dialog-head h3 {
  font-size: 15px;
}

.dialog-body {
  padding: 22px;
  max-height: 66vh;
  overflow: auto;
}

.dialog-body h4 {
  margin: 0 0 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #4d6660;
}

.dialog-body h4 + pre {
  margin-top: 0;
}

.dialog-body pre {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  background: #fafcfa;
  border: 1px solid var(--line);
  padding: 14px;
  overflow: auto;
  margin: 0 0 22px;
  white-space: pre-wrap;
  word-break: break-word;
}

.note {
  border-left: 3px solid var(--lime);
  padding: 2px 0 2px 12px;
  margin: 0 0 20px;
  font-size: 12.5px;
  color: #4d6660;
}

.close-x {
  border: 1px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
  padding: 5px 11px;
  font-family: var(--mono);
}

/* ----------------------------------------------------------------- error */

.error {
  border: 1px solid var(--orange);
  border-left-width: 4px;
  background: #fff5f0;
  color: var(--ink);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 13px;
}

.error:empty {
  display: none;
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--line);
  padding: 4px 9px;
  color: #4d6660;
  white-space: nowrap;
}
