/* ============================================================
   Kassenabrechnung — Design v2
   Kompakt · Konsistent · Professionell
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Farben */
  --green:       #16a34a;
  --green-d:     #15803d;
  --green-l:     #f0fdf4;
  --green-mid:   #dcfce7;
  --red:         #dc2626;
  --red-l:       #fef2f2;
  --amber:       #d97706;
  --amber-l:     #fffbeb;
  --blue:        #2563eb;
  --blue-l:      #eff6ff;
  --purple:      #7c3aed;
  --purple-l:    #f5f3ff;

  /* Grautöne */
  --g50:  #f9fafb;
  --g100: #f3f4f6;
  --g200: #e5e7eb;
  --g300: #d1d5db;
  --g400: #9ca3af;
  --g500: #6b7280;
  --g600: #4b5563;
  --g700: #374151;
  --g800: #1f2937;
  --g900: #111827;
  --white: #ffffff;

  /* Schatten */
  --s1: 0 1px 2px rgba(0,0,0,.06);
  --s2: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --s3: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --s4: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  /* Layout */
  --radius:   6px;
  --radius-l: 10px;
  --nav-h:    52px;
  --font:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--g800);
  background: #e8ede9;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Screens ─────────────────────────────────────────── */
.screen { min-height: 100vh; }

/* ── Login ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1f14;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(22,163,74,.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(22,163,74,.08) 0%, transparent 50%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  padding: 40px 36px 36px;
}
.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-d) 100%);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 6px 20px rgba(22,163,74,.35);
}
.login-logo svg { width: 28px; height: 28px; color: white; stroke-width: 2.5; }
.login-card h1 { text-align: center; font-size: 22px; font-weight: 700; color: var(--g900); letter-spacing: -.4px; }
.login-subtitle { text-align: center; color: var(--g400); font-size: 12px; margin-bottom: 28px; margin-top: 4px; letter-spacing: .02em; text-transform: uppercase; font-weight: 500; }

.otp-inputs {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 4px;
}
.otp-digit {
  width: 44px !important; height: 52px;
  text-align: center !important;
  font-size: 22px !important; font-weight: 700;
  border: 2px solid var(--g300) !important;
  border-radius: var(--radius) !important;
  padding: 0 !important;
  caret-color: transparent;
}
.otp-digit:focus { border-color: var(--green) !important; box-shadow: 0 0 0 3px rgba(22,163,74,.12) !important; }
.otp-digit.filled { border-color: var(--green) !important; background: var(--green-l) !important; }

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
  height: var(--nav-h);
  background: #0f1f14;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 20px;
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 2px 12px rgba(0,0,0,.25);
}
.nav-left {
  display: flex; align-items: center; gap: 16px;
}
.nav-right {
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end;
}
.nav-brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; color: #fff;
  white-space: nowrap; text-decoration: none;
  letter-spacing: -.2px;
}
.nav-brand svg { width: 18px; height: 18px; color: var(--green); }
.nav-pharmacy-wrap {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 0 4px 0 8px;
  min-width: 160px; max-width: 220px;
}
.nav-logo {
  height: 22px; max-width: 60px;
  object-fit: contain; border-radius: 3px;
  flex-shrink: 0;
}
.nav-pharmacy-select {
  border: none;
  background: transparent;
  color: rgba(255,255,255,.9);
  font-size: 13px; font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  padding: 6px 4px;
  flex: 1; min-width: 0;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 22px;
}
.nav-pharmacy-select:focus { outline: none; }
.nav-pharmacy-select option { background: #1a2e1f; color: #fff; }
.nav-links { display: flex; gap: 2px; justify-content: center; }
.nav-link {
  padding: 5px 11px;
  border-radius: var(--radius);
  text-decoration: none;
  color: rgba(255,255,255,.6);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.95); }
.nav-link.active { background: rgba(22,163,74,.25); color: #4ade80; }
.nav-user-info {
  display: flex; align-items: center; gap: 5px;
  color: rgba(255,255,255,.5); font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.nav-user-info svg { opacity: .5; }
#nav-username { color: rgba(255,255,255,.7); }

/* ── Main ────────────────────────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 20px) 16px 40px;
}

/* ── View Header ─────────────────────────────────────── */
.view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 10px; flex-wrap: wrap;
}
.view-header h2 { font-size: 17px; font-weight: 700; color: var(--g900); letter-spacing: -.2px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--g200);
  border-radius: var(--radius-l);
  padding: 16px;
  box-shadow: var(--s1);
}
.card h3 { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--g700); }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px;
  border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all .12s; text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--green); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--green-d); }
