/* Fidge. Every colour, font and radius comes from variables.css.
   No hex value appears in this file. Spacing is in multiples of 4px. */

@import url('variables.css');

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

/* The browser hides [hidden] with display:none, but any author rule setting
   display wins over it — .icon-btn { display: inline-flex } made a button that
   the code had hidden stay clickable, and clicking it produced a 409. This makes
   the attribute mean what it says everywhere. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); }

h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 24px 0;
}

/* The list a <select> drops down is drawn by the browser, not by this
   stylesheet, so `color-scheme` on :root is what decides whether it comes up
   light or dark. That is the actual fix; these rules only put our own palette on
   the parts an author is allowed to touch, and they sit here as element
   selectors so every select in the app is covered rather than one screen's.

   Two things stay the browser's: the row under the pointer or the arrow keys
   uses the system highlight, and the arrow glyph is its own. Both follow
   color-scheme, so both land on the right side of light and dark by themselves.

   The chosen row is deliberately the 20% primary and not the solid one. Firefox
   paints the selected option's own colours onto the closed control, so a white
   on solid blue rule there would leave the closed select unreadable against the
   page. Tinted background plus normal text reads correctly in both places. */
option, optgroup {
  background: var(--color-surface);
  color: var(--color-text);
}

optgroup {
  font-weight: 600;
  color: var(--color-text-muted);
}

option:checked {
  background: var(--color-primary-20);
  color: var(--color-text);
}

/* ── Sidebar (icon rail) ────────────────────────────────────────────── */

.sidebar {
  width: 60px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

/* The colour lives here rather than on the mark, which draws itself in
   currentColor. So the token is named once and the SVG has no colour of its
   own. */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0 16px;
  color: var(--color-primary);
  text-decoration: none;
}

.brand-mark { width: 24px; height: 24px; display: block; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  width: 100%;
}
.sidebar-config-nav {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sidebar-nav a,
.sidebar-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav-btn:hover {
  background: var(--color-primary-20);
  color: var(--color-text);
}

.sidebar-nav a.active {
  background: var(--color-primary-20);
  color: var(--color-text);
}

.sidebar-nav .nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-divider {
  width: 24px;
  height: 1px;
  background: var(--color-border);
  margin: 8px 0;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

.sidebar-user {
  margin-top: auto;
  padding: 12px 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
}

/* Shows the current administration, not the user: which set of books you are
   looking at is the thing worth knowing at a glance. */
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-muted-20);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

/* The same mark, list-sized. */
.id-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  background: var(--color-muted-20);
  color: var(--color-text-muted);
}

/* The page title on administration-scoped pages. Neutral by default; an .id-*
   class below tints the background and sets currentColor, which the border
   picks up. Must stay above the identity colours for the same reason as the badge. */
.administration-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-border-strong);
}

.administration-card .id-badge { width: 40px; height: 40px; font-size: 14px; }
.administration-card h1 { margin: 0; font-size: 24px; color: var(--color-text); overflow-wrap: anywhere; }

/* Identity colours, chosen per administration. Applied to the avatar and to the
   badge in the list, so the two always agree.

   These must stay BELOW .sidebar-avatar and .id-badge. All three are
   single-class selectors, so specificity ties and source order decides: with the
   colours first, the neutral background of the shape wins and every
   administration renders grey. That was a real bug — the sidebar showed the
   colour and the list did not, because the avatar happened to be declared
   earlier. */
.id-blue   { background: var(--color-id-blue-20);   color: var(--color-id-blue); }
.id-teal   { background: var(--color-id-teal-20);   color: var(--color-id-teal); }
.id-green  { background: var(--color-id-green-20);  color: var(--color-id-green); }
.id-amber  { background: var(--color-id-amber-20);  color: var(--color-id-amber); }
.id-purple { background: var(--color-id-purple-20); color: var(--color-id-purple); }
.id-rose   { background: var(--color-id-rose-20);   color: var(--color-id-rose); }

/* Colour picker in the edit modal. */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.swatch.selected { border-color: var(--color-text); }

.sidebar-avatar:hover { opacity: 0.8; }

.sidebar-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 0;
  z-index: 200;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.sidebar-popup.open { display: block; }

