/* Lokale Schriftart - kein externer CDN, keine Datenabfluesse */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/inter-700.woff2") format("woff2");
}

:root {
  --bg: #ffdb8d;
  --bg-grad: radial-gradient(1200px 600px at 20% -10%, #ffe7b0 0%, #ffdb8d 60%);
  --card: #ffffff;
  --ink: #3b2f14;
  --muted: #7a6a45;
  --line: #f0e2c4;
  --brand: #ffb81f;
  --brand-ink: #9a6a00;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(122, 92, 20, 0.22);
}

* { box-sizing: border-box; }

/* hidden-Attribut muss auch gegen display:flex/grid der Komponenten gewinnen */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg-grad), var(--bg);
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}

.shell { width: 100%; max-width: 720px; }
.card.wide, .shell:has(.wide) { max-width: 980px; }

.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink); margin-bottom: 18px;
}
.brand-logo {
  width: 52px; height: 52px; object-fit: contain;
  background: #fff; border-radius: 14px; padding: 5px;
  box-shadow: 0 4px 14px rgba(122, 92, 20, 0.18);
}
.brand-text { font-weight: 700; font-size: 1.1rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 420px; margin: 0 auto; }
.card.wide { max-width: 980px; }
.card.center { text-align: center; }

h1 { font-size: 1.5rem; margin: 0 0 8px; }
h2 { font-size: 1.05rem; margin: 28px 0 12px; color: var(--brand-ink); }
.lead { color: var(--muted); margin: 0 0 20px; line-height: 1.5; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px;
}
.form.grid button { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .85rem; font-weight: 600; color: #334155; }
.hint { font-size: .78rem; color: var(--muted); }

input, select {
  font: inherit; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #f8fafc; color: var(--ink);
}
input:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 184, 31, 0.25); background: #fff;
}

.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0;
  padding: 12px 18px; border-radius: 10px; color: #3b2f14;
  background: var(--brand);
  transition: transform .05s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: #fdf3dd; color: var(--brand-ink); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-small { padding: 7px 11px; font-size: .82rem; border-radius: 8px; }
.inline { display: inline; margin: 0; }

.alert {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 16px;
  background: #f1f5f9; color: #334155; font-size: .9rem;
}
.alert-error { background: #fef2f2; color: var(--danger); }
.alert-success { background: #ecfdf5; color: #065f46; }
.linkbox {
  display: block; margin-top: 8px; padding: 10px; background: #fff;
  border: 1px dashed var(--ok); border-radius: 8px; word-break: break-all;
  font-size: .85rem;
}

.check, .cross {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center; font-size: 2rem; font-weight: 700; color: #fff;
}
.check { background: var(--ok); }
.cross { background: var(--danger); }
.filename {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f1f5f9; padding: 10px; border-radius: 8px; word-break: break-all;
  margin: 16px 0;
}

.table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-bottom: 8px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: #f1f5f9; color: #475569; }
.tag-on { background: #dcfce7; color: #166534; }
.tag-off { background: #fee2e2; color: var(--danger); }

.row-between { display: flex; align-items: center; justify-content: space-between; }
.foot { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 18px; }

/* --- Upload-Formular: Hinweistext, Monat/Jahr, Kamera, Historie --- */
.page-title { text-align: center; }
.cat-hint { background: #fff7e6; color: #7a5c14; border: 1px solid #ffe2a3; }
.month-year-row { display: flex; gap: 10px; }
.month-year-row select { flex: 1.2; }
.month-year-row input { flex: 1; }
.history-card { margin-top: 18px; }
.history-title { margin-top: 0; }
.nowrap { white-space: nowrap; }

/* Mehrere Datei-Felder (z. B. 4 Rückenfotos) */
.file-slot {
  background: #fcf7ea; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-top: 8px;
}
.file-slot-label { font-size: .85rem; font-weight: 600; color: #5a4a1f; }

/* Ungültige Felder rot markieren: sofort nach Verlassen des Felds ... */
input:user-invalid, select:user-invalid, textarea:user-invalid {
  border: 2px solid var(--danger);
  background: #fef2f2;
}
/* ... und alle beim Absende-Versuch (Klasse setzt upload.js) */
.show-invalid input:invalid,
.show-invalid select:invalid,
.show-invalid textarea:invalid {
  border: 2px solid var(--danger);
  background: #fef2f2;
}

/* --- Kategorie-Verwaltung --- */
.nav-actions { display: flex; gap: 8px; }
textarea {
  font: inherit; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #f8fafc; color: var(--ink); resize: vertical;
}
textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 184, 31, 0.25); background: #fff;
}
.cat-block {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-top: 18px; background: #fcfdfe;
}
.cat-block h2 { margin-top: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-block h3.sub { font-size: .9rem; color: #334155; margin: 18px 0 8px; }
.details { margin: 10px 0; }
.details > summary {
  cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--brand-ink);
  padding: 6px 0; user-select: none;
}
.details[open] > summary { margin-bottom: 8px; }
.link-summary { font-weight: 500; }
.field.checkbox { flex-direction: row; align-items: center; gap: 10px; }
.field.checkbox input { width: 18px; height: 18px; }
.field.wide-field { grid-column: 1 / -1; }
.form.mini { gap: 10px; margin: 6px 0 10px; padding: 12px; background: #f8fafc; border-radius: 10px; }
.form.mini .field-label { font-size: .78rem; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }

/* --- Suche, Kundin-Detail, Vorschau, SeaTable-Picker --- */
.search-form { flex-direction: row; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.search-form .field { flex: 1; min-width: 200px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.panel { background: #f8fafc; border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.panel-title { font-size: .95rem; margin: 0 0 10px; color: #334155; }
.st-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.st-result-item {
  font: inherit; text-align: left; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.st-result-item:hover { border-color: var(--brand); background: #ecfdf5; }
.st-selected { font-weight: 600; color: var(--brand-ink); margin: 0; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.doc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.doc-card {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f8fafc;
}
.doc-card-preview {
  height: 140px; background: #e2e8f0; display: flex; align-items: center; justify-content: center;
}
.doc-card-preview a { display: block; width: 100%; height: 100%; }
.thumb { width: 100%; height: 140px; object-fit: cover; display: block; }
.pdf-thumb, .file-thumb {
  display: flex; align-items: center; justify-content: center; height: 140px;
  font-weight: 700; color: var(--brand-ink); text-decoration: none;
}
.doc-card-body { padding: 12px; }
.doc-cat { font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.filename-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-line { margin-top: 4px; }
.doc-card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.preview-card .preview-frame { margin-top: 16px; }
.preview-image { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 8px; }
.preview-pdf { width: 100%; height: 75vh; border: 0; border-radius: 8px; background: #f1f5f9; }

@media (max-width: 640px) {
  .form.grid { grid-template-columns: 1fr; }
  .card { padding: 22px; }
}
