/* ============================================================
   Reiseabrechnung – Stylesheet
   Modernes, aufgeräumtes UI, responsiv (Mobil & Desktop).
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --muted: #9ca3af;

  --green: #059669;
  --green-50: #ecfdf5;
  --red: #dc2626;
  --red-50: #fef2f2;
  --amber: #d97706;

  --cat-fahrt: #2563eb;
  --cat-uebernachtung: #7c3aed;
  --cat-verpflegung: #ea580c;
  --cat-sonstiges: #0891b2;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --ff: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;

  --container: 880px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--ff);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
p { margin: 0; }

a { color: inherit; text-decoration: none; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: clamp(16px, 4vw, 28px);
  padding-right: clamp(16px, 4vw, 28px);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

/* -------------------- Header -------------------- */
.app-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  box-shadow: var(--shadow);
}

/* -------------------- Buttons -------------------- */
.btn {
  --bg-btn: var(--primary);
  --fg-btn: #fff;
  appearance: none;
  border: 1px solid transparent;
  background: var(--bg-btn);
  color: var(--fg-btn);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s ease, background 0.15s ease, transform 0.05s ease,
    box-shadow 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--primary-100); outline-offset: 2px; }

.btn--primary { background: var(--primary); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--primary-600); filter: none; }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--surface-2); filter: none; color: var(--text); }

.btn--outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn--outline:hover { background: var(--surface-2); filter: none; }