.sidebar-popup-header { padding: 8px 16px; }
.sidebar-popup-name { font-size: 14px; font-weight: 500; }
.sidebar-popup-email {
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-popup-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

.sidebar-popup-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.sidebar-popup-item:hover { background: var(--color-hover); color: var(--color-text); }
.sidebar-popup-item.current { color: var(--color-text); }

/* ── Layout ─────────────────────────────────────────────────────────── */

.main { margin-left: 60px; padding: 32px 32px 64px; }
.container { max-width: 1040px; }

.page-head { margin-bottom: 24px; }
.page-head p { margin: 0; color: var(--color-text-muted); }

/* Title on the left, page-level action on the right. A modifier rather than a
   change to .page-head, which elsewhere stacks its heading and subtitle. */
.page-head-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* Square icon-only button for a page-level action. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover:not(:disabled) {
  background: var(--color-hover);
  color: var(--color-text);
}

.icon-btn:disabled { opacity: 0.5; cursor: wait; }

.icon-btn .nav-icon { width: 18px; height: 18px; }

.icon-btn.busy .nav-icon { animation: spin 1s linear infinite; }

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

/* A status line or button that is waiting on the server, such as an OCR run
   that can take most of a minute. The ring says it has not stalled. */
.busy-status::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid var(--color-border-strong);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-head {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.card-head h2 { margin: 0; }
.card-title-with-info { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; }
.card-title-with-info h3 { margin: 0; }
.card-title-with-info .report-info { position: static; }
.report-info {
  position: relative;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
}
.report-info:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 4px; }
.report-info:is(:hover, :focus)::after {
  content: attr(data-info);
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 10;
  width: min(300px, 75vw);
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.card-title-with-info .report-info:is(:hover, :focus)::after {
  left: 0;
  right: auto;
  width: min(300px, calc(100vw - 72px));
}
.card-note { margin: 0 0 16px; color: var(--color-text-muted); font-size: 13px; }
.dossier-search { display: flex; align-items: stretch; gap: 12px; }
.dossier-search input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}
.dossier-search input:focus { outline: none; border-color: var(--color-primary); }
#searchResults:not(:empty) { margin-top: 20px; }
.dossier-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.document-side-overlay[hidden] { display: none; }
.document-side-overlay { position: fixed; inset: 0; z-index: 250; display: flex; justify-content: flex-end; }
.document-side-backdrop { position: absolute; inset: 0; background: var(--color-overlay); }
.document-side-panel {
  position: relative; display: flex; flex-direction: column; gap: 12px;
  box-sizing: border-box; width: min(950px, 70vw); height: 100%; min-width: 0;
  padding: 20px; background: var(--color-surface); border-left: 1px solid var(--color-border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.2);
}
.document-side-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.document-side-head h2 { margin: 0 0 4px; overflow-wrap: anywhere; }
.document-side-head .card-note { margin: 0; }
.document-side-preview { flex: 1 1 55%; min-height: 180px; width: 100%; border: 1px solid var(--color-border); background: var(--color-bg); }
.document-side-controls { flex: 0 1 auto; max-height: 45vh; overflow-y: auto; }
.document-side-controls .btn-row { margin-top: 12px; }
.document-side-rename { display: flex; align-items: flex-end; gap: 12px; }
.document-side-rename .field { flex: 1; min-width: 0; }
.document-side-rename .btn { flex: 0 0 auto; }
.document-side-email { margin-top: 16px; }
.document-side-controls .notice { margin-bottom: 12px; }
.document-side-controls .document-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.document-side-controls details { margin: 10px 0; }
.receipt-analysis-raw {
  max-height: 300px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-bg); font-size: 12px;
}
.tax-help-panel { overflow-y: auto; }
.tax-help-panel .tabs { flex: 0 0 auto; margin-bottom: 4px; }
.tax-help-panel .tabs button { padding: 8px 12px; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; background: transparent; color: var(--color-text-muted); font: inherit; cursor: pointer; }
.tax-help-panel .tabs button:hover, .tax-help-panel .tabs button.active { color: var(--color-text); }
.tax-help-panel .tabs button.active { border-bottom-color: var(--color-primary); }
.tax-help-rule { padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.tax-help-rule p { white-space: pre-wrap; overflow-wrap: anywhere; }
.vat-filing { margin-top: 22px; }
.vat-filing h4 { margin: 0 0 12px; }
.vat-filing-line, .vat-filing-total {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--color-border);
}
.vat-filing-line b { display: inline-block; min-width: 28px; color: var(--color-accent); }
.vat-filing-line strong, .vat-filing-total strong { font-family: var(--font-code); white-space: nowrap; }
.vat-filing-other { margin-top: 18px; }
.vat-filing-other h5 { margin: 0 0 6px; color: var(--color-text-muted); }
.vat-filing-calculation { margin: 22px 16px 0; color: var(--color-text-muted); font-size: 13px; }
.vat-filing-total {
  margin-top: 18px; border: 1px solid var(--color-primary); border-radius: var(--radius);
  background: var(--color-primary-20); font-weight: 700;
}
.vat-filing-total strong { font-size: 24px; }
.vat-filing-warning { margin: 14px 0 0; color: var(--color-warning); font-weight: 600; }
.vat-control-details { margin-top: 20px; border-top: 1px solid var(--color-border); padding-top: 16px; }
.vat-control-details summary { color: var(--color-primary); cursor: pointer; font-weight: 600; }
.vat-control-details > div { margin-top: 16px; overflow-x: auto; }
.vat-document-table table { width: 100%; table-layout: fixed; }
.vat-document-table td:first-child { overflow-wrap: anywhere; }
.vat-document-table#vatDocuments td:last-child, .vat-document-table#vatDocuments th:last-child { width: 130px; text-align: right; white-space: nowrap; }
.vat-document-table small { display: block; margin-top: 4px; color: var(--color-text-muted); }
.input-static { min-height: 38px; padding: 9px 12px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); background: var(--color-bg); }
.text-action { padding: 5px 0; border: 0; background: none; color: var(--color-primary);
  font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; text-align: left; }