.btn-secondary { background: var(--g100); color: var(--g700); border: 1px solid var(--g200); }
.btn-secondary:hover:not(:disabled) { background: var(--g200); }
.btn-danger   { background: var(--red); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost    { background: transparent; color: var(--g600); padding: 4px 8px; }
.btn-ghost:hover { background: var(--g100); }
.navbar .btn-ghost { color: rgba(255,255,255,.5); }
.navbar .btn-ghost:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.8); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--g600); margin-bottom: 4px;
}
.form-group small { display: block; font-size: 11px; color: var(--g400); margin-top: 3px; }
.form-group textarea { resize: vertical; min-height: 60px; }
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], input[type="month"],
select, textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--g300);
  border-radius: var(--radius);
  font-size: 13px; font-family: var(--font);
  color: var(--g800);
  background: var(--white);
  transition: border-color .12s, box-shadow .12s;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}
input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 28px; }

.form-row   { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 100px; }
.form-cols  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--g100); }

.error-msg   { color: var(--red); font-size: 12px; margin-top: 6px; }
.success-msg { color: var(--green); font-size: 12px; margin-top: 6px; }
.text-muted  { color: var(--g500); font-size: 12px; }
.mt-2 { margin-top: 12px; }
.mb-1 { margin-bottom: 6px; }

/* ── Section Separator ───────────────────────────────── */
.form-section {
  background: var(--g50);
  border: 1px solid var(--g200);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.form-section-title {
  font-size: 11px; font-weight: 600; color: var(--g500);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}

/* ── Diff Preview ────────────────────────────────────── */
.diff-row {
  display: flex; gap: 16px; margin-top: 8px;
  padding: 8px 10px;
  background: var(--white);
  border: 1px solid var(--g200);
  border-radius: var(--radius);
}
.diff-item-label { font-size: 10px; color: var(--g500); text-transform: uppercase; letter-spacing: .04em; }
.diff-item-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos  { color: var(--green); }
.neg  { color: var(--red); }
.zero { color: var(--g400); }

/* ── Entry Cards ─────────────────────────────────────── */
.entries-list { display: flex; flex-direction: column; gap: 8px; }
.entry-card {
  background: var(--white);
  border: 1px solid var(--g200);
  border-radius: var(--radius-l);
  padding: 8px 10px;
  box-shadow: var(--s1);
  cursor: pointer;
  transition: box-shadow .12s, border-color .12s;
}
.entry-card:hover { box-shadow: var(--s3); border-color: var(--g300); }
.entry-card.modified  { border-left: 3px solid var(--amber); }
.entry-card.closed    { border-left: 3px solid var(--green); }

.entry-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.entry-date { font-size: 14px; font-weight: 700; color: var(--g900); }
.entry-author { font-size: 12px; color: var(--g500); }
.entry-badges { display: flex; gap: 5px; margin-left: auto; }

.badge {
  padding: 2px 7px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.badge-mod    { background: var(--amber-l); color: var(--amber); }
.badge-closed { background: var(--green-mid); color: var(--green-d); }
.badge-open   { background: var(--g100); color: var(--g500); }

/* Neue Entry-Sektionen */
.entry-body {
  display: flex; flex-direction: column;
  border: 1px solid var(--g200); border-radius: var(--radius);
  overflow: hidden;
}
.entry-sec {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--g200);
}
.entry-sec:last-child { border-bottom: none; }

.entry-sec-title {
  display: flex; align-items: center;
  padding: 5px 10px;
  background: var(--g50);
  border-right: 1px solid var(--g200);
  font-size: 10px; font-weight: 600; color: var(--g500);
  text-transform: uppercase; letter-spacing: .06em;
  writing-mode: vertical-rl;
  min-width: 28px;
}

.entry-fields {
  display: flex; flex: 1; flex-wrap: wrap;
}
.entry-field {
  padding: 5px 10px;
  border-right: 1px solid var(--g100);
  min-width: 100px; flex: 1;
}
.entry-field:last-child { border-right: none; }
.entry-field.diff-field { background: var(--g50); flex: 0 0 120px; }
.entry-field.diff-field.pos { background: color-mix(in srgb, var(--green-l) 60%, white); }
.entry-field.diff-field.neg { background: color-mix(in srgb, var(--red-l) 60%, white); }
.entry-field.total-field { background: var(--g100); flex: 0 0 120px; }
.entry-field.total-field.pos { background: var(--green-l); }
.entry-field.total-field.neg { background: var(--red-l); }

.ef-label {
  font-size: 10px; font-weight: 500; color: var(--g500);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px;
}
.ef-val {
  font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--g800);
}
.ef-val.pos { color: var(--green-d); }
.ef-val.neg { color: var(--red); }
.ef-val.zero { color: var(--g400); }
.ef-val.big  { font-size: 16px; }
.ef-sub { font-size: 11px; color: var(--g400); margin-top: 1px; font-variant-numeric: tabular-nums; }

