:root {
  --accent: #F39C12;
  --accent-dark: #D98A0B;
  --navy: #1E2A3B;
  --ink: #1F2937;
  --muted: #6B7280;
  --bg: #ffffff;
  --card: #ffffff;
  --border: #E5E7EB;
  --danger: #DC2626;
  --ok: #15803D;
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
.hidden { display: none !important; }

/* ---------- Aufteilung: links Bild und Logo, rechts Inhalt ---------- */
.shell { display: grid; grid-template-columns: minmax(280px, 44%) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 16px; }
.logo, .logo-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; background: var(--accent); color: #000;
  font-weight: 900; font-size: 26px; letter-spacing: -1px; border-radius: 2px; text-decoration: none;
}
.logo { object-fit: contain; padding: 4px; }
.side-img {
  position: absolute; left: 0; right: 0; bottom: 0; top: 84px;
  background: #eef0f3 url('assets/intergrund.jpeg') center / cover no-repeat;
  margin: 0 16px 16px; border-radius: 4px;
}
.side { position: relative; }
.content { padding: 28px 32px 40px; max-width: 1100px; width: 100%; }

/* ---------- Überschriften wie „Startseite“: dunkel mit orangem Wortteil ---------- */
h1 { font-size: 30px; margin: 0 0 8px; font-weight: 700; color: var(--ink); }
h1 span, .title span { color: var(--accent); }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
h2::before { content: ''; display: inline-block; width: 9px; height: 9px; background: var(--accent); margin-right: 10px; vertical-align: middle; }
.title { font-size: 30px; margin: 0 0 14px; font-weight: 700; }

.hint, .muted { color: var(--muted); font-size: 13px; }
.msg { min-height: 1.2em; color: var(--danger); }

/* ---------- Eingaben und Schaltflächen ---------- */
button, input, select, textarea { font: inherit; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; width: 100%; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 60px; }
button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
button.small { padding: 4px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid label, label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Karten: weiß, mit orangem Balken links ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px 20px; margin-bottom: 16px; border-left: 4px solid var(--accent);
}
.card.plain { border-left: 1px solid var(--border); }

/* ---------- Anmeldung ---------- */
.login-box { max-width: 420px; margin-top: 60px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Kopfzeile mit Navigation ---------- */
.topbar {
  display: flex; flex-direction: column; gap: 10px;
  margin: -28px -32px 18px; padding: 0 32px;
  border-bottom: 1px solid var(--border);
}
.topbar nav {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  width: 100%;
}
.topbar nav button {
  background: transparent; border: none; border-bottom: 3px solid transparent; border-radius: 0;
  color: var(--muted); padding: 14px 4px; font-weight: 700; font-size: 14px; width: 100%; text-align: center;
}
.topbar nav button:hover { color: var(--ink); border-color: transparent; }
.topbar nav button.active { color: var(--ink); border-bottom-color: var(--accent); }
.topbar .who { display: flex; gap: 6px; align-items: center; justify-content: flex-end; font-size: 13px; color: var(--muted); flex-wrap: wrap; padding-top: 8px; }

main { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 14px; }
th { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.selected { background: #FEF6E7; }

/* ---------- Kennzahlen-Kacheln ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
a.kpi { text-decoration: none; color: inherit; display: block; transition: border-color .15s; }
a.kpi:hover { border-color: var(--accent); }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--ink); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Status-Marken ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: #E5E7EB; color: var(--ink); }
.badge.benötigt, .badge.open { background: #FDE2E2; color: #991B1B; }
.badge.bestellt { background: #FEF3C7; color: #92400E; }
.badge.erledigt, .badge.paid { background: #DCFCE7; color: #166534; }

/* ---------- Dateien ---------- */
.thumbs { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.thumb { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; border-top: 3px solid var(--accent); }
.thumb .preview { height: 130px; display: flex; align-items: center; justify-content: center; background: #F3F4F6; cursor: pointer; }
.thumb .preview img { width: 100%; height: 100%; object-fit: cover; }
.thumb .preview .pdf { font-weight: 700; color: var(--navy); font-size: 20px; }
.thumb .meta { padding: 9px; font-size: 13px; }

/* ---------- Dialoge ---------- */
.modal { position: fixed; inset: 0; background: rgba(31, 41, 55, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-box { width: min(1000px, 100%); max-height: 92vh; overflow: auto; border-left: 4px solid var(--accent); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal iframe, .modal img { width: 100%; height: 75vh; border: 0; object-fit: contain; }

/* ---------- Bildbetrachter: Vor/Zurück, Vergrößern ---------- */
.modal .viewer-stage { background: #F3F4F6; border-radius: 6px; overflow: auto; max-height: 75vh; }
.modal .viewer-stage img { display: block; margin: 0 auto; width: auto; height: auto; max-width: 100%; max-height: 75vh; object-fit: contain; cursor: zoom-in; }
.modal .viewer-bar { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.modal .viewer-nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: 11; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); font-size: 30px; line-height: 1; color: var(--navy); cursor: pointer; }
.modal .viewer-nav:hover { background: #fff; }
.modal .viewer-nav.prev { left: 12px; }
.modal .viewer-nav.next { right: 12px; }
.modal.zoom { padding: 0; }
.modal.zoom .modal-box { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; border-left: 0; padding: 12px; }
.modal.zoom .viewer-stage { max-height: none; height: calc(100vh - 120px); }
.modal.zoom .viewer-stage img { max-width: none; max-height: none; cursor: zoom-out; }
.ocr-status { font-size: 13px; color: var(--accent-dark); min-height: 1.2em; font-weight: 700; }

/* ---------- Schmale Bildschirme: Bild oben ausblenden ---------- */
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; padding-bottom: 0; }
  .side-img { display: none; }
  .content { padding: 18px; }
  .topbar { margin: -18px -18px 14px; padding: 0 18px; }
  .topbar nav button { padding: 10px 4px; font-size: 13px; }
}

/* ---------- Export-Schaltflächen ---------- */
a.btn { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 700; background: #fff; }
a.btn:hover { border-color: var(--accent); }
.export-bar { justify-content: flex-end; margin: 0 0 -6px; }

/* ---------- Einklappbare Bereiche ---------- */
h2.collapsible { cursor: pointer; user-select: none; display: flex; align-items: center; }
h2.collapsible::after { content: '▾'; color: var(--accent); font-size: 16px; margin-left: auto; padding-left: 12px; }
h2.collapsible.closed::after { content: '▸'; }
.collapsible-head { cursor: pointer; }

th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: var(--ink); }
th[data-sort]::after { content: attr(data-arrow); color: var(--accent); }

/* ---------- Handy: nichts über den Bildschirmrand hinaus ---------- */
@media (max-width: 800px) {
  .shell, .content, main, .card { min-width: 0; max-width: 100%; }
  .card { overflow-wrap: anywhere; }
  .topbar { margin: -18px -18px 12px; padding: 0 12px; }
  .topbar nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .topbar nav button { font-size: 14px; padding: 10px 2px; }
  .topbar .who { justify-content: center; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .login-box { margin-top: 24px; }
  .modal-box { padding: 14px; }
  .modal iframe, .modal img { height: 60vh; }
}
