:root {
  --blue: #4472C4;
  --blue-light: #D9E1F2;
  --green: #2e7d32;
  --red: #c62828;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e2e5e9;
  --bg: #f7f8fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--blue);
  color: white;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; }

.btn {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: rgba(255,255,255,0.28); }
.btn-primary { background: white; color: var(--blue); border-color: white; font-weight: 600; }
.btn-primary:hover { background: #f0f3fb; }

.status {
  margin: 12px 24px 0;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
}
.status.ok { background: #e6f4ea; color: var(--green); border: 1px solid #b7ddc0; }
.status.error { background: #fdecea; color: var(--red); border: 1px solid #f2c1bd; }

.breadcrumb {
  padding: 12px 24px 0;
  font-size: 14px;
  color: var(--muted);
}
.breadcrumb a { color: var(--blue); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }

main { padding: 20px 24px 60px; max-width: 1100px; margin: 0 auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
th, td {
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th:first-child, td:first-child { text-align: left; }
thead th {
  background: var(--blue);
  color: white;
  font-weight: 600;
}
tbody tr:hover { background: #f2f5fb; cursor: pointer; }
tbody tr.total-row { background: var(--blue-light); font-weight: 700; cursor: default; }
tbody tr.total-row:hover { background: var(--blue-light); }
tbody tr.no-hover:hover { background: white; cursor: default; }

.negative { color: var(--red); }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 16px; }
.card h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; }

.kasse-meta {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.kasse-meta div { font-size: 14px; }
.kasse-meta strong { display: block; font-size: 20px; color: var(--blue); }

/* --- Kassenbericht-Formular --- */
.bericht-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.bericht-form-grid label,
.uitgave-form label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 4px;
}
.bericht-form-grid input,
.position-row input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}

.positionen-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}
.position-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 10px;
  margin-bottom: 8px;
  align-items: center;
}
.btn-remove {
  background: none;
  border: 1px solid var(--border);
  color: var(--red);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}
.btn-remove:hover { background: #fdecea; }
.btn-small {
  background: white;
  border: 1px dashed var(--blue);
  color: var(--blue);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.btn-small:hover { background: var(--blue-light); }

.btn-add {
  background: var(--blue);
  color: white;
  border: none;
  padding: 9px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn-add:hover { background: #375aa0; }

.bericht-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg);
}
.bericht-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.bericht-card-head .datum { font-weight: 600; }
.bericht-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 13px;
  margin-top: 8px;
}
.bericht-summary strong { display: block; font-size: 15px; }
.bericht-positionen {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.delete-link {
  color: var(--red);
  cursor: pointer;
  font-size: 13px;
}
.delete-link:hover { text-decoration: underline; }

.empty-hint {
  color: var(--muted);
  font-style: italic;
  padding: 20px;
  text-align: center;
}

/* --- Druckansicht: siehe unten, eigenständiger #printArea-Block --- */

/* --- Branding (Logo in der Kopfzeile) --- */
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  height: 40px;
  width: auto;
  background: white;
  border-radius: 6px;
  padding: 4px 10px;
}
.brand h1 { margin: 0; }

/* --- Login-Seite --- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f7f8fa 0%, #eef1f7 100%);
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.login-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px;
  width: 340px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-logo { width: 140px; height: auto; margin-bottom: 12px; }
.login-card h1 { font-size: 18px; margin: 0 0 20px; color: var(--text); }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 5px;
}
.login-form input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login-form .btn-add { margin-top: 8px; }
.login-error {
  background: #fdecea;
  color: var(--red);
  border: 1px solid #f2c1bd;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* --- Druck-Auswahlmenü --- */
.print-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.print-modal {
  background: white;
  border-radius: 12px;
  padding: 28px 30px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.print-modal h2 { margin: 0 0 4px; font-size: 18px; }
.print-modal-scope { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.print-modal-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}
.checkbox-row input { width: 17px; height: 17px; cursor: pointer; flex-shrink: 0; }
.print-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn-cancel:hover { background: var(--bg); }

/* --- Eigenständiger Druckbereich (auf dem Bildschirm unsichtbar) --- */
#printArea { display: none; }

.print-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--blue);
}
.print-header img { height: 60px; width: auto; }
.print-header h1 { margin: 0; font-size: 22px; }
.print-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.print-kasse-titel { margin-top: 28px; }
.print-empty { color: var(--muted); font-style: italic; font-size: 13px; }
.print-details-cell { text-align: left; font-size: 12px; color: var(--muted); }

/* --- Druckansicht --- */
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  body { background: white; }
  table { border: none; width: 100%; margin-bottom: 18px; }
  thead th { background: #eee !important; color: black !important; -webkit-print-color-adjust: exact; }
  tbody tr.total-row { background: #eee !important; -webkit-print-color-adjust: exact; font-weight: 700; }
  h2 { font-size: 16px; margin-top: 24px; page-break-after: avoid; }
  h3 { font-size: 14px; color: #555; margin: 16px 0 8px; page-break-after: avoid; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
}

/* --- Horizontal scrollbare Tabellen (fuer schmale Bildschirme) --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}
.table-wrap table { min-width: 560px; }

/* ================================================================
   Mobile / kleine Bildschirme
   ================================================================ */
@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 16px;
  }
  .brand { justify-content: center; }
  .logo { height: 34px; }
  .brand h1 { font-size: 17px; }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .topbar-actions .btn,
  .topbar-actions label.btn {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 11px 10px;
    font-size: 13.5px;
  }
  /* Abmelden-knop over de volle breedte op de tweede rij */
  .topbar-actions a.btn { grid-column: 1 / -1; }

  .breadcrumb { padding: 10px 16px 0; }

  main { padding: 14px 14px 50px; }

  .card { padding: 14px 14px; }
  .card h2 { font-size: 15px; }

  th, td { padding: 9px 10px; font-size: 13px; }

  .kasse-meta { gap: 16px 22px; }
  .kasse-meta strong { font-size: 17px; }

  .bericht-form-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .positionen-block { padding: 12px; }
  .position-row {
    grid-template-columns: 1fr;
    gap: 6px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
  }
  .position-row .btn-remove { justify-self: start; }

  .bericht-card-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .bericht-summary { gap: 14px 20px; }
  .bericht-summary strong { font-size: 14px; }

  .print-modal-overlay { padding: 16px; }
  .print-modal { width: 100%; padding: 22px 20px; }
  .login-card { width: 100%; max-width: 320px; padding: 28px 24px; }

  .status { margin: 10px 14px 0; }
}

@media (max-width: 420px) {
  .bericht-form-grid { grid-template-columns: 1fr; }
  .topbar-actions { grid-template-columns: 1fr; }
  .topbar-actions a.btn { grid-column: auto; }
  .kasse-meta { flex-direction: column; gap: 10px; }
}

/* Grote, makkelijk te raken knoppen op touch-apparaten */
@media (hover: none) and (pointer: coarse) {
  .btn, .btn-add, .btn-small, .btn-remove, .btn-cancel { min-height: 40px; }
  input[type="text"], input[type="number"], input[type="date"], input[type="password"] {
    min-height: 38px;
  }
}

/* --- Transaktions-Detailmodal (pro Z-Nummer) --- */
.hint-text { font-size: 12px; font-weight: 400; color: var(--muted); }

.trans-modal {
  width: 640px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.trans-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.trans-modal-head h2 { margin: 0; }
.trans-modal-table {
  max-height: 55vh;
  overflow-y: auto;
  margin-top: 10px;
}
.trans-modal-table table { min-width: 100%; }
.trans-modal-table thead th { position: sticky; top: 0; z-index: 1; }
tbody tr.negative { background: #fdf3f2; }
tbody tr.negative:hover { background: #fbe7e5; }

@media (max-width: 720px) {
  .trans-modal { width: 100%; }
  .trans-modal-table { max-height: 50vh; }
}

/* --- Kassenbericht: Vorschlag-Hinweise --- */
.vorschlag-hint {
  font-size: 11px;
  color: var(--blue);
  font-weight: 400;
  min-height: 14px;
}
.formel-hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 4px 0 16px;
}
