/* Reisekosten – application styles (no external fonts or CDNs). */

:root {
  color-scheme: light dark;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef1f6;
  --border: #dfe3ea;
  --border-strong: #c7cdd8;
  --text: #182033;
  --text-2: #465167;
  --muted: #677186;

  --accent: #2457c5;
  --accent-hover: #1c479f;
  --accent-fg: #2457c5;
  --accent-soft: #e8eefb;

  --open: #955800;
  --open-bg: #fdf1d8;
  --open-border: #f0d49a;
  --matched: #17723f;
  --matched-bg: #dff4e7;
  --matched-border: #a9dcbd;
  --private: #525c6c;
  --private-bg: #edf0f4;
  --noreceipt: #6739cf;
  --noreceipt-bg: #efe9fd;
  --fee: #0b706c;
  --fee-bg: #d8f2f0;
  --error: #b52525;
  --error-bg: #fde8e8;
  --error-border: #f2b8b8;

  --toast-bg: #1d2433;
  --toast-fg: #f3f5f9;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 2px 6px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.18), 0 2px 8px rgba(16, 24, 40, 0.08);
  --focus-ring: 0 0 0 3px rgba(36, 87, 197, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b;
    --surface: #161c26;
    --surface-2: #1a212d;
    --surface-3: #222a38;
    --border: #2a3343;
    --border-strong: #3a4558;
    --text: #e7ebf2;
    --text-2: #b9c1cf;
    --muted: #8c96a8;

    --accent: #3d6fd8;
    --accent-hover: #5282e3;
    --accent-fg: #8db0f6;
    --accent-soft: rgba(84, 132, 232, 0.16);

    --open: #f0b54f;
    --open-bg: rgba(240, 181, 79, 0.14);
    --open-border: rgba(240, 181, 79, 0.4);
    --matched: #56c98f;
    --matched-bg: rgba(86, 201, 143, 0.14);
    --matched-border: rgba(86, 201, 143, 0.4);
    --private: #a3abba;
    --private-bg: rgba(163, 171, 186, 0.14);
    --noreceipt: #b89bf7;
    --noreceipt-bg: rgba(184, 155, 247, 0.16);
    --fee: #43c9c1;
    --fee-bg: rgba(67, 201, 193, 0.14);
    --error: #f27b7b;
    --error-bg: rgba(242, 123, 123, 0.14);
    --error-border: rgba(242, 123, 123, 0.45);

    --toast-bg: #2a3243;
    --toast-fg: #eef1f6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
    --focus-ring: 0 0 0 3px rgba(141, 176, 246, 0.35);
  }
}

/* ---------------------------------------------------------------- base */

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

h1,
h2,
h3 {
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h1 {
  margin: 0;
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

[tabindex="-1"]:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent-fg);
  outline-offset: 2px;
}