@media (max-width: 800px) {
  .document-side-panel { width: 100vw; padding: 12px; }
  .document-side-controls .document-detail-grid { grid-template-columns: 1fr; }
}
.dossier-result { padding: 14px 0; border-bottom: 1px solid var(--color-border); }
.dossier-result-title { border: 0; padding: 0; background: none; color: var(--color-primary); cursor: pointer; font: inherit; font-weight: 600; text-align: left; }
.dossier-result p { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 0; }
.dossier-page-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; max-height: 65vh; overflow: auto; }
.bank-row-actions { text-align: right; white-space: nowrap; }
.bank-remittance-info {
  display: inline-block; margin-left: 7px; color: var(--color-text-muted);
  font-size: 13px; font-weight: 700; cursor: help; text-decoration: underline dotted;
}
.bank-remittance-info:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.bank-row-actions .icon-btn { margin-left: 6px; }
.bank-booking-cell { min-width: 140px; }
.bank-state-action { width: 32px; height: 32px; }
.bank-state-action svg { width: 18px; height: 18px; }
.icon-btn-danger { color: var(--color-error); border-color: var(--color-error); }
.icon-btn-danger:hover:not(:disabled) { color: var(--color-error); background: var(--color-error-bg); }
.icon-btn-danger svg { width: 18px; height: 18px; }
.bank-state-missing { color: var(--color-error); border-color: var(--color-error); background: var(--color-error-bg); }
.bank-state-complete { color: var(--color-success); border-color: var(--color-success); background: var(--color-success-20); }
.bank-state-waived { color: var(--color-text-muted); border-color: var(--color-border-strong); background: var(--color-surface); }
.bank-state-missing:hover:not(:disabled) { color: var(--color-error); background: var(--color-error-bg); }
.bank-state-complete:hover:not(:disabled) { color: var(--color-success); background: var(--color-success-20); }
.bank-evidence-list { display: grid; gap: 8px; margin: 12px 0 20px; }
.bank-evidence-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.bank-evidence-list a { overflow-wrap: anywhere; }
.settlement-list { display: grid; gap: 8px; margin-top: 12px; }
.settlement-list > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.settlement-list span { min-width: 0; overflow-wrap: anywhere; }
.settlement-list .num { white-space: nowrap; }
.settlement-list > div > span:first-child { flex: 1; }
/* The description shrinks and wraps; the amount and its action never do. */
.settlement-list .settlement-amount {
  flex: none; min-width: max-content;
  display: inline-flex; align-items: center; gap: 8px;
}
.bank-allocation-list { display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; margin: 16px 0; }
.bank-link-section[hidden] { display: none; }
.bank-allocation-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px; align-items: center; gap: 12px; }
.bank-allocation-row small { display: block; color: var(--color-text-muted); }
.tax-actions { text-align: right; white-space: nowrap; }
.tax-actions .icon-btn + .icon-btn { margin-left: 6px; }
.tax-actions svg { width: 18px; height: 18px; }
.tax-matches svg, #taxCandidates svg { width: 16px; height: 16px; }
.tax-link-modal .modal-actions { justify-content: flex-end; }
.tax-link-modal .modal-actions .btn { flex: 0 0 auto; }
.tax-amount-suggestion { display: flex; align-items: center; gap: 8px; margin: -8px 0 16px; font-size: 13px; }
.tax-check { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; white-space: nowrap; cursor: pointer; }
.tax-check input { margin: 0; accent-color: var(--color-primary); }
.tax-date-row { flex-wrap: wrap; }
.tax-date-row .field { min-width: 160px; }
.tax-upcoming-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--color-border); color: var(--color-text); text-decoration: none; }
.tax-upcoming-row:last-child { border-bottom: 0; }
.tax-upcoming-row:hover { color: var(--color-primary); }
.tax-upcoming-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tax-matches { margin-bottom: 16px; }
.tax-matches > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--color-border); }
.tax-matches > div > span, .tax-matches > div > a { min-width: 0; overflow-wrap: anywhere; }
.file-drop-zone { display: grid; place-items: center; gap: 6px; min-height: 126px; padding: 20px;
  border: 2px dashed var(--color-border); border-radius: var(--radius); text-align: center;
  color: var(--color-text-muted); cursor: pointer; }
.file-drop-zone:hover, .file-drop-zone:focus-visible, .file-drop-zone.is-dragging {
  border-color: var(--color-primary); background: var(--color-primary-20); color: var(--color-text); }
.file-drop-zone strong { color: var(--color-text); }
.file-drop-list ul { list-style: none; padding: 0; margin: 0; }
.file-drop-list li { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--color-border); overflow-wrap: anywhere; }
.file-drop-list li > span { min-width: 0; }
.file-drop-list small { color: var(--color-text-muted); margin-left: 8px; white-space: nowrap; }
.file-drop-error { color: var(--color-error); }

/* The controls for a grid, on their own row directly above it: below the heading
   and the explanation, so they sit with the thing they act on rather than with the
   title. Search first and taking the width up to the filters, filters at the
   right. Search asks "which record", a filter asks "which situation", and reading
   left to right that is narrow, then narrow further. */
.grid-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* The search box is mounted into a wrapper div, so the wrapper is the flex child
   and it is the one that has to grow. Putting flex:1 on the input alone did
   nothing: its parent is not a flex container, so it sized to its own content and
   the row stayed short. */
.grid-tools > [data-grid-search] { flex: 1; min-width: 0; }

