/* LungoLedger: calm, businesslike theme. White cards on a cool light surface, navy text, one
   blue accent, hairline borders and soft shadows. Text and buttons keep WCAG AA contrast. */
:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --fg: #14213d;            /* body text */
  --text: #3c4a64;          /* running text */
  --muted: #5b6880;         /* secondary text, >= 5:1 on --bg */
  /* Blue, not violet: next to the red of errors violet read as an alarm (Jeroen 30-11-2026).
     Red is only for errors and things that are late. */
  --accent: #1f63b6;        /* white text on it: 6:1 */
  --accent-dark: #164a8a;
  --accent-soft: #e8f1fc;
  --ok: #13693b; --ok-soft: #e5f6ec;
  --err: #b3192f; --err-soft: #fdecef;
  --warn: #7a4b00; --warn-soft: #fff5df; --warn-line: #e0a526;
  --line: #e3e8ef;
  --field: #8592a8;         /* field border, >= 3:1 on white */
  --shadow-sm: 0 1px 2px rgba(20, 33, 61, .08);
  --shadow: 0 1px 3px rgba(20, 33, 61, .07), 0 6px 18px rgba(20, 33, 61, .05);
  --shadow-lg: 0 18px 50px rgba(20, 33, 61, .16), 0 4px 14px rgba(20, 33, 61, .08);
  --radius: 10px; --radius-sm: 6px;
}
html { scroll-padding-top: 6rem; }
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { color: var(--fg); line-height: 1.25; }
h1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; margin: .5rem 0 1.25rem; }
h2 { font-size: 1.2rem; font-weight: 650; letter-spacing: -.01em; }
strong { color: var(--fg); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* --- Top bar ----------------------------------------------------------------------- */
.topbar { display: flex; gap: 1.25rem; align-items: center; padding: .75rem 1.5rem; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar a { color: var(--text); text-decoration: none; }
.topbar .brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 750;
  color: var(--fg); font-size: 1.15rem; letter-spacing: -.02em; }
.brand svg { width: 1.5rem; height: 1.5rem; }
.mainnav { display: flex; gap: .1rem; flex: 1; flex-wrap: wrap; }
.mainnav a, .submenu summary { padding: .35rem .65rem; border-radius: var(--radius-sm);
  font-size: .92rem; font-weight: 500; transition: background-color .15s, color .15s; }
.mainnav a:hover, .submenu summary:hover { background: var(--bg); color: var(--fg); }
.mainnav a[aria-current="page"], .submenu summary[aria-current="page"], .submenu[open] summary {
  background: var(--accent-soft); color: var(--accent-dark); }
.submenu { position: relative; }
.submenu summary { list-style: none; cursor: pointer; }
.submenu summary::-webkit-details-marker { display: none; }
.submenu summary::after { content: ""; display: inline-block; width: .4em; height: .4em;
  margin: 0 0 .18em .5em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.submenu-items { position: absolute; right: 0; top: calc(100% + .5rem); min-width: 12rem; z-index: 20;
  display: flex; flex-direction: column; gap: .1rem; padding: .5rem; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.logout { margin: 0; }
button.link, button.link-dark { background: none; border: 0; box-shadow: none; padding: 0;
  color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
button.link-dark { font-weight: 600; }
button.link:hover, button.link-dark:hover { background: none; color: var(--accent-dark); }
.topbar button.link { text-decoration: none; padding: .35rem .65rem; color: var(--text);
  font-size: .92rem; font-weight: 500; }
.topbar button.link:hover { color: var(--fg); background: var(--bg); }

/* --- Surfaces ---------------------------------------------------------------------- */
.content { max-width: 1120px; margin: 2rem auto 4rem; padding: 0 1.5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem 1.75rem; margin-bottom: 1.5rem; }
.card > :first-child { margin-top: 0; }
.narrow { max-width: 440px; margin: 4rem auto; }
/* Before logging in: a slanted band of colour behind the form. */
.entry { min-height: 100vh; }
.entry::before { content: ""; position: absolute; z-index: -1; inset: 0 0 auto; height: 24rem;
  background: linear-gradient(115deg, #14213d 0%, #1f4f99 48%, #2c86b8 100%);
  clip-path: polygon(0 0, 100% 0, 100% 62%, 0 100%); }
.entry .topbar { background: none; border: 0; position: static; padding: 1.25rem 2rem; }
.entry .topbar .brand { color: #fff; }
.entry .topbar :focus-visible { outline-color: #fff; }
.entry .card.narrow { padding: 2.25rem 2.5rem; border: 0; box-shadow: var(--shadow-lg); }

/* --- Dashboard --------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem;
  margin-bottom: 1.5rem; }
.stats .card { margin: 0; }
.stats h2 { font-size: .9rem; font-weight: 600; color: var(--muted); margin: 0 0 .5rem; letter-spacing: 0; }
.stats p { margin: 0 0 .4rem; }
.stats .amount { font-size: 1.5rem; letter-spacing: -.02em; white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.stats + .actions { margin: 0 0 2rem; }
ul.todo, ul.plain { list-style: none; padding: 0; margin: 0; }
ul.todo li, ul.plain li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
ul.todo li:last-child, ul.plain li:last-child { border-bottom: 0; padding-bottom: 0; }

/* --- Forms ------------------------------------------------------------------------- */
label { display: block; margin: .75rem 0; font-weight: 600; font-size: .95rem; color: var(--fg); }
input, select, textarea { display: block; width: 100%; padding: .55rem .75rem; font: inherit;
  font-size: 1rem; font-weight: normal; color: var(--fg); background: var(--card);
  border: 1px solid var(--field); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent);
  outline: 2px solid var(--accent); outline-offset: 0; }
label > input, label > select, label > textarea { margin-top: .35rem; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox], input[type=radio] { display: inline; width: auto; box-shadow: none;
  accent-color: var(--accent); transform: scale(1.15); margin-right: .35rem; }
input[type=file] { border: 0; box-shadow: none; padding: .3rem 0; }
select { appearance: auto; }

/* --- Buttons ----------------------------------------------------------------------- */
button, .button { display: inline-block; padding: .5rem 1.05rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--card); box-shadow: var(--shadow-sm);
  cursor: pointer; font: inherit; font-size: .95rem; font-weight: 600; color: var(--fg);
  text-decoration: none; transition: background-color .15s, border-color .15s, box-shadow .15s; }
button:hover, .button:hover { background: var(--bg); border-color: var(--field); color: var(--fg); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--accent-dark);
  border-color: var(--accent-dark); color: #fff; box-shadow: var(--shadow); }
button.danger, .button.danger { background: var(--err); border-color: var(--err); color: #fff; }
button.danger:hover, .button.danger:hover { background: #8f1325; border-color: #8f1325; color: #fff; }
button:disabled, button:disabled:hover { opacity: .55; cursor: not-allowed; box-shadow: none; }
.entry form > button.primary { width: 100%; margin-top: .75rem; padding: .7rem; }

/* --- Feedback ---------------------------------------------------------------------- */
.error, .errorlist, .error-text { color: var(--err); }
.errorlist { padding-left: 1rem; margin: .3rem 0; font-weight: 600; }
.muted, .helptext { color: var(--muted); font-size: .9rem; font-weight: normal; }
.messages { list-style: none; padding: 0; }
.msg { padding: .8rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: .75rem;
  background: var(--accent-soft); color: var(--fg); border-left: 4px solid var(--accent); }
.msg-success { background: var(--ok-soft); color: var(--ok); border-left-color: var(--ok); }
.msg-error { background: var(--err-soft); color: var(--err); border-left-color: var(--err); }
.msg-warning { background: var(--warn-soft); color: var(--warn); border-left-color: var(--warn-line); }
.msg strong, .error strong { color: inherit; }

/* --- Tables ------------------------------------------------------------------------ */
table { width: 100%; border-collapse: collapse; background: transparent; font-size: .95rem; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line);
  vertical-align: top; }
th { color: var(--fg); }
thead th { color: var(--muted); font-size: .85rem; font-weight: 600; }
tbody tr:hover { background: #f9fafd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.content > table { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  outline: 1px solid var(--line); overflow: hidden; margin-bottom: 1.5rem; }
.content > table tbody tr:last-child td { border-bottom: 0; }
/* Trips: every other day a slightly different background, so one day's trips read as a group. */
table.trips tr.day-band { background: #eff3f8; }
table.trips tbody tr:hover { background: #eaf0f7; }

/* --- Help / explanations ----------------------------------------------------------- */
.help { background: var(--accent-soft); border: 1px solid #cfe0f5; border-radius: var(--radius);
  padding: 1.1rem 1.4rem; margin-bottom: 1.5rem; }
.help h2 { margin-top: 0; font-size: 1.05rem; }
.help-link { margin: 0 0 1rem; font-size: .9rem; }
/* Opening and closing: htmx marks the old block (htmx-swapping, 250ms, see hx-swap) and the new
   one (htmx-added, briefly); the transition does the rest. Off with prefers-reduced-motion. */
.help, .help-link { transition: opacity .25s ease, transform .25s ease; }
.help.htmx-swapping, .help-link.htmx-swapping,
.help.htmx-added, .help-link.htmx-added { opacity: 0; transform: translateY(-.4rem); }
.flow { color: var(--muted); font-style: italic; font-size: .9rem; }
.preview { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .9rem 1.1rem; margin: 1rem 0; }
.preview h2 { font-size: 1rem; margin: 0 0 .5rem; }
.flow-list { margin: 0 0 .5rem; color: var(--text); }

/* --- Badges ------------------------------------------------------------------------ */
.badge { display: inline-block; padding: .05rem .55rem; border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600; background: #edf1f6; color: #4a5770; }
.badge-posted { background: var(--ok-soft); color: var(--ok); }
.badge-draft { background: var(--warn-soft); color: var(--warn); }
.badge-locked { background: var(--accent-soft); color: var(--accent-dark); }  /* done, not wrong */
.badge-late { background: var(--err-soft); color: var(--err); }

/* --- Layout helpers ---------------------------------------------------------------- */
.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; align-items: center; }
.glossary dt { font-weight: 700; margin-top: 1rem; color: var(--fg); }
.glossary dd { margin: .2rem 0 0 0; }
.wizard-steps { list-style: none; display: flex; gap: 1.25rem; padding: 0; flex-wrap: wrap;
  color: var(--muted); font-size: .9rem; }
.wizard-steps li.current { color: var(--accent-dark); font-weight: 700; }
.field { margin: 1rem 0; }
.field label { margin: 0 0 .3rem; }
.field ul { list-style: none; padding: 0; margin: .2rem 0; }
.field ul label { font-weight: normal; display: inline; }
.grid2 { display: grid; grid-template-columns: 1fr 2fr; gap: 1.25rem; }
table.lines input, table.lines select { min-width: 6rem; }
table.lines td.num input { text-align: right; }
.totals { margin: .5rem 0 0; }
.totals-table { width: auto; min-width: 50%; background: transparent; }
.totals-table td, .totals-table th { border: 0; padding: .15rem .6rem; }
dialog { width: min(36rem, calc(100vw - 2rem)); max-height: 90vh; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.5rem 1.75rem; color: var(--text); }
dialog::backdrop { background: rgba(20, 33, 61, .45); }
dialog h2 { margin-top: 0; }
.vat-hint { display: block; text-align: right; min-height: 1.2em; font-size: .85rem; color: var(--muted); }
.hero { font-size: 2.2rem; font-weight: 700; color: var(--fg); letter-spacing: -.02em; margin: .25rem 0; font-variant-numeric: tabular-nums; }
.note { background: var(--bg); border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .9rem; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.figures p { margin: 0; display: flex; flex-direction: column; }
.figures .amount { font-size: 1.4rem; font-weight: 650; color: var(--fg); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1.5rem; margin-top: 1rem; }
.charts h3 { font-size: 1rem; margin: 0 0 .25rem; }
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--field); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .mark:hover .bar, .chart .mark:hover .dot { fill: var(--accent-dark); }
.chart details { font-size: .9rem; }
.report-tabs { display: flex; gap: .5rem; }
.report-tabs a { padding: .35rem .8rem; border-radius: var(--radius-sm); text-decoration: none; font-weight: 500; }
.report-tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); }
.report-form .actions { margin-top: 0; align-items: end; }
.report .total th, .report .total td { font-weight: 650; color: var(--fg); }
.report .grand th, .report .grand td { border-top: 2px solid var(--fg); }
.balance { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.25rem; align-items: start; }
@media (max-width: 700px) {
  .balance { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .content { padding: 0 1rem; }
  .topbar { position: static; justify-content: space-between; gap: .5rem; }
  .mainnav { order: 3; flex: 1 0 100%; }
  .mainnav { position: relative; }
  .submenu { position: static; }
  .submenu-items { left: 0; right: 0; }
  .card, .entry .card.narrow { padding: 1.25rem; }
  .content > table, .card table { display: block; overflow-x: auto; }
}

/* --- VAT return wizard ------------------------------------------------------------- */
.steps { display: flex; gap: .5rem; list-style: none; padding: 0; flex-wrap: wrap; margin: 0 0 1.5rem; }
.steps li a { display: block; padding: .4rem .9rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--line);
  font-size: .92rem; }
.steps li.current a { background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent-dark); font-weight: 700; }
.checks { list-style: none; padding: 0; }
.checks li { padding: .65rem .9rem; margin-bottom: .6rem; border-radius: var(--radius-sm);
  background: var(--bg); }
.checks li.ok { background: var(--ok-soft); color: var(--ok); }
.checks li.error { background: var(--err-soft); border-left: 4px solid var(--err); }
.checks li.msg-warning { background: var(--warn-soft); border-left: 4px solid var(--warn-line); }
tr.total td { font-weight: 700; color: var(--fg); } tr.section th { text-align: left; padding-top: 1rem; }
ul.drill { font-size: .9rem; margin: .3rem 0; }
details summary { cursor: pointer; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1000; }
.celebrate { font-size: 1.3rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  body { background: #fff; }
  .topbar, .actions, .report-tabs, .report-form { display: none; }
  .entry::before { display: none; }
  .card, .help, .msg, .content > table { box-shadow: none; border: 1px solid #ccc; }
}

.nowrap { white-space: nowrap; }

/* Trip wizard (Ritten → Nieuwe rit): form left, map right on wide screens. */
.trip-wizard.with-map { display: grid; grid-template-columns: minmax(0, 30rem) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .trip-wizard.with-map { grid-template-columns: 1fr; } }
.map-col { position: sticky; top: 5rem; }
#route-map { height: 30rem; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.small { font-size: .85rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
fieldset.field { border: 0; padding: 0; margin: 0 0 1rem; }
fieldset.field legend { font-weight: 600; color: var(--fg); padding: 0; margin-bottom: .25rem; }
.calendar { max-width: 24rem; }
.calendar-head { display: grid; grid-template-columns: 2.5rem 1fr 2.5rem; align-items: center; text-align: center; margin-bottom: .25rem; }
.calendar-head button { font-size: 1.4rem; line-height: 1; padding: 0 .5rem; }
.calendar table { width: 100%; border-collapse: separate; border-spacing: 3px; }
.calendar th { font-weight: 500; color: var(--muted); font-size: .85rem; text-align: center; padding: 0; }
.calendar td { padding: 0; text-align: center; }
.calendar .day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 2.6rem; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; }
.calendar .day input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.calendar .day small { font-size: .7rem; color: var(--accent-dark); font-weight: 600; line-height: 1; }
.calendar .day.has-trips { background: var(--accent-soft); }
.calendar .day:hover { border-color: var(--accent); }
.calendar .day:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
  box-shadow: var(--shadow-sm); }
.calendar .day:has(input:checked) small { color: #fff; }
.calendar .day:has(input:checked):hover { background: var(--accent-dark); }
.calendar .day:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.calendar .day.future { color: var(--field); cursor: default; }
.calendar .day.future:hover { background: none; }
.stop label { display: block; }
.stop input { width: 100%; }
table.legs { width: 100%; margin: .5rem 0; }
table.legs input.km { display: inline-block; width: 6rem; text-align: right; }
table.legs label { display: inline; }
table.legs tr.km-check td { padding: .4rem .6rem; color: var(--warn); background: var(--warn-soft);
  border-left: 3px solid var(--warn-line); border-radius: var(--radius-sm); }
.favourite label { font-weight: normal; }
.favourite-name { margin-top: .5rem; }
/* The name only matters once you tick "bewaren bij mijn favorieten". */
.favourite:not(:has(input[name=favourite]:checked)) .favourite-name { display: none; }

/* Address suggestions (trip-wizard.js puts the list under the field you are in). */
#trip-wizard > .card { position: relative; }
.suggestions { position: absolute; z-index: 20; margin: 0; padding: .3rem; list-style: none; max-height: min(18rem, 50vh);
  overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); }
.suggestions .group { padding: .45rem .6rem .2rem; font-size: .75rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); }
.suggestions [role=option] { padding: .45rem .6rem; border-radius: var(--radius-sm); cursor: pointer; line-height: 1.35; }
.suggestions [role=option] strong { margin-right: .35rem; }
.suggestions [role=option] span { color: var(--muted); }
.suggestions [role=option]:hover, .suggestions [role=option].active { background: var(--accent-soft); }
.suggestions [role=option].active strong, .suggestions [role=option].active span { color: var(--accent-dark); }

/* While the route is calculated: a small spinner, and the old km fade. */
.busy { display: flex; align-items: center; gap: .5rem; margin: .25rem 0 0; min-height: 1.5rem;
  font-size: .9rem; color: var(--muted); visibility: hidden; }
.busy.htmx-request { visibility: visible; }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#route { transition: opacity .2s; }
#route.htmx-request { opacity: .45; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } #route { transition: none; } }
/* A return trip only for a journey without extra stops (the server checks it too). */
#trip-wizard:has(#stops > .stop:nth-child(3)) .return-trip { display: none; }
/* Receipts: the receipt beside the purchase form, with the place a value came from */
.with-receipt { display: grid; grid-template-columns: minmax(0, 3fr) minmax(16rem, 2fr); gap: 1rem; align-items: start; }
@media (max-width: 60rem) { .with-receipt { grid-template-columns: 1fr; } }
.receipt-panel { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.receipt-panel h2 { margin-top: 0; }
.receipt-view { position: relative; border: 1px solid var(--border, #d0d7e2); }
.receipt-view img { display: block; width: 100%; height: auto; }
.receipt-mark { position: absolute; border: 2px solid transparent; border-radius: 3px; background: rgba(31, 99, 182, 0.08); pointer-events: none; transition: background .15s, border-color .15s; }
.receipt-mark.active { border-color: #1f63b6; background: rgba(255, 214, 0, 0.35); box-shadow: 0 0 0 3px rgba(31, 99, 182, 0.25); }
.receipt-found { list-style: none; padding: 0; }
.receipt-found li { padding: .2rem .4rem; border-radius: 4px; cursor: default; }
.receipt-found li:hover, .receipt-found li:focus { background: rgba(31, 99, 182, 0.1); outline: none; }
@media (prefers-reduced-motion: reduce) { .receipt-mark { transition: none; } }
