:root {
  --bg: #f4f4f2;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --accent: #b3140f;
  --line: #e2e2df;
  --ok: #1a7f37;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; background: #1d1d1f; color: #fff;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.brand-logo { height: 14px; opacity: .92; }
main { max-width: 1080px; margin: 24px auto; padding: 0 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 24px; margin-bottom: 20px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13px; }
.note {
  background: #fff8e6; border: 1px solid #f0dfa8; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; margin-bottom: 12px;
}
.big-note { font-size: 14px; padding: 12px 14px; margin: 14px 0 0; }
.header-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
}
.header-grid label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.modus-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.modus-title { font-size: 12px; color: var(--muted); font-weight: 600; }
.modus-row .radio { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.modus-row .radio input { accent-color: var(--accent); }
#iban-label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; flex-basis: 100%; max-width: 340px; }
input, .cell-input {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid #b3140f33; border-color: var(--accent); }

.gate-card { max-width: 460px; margin: 10vh auto 0; }
.gate-row { display: flex; gap: 10px; margin-top: 10px; }
.gate-row input { flex: 1; }
.gate-error { color: var(--accent); font-size: 13px; }
input[readonly] { background: #f1f1ef; color: var(--muted); cursor: default; }

#dropzone {
  border: 2px dashed #c9c9c4; border-radius: 10px; padding: 28px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
}
#dropzone.dragover { border-color: var(--accent); background: #fdf1f0; }
#dropzone p { margin: 4px 0; }

#upload-status { margin-top: 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#upload-errors { color: var(--accent); font-size: 13px; margin-top: 8px; white-space: pre-line; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.nr { font-weight: 700; color: var(--muted); width: 36px; }
.thumb {
  width: 52px; height: 68px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line); cursor: zoom-in; background: #eee; display: block;
}
.thumb-badge { font-size: 10px; color: var(--muted); text-align: center; display: block; }
.cell-input { width: 100%; }
.cell-input.num { text-align: right; width: 96px; }
.cell-input.date { width: 140px; }
tr.warn { background: #fff8e6; }
.hinweis { font-size: 12px; color: #9a6700; margin-top: 3px; }
.row-actions { white-space: nowrap; }
.row-actions button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer;
  padding: 4px 8px; font-size: 12px; margin-left: 4px; color: var(--ink);
}
.row-actions button:hover { border-color: var(--accent); color: var(--accent); }
tfoot td { font-weight: 700; border-bottom: none; padding-top: 12px; }
tfoot .sum-label { text-align: right; }
#sum-netto, #sum-brutto { text-align: right; width: 96px; padding-right: 17px; }

button.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 11px 20px; font: inherit; font-weight: 600; cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }
button.primary:disabled { background: #c9c9c4; cursor: default; }
#export-status { margin-left: 12px; font-size: 14px; }
#export-links { margin-top: 14px; display: flex; gap: 12px; flex-wrap: wrap; }
#export-links a {
  display: inline-block; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--ink); font-weight: 600; background: #fafaf8;
}
#export-links a:hover { border-color: var(--ok); color: var(--ok); }

#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex;
  align-items: center; justify-content: center; cursor: zoom-out; z-index: 50;
}
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }
footer { text-align: center; padding: 16px 0 32px; }