/* Fills whatever the filters leave, which is the whole row when there are none. */
.grid-search {
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}

.grid-search:focus { outline: none; border-color: var(--color-primary); }

/* The search input is the flexible one, so a filter beside it keeps its own
   width instead of being squeezed. */
.grid-tools .filter { flex-shrink: 0; }

/* The period chooser next to a search box. Picking which month's balance you are
   looking at is not filtering a list, it is choosing which snapshot: there is
   nothing to untick and no "alle", so it is a select rather than a filter
   dropdown. It borrows the trigger's shape because they share a row, and a
   control that looks different there reads as a different kind of thing. */
.grid-tools select {
  flex-shrink: 0;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.grid-tools select:focus { outline: none; border-color: var(--color-primary); }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ── Tabs (settings sections) ───────────────────────────────────────── */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
}

.tabs a {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs a:hover { color: var(--color-text); }
.tabs a.active { color: var(--color-text); border-bottom-color: var(--color-primary); }

/* ── Tables ─────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
#journalList table { table-layout: fixed; min-width: 820px; }
#journalList th:first-child { width: 105px; }
#journalList th:nth-child(2) { width: 34%; }
#journalList th:nth-child(3) { width: 160px; }
#journalList th:last-child { width: 90px; }
#journalList td:nth-child(3) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.journal-actions { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.journal-actions svg { width: 18px; height: 18px; }
.journal-cell-ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.document-detail-row td { background: var(--color-surface); }
.document-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.document-detail-grid p { margin: 8px 0 0; overflow-wrap: anywhere; }
.document-detail-grid select { max-width: 100%; }
.document-detail-grid .btn-row { align-content: start; align-items: start; flex-wrap: wrap; }
#documentList td:first-child { overflow-wrap: anywhere; }
.document-action-buttons { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.document-action-buttons svg { width: 18px; height: 18px; }
.document-intake-missing { display: block; margin-top: 4px; color: var(--color-text-muted); line-height: 1.35; }
.receipt-ocr-details summary { cursor: pointer; }
.receipt-ocr-details .table-wrap { margin-top: 12px; }
.jev-answers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0 20px; }
.jev-answer { min-width: 0; padding: 14px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); }
.jev-answer h4 { margin: 0 0 8px; font-size: 14px; }
.jev-answer-question { min-height: 40px; margin: 0 0 10px; color: var(--color-text-muted); font-size: 13px; }
.jev-answer-result { margin: 0 0 12px; font-weight: 600; overflow-wrap: anywhere; }
.jev-answer-score { display: block; margin-top: 5px; color: var(--color-text-muted); font-size: 12px; font-weight: 400; }
.jev-answer details, .jev-technical { color: var(--color-text-muted); font-size: 13px; }
.jev-answer summary, .jev-technical summary { cursor: pointer; }
.jev-answer ul { margin: 8px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; }
.jev-answer li { margin: 0 0 5px; overflow-wrap: anywhere; }
.jev-technical { margin-top: 18px; }
.jev-technical .card-note { margin-top: 12px; }
@media (max-width: 800px) { .jev-answers { grid-template-columns: 1fr; } .jev-answer-question { min-height: 0; } }
@media (max-width: 640px) {
  #documentList thead th:nth-child(2),
  #documentList tbody tr:not(.document-detail-row) td:nth-child(2),
  #documentList thead th:nth-child(3),
  #documentList tbody tr:not(.document-detail-row) td:nth-child(3) { display: none; }
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

th.th-right { text-align: right; }

/* A sortable header is a button that looks like the header it sits in, so the
   column names keep one visual language whether they sort or not. */
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.th-sort:hover, th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort {
  color: var(--color-text);
}

.th-sort:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.th-sort-arrow { display: inline-block; min-width: 8px; font-size: 8px; }

.grid-note { margin: 0 0 8px; }

/* Thin divider between column headers. A table's own structure rather than an
   ad-hoc element border, so it does not conflict with the "use hr or a
   container border" rule in ui.md. */
thead th + th { border-left: 1px solid var(--color-border); }

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }

/* Declared column widths instead of content-derived ones. Without this each
   table measures itself, so a grid split into several tables shifts its columns
   sideways whenever one label happens to be longer — which is exactly what the
   memorial entries did as the reference changed length. */
.table-fixed { table-layout: fixed; }

/* Long values wrap rather than force the column wider. .num keeps its nowrap:
   an amount is read as one unit and must never break across lines. */
.table-fixed td { overflow-wrap: anywhere; }

/* Two levels of grouping inside one grid: the month, and the document within
   it. A full-width row rather than a heading above a new table, so every group
   shares one set of column widths and the header appears once at the top.
   The space above a group is what separates it from the previous one. */
.row-month td,
.row-group td { border-bottom: none; }

