/* ================= BelegSafe – Kontoauszug-Ästhetik =================
   Palette:
   --paper  #F1F4F2  kühles Papier
   --card   #FFFFFF
   --ink    #17251F  Tannen-Schwarz
   --fir    #1E3D2F  Kopfleiste
   --line   #D9E1DB
   --red    #BE3B32  Stempelrot (offen / Soll)
   --green  #2E7B52  Belegt / Haben
==================================================================== */

:root {
  --paper: #f1f4f2;
  --card: #ffffff;
  --ink: #17251f;
  --muted: #64726a;
  --fir: #1e3d2f;
  --fir-light: #e7eeea;
  --line: #d9e1db;
  --red: #be3b32;
  --green: #2e7b52;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;
  --sans: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.error { color: var(--red); font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Marke ---------- */
.brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 18px;
}
.brand span { color: var(--green); }
.topbar .brand span { color: #8fd4ae; }

/* ---------- Vollbild-Karten (Setup / Login / Sperre) ---------- */
.gate, .lock {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper);
  padding: 24px;
  z-index: 40;
}
.lock { background: rgba(23, 37, 31, 0.55); backdrop-filter: blur(10px); z-index: 60; }
.gate-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--fir);
  max-width: 400px; width: 100%;
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(23, 37, 31, 0.10);
}
.gate-card h1 { font-size: 22px; margin: 18px 0 8px; }
.gate-card p { margin: 8px 0 18px; color: var(--muted); }
.gate-card .hint { font-size: 12.5px; margin-top: 14px; }
.lock-icon { font-size: 40px; color: var(--fir); }

/* ---------- Buttons ---------- */
button { font: inherit; cursor: pointer; }
.primary {
  background: var(--fir); color: #fff;
  border: none; padding: 11px 22px;
  font-weight: 600; letter-spacing: 0.01em;
  width: 100%;
}
.primary:hover { background: #2a5240; }
.ghost {
  background: transparent; color: inherit;
  border: 1px solid currentColor;
  padding: 5px 12px; font-size: 13px;
  opacity: 0.85;
}
.ghost:hover { opacity: 1; }
.link {
  background: none; border: none;
  color: var(--fir); text-decoration: underline;
  text-underline-offset: 3px;
  padding: 2px 4px; font-size: 13px;
  display: inline-block;
}
.link.strong { font-weight: 700; text-decoration: none; border: 1px dashed var(--fir); padding: 3px 8px; }
.link.strong:hover { background: var(--fir-light); }
.link.danger { color: var(--red); }
button:focus-visible, .filebtn:focus-within, a:focus-visible {
  outline: 2px solid var(--green); outline-offset: 2px;
}

/* ---------- Kopfleiste ---------- */
.topbar {
  background: var(--fir); color: #f2f7f4;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  position: sticky; top: 0; z-index: 10;
}
.session { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.keychip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); }
.keydot { width: 8px; height: 8px; border-radius: 50%; background: #59c98d; box-shadow: 0 0 6px #59c98d; }
.idle { font-family: var(--mono); opacity: 0.85; }

/* ---------- Hauptbereich ---------- */
main { max-width: 1060px; margin: 0 auto; padding: 26px 22px 80px; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.import-box { display: flex; align-items: center; gap: 12px; }
.filebtn {
  background: var(--card); border: 1px solid var(--fir); color: var(--fir);
  padding: 9px 16px; font-weight: 600; cursor: pointer; display: inline-block;
}
.filebtn:hover { background: var(--fir-light); }
.filebtn input { display: none; }

.filters { display: flex; border: 1px solid var(--line); background: var(--card); }
.filters button {
  border: none; background: none; padding: 8px 16px; font-size: 13.5px; color: var(--muted);
}
.filters button.active { background: var(--fir); color: #fff; }

.progress-line { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.progress { flex: 1; height: 6px; background: var(--line); }
#progress-fill { height: 100%; width: 0; background: var(--green); transition: width 0.4s ease; }

.empty { text-align: center; padding: 70px 20px; border: 1px dashed var(--line); background: var(--card); }

/* ---------- Tabelle (Kontoauszug) ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 10px 14px; border-bottom: 2px solid var(--ink);
  background: var(--card); position: sticky; top: 54px;
}
tbody td { padding: 12px 14px; border-bottom: 1px dashed var(--line); vertical-align: top; }
tbody tr:hover { background: #f7faf8; }
.c-date { width: 100px; white-space: nowrap; font-size: 13.5px; }
.c-amount { width: 130px; text-align: right; white-space: nowrap; }
.c-status { width: 110px; }
.c-actions { width: 220px; }
th.c-amount { text-align: right; }
.party { font-weight: 600; font-size: 14px; }
.desc { color: var(--muted); font-size: 13px; word-break: break-word; }
.neg { color: var(--red); }
.pos { color: var(--green); }

/* Stempel – das Erkennungszeichen der App */
.stamp {
  display: inline-block;
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  padding: 3px 8px; border: 2px solid currentColor; border-radius: 2px;
  transform: rotate(-3deg);
}
.stamp.open { color: var(--red); }
.stamp.done { color: var(--green); }
.stamp.none_needed { color: var(--muted); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(23, 37, 31, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--card); border-top: 4px solid var(--fir);
  max-width: 760px; width: 100%; max-height: 90vh; overflow: auto;
  padding: 26px 28px;
}
.modal-card h2 { margin: 0 0 4px; font-size: 19px; }
.map-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin: 18px 0;
}
.map-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.map-grid select { font: inherit; padding: 7px 9px; border: 1px solid var(--line); background: var(--paper); }
.preview-wrap { overflow-x: auto; border: 1px solid var(--line); margin-bottom: 16px; }
#map-preview { border: none; }
#map-preview th, #map-preview td {
  font-size: 12px; padding: 6px 10px; white-space: nowrap; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line);
}
#map-preview th { position: static; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions .primary { width: auto; }
.modal-actions .ghost { color: var(--muted); }

/* ---------- YubiKey-Aufforderung ---------- */
.touch {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(23, 37, 31, 0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.touch-card { text-align: center; color: #fff; }
.touch-card p { font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }
.pulse {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid #8fd4ae;
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(143, 212, 174, 0.55); }
  100% { box-shadow: 0 0 0 26px rgba(143, 212, 174, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  #progress-fill { transition: none; }
}

/* ---------- Sperre: Inhalt unkenntlich ---------- */
body.is-locked #view-app { filter: blur(14px); pointer-events: none; user-select: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; font-size: 14px;
  z-index: 80; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.toast-error { background: var(--red); }

/* ---------- Mobil ---------- */
@media (max-width: 720px) {
  .c-actions { width: auto; }
  thead th { top: 0; position: static; }
  .map-grid { grid-template-columns: 1fr; }
  .session .idle { display: none; }
}