.entry-notes {
  margin-top: 8px; font-size: 12px; color: var(--g600);
  padding: 6px 10px; background: var(--g50);
  border-radius: var(--radius); border: 1px solid var(--g200);
}

/* ── Summary Table ───────────────────────────────────── */
.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.stat-box {
  background: var(--white); border: 1px solid var(--g200);
  border-radius: var(--radius); padding: 10px 12px;
}
.stat-box-label { font-size: 11px; color: var(--g500); margin-bottom: 2px; }
.stat-box-value { font-size: 18px; font-weight: 700; color: var(--g900); font-variant-numeric: tabular-nums; }
.stat-box-value.pos { color: var(--green); }
.stat-box-value.neg { color: var(--red); }

.tbl-wrap {
  background: var(--white);
  border: 1px solid var(--g200);
  border-radius: var(--radius-l);
  overflow: hidden;
}
.data-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-tbl th, .data-tbl td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--g100);
}
.data-tbl th { background: var(--g50); font-size: 11px; font-weight: 600; color: var(--g500); text-transform: uppercase; letter-spacing: .05em; }
.data-tbl th:first-child, .data-tbl td:first-child { text-align: left; }
.data-tbl tbody tr:hover td { background: var(--g50); cursor: pointer; }
.data-tbl tbody tr:last-child td { border-bottom: none; }
.data-tbl .total-row td { font-weight: 700; background: var(--g50); border-top: 2px solid var(--g200); border-bottom: none; }
.num { font-variant-numeric: tabular-nums; }

/* ── Badges / Status ─────────────────────────────────── */
.role-badge { padding: 2px 7px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.role-superadmin { background: #fce7f3; color: #9d174d; }
.role-admin      { background: var(--blue-l); color: var(--blue); }
.role-user       { background: var(--g100); color: var(--g600); }
.status-on  { color: var(--green); font-weight: 500; }
.status-off { color: var(--red); font-weight: 500; }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px 20px;
  overflow-y: auto;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-l);
  width: 100%; max-width: 580px;
  box-shadow: var(--s4);
  margin: auto;
}
.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--g200);
  position: sticky; top: 0; background: var(--white); z-index: 1;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
}
.modal-hd h3 { font-size: 15px; font-weight: 700; color: var(--g900); }
.modal-bd { padding: 18px; }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--g900); color: white;
  padding: 10px 16px;
  border-radius: var(--radius); font-size: 13px;
  box-shadow: var(--s4); z-index: 300;
  max-width: 320px; line-height: 1.4;
  animation: slideUp .2s ease;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes slideUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ── Stats ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 16px; }
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.bar-label { width: 60px; color: var(--g600); text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 20px; background: var(--g100); border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill  { height: 100%; border-radius: 4px; transition: width .4s ease; min-width: 2px; }
.bar-fill.pos  { background: var(--green); }
.bar-fill.neg  { background: var(--red); }
.bar-fill.zero { background: var(--g300); }
.bar-val   { width: 80px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--g700); flex-shrink: 0; }
.bar-val.pos { color: var(--green); }
.bar-val.neg { color: var(--red); }