.row-month td {
  padding-top: 28px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.row-group td { padding-top: 16px; font-weight: 600; }

/* Nothing above the very first group, or it floats away from the header. */
tbody tr:first-child.row-month td,
tbody tr:first-child.row-group td { padding-top: 8px; }

/* A sub-account under the account it rolls up into on the balance sheet. */
td.nested { padding-left: 32px; }

/* Every amount and every code is mono: a column of euros in a proportional
   font cannot be read down. Amounts right-aligned, two decimals always. */
.num, .code {
  font-family: var(--font-code);
  font-variant-numeric: tabular-nums;
}
.num { text-align: right; white-space: nowrap; }
.code { font-size: 13px; }

/* ── Badges ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* A reconciliation signal is not an error. Error styling is reserved for
   things that are actually wrong, so signals stay secondary and do not train
   the eye to dismiss them. See .claude/rules/ui.md. */
/* A badge that is also a switch, for a single boolean in a grid row. It keeps
   the badge shapes so the value reads exactly as it does elsewhere, and only the
   cursor and the hover say it can be clicked. */
.badge-toggle {
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.badge-toggle:hover:not(:disabled) { filter: brightness(1.25); }
.badge-toggle:disabled { opacity: 0.5; cursor: wait; }

/* The series marker sits after the reference in a grouping row, so it needs the
   gap the row's flex layout does not give it. */
.series-mark { margin-left: 12px; }

/* Four distinguishable hues, which took two new tokens. badge-ok and badge-signal
   used accent and secondary, two cyans one hue apart, so "compleet" and "zonder
   bon" read as the same badge from a metre away. */
.badge-ok      { background: var(--color-success-20);   color: var(--color-success); }
.badge-signal  { background: var(--color-secondary-20); color: var(--color-secondary); }
.badge-warn    { background: var(--color-warning-20);   color: var(--color-warning); }
.badge-neutral { background: var(--color-muted-20);     color: var(--color-text-muted); }
.badge-error   { background: var(--color-error-bg);     color: var(--color-error); }

/* ── Stat tiles ─────────────────────────────────────────────────────── */

.stat {
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
}
a.stat { color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--color-primary); }

.stat-label { font-size: 13px; color: var(--color-text-muted); margin-bottom: 8px; }
.stat-value {
  font-family: var(--font-code);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 600;
}
.stat-sub { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }
.stat.empty .stat-value { color: var(--color-text-muted); font-weight: 400; }
.report-ledger-row { cursor: pointer; }
.report-ledger-row:hover { background: var(--color-primary-20); }
.report-ledger-button {
  border: 0; padding: 0; background: none; color: var(--color-primary);
  font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.report-ledger-button:hover, .report-ledger-button:focus-visible { text-decoration: underline; }
.ledger-entry-source { display: block; margin-top: 4px; color: var(--color-text-muted); }
.ledger-load-more { margin-top: 16px; }

/* A tile whose value is a name or a date rather than an amount. The 20px of
   .stat-value is sized for a figure you read at a glance; a name at that size
   wraps and stops looking like a value. A modifier rather than font-size
   written inline at each of the six call sites, which is what it was. */
.stat-value-text { font-size: 16px; }

.dashboard-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 190px;
  padding: 32px 44px;
  margin-bottom: 24px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--color-border-strong);
  border-radius: 20px;
  background:
    radial-gradient(circle at 79% 40%, var(--color-primary-20), transparent 38%),
    linear-gradient(115deg, var(--color-surface), color-mix(in srgb, var(--color-surface) 82%, var(--color-primary)));
}
.dashboard-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .35;
  background-image: linear-gradient(var(--color-border-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-border-strong) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(90deg, transparent 35%, black);
}
.dashboard-hero-copy { position: relative; z-index: 1; }
.dashboard-eyebrow {
  display: block;
  margin-bottom: 12px;
  color: var(--color-accent);
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
}
.dashboard-hero h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.1;
}
.dashboard-hero p { margin: 12px 0 0; color: var(--color-text-muted); }
.dashboard-orbit { position: relative; width: 170px; height: 138px; margin-right: 24px; flex: none; }
.dashboard-orbit-ring {
  position: absolute;
  inset: -26px -18px;
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  border-radius: 50%;
  transform: rotate(-19deg);
  box-shadow: 0 0 28px var(--color-primary-20);
}
.dashboard-orbit-ring::after {
  content: '';
  position: absolute;
  inset: 19px 28px;
  border: 1px dashed color-mix(in srgb, var(--color-accent) 40%, transparent);
  border-radius: 50%;
}
.dashboard-buddy {
  position: absolute;
  top: 10px;
  left: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  width: 116px;
  height: 116px;
  border: 2px solid color-mix(in srgb, var(--color-accent) 70%, white);
  border-radius: 36px;
  transform: rotate(-10deg);
  background: linear-gradient(145deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 55%, var(--color-secondary)));
  box-shadow: 0 20px 42px color-mix(in srgb, var(--color-primary) 38%, transparent),
    inset 0 2px 4px color-mix(in srgb, white 28%, transparent);
}
.dashboard-buddy-eye { width: 9px; height: 12px; border-radius: 50%; background: var(--color-on-primary); }
.dashboard-buddy-smile {
  position: absolute;
  top: 61px;
  left: 44px;
  width: 30px;
  height: 15px;
  border-bottom: 3px solid var(--color-on-primary);
  border-radius: 50%;
}
.dashboard-orbit-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 16px var(--color-accent);
}
.dashboard-orbit-spark-one { top: 0; left: 16px; }
.dashboard-orbit-spark-two { right: 0; bottom: 9px; width: 5px; height: 5px; }
.dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dashboard-grid .stat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 174px;
  padding: 25px 16px 20px;
  overflow: hidden;
  border-color: var(--color-border-strong);
  border-radius: 16px;
  background: radial-gradient(circle at 50% 125%, var(--color-primary-20), transparent 63%), var(--color-surface);
  text-align: center;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.dashboard-grid .stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 72px;
  height: 2px;
  transform: translateX(-50%);
  background: var(--color-primary);
  box-shadow: 0 0 16px var(--color-primary);
}
.dashboard-grid a.stat:hover, .dashboard-grid a.stat:focus-visible {
  transform: translateY(-4px);
  border-color: var(--color-primary);
  box-shadow: 0 16px 36px color-mix(in srgb, var(--color-primary) 12%, transparent);
}
.dashboard-grid .stat-label {
  margin: 0;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 600;
}
.dashboard-grid .stat-value {
  margin-top: 16px;
  font-size: clamp(38px, 4vw, 50px);
  line-height: 1.15;
  letter-spacing: -.05em;
}
.dashboard-grid .dashboard-balance .stat-value { font-size: clamp(27px, 3vw, 38px); }
.dashboard-grid .dashboard-health .stat-value { font-family: var(--font-ui); font-size: clamp(28px, 3.5vw, 40px); }
.dashboard-grid .dashboard-loading { color: var(--color-text-muted); font-size: 24px !important; }
.dashboard-health-dot {
  position: absolute;
  bottom: 18px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}