a {
  color: var(--accent-fg);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:not(:hover) {
  text-decoration: none;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
}

img {
  max-width: 100%;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.ellipsis {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link {
  font-size: 14px;
  font-weight: 600;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

.boot {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.boot-noscript {
  max-width: 480px;
  margin: 48px auto;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--error-bg);
  color: var(--error);
  font-weight: 600;
  text-align: center;
}

/* ---------------------------------------------------------------- icons & spinner */

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-spacer {
  display: inline-block;
  width: 16px;
  height: 16px;
}

.spinner {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--accent-fg);
  animation: spin 0.75s linear infinite;
}

.spinner-xs {
  width: 10px;
  height: 10px;
  color: inherit;
}

.spinner-sm {
  width: 14px;
  height: 14px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

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

/* ---------------------------------------------------------------- buttons */

.btn {
  --busy: var(--text-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:hover {
  background: var(--surface-3);
  text-decoration: none;
}

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

.btn:disabled:hover {
  background: var(--surface);
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  --busy: #fff;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-primary:disabled:hover {
  border-color: var(--accent);
  background: var(--accent);
}

.btn-danger {
  --busy: #fff;
  border-color: var(--error);
  background: var(--error);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(0.94);
  background: var(--error);
}

.btn-danger-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--error);
}

.btn-danger-ghost:hover {
  background: var(--error-bg);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.btn-icon {
  width: 36px;
  padding: 6px;
}

.btn-block {
  width: 100%;
  min-height: 42px;
}

.btn.is-busy {
  color: transparent !important;
  cursor: progress;
}

.btn.is-busy:disabled {
  opacity: 1;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--busy);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.btn .count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-size: 12px;
  font-weight: 700;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.35;
  background: transparent;
  cursor: not-allowed;
}

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

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--accent-fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

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

.link-btn .icon {
  width: 14px;
  height: 14px;
}

.icon-btn.is-busy,
.link-btn.is-busy,
.chip-action.is-busy {
  opacity: 0.5;
  cursor: progress;
}

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

/* ---------------------------------------------------------------- forms */

.input,
.select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea.input {
  min-height: 76px;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8697' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  cursor: pointer;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent-fg);
  box-shadow: var(--focus-ring);
}

.input[readonly] {
  background: var(--surface-2);
  color: var(--text-2);
}

.select:disabled,
.input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.input-sm,
.select-sm {
  min-height: 32px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 14px;
}

.select-sm {
  padding-right: 28px;
  background-position: right 6px center;
}

.select[aria-busy="true"] {
  opacity: 0.6;
}

[aria-invalid="true"] {
  border-color: var(--error) !important;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.field-wide,
.form-actions {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

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

.field-error {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--error-bg);
  color: var(--error);
  font-size: 14px;
  font-weight: 600;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

/* ---------------------------------------------------------------- shell */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1280px;
  height: 60px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand-bg {
  fill: var(--accent);
}

.brand-fg {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mainnav {
  display: flex;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-fg);
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  min-width: 0;
}

.job-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.job-count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.user-name {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 72px;
  outline: none;
}

.page {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.page > * {
  min-width: 0;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-sub {
  margin: 4px 0 0;
  color: var(--muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section {
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
}

.section > .empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  margin-bottom: -12px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
}

.back-link .icon {
  width: 16px;
  height: 16px;
}

/* ---------------------------------------------------------------- cards, callouts, badges */

.card {
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

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

.card-head h2 {
  margin: 0;
}

.card-desc {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.callout {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
}

.callout-icon {
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.callout-body {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.callout-body p {
  margin: 0;
}

.callout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.callout-success {
  border-color: var(--matched-border);
  background: var(--matched-bg);
}

.callout-success .callout-icon {
  color: var(--matched);
}

.callout-warning {
  border-color: var(--open-border);
  background: var(--open-bg);
}

.callout-warning .callout-icon {
  color: var(--open);
}

.callout-error {
  border-color: var(--error-border);
  background: var(--error-bg);
}

.callout-error .callout-icon {
  color: var(--error);
}

.callout-info {
  border-color: transparent;
  background: var(--accent-soft);
}

.callout-info .callout-icon {
  color: var(--accent-fg);
}

.warning-list {
  margin: 6px 0 0;
  padding-left: 20px;
}

.notices {
  display: grid;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}

.badge-success {
  background: var(--matched-bg);
  color: var(--matched);
}

.badge-warning,
.badge-open {
  background: var(--open-bg);
  color: var(--open);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
}

.badge-info {
  background: var(--accent-soft);
  color: var(--accent-fg);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.tag-muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-open,
.status-x-queued {
  background: var(--open-bg);
  color: var(--open);
}

.status-matched,
.status-x-done {
  background: var(--matched-bg);
  color: var(--matched);
}

.status-private,
.status-ignored {
  background: var(--private-bg);
  color: var(--private);
}

.status-noreceipt {
  background: var(--noreceipt-bg);
  color: var(--noreceipt);
}

.status-fee {
  background: var(--fee-bg);
  color: var(--fee);
}

.status-x-processing {
  background: var(--accent-soft);
  color: var(--accent-fg);
}

.status-x-processing::before {
  display: none;
}

.status-x-error {
  background: var(--error-bg);
  color: var(--error);
}

.progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--matched);
  transition: width 0.3s ease;
}

.progress-sm {
  height: 4px;
}

.progress-lg {
  height: 10px;
}

.progress-sm .progress-fill,
.progress-lg .progress-fill {
  background: var(--accent);
}

.progress-text {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
}

.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
  font-size: 14px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.kv-compact {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.code-inline {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--surface-3);
  font-size: 13px;
  white-space: nowrap;
}

.code-block {
  max-height: 320px;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  border-radius: var(--radius);
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- empty & loading states */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  color: var(--text-2);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
}

.empty-icon .icon {
  width: 26px;
  height: 26px;
}

.empty-title {
  margin: 0;
  color: var(--text);
  font-size: 17px;
}

.empty-text {
  max-width: 54ch;
  margin: 0;
  font-size: 14px;
}

.empty-action {
  margin-top: 8px;
}

.empty-error .empty-icon {
  background: var(--error-bg);
  color: var(--error);
}

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-stack {
  display: grid;
  gap: 12px;
}

.skeleton-line {
  height: 12px;
}

.skeleton-line.short {
  width: 40%;
}

.skeleton-title {
  width: 60%;
  height: 18px;
}

.skeleton-card {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 150px;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -100% 0;
  }
}

/* ---------------------------------------------------------------- dashboard */

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 24px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone:hover {
  border-color: var(--accent-fg);
}

.dropzone.is-drop-over {
  border-color: var(--accent-fg);
  background: var(--accent-soft);
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-fg);
}

.dropzone-icon .icon {
  width: 24px;
  height: 24px;
}

.dropzone-title {
  margin: 4px 0 0;
  font-size: 16px;
}

.dropzone-hint {
  max-width: 44ch;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.dropzone-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.dropzone-compact {
  padding: 16px;
  cursor: default;
}

.camera-btn {
  display: none;
}

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

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s;
}

.stat:hover {
  border-color: var(--accent-fg);
  text-decoration: none;
}

.stat-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-open .stat-value {
  color: var(--open);
}

.stat-info .stat-value {
  color: var(--accent-fg);
}

.stat-error .stat-value {
  color: var(--error);
}

.st-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 16px;
}

.st-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.st-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.st-card.is-closed {
  background: var(--surface-2);
}

.st-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
}

/* A long status badge moves below the title on narrow cards instead of wrapping inside the pill. */
.st-card-head .badge {
  flex: 0 0 auto;
  max-width: 100%;
}

.st-card-heading {
  flex: 1 1 180px;
  min-width: 0;
}

.st-card-title {
  margin: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.st-card-title a {
  color: var(--text);
}

.stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: var(--radius-lg);
}

.stretched-link:focus-visible {
  outline: none;
}

.stretched-link:focus-visible::after {
  outline: 2px solid var(--accent-fg);
  outline-offset: 2px;
}

.raise {
  position: relative;
  z-index: 1;
}

.st-card-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.st-card-state {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.st-card-state p {
  margin: 2px 0 8px;
}

.st-card-state.is-error {
  background: var(--error-bg);
}

.st-card-state.is-error > .icon {
  color: var(--error);
  margin-top: 2px;
}

.st-card-progress {
  display: grid;
  gap: 6px;
}

.st-card-open {
  margin: 0;
  color: var(--open);
  font-weight: 600;
}

.st-card-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--matched);
  font-weight: 600;
}

.st-card-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  color: var(--text-2);
  font-size: 14px;
}

.st-card-totals strong {
  color: var(--text);
}

.st-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.st-card-foot {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ---------------------------------------------------------------- statement detail */

.st-head {
  display: grid;
  gap: 16px;
}

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

.st-title-row h1 {
  overflow-wrap: anywhere;
}

.st-meta {
  margin: 6px 0 0;
  color: var(--muted);
}

.st-notes {
  display: flex;
  gap: 8px;
  margin: 8px 0 0;
  color: var(--text-2);
  white-space: pre-line;
}

.st-notes .icon {
  margin-top: 2px;
  color: var(--muted);
}

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

.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.kpi-sub {
  color: var(--muted);
  font-size: 12px;
}

.kpi-open .kpi-value {
  color: var(--open);
}

.kpi-ok .kpi-value {
  color: var(--matched);
}

.kpi-accent {
  border-color: transparent;
  background: var(--accent-soft);
}

.kpi-accent .kpi-value {
  color: var(--accent-fg);
}

.kpi-check {
  margin-top: 10px;
}

.kpi-check .badge {
  white-space: normal;
}

.state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}

.state-card h2 {
  margin: 0;
}

.state-card p {
  max-width: 62ch;
  margin: 0;
}

.state-card .btn-row {
  justify-content: center;
  margin-top: 4px;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--error-bg);
  color: var(--error);
}

.state-icon .icon {
  width: 26px;
  height: 26px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.toolbar-end {
  margin-left: auto;
}

.cta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.cta-hint {
  color: var(--open);
  font-size: 12px;
  font-weight: 600;
}

.tx-section {
  display: grid;
  gap: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  background: var(--surface-3);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.tab.is-active .tab-count {
  background: var(--accent-soft);
  color: var(--accent-fg);
}

.tab-error .tab-count {
  background: var(--error-bg);
  color: var(--error);
}

.table-card {
  padding: 0;
  overflow-x: auto;
}

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

.tx-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.tx-table th:first-child {
  border-top-left-radius: var(--radius-lg);
}

.tx-table th:last-child {
  border-top-right-radius: var(--radius-lg);
}

.tx-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.tx-table tbody tr:last-child td {
  border-bottom: 0;
}

.tx-table th.num,
.tx-table td.num,
.totals-table .num,
.vat-table .num {
  text-align: right;
}

.tx-row {
  transition: background-color 0.15s;
}

.tx-row:hover {
  background: var(--surface-2);
}

.tx-row.is-open > td:first-child {
  box-shadow: inset 3px 0 0 var(--open);
}

.tx-row.is-private,
.tx-row.is-ignored {
  color: var(--muted);
}

.tx-row.is-drop-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent-fg);
  outline-offset: -2px;
}

.c-date {
  width: 1%;
  white-space: nowrap;
}

.c-date .tx-sub {
  display: block;
}

.c-merchant {
  min-width: 200px;
}

.c-amount {
  width: 1%;
  font-weight: 600;
  white-space: nowrap;
}

.c-category {
  width: 190px;
}

.c-receipt {
  min-width: 210px;
}

.c-status {
  width: 1%;
  white-space: nowrap;
}

.c-actions {
  width: 1%;
  text-align: right;
}

.tx-merchant {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tx-desc,
.tx-sub {
  color: var(--muted);
  font-size: 12px;
}

.tx-desc {
  overflow-wrap: anywhere;
}

.tx-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.tx-note .icon {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  color: var(--muted);
}

.tx-details:empty {
  display: none;
}

.tx-warn {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  color: var(--open);
  font-size: 13px;
  font-weight: 600;
}

.tx-warn .icon {
  flex: none;
  width: 14px;
  height: 14px;
}

.tx-warn .link-btn {
  padding: 0;
  color: inherit;
  text-align: left;
}

.is-credit {
  color: var(--matched);
}

.tx-credit-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tx-empty td {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.chip-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 3px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.chip-main:hover {
  background: var(--surface-3);
}

.chip-main .icon {
  width: 14px;
  height: 14px;
}

.chip-text {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-amount,
.chip-score {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chip-receipt {
  border-color: var(--matched-border);
  background: var(--matched-bg);
}

.chip-receipt .chip-main .icon {
  color: var(--matched);
}

.chip-suggest {
  border-style: dashed;
  border-color: var(--accent-fg);
  background: var(--accent-soft);
}

.chip-suggest .chip-main .icon,
.chip-suggest .chip-score {
  color: var(--accent-fg);
  font-weight: 700;
}

.chip-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.chip-action:hover {
  background: var(--surface-3);
  color: var(--text);
}

.chip-action.is-ok:hover {
  background: var(--matched);
  color: #fff;
}

.chip-action.is-no:hover {
  background: var(--error);
  color: #fff;
}

.chip-action .icon {
  width: 14px;
  height: 14px;
}

.chip-action-text {
  font-weight: 600;
}

.chip-static {
  padding: 3px 10px;
  font-weight: 600;
}

.chip-noreceipt {
  border-color: transparent;
  background: var(--noreceipt-bg);
  color: var(--noreceipt);
}

.hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.hint .icon {
  width: 16px;
  height: 16px;
}

.totals-card h2 {
  margin: 0 0 12px;
}

.totals-table,
.vat-table,
.check-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.totals-table th,
.totals-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.totals-table th + th,
.totals-table td + td {
  padding-left: 16px;
}

.totals-table thead th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.totals-table tfoot th,
.totals-table tfoot td {
  padding-top: 12px;
  border-bottom: 0;
  font-weight: 700;
}

/* ---------------------------------------------------------------- receipts */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-box {
  position: relative;
  flex: 0 1 340px;
  min-width: 220px;
}

.search-box .icon {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-box .input {
  padding-left: 34px;
}

.result-info {
  margin: -12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.result-info:empty {
  display: none;
}

.rc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rc-item {
  min-width: 0;
}

.rc-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rc-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.rc-card.is-error {
  border-color: var(--error-border);
}

.rc-card .thumb-lg {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.rc-body {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 6px;
  padding: 12px 14px 14px;
}

.rc-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.rc-merchant {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-merchant.is-muted {
  color: var(--muted);
  font-weight: 600;
}

.rc-warn {
  color: var(--open);
}

.rc-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-2);
  font-size: 14px;
}

.rc-amount {
  color: var(--text);
  font-weight: 700;
}

.rc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rc-assign {
  min-width: 0;
  font-size: 13px;
}

.rc-assigned {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--matched);
}

.rc-assigned .icon {
  width: 14px;
  height: 14px;
}

.rc-unassigned {
  color: var(--open);
  font-weight: 600;
}

.rc-error {
  color: var(--error);
  font-weight: 600;
}

.rc-retry {
  color: var(--open);
  font-weight: 600;
}

.rc-foot {
  color: var(--muted);
  font-size: 12px;
}

.thumb {
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--muted);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.thumb-sm {
  width: 56px;
  height: 56px;
}

.thumb-md {
  width: 80px;
  height: 80px;
}

.thumb-lg {
  width: 100%;
  height: 150px;
}

.thumb-pdf {
  align-content: center;
  gap: 2px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
}

.thumb-pdf .icon {
  width: 30px;
  height: 30px;
  color: var(--error);
}

.thumb-sm.thumb-pdf .icon {
  width: 20px;
  height: 20px;
}

.thumb-pdf span {
  color: var(--error);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

/* receipt detail */

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

.rd-preview {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rd-img {
  display: block;
  width: 100%;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  object-fit: contain;
}

.rd-frame {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.rd-preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rd-preview-bar .ellipsis {
  flex: 1 1 120px;
}

.rd-side {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.rd-status {
  display: grid;
  gap: 10px;
}

.rd-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rd-retry:empty,
.state-retry:empty {
  display: none;
}

/* receipt form locked while an extraction is pending (receipt_update answers 409) */
.rd-lock-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.rd-lock-hint .icon {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--accent-fg);
}

.rd-section.is-locked .field-label {
  color: var(--muted);
}

.state-retry {
  width: 100%;
  max-width: 62ch;
  text-align: left;
}

.rd-section h3,
.picker-section h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.link-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.link-main {
  display: flex;
  flex: 1 1 240px;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.link-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.link-text a {
  font-weight: 600;
}

.link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vat-table {
  margin-top: 14px;
  font-size: 13px;
}

.vat-table caption {
  padding-bottom: 6px;
  color: var(--text-2);
  font-weight: 600;
  text-align: left;
}

.vat-table th,
.vat-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.vat-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* candidate picker */

.picker {
  display: grid;
  gap: 22px;
}

.tx-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.tx-summary-date {
  color: var(--muted);
  font-size: 14px;
}

.tx-summary-merchant {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tx-summary-amount {
  font-weight: 700;
}

.picker-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.picker-section-head h3 {
  margin: 0;
}

.picker-section-head .input {
  max-width: 300px;
}

.pick-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.pick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pick-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.pick-thumb {
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  cursor: zoom-in;
}

.pick-info {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.pick-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.pick-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 4px;
  color: var(--text-2);
  font-size: 13px;
}

.pick-reason {
  color: var(--muted);
  font-size: 12px;
}

.pick-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
}

.preview {
  display: grid;
  place-items: center;
}

.preview-note {
  justify-self: stretch;
  margin: 0 0 12px;
  color: var(--text-2);
  font-size: 14px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.preview-img {
  max-height: 75vh;
  border-radius: var(--radius);
  object-fit: contain;
}

.preview-frame {
  width: 100%;
  height: 75vh;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
}

/* report dialog */

.report-options {
  display: grid;
  gap: 4px;
}

.report-progress {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.report-result {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.report-result:empty {
  display: none;
}

/* ---------------------------------------------------------------- settings */

.page-settings .page-head,
.jump-nav,
.settings-grid {
  max-width: 880px;
}

.jump-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -8px;
}

.jump-link {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.jump-link:hover {
  border-color: var(--accent-fg);
  color: var(--accent-fg);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

.settings-card {
  display: grid;
  gap: 16px;
  scroll-margin-top: 84px;
}

.settings-card h2 {
  margin: 0;
}

.sub-heading {
  margin: 4px 0 0;
}

.steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 22px;
  color: var(--text-2);
  font-size: 14px;
}

.cat-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-item .input {
  flex: 1;
  min-width: 0;
}

.cat-pos {
  flex: none;
  width: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.cat-actions {
  display: flex;
  flex: none;
  gap: 2px;
}

.cat-add {
  display: flex;
  gap: 8px;
}

.cat-add .input {
  flex: 1;
}

.token-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.token-panel {
  display: grid;
  gap: 14px;
}

.token-panel:empty,
.ai-test-result:empty {
  display: none;
}

.check-table th,
.check-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: break-word;
}

.check-table td:not(.check-state) {
  padding-right: 8px;
}

.check-table tr:last-child th,
.check-table tr:last-child td {
  border-bottom: 0;
}

.check-table th {
  padding-right: 16px;
  font-weight: 600;
}

.check-table td {
  color: var(--text-2);
}

.check-state {
  width: 36px;
  text-align: right !important;
}

.check-dot {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.check-dot .icon {
  width: 13px;
  height: 13px;
  stroke-width: 3;
}

.check-dot.is-ok {
  background: var(--matched-bg);
  color: var(--matched);
}

.check-dot.is-warn {
  background: var(--open-bg);
  color: var(--open);
}

.check-dot.is-error {
  background: var(--error-bg);
  color: var(--error);
}

/* ---------------------------------------------------------------- login */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--accent-soft), var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 22px;
}

.login-card > .muted {
  margin: 4px 0 24px;
}

.login-card .empty {
  padding: 8px 0 0;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 18px;
  font-weight: 700;
}

.login-brand .brand-mark {
  width: 36px;
  height: 36px;
}

.login-form {
  display: grid;
  gap: 16px;
}

/* ---------------------------------------------------------------- overlays: modal, menu, toasts, tray, drop */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 17, 27, 0.5);
  animation: fade-in 0.15s ease;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  outline: none;
  animation: pop-in 0.18s ease;
}

.modal-sm {
  max-width: 480px;
}

.modal-md {
  max-width: 620px;
}

.modal-lg {
  max-width: 840px;
}

.modal-xl {
  max-width: 1180px;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 14px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-body > p:first-child {
  margin-top: 0;
}

.modal-body > p:last-child {
  margin-bottom: 0;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface-2);
}

.footer-start {
  margin-right: auto;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

.menu {
  position: fixed;
  z-index: 80;
  min-width: 250px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  outline: none;
  background: var(--surface-3);
}

.menu-item .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.menu-item.is-danger,
.menu-item.is-danger .icon {
  color: var(--error);
}

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

.menu-sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  border-left: 4px solid var(--accent-fg);
  border-radius: var(--radius);
  background: var(--toast-bg);
  box-shadow: var(--shadow-lg);
  color: var(--toast-fg);
  font-size: 14px;
  pointer-events: auto;
  animation: pop-in 0.2s ease;
  transition: opacity 0.18s, transform 0.18s;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(4px);
}

.toast-success {
  border-left-color: #4cc38a;
}

.toast-error {
  border-left-color: #f07575;
}

.toast-warning {
  border-left-color: #f0b44c;
}

.toast-icon {
  margin-top: 1px;
  color: #8db0f6;
}

.toast-success .toast-icon {
  color: #4cc38a;
}

.toast-error .toast-icon {
  color: #f07575;
}

.toast-warning .toast-icon {
  color: #f0b44c;
}

.toast-msg {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-action {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: #8db0f6;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.toast-action:hover {
  color: #b3cbfa;
}

.toast-close {
  width: 24px;
  height: 24px;
  margin: -2px 0;
  color: inherit;
  opacity: 0.7;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  opacity: 1;
}

.tray {
  position: fixed;
  left: 24px;
  bottom: 24px;
  /* Below the modal backdrop (60): the tray must not cover dialog buttons. */
  z-index: 55;
  width: min(400px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.tray-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-bottom: 1px solid var(--border);
}

.tray.is-collapsed .tray-head {
  border-bottom: 0;
}

.tray.is-collapsed .tray-list {
  display: none;
}

.tray-title {
  font-size: 14px;
  font-weight: 700;
}

.tray-summary {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.tray-actions {
  display: flex;
  gap: 2px;
}

.tray-list {
  max-height: min(320px, 45vh);
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  list-style: none;
}

.tray-item {
  display: flex;
  gap: 10px;
  padding: 8px 16px;
}

.tray-icon {
  margin-top: 2px;
  color: var(--muted);
}

.tray-item.is-done .tray-icon {
  color: var(--matched);
}

.tray-item.is-error .tray-icon {
  color: var(--error);
}

.tray-body {
  display: grid;
  flex: 1;
  gap: 4px;
  min-width: 0;
}

.tray-name {
  display: flex;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}

.tray-size {
  flex: none;
  margin-left: auto;
  color: var(--muted);
  font-weight: 400;
}

.tray-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tray-progress .progress {
  flex: 1;
}

.tray-state {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.tray-state.is-ok {
  color: var(--matched);
}

.tray-state.is-error {
  color: var(--error);
  white-space: normal;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 32px 16px;
  background: rgba(36, 87, 197, 0.06);
  box-shadow: inset 0 0 0 3px var(--accent-fg);
  pointer-events: none;
}

.drop-overlay-msg {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-weight: 600;
}

/* ---------------------------------------------------------------- responsive */

@media (pointer: coarse), (max-width: 720px) {
  .camera-btn {
    display: inline-flex;
  }
}

@media (pointer: coarse) {
  .only-fine-pointer {
    display: none !important;
  }
}

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

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

  .rd-preview {
    position: static;
  }

  .rd-frame {
    height: 55vh;
  }

  .rd-img {
    max-height: 55vh;
  }

  /* Transactions table becomes a list of cards. */
  .table-card {
    overflow: visible;
  }

  .tx-table,
  .tx-table tbody {
    display: block;
  }

  .tx-table thead {
    display: none;
  }

  .tx-table tr.tx-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "merchant amount actions"
      "details details details"
      "date status status"
      "category category category"
      "receipt receipt receipt";
    gap: 6px 12px;
    padding: 14px 12px 14px 16px;
    border-bottom: 1px solid var(--border);
  }

  .tx-table tr.tx-row:last-child {
    border-bottom: 0;
  }

  .tx-table tr.tx-row.is-open {
    box-shadow: inset 3px 0 0 var(--open);
  }

  .tx-row.is-open > td:first-child {
    box-shadow: none;
  }

  .tx-table td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  /* Merchant name next to the amount, notes and reasons below across the full card width. */
  .tx-table .c-merchant {
    display: contents;
  }

  .tx-table .tx-merchant {
    grid-area: merchant;
    min-width: 0;
  }

  .tx-table .tx-details {
    grid-area: details;
    min-width: 0;
    margin-top: -4px;
  }

  .tx-table .c-amount {
    grid-area: amount;
  }

  .tx-table .c-actions {
    grid-area: actions;
    margin: -6px -6px 0 0;
  }

  .tx-table .c-date {
    grid-area: date;
    align-self: center;
    color: var(--muted);
    font-size: 13px;
  }

  .tx-table .c-date .tx-sub {
    display: inline;
    margin-left: 6px;
  }

  .tx-table .c-status {
    grid-area: status;
    justify-self: end;
  }

  .tx-table .c-category {
    grid-area: category;
    max-width: 360px;
  }

  .tx-table .c-receipt {
    grid-area: receipt;
  }

  .tx-table .c-receipt .chips:empty {
    display: none;
  }

  .tx-table tr.tx-empty,
  .tx-table tr.tx-empty td {
    display: block;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }

  h1 {
    font-size: 22px;
  }

  .topbar-inner {
    gap: 12px;
    height: 56px;
    padding: 0 16px;
  }

  .mainnav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    justify-content: space-around;
    gap: 0;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  .nav-link {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    font-size: 12px;
  }

  .main {
    padding: 20px 16px calc(96px + env(safe-area-inset-bottom));
  }

  .user-name,
  .hide-narrow,
  .job-label {
    display: none;
  }

  .card {
    padding: 16px;
  }

  .table-card {
    padding: 0;
  }

  .upload-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .dropzone {
    padding: 20px 16px;
  }

  /* Phones: compact upload zones and the statement status before the receipt inbox. */
  .page-dashboard {
    gap: 16px;
  }

  .page-dashboard > .inbox {
    order: 1;
  }

  .upload-grid .dropzone {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px 12px;
    padding: 14px;
    text-align: left;
  }

  .upload-grid .dropzone-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .upload-grid .dropzone-title {
    margin: 0;
    font-size: 15px;
  }

  .upload-grid .dropzone-hint {
    display: none;
  }

  .upload-grid .dropzone-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
    margin-top: 0;
  }

  .upload-grid .dropzone-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-end {
    margin-left: 0;
  }

  .cta {
    align-items: flex-start;
  }

  .filter-bar .search-box {
    flex: 1 1 100%;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toasts {
    top: 64px;
    right: 8px;
    bottom: auto;
    left: 8px;
    width: auto;
  }

  .tray {
    right: 8px;
    bottom: calc(68px + env(safe-area-inset-bottom));
    left: 8px;
    width: auto;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 16px 16px 0 0;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-head {
    padding: 12px 12px 12px 16px;
  }

  .modal-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-radius: 0;
  }

  .modal-foot .btn {
    flex: 1 1 auto;
  }

  .footer-start {
    margin-right: 0;
  }

  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .kv dd {
    margin-bottom: 8px;
  }

  .drop-overlay {
    align-items: center;
  }

  .drop-overlay-msg {
    border-radius: var(--radius-lg);
  }
}

@media (max-width: 420px) {
  .kpis {
    gap: 8px;
  }

  .kpi {
    padding: 10px 12px;
  }

  .kpi-value {
    font-size: 18px;
  }

  .brand-name {
    font-size: 16px;
  }

  .job-indicator {
    padding: 3px 4px 3px 8px;
  }

  .tabs {
    width: 100%;
  }

  .chip-text {
    max-width: 130px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .spinner,
  .btn.is-busy::after {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}