.btn--danger { background: var(--surface); color: var(--red); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn--danger:hover { background: var(--red-50); filter: none; border-color: #fecaca; }

.btn--icon { padding: 9px; border-radius: 10px; }
.btn--sm { padding: 7px 12px; font-size: 0.875rem; }
.btn--block { width: 100%; }

.icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  padding: 7px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn--danger:hover { background: var(--red-50); color: var(--red); }
.icon-btn:focus-visible { outline: 2px solid var(--primary-100); outline-offset: 1px; }

/* Auf Touch-Geräten ausreichend große Tap-Ziele (>= 44px) */
@media (pointer: coarse) {
  .icon-btn, .btn--icon { min-width: 44px; min-height: 44px; }
}

/* -------------------- Page header / sections -------------------- */
main { flex: 1 0 auto; padding-top: 28px; padding-bottom: 56px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head__titles h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
.page-head__titles p { color: var(--text-3); margin-top: 4px; font-size: 0.95rem; }

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 0.9rem;
  margin-bottom: 14px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px 6px 6px;
  border-radius: 8px;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
.breadcrumb:hover { background: var(--surface); color: var(--text); }

/* -------------------- Summary / Overview -------------------- */
.overview {
  /* dunklere Verlaufsstufen -> ausreichender Kontrast für weiße Labels (>= 4,5:1) */
  background: linear-gradient(135deg, var(--primary-600), var(--primary));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.overview__label { opacity: 0.92; font-size: 0.9rem; font-weight: 600; }
.overview__value { font-size: clamp(1.8rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.overview__meta { text-align: right; opacity: 0.9; font-size: 0.9rem; }
.overview__meta strong { font-size: 1.2rem; display: block; }

/* -------------------- Cards / Trip list -------------------- */
.card-grid { display: grid; gap: 14px; }

.trip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}
.trip-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.trip-card:focus-visible { outline: 3px solid var(--primary-100); outline-offset: 2px; }

.trip-card__body { flex: 1; min-width: 0; }
.trip-card__title {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trip-card__meta {
  color: var(--text-3);
  font-size: 0.9rem;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.trip-card__meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }
.trip-card__amount { text-align: right; }
.trip-card__amount b { font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
.trip-card__amount span { display: block; color: var(--text-3); font-size: 0.8rem; }
.trip-card__chev { color: var(--muted); flex-shrink: 0; }

/* -------------------- Empty state -------------------- */
.empty {
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty__icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  background: var(--primary-50);
  color: var(--primary);
  border-radius: 18px;
}
.empty h3 { font-size: 1.2rem; }
.empty p { color: var(--text-3); margin: 8px auto 20px; max-width: 360px; }

/* -------------------- Trip detail -------------------- */
.detail-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.detail-head__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.detail-head h1 { font-size: clamp(1.35rem, 4vw, 1.7rem); }
.detail-head__sub { color: var(--text-3); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.detail-head__actions { display: flex; gap: 6px; flex-shrink: 0; }
.meta-item { display: inline-flex; align-items: center; gap: 5px; }
.meta-item svg { flex-shrink: 0; opacity: 0.8; }
.trip-card__meta .ic { display: inline-flex; align-items: center; }
.trip-card__meta .ic svg { opacity: 0.7; }
@media (max-width: 380px) { .hide-xs { display: none; } }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat__label { color: var(--text-3); font-size: 0.82rem; font-weight: 600; }
.stat__value { font-size: 1.3rem; font-weight: 800; margin-top: 2px; letter-spacing: -0.01em; }
.stat--total { background: var(--primary-50); border-color: var(--primary-100); }
.stat--total .stat__value { color: var(--primary-600); }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}
.section-title h2 { font-size: 1.15rem; }

/* -------------------- Expense list -------------------- */
.expense-list { display: flex; flex-direction: column; gap: 10px; }
.expense {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 13px;
}
.expense__icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.cat-fahrt { background: var(--cat-fahrt); }
.cat-uebernachtung { background: var(--cat-uebernachtung); }
.cat-verpflegung { background: var(--cat-verpflegung); }
.cat-sonstiges { background: var(--cat-sonstiges); }

.expense__body { flex: 1; min-width: 0; }
.expense__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense__meta { color: var(--text-3); font-size: 0.85rem; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.tag--auto { background: var(--primary-50); color: var(--primary-600); border-color: var(--primary-100); }
.expense__amount { font-weight: 800; white-space: nowrap; }
.expense__actions { display: flex; gap: 2px; flex-shrink: 0; }

/* Auto-Verpflegung Karte */
.auto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.auto-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auto-card__title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.auto-card__detail { color: var(--text-3); font-size: 0.875rem; margin-top: 10px; line-height: 1.6; }
.auto-card__detail strong { color: var(--text-2); }

/* -------------------- Switch -------------------- */
.switch { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  width: 46px; height: 27px;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background 0.2s ease;
  position: relative;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(19px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--primary-100); outline-offset: 2px; }

/* -------------------- Forms / Modal -------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 150;
  padding: 0;
  animation: fade 0.15s ease;
}
@media (min-width: 600px) { .modal-overlay { align-items: center; padding: 24px; } }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
@media (min-width: 600px) { .modal { border-radius: var(--radius-lg); animation: pop 0.16s ease; } }

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal__head h2 { font-size: 1.2rem; }
.modal__body { padding: 20px; }
.modal__foot {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0.6; } }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; color: var(--text-2); }
.field__hint { color: var(--text-3); font-size: 0.82rem; margin-top: 6px; }

.input, .select, .textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.textarea { min-height: 78px; resize: vertical; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}
.input--invalid { border-color: var(--red); }
.input-amount { position: relative; }
.input-amount .input { padding-right: 38px; }
.input-amount__suffix {
  position: absolute;
  right: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-weight: 600;
  pointer-events: none;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* Kategorie-Auswahl als Segmente */
.cat-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 480px) { .cat-picker { grid-template-columns: repeat(2, 1fr); } }
.cat-option {
  position: relative;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
}
.cat-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.cat-option__icon { display: block; margin: 0 auto 5px; width: 22px; height: 22px; }
.cat-option:hover { background: var(--surface-2); }
.cat-option:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary-600); }
.cat-option:has(input:focus-visible) { outline: 3px solid var(--primary-100); outline-offset: 2px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.checkbox-row span { font-size: 0.92rem; font-weight: 500; }

.computed-amount {
  background: var(--green-50);
  border: 1px solid #a7f3d0;
  color: var(--green);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.computed-amount span:first-child { font-weight: 600; color: var(--text-2); }

.hidden { display: none !important; }

/* -------------------- Toast -------------------- */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}
.toast {
  background: #111827;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.2s ease;
}
.toast--success { background: #065f46; }
.toast--error { background: #991b1b; }
.toast.removing { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(12px); opacity: 0; } }

/* -------------------- Footer -------------------- */
.app-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: var(--text-3);
  font-size: 0.82rem;
  text-align: center;
}

/* -------------------- Print / PDF -------------------- */
#printRoot { display: none; }

@media print {
  :root { --bg: #fff; }
  body { background: #fff; }
  .app-header, .app-footer, #modalRoot, .toast-root, main, .skip-link { display: none !important; }
  #printRoot { display: block; }
}

.print-doc {
  color: #111;
  font-size: 12px;
  line-height: 1.5;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px;
}
.print-doc__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #111;
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.print-doc__header h1 { font-size: 22px; margin-bottom: 4px; }
.print-doc__brand { text-align: right; font-size: 11px; color: #555; }
.print-doc__brand strong { font-size: 14px; color: #111; display: block; }
.print-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; margin-bottom: 20px; font-size: 12px; }
.print-meta div { padding: 4px 0; border-bottom: 1px solid #eee; }
.print-meta span { color: #666; display: inline-block; min-width: 96px; }
.print-doc h2 { font-size: 14px; margin: 22px 0 8px; }
.print-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.print-table th, .print-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #ddd; vertical-align: top; }
.print-table th { background: #f3f4f6; font-weight: 700; border-bottom: 1.5px solid #999; }
.print-table td.num, .print-table th.num { text-align: right; white-space: nowrap; }
.print-table tfoot td { font-weight: 700; border-top: 2px solid #111; border-bottom: none; font-size: 13px; padding-top: 10px; }
.print-cat-summary { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 8px; }
.print-cat-summary td { padding: 5px 8px; border-bottom: 1px solid #eee; }
.print-cat-summary td.num { text-align: right; }
.print-doc__footer { margin-top: 40px; font-size: 10px; color: #777; border-top: 1px solid #ddd; padding-top: 10px; }
.print-sign { margin-top: 48px; display: flex; gap: 48px; }
.print-sign div { flex: 1; border-top: 1px solid #111; padding-top: 6px; font-size: 10.5px; color: #555; }

@page { margin: 16mm; }