.dashboard-health.signal-ok .dashboard-health-dot { color: var(--color-success); }
.dashboard-health.signal-error .dashboard-health-dot { color: var(--color-error); }
.signal-card.signal-ok .stat-value { color: var(--color-success); }
.signal-card.signal-warn .stat-value { color: var(--color-warning); }
.signal-card.signal-error .stat-value { color: var(--color-error); }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .dashboard-hero { min-height: 156px; padding: 24px; }
  .dashboard-hero-copy { max-width: 72%; }
  .dashboard-orbit { position: absolute; right: 0; top: 8px; transform: scale(.5); transform-origin: right top; margin: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .stat { min-height: 145px; }
}
@media (prefers-reduced-motion: reduce) { .dashboard-grid .stat { transition: none; } }


/* ── List rows ──────────────────────────────────────────────────────── */

/* A row in a list that is not a grid: an identity mark, a title with its
   status beside it, a sub-line, and the row's actions on the right. One class,
   because the alternative was this same flex layout written inline on every
   page that needed it. */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.list-row:last-child { margin-bottom: 0; }

/* min-width:0 so a long name ellipsises instead of pushing the actions off. */
.list-row-body { flex: 1; min-width: 0; }

/* The status marker sits beside the name because it describes the row. The
   right-hand side is reserved for actions, so a badge and a button never sit
   shoulder to shoulder looking alike. */
.list-row-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.list-row-sub { font-size: 13px; color: var(--color-text-muted); }

/* ── Forms ──────────────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }

/* Label above the input, never a placeholder: a placeholder disappears the
   moment you start typing. */
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.field input.mono { font-family: var(--font-code); }
/* An amount field reads like an amount column: mono, right-aligned. Written as
   .field input.num because .field input resets the font and would otherwise win. */
.field input.num { font-family: var(--font-code); font-variant-numeric: tabular-nums; text-align: right; }
.field textarea { resize: vertical; }

.field .hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

.field .error {
  font-size: 12px;
  color: var(--color-error);
  margin-top: 4px;
  min-height: 16px;
}

.field.invalid input { border-color: var(--color-error); }

/* ── Searchable select (Fidge.searchSelect) ─────────────────────────────
   The field you type in replaces the dropdown's face; the native select stays
   underneath as the value, invisible but focusable so the browser can still
   point at it when a required one is empty. */
.search-select { position: relative; width: 100%; }

.search-select-native {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.search-select-input,
.field .search-select-input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  text-overflow: ellipsis;
}

.search-select-input:focus { outline: none; border-color: var(--color-primary); }
.search-select-input:disabled { opacity: 0.6; cursor: not-allowed; }
.search-select.invalid .search-select-input { border-color: var(--color-error); }

/* The chevron says "this is a choice", not free text. */
.search-select::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 12px;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  transform: rotate(45deg);
  pointer-events: none;
}

/* Fixed, not absolute: a modal or a table scrolls its own overflow and would cut
   the list off. searchSelect places it against the input, above it when the
   viewport has no room below. Above the modal overlay's 300. */
.search-select-list {
  position: fixed;
  z-index: 310;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}

.search-select-option {
  padding: 8px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.search-select-option.active { background: var(--color-hover); }
.search-select-option.selected { color: var(--color-primary); font-weight: 600; }
.search-select-option[aria-disabled="true"] { color: var(--color-text-muted); cursor: not-allowed; }
.search-select-empty { padding: 8px; font-size: 14px; color: var(--color-text-muted); }

.field input:disabled, .field select:disabled {
  color: var(--color-text-muted);
  background: var(--color-surface);
  cursor: not-allowed;
}

/* Two fields that are really one decision: a value and its unit, a validity start
   and its end. Reading them apart is what makes you forget the second one.
   .field is the direct flex child here, which is what makes flex: 1 work at all. */
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; min-width: 0; }
.field-row > .btn, .field-row > .icon-btn { align-self: flex-end; margin-bottom: 16px; }
#tab-resultaat > .field-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* A single tick box in a form. The label sits beside it rather than above it,
   unlike every other field: a label above a checkbox reads as a heading with an
   orphan box underneath. */