/* ── Security / Login Log ────────────────────────────── */
.log-row { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--g100); align-items: center; }
.log-row:last-child { border-bottom: none; }
.log-ok  { color: var(--green); font-weight: 600; font-size: 13px; }
.log-err { color: var(--red);   font-weight: 600; font-size: 13px; }

/* ── Audit ───────────────────────────────────────────── */
.audit-item { padding: 8px 12px; border-bottom: 1px solid var(--g100); font-size: 12px; }
.audit-item:last-child { border-bottom: none; }
.audit-meta { display: flex; gap: 10px; color: var(--g500); margin-bottom: 3px; flex-wrap: wrap; }
.act-insert { color: var(--green); font-weight: 600; }
.act-update { color: var(--amber); font-weight: 600; }

/* ── QR / 2FA ────────────────────────────────────────── */
.qr-wrap { text-align: center; margin: 12px 0; }
.qr-wrap img { border: 4px solid var(--white); border-radius: var(--radius); box-shadow: var(--s2); }
details summary { cursor: pointer; font-size: 12px; color: var(--g500); margin: 8px 0; }
details code { display: block; background: var(--g100); padding: 8px 10px; border-radius: var(--radius); font-size: 12px; word-break: break-all; margin-top: 6px; }

/* ── Logo Upload ─────────────────────────────────────── */
.logo-preview { width: 80px; height: 60px; object-fit: contain; border: 1px solid var(--g200); border-radius: var(--radius); background: var(--g50); }
.logo-placeholder { width: 80px; height: 60px; border: 2px dashed var(--g300); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--g400); font-size: 11px; text-align: center; cursor: pointer; }
.logo-placeholder:hover { border-color: var(--green); color: var(--green); }

/* ── Print ───────────────────────────────────────────── */
.print-only { display: none; }
.print-logo { display: none; }
@media print {
  .navbar, .btn, .header-actions, .nav-links, .nav-user,
  #modal-overlay, .toast, .entries-list { display: none !important; }
  .main-content { padding-top: 10px !important; }
  .print-only { display: block !important; }
  .print-logo { display: block !important; max-height: 50px; margin-bottom: 10px; }
  body { font-size: 11px; background: white; }

  .print-tbl { width: 100%; border-collapse: collapse; font-size: 10px; }
  .print-tbl th {
    background: #f3f4f6; font-size: 9px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    padding: 4px 5px; border: 1px solid #d1d5db; text-align: right;
  }
  .print-tbl th:first-child { text-align: left; }
  .print-tbl td { padding: 3px 5px; border: 1px solid #e5e7eb; text-align: right; white-space: nowrap; }
  .print-tbl td:first-child { text-align: left; font-weight: 600; }
  .print-tbl tr:nth-child(even) td { background: #f9fafb; }
  .print-tbl tfoot td { font-weight: 700; background: #f3f4f6 !important; border-top: 2px solid #9ca3af; }
  .print-tbl .neg { color: #dc2626; }
  .print-tbl .pos { color: #16a34a; }
  .print-tbl .zero { color: #9ca3af; }

  .print-header { margin-bottom: 10px; }
  .print-header h2 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
  .print-header p { font-size: 11px; color: #6b7280; }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; padding-bottom: 4px; }
  .main-content { padding-top: 100px; }
  .form-cols, .form-cols-3 { grid-template-columns: 1fr; }
  .entry-grid { grid-template-columns: repeat(2, 1fr); }
}