.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.field-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.field-check label {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  /* Centred so a full-width button does not leave its label hanging left. */
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }

/* Both outlined variants take the control border, so being visible is the
   default rather than something each caller opts into. There used to be a
   .btn-outline modifier for this, applied to exactly one button, which is how
   the sync and user rows ended up with a border nobody could see. */
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-hover); }

.btn-danger {
  background: transparent;
  color: var(--color-error);
  border-color: var(--color-border-strong);
}
.btn-danger:hover:not(:disabled) { background: var(--color-error-bg); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* An action inside a row is smaller than a page or card action: the row is the
   unit of reading, and a full-size button in it competes with the content.
   Attached to the container rather than a class on the button, so a new grid
   gets it for free and cannot forget it. */
td .btn, .list-row .btn { padding: 4px 10px; font-size: 13px; }

td .icon-btn { width: 28px; height: 28px; }
td .icon-btn .nav-icon { width: 15px; height: 15px; }

/* ── Notices ────────────────────────────────────────────────────────── */

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
}

.notice-info    { background: var(--color-secondary-20); border-color: transparent; }
.notice-ok      { background: var(--color-accent-20);    border-color: transparent; }
.notice-error   { background: var(--color-error-bg);     border-color: transparent; color: var(--color-error); }

/* ── Toasts ─────────────────────────────────────────────────────────── */

/* Transient outcomes: saved, deleted, or a request failure. Bottom centre so
   it never covers the thing you just acted on, with a countdown line so the
   disappearance is expected rather than surprising. */

.toast-stack {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 400;
  /* The stack must not swallow clicks on the page behind it; each toast opts
     back in so it can still be dismissed. */
  pointer-events: none;
}

.toast {
  position: relative;
  min-width: 280px;
  max-width: 460px;
  padding: 12px 16px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
  animation: toast-in 0.15s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast-ok    { background: var(--color-accent-20);    border-color: transparent; }
.toast-info  { background: var(--color-secondary-20); border-color: transparent; }
.toast-error { background: var(--color-error-bg);     border-color: transparent; color: var(--color-error); }

/* The countdown. Shrinks left to right over the toast's lifetime. */
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--color-overlay);
  transform-origin: left center;
  animation: toast-countdown linear forwards;
}

@keyframes toast-countdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Reading an error should not race a timer. */
.toast:hover .toast-timer { animation-play-state: paused; }

@media (max-width: 480px) {
  .toast-stack { left: 12px; right: 12px; transform: none; }
  .toast { min-width: 0; width: 100%; }
}

/* ── Filter dropdown ────────────────────────────────────────────────── */

/* A filter is a dropdown with tick boxes, not a row of buttons: a button row
   reads as "pick one action", a checkbox list reads as "narrow this down", and
   only the second is what a filter does. See .claude/rules/ui.md. */

.filter { position: relative; display: inline-block; }

.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.filter-trigger:hover { background: var(--color-hover); }

/* Filtered is a state worth seeing at a glance, so the trigger says so. */
.filter-trigger.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.filter-caret { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.7; }

.filter-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 0;
  z-index: 200;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.filter-panel.open { display: block; }

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}

.filter-option:hover { background: var(--color-hover); }

.filter-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.filter-option-count {
  margin-left: auto;
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--color-text-muted);
}

.filter-panel hr { margin: 8px 0; }

.filter-clear {
  display: block;
  width: 100%;
  padding: 6px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
}

.filter-clear:hover { color: var(--color-text); background: var(--color-hover); }
.filter-clear:disabled { opacity: 0.4; cursor: default; background: none; }

/* ── Modal ──────────────────────────────────────────────────────────── */

/* Create and edit live behind a button and open here, so a list stays a list
   and a form is never in the way of reading. Built by Fidge.openModal. */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 300;
}

.modal {
  width: 100%;
  max-width: 440px;
  min-width: 0;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Below .modal on purpose: both are single-class selectors, so source order is
   what lets this win. */
.modal-wide { max-width: 760px; }

.modal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-head h2 { margin: 0; }

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover { color: var(--color-text); }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

/* Equal width, so neither the confirm nor the cancel reads as the safe default
   by being larger. */
.modal-actions .btn { flex: 1; }
.modal-body .book-maintenance-form > button[type="submit"] { display: none; }
.modal-body #journalForm .btn-row > button[type="submit"] { display: none; }
.modal-body .book-maintenance-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.modal-body .book-maintenance-form > * { min-width: 0; }
.modal-body .book-maintenance-form .field { min-width: 0; }
.modal-body .book-maintenance-form .field-check { min-width: 0; margin-bottom: 0; }
.book-maintenance-form[hidden] { display: none !important; }

@media (max-width: 480px) {
  .modal-overlay { padding: 12px; align-items: flex-start; }
  .modal { padding: 20px; }
  .modal-body #journalForm .book-line { flex-wrap: wrap; }
  .modal-body #journalForm .book-line > .field:first-child { flex-basis: 100%; }
}

/* ── Message panel ──────────────────────────────────────────────────── */

/* An outcome rather than a form: "link is verstuurd", "er ging iets mis". The
   text centres and the actions fill the width, so it reads as a statement with
   one obvious next step. The brand and the page title stay left-aligned above
   it, which is what keeps the card anchored.

   Use this for any confirmation or outcome panel. Don't restyle one by hand. */
.message { text-align: center; }

.message h2 { margin: 16px 0 8px; }

/* margin auto keeps the block centred once the container is wider than the
   text wants to be. */
.message p {
  max-width: 44ch;
  margin-left: auto;
  margin-right: auto;
}

.message .btn-row {
  flex-direction: column;
  align-items: stretch;
  margin-top: 16px;
}

.message .btn { width: 100%; }

/* Absence of data is informative, so an empty state is shown rather than the
   container being hidden. "Checked, nothing to report" and "has not run yet"
   are different states and both have to be visible. */
.empty {
  color: var(--color-text-muted);
  font-size: 14px;
  padding: 16px 0;
}

/* The "no records" row inside a grid. Centred under the headers with room above
   it, so an empty grid reads as an answer rather than a table cut short. */
td.empty {
  text-align: center;
  padding: 32px 12px 24px;
}

/* margin auto on the text itself, so a long message stays a centred block
   instead of running the full width of a wide table. */
.empty-message {
  display: block;
  max-width: 46ch;
  margin-left: auto;
  margin-right: auto;
}

.muted { color: var(--color-text-muted); }
.small { font-size: 13px; }

/* The name column of a data grid opens the record behind it. Styled as
   a link rather than as a button: it belongs to the row it names, and a real
   button in every row would read as an action column. */
.record-link {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--color-primary);
  text-align: left;
  cursor: pointer;
}

.record-link:hover { text-decoration: underline; }

/* A raw API payload. Unwrapped and scrollable in both directions: this is here
   to be read as JSON, and reflowed lines make nesting impossible to follow. */
.json-view {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
}

.benchmark-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.benchmark-metrics > div { display: flex; flex-direction: column; gap: 4px; padding: 14px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); }
.benchmark-metrics strong { font-size: 24px; }
.benchmark-metrics span { color: var(--color-text-muted); font-size: 13px; }
.benchmark-table { min-width: 960px; }
.benchmark-table th:first-child { width: 27%; }
.benchmark-table th:nth-child(2) { width: 17%; }
.benchmark-table th:nth-child(n+3):nth-child(-n+6) { width: 9%; }
.benchmark-table th:nth-child(7) { width: 11%; }
.benchmark-table th:last-child { width: 9%; }
.benchmark-table td { overflow-wrap: anywhere; }
.benchmark-case-label { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.benchmark-case-label span { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.benchmark-case-label strong { overflow-wrap: anywhere; }
.benchmark-case-label small { color: var(--color-text-muted); }
#benchmarkRows td { vertical-align: top; }
#benchmarkRows td:last-child small { display: block; margin-top: 6px; }
.benchmark-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.benchmark-detail-grid iframe { width: 100%; min-height: 75vh; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); background: var(--color-bg); }
.benchmark-detail-grid > div { min-width: 0; }
.benchmark-detail-grid details { margin: 10px 0; }
.benchmark-detail-grid summary { cursor: pointer; }
@media (max-width: 800px) {
  .benchmark-metrics { grid-template-columns: 1fr; }
  .benchmark-detail-grid { grid-template-columns: 1fr; }
  .benchmark-detail-grid iframe { min-height: 55vh; }
}

.mail-address { font-family: var(--font-code); font-size: 12px; overflow-wrap: anywhere; }
.mail-excerpt {
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 0 16px; padding: 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.mail-excerpt small { color: var(--color-text-muted); overflow-wrap: anywhere; }
.mail-excerpt p {
  margin: 4px 0 0; max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px;
}

.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input { flex: 1; font-family: var(--font-code); font-size: 12px; }

/* ── Auth pages ─────────────────────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
}

/* The mark and the name on one line. currentColor on the mark, so the token is
   named once here and the SVG has no colour of its own. */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-code);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 24px;
}

.auth-brand .brand-mark { width: 22px; height: 22px; }

/* An auth card is one decision, so its action fills the width: there is nothing
   to weigh it against and a button floating left reads as optional. Same reason
   .message stacks its actions full-width. */
.auth-card .btn { width: 100%; }

/* A form that is the whole page can afford a bigger target than a field in a
   modal. Written as .field input.input-lg rather than .input-lg, because
   `.field input` is the more specific selector and would otherwise win. Raising
   specificity beats reaching for !important, which only moves the fight. */
.field input.input-lg { padding: 12px 14px; font-size: 16px; }

@media (max-width: 480px) {
  .auth-wrap { padding: 12px; min-height: 100dvh; }
  .auth-card { padding: 24px 20px; }
}

/* ── Mobile ─────────────────────────────────────────────────────────── */

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 40;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); padding-top: 56px; }
  .sidebar-overlay.open { display: block; }
  .mobile-menu-btn { display: flex; }
  .main { margin-left: 0; padding: 64px 16px 48px; }
}
