/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  /* -- Markenfarben (EzKiosk-Logo) ------------------------------------------- */
  --brand-primary:      #0A5CF0;   /* tiefes Logo-Blau - Fuellflaechen mit weisser Schrift (AA) */
  --brand-primary-dark: #0843C2;   /* Hover / aktiv gedrueckt */
  --brand-accent:       #4E8BF5;   /* helles Blau - Text/Icons/Borders/Links auf dunklem Grund (AA) */
  --brand-navy:         #0A1A3A;   /* Navy aus dem Schriftzug - sekundaer */

  --bg:        #1a1a2e;
  --card:      #16213e;
  --accent:    #0f3460;
  --highlight: var(--brand-accent);  /* Akzent (vormals #e94560) - als Text/Border lesbar */
  --text:      #e0e0e0;
  --text-muted:#8892b0;
  --border:    #1e3a5f;
  --success:   #00c896;
  --warning:   #f7b731;
  --danger:    #e94560;              /* bleibt Rot - Fehler/Loeschen/Storno/Bestand */
  --sidebar-w: 230px;
  --radius:    12px;
  --shadow:    0 4px 20px rgba(0,0,0,.4);
  /* Responsive breakpoints & sidebar widths */
  --bp-md:     768px;
  --bp-xl:     1200px;
  --sb-desktop:230px;
  --sb-tablet: 64px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: clamp(0.875rem, 2vw, 1rem);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
h1 { font-size: clamp(1.5rem, 4vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; min-height: 44px; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }
/* Touch targets */
button, .btn, a.nav-link { min-height: 44px; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar — MOBILE-FIRST ────────────────────────────────────────────────── */
.sidebar {
  background: var(--accent);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: -260px;       /* Mobile: off-screen */
  width: 230px;
  height: 100vh;
  z-index: 1000;
  transition: left 0.3s, width 0.3s;
  overflow: hidden;
}
.sidebar.open { left: 0; }  /* Mobile overlay */

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 14px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  min-height: 70px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
}
.logo-icon { font-size: 1.5rem; flex-shrink: 0; }
.logo-img {
  height: 34px; width: 34px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
}
.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 1.2rem;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background .15s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.15); color: #fff; }

.nav-menu {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.nav-item { margin: 2px 8px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  transition: background .15s, color .15s;
  white-space: nowrap;
  color: rgba(255,255,255,.75);
  font-size: .95rem;
}
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active .nav-link {
  background: var(--brand-primary);
  color: #fff;
  font-weight: 600;
}
.nav-icon { font-size: 1.25rem; flex-shrink: 0; width: 24px; text-align: center; }
.nav-text { overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .8rem;
  color: rgba(255,255,255,.5);
  white-space: nowrap;
  overflow: hidden;
}
.clock { font-size: .9rem; color: rgba(255,255,255,.7); margin-bottom: 2px; }

/* ── Main Content — MOBILE-FIRST ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 0;            /* Mobile: full width */
  transition: margin-left 0.3s;
  min-height: 100vh;
  min-width: 0;              /* Flex-Item darf unter seine Inhaltsbreite schrumpfen (sonst Tablet-Überlauf) */
  display: flex;
  flex-direction: column;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}
.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.page-body { padding: 24px 28px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.card-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}
.card-sub {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-grid, .stats-grid, .dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  container-type: inline-size;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(10px, 2.5vw, 20px);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 100px;
  min-width: 0;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--accent);
}
.kpi-card.highlight::before { background: var(--highlight); }
.kpi-card.success::before   { background: var(--success); }
.kpi-card.warning::before   { background: var(--warning); }
.kpi-card.danger::before    { background: var(--danger); }

.kpi-icon { font-size: 1.8rem; flex-shrink: 0; }
.kpi-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kpi-value {
  font-size: clamp(1.25rem, 5vw, 2rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

@container (min-width: 280px) {
  .kpi-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .kpi-card .kpi-value {
    flex-shrink: 0;
    width: auto;
    text-align: right;
  }
}

/* ── Dashboard Sections ────────────────────────────────────────────────────── */
.dashboard-grid {
  gap: 20px;
}

.section-title {
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  transition: filter .15s, transform .1s;
  min-height: 44px;
  white-space: nowrap;
}
.btn:hover  { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--brand-primary); color: #fff; }
.btn-secondary { background: var(--accent);    color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-warning   { background: var(--warning);   color: #1a1a2e; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .82rem; min-height: 34px; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; min-height: 52px; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.table-wrap table { min-width: max-content; width: 100%; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
thead th {
  background: var(--accent);
  color: rgba(255,255,255,.8);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}
tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { background: var(--card); transition: background .1s; }
tbody tr:hover { background: #1c2d50; }
tbody tr.low-stock td { background: rgba(233,69,96,.08); }
tbody tr.low-stock td:first-child { border-left: 3px solid var(--danger); }
tbody tr.out-stock   td { background: rgba(233,69,96,.18); }
tbody tr.expired-row td { background: rgba(233,69,96,.13); }
tbody tr.expired-row td:first-child { border-left: 3px solid var(--danger); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .3px;
}
.badge-success  { background: rgba(0,200,150,.2); color: var(--success); }
.badge-warning  { background: rgba(247,183,49,.2); color: var(--warning); }
.badge-danger   { background: rgba(233,69,96,.25); color: var(--danger); }
.badge-info     { background: rgba(15,52,96,.6);   color: #7eb8f7; }

/* ── Lagerverwaltung: lange Listen (150+ Zeilen) ───────────────────────────────
   Nur die Lager-Tabelle (.lager-table-wrap) — andere .table-wrap (Bons, Berichte,
   Nachfrage, Tagesabschluss) bleiben unveraendert.
   Tabellenbereich scrollt INTERN (vertikal + horizontal) und fuellt die Hoehe;
   die Kopfzeile bleibt sticky. max-height (nicht height) => wenige Zeilen erzeugen
   keinen haesslichen Leerraum (Container haengt an der Inhaltshoehe). */
.lager-table-wrap {
  overflow: auto;                      /* vertikal + horizontal in sich scrollen */
  max-height: calc(100vh - 250px);     /* Fallback fuer Browser ohne dvh */
  max-height: calc(100dvh - 250px);    /* dynamische Viewport-Hoehe (Mobile-Browserleiste) */
}
.lager-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 5;                          /* ueber den Zeilen, unter Modals (2000) */
  box-shadow: inset 0 -1px 0 var(--border);
}
/* Lange Produktnamen sauber umbrechen statt die Tabelle in die Breite zu ziehen */
.lager-table-wrap tbody td:nth-child(2) {
  max-width: 280px;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* AKTIONEN-Spalte (letzte Spalte) rechts anpinnen — bleibt beim horizontalen Scrollen
   sichtbar (+/Bearbeiten/Loeschen ohne Wischen erreichbar). Die mittleren Spalten
   scrollen weiter (af9781a unveraendert). Hintergrund opak, sonst scheinen scrollende
   Zellen durch; dezenter Border/Schatten links zur Abgrenzung. */
.lager-table-wrap thead th:last-child,
.lager-table-wrap tbody td:last-child {
  position: sticky;
  right: 0;
  background: var(--card);
  box-shadow: inset 1px 0 0 var(--border), -5px 0 6px -5px rgba(0,0,0,.4);
  z-index: 4;                          /* ueber normalen Zellen, unter Kopfzeile (5) */
}
.lager-table-wrap thead th:last-child {
  top: 0;                              /* Eckzelle: sticky in BEIDEN Achsen (oben + rechts) */
  z-index: 6;                          /* ueber Kopfzeile (5) + Pin-Spalte (4); unter Modals (2000) */
  background: var(--accent);           /* Header-Hintergrund, opak */
  box-shadow: inset 1px 0 0 rgba(255,255,255,.12),
              inset 0 -1px 0 var(--border),
              -5px 0 6px -5px rgba(0,0,0,.4);
}
/* Status-/Zebra-Zeilenfarben unter der Pin-Spalte exakt nachbilden
   (Tint-Layer ueber opakem --card => kein Durchscheinen). */
.lager-table-wrap tbody tr.low-stock   td:last-child { background: linear-gradient(rgba(233,69,96,.08), rgba(233,69,96,.08)), var(--card); }
.lager-table-wrap tbody tr.out-stock   td:last-child { background: linear-gradient(rgba(233,69,96,.18), rgba(233,69,96,.18)), var(--card); }
.lager-table-wrap tbody tr.expired-row td:last-child { background: linear-gradient(rgba(233,69,96,.13), rgba(233,69,96,.13)), var(--card); }
/* Voll-breite Platzhalterzeilen (Spinner / "Keine Produkte") nicht anpinnen */
.lager-table-wrap tbody td[colspan] { position: static; background: var(--card); box-shadow: none; }

@media (min-width: 768px) and (max-width: 1199px) {
  /* Tablet-Hochformat: Kopf + Suche brauchen etwas mehr Hoehe */
  .lager-table-wrap { max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px); }
  .lager-table-wrap tbody td:nth-child(2) { max-width: 200px; }
  /* Touch-Targets der Zeilen-Aktionen (+/Bearbeiten/Loeschen) gross genug */
  .lager-table-wrap .btn-sm { min-height: 42px; min-width: 42px; padding: 6px 10px; }
  /* Status-/Kategorie-Badges auf dem Tablet besser lesbar */
  .lager-table-wrap .badge { font-size: .8rem; padding: 4px 10px; }
}
@media (min-width: 1200px) {
  .lager-table-wrap { max-height: calc(100vh - 220px); max-height: calc(100dvh - 220px); }
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
  min-height: 44px;
}
.form-control:focus {
  outline: none;
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px rgba(78,139,245,.30);
}
.form-control::placeholder { color: var(--text-muted); }
/* Touch-Haertung (Samsung-Tablet): Felder muessen zuverlaessig fokussier-/tippbar
   sein — kein Doppeltipp-Zoom-Delay, Caret + Textauswahl aktiv, Eingaben kommen an. */
.form-control, input, textarea, select {
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
  pointer-events: auto;
}
select.form-control { appearance: none; background-image:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%238892b0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Search Bar ────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap .form-control { padding-left: 38px; }
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .95rem;
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 2000;
  backdrop-filter: blur(2px);
  align-items: center;        /* Fallback-Zentrierung (margin:auto am .modal hat Vorrang) */
  justify-content: center;
  overflow-y: auto;           /* sehr hoher Inhalt: Overlay scrollt statt abzuschneiden */
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px;         /* Rand, damit das Modal nicht am Viewport-Rand klebt */
}
.modal-overlay.active { display: flex; }
.modal {
  margin: auto;               /* H+V zentriert, unabhaengig von inline align/justify am Overlay;
                                 bei zu hohem Inhalt oben erreichbar (kein Abschneiden) */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(560px, 95vw);
  max-height: calc(100vh - 48px);    /* Fallback fuer Browser ohne dvh */
  max-height: calc(100dvh - 48px);   /* dyn. Viewporthoehe (Tastatur): Modal bleibt sichtbar, scrollt intern */
  overflow-y: auto;
  scroll-padding-block: 72px;        /* fokussiertes Feld nicht unter Sticky Header/Footer scrollen */
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  position: sticky;            /* Titel beim internen Scrollen sichtbar */
  top: 0;
  z-index: 2;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: #fff; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: #fff; background: rgba(255,255,255,.1); }
.modal-body  { padding: 20px 24px; }
.modal-footer {
  position: sticky;            /* Bestaetigen-Button bleibt erreichbar (auch bei offener Tastatur) */
  bottom: 0;
  z-index: 2;
  background: var(--card);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border);
}

/* ── Confirm Modal ─────────────────────────────────────────────────────────── */
#confirmModal .modal { width: min(420px, 95vw); }
.confirm-text { color: var(--text); line-height: 1.6; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow);
  animation: toastIn .25s ease;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1a1a2e; }
.toast.info    { background: var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: none; }
}
.toast.fade-out { animation: toastOut .3s ease forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* ── Zahlungsart-Buttons ───────────────────────────────────────────────────── */
.pay-method-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  font-size: .9rem;
  gap: 4px;
}
.pay-method-btn:hover {
  border-color: var(--highlight);
  background: rgba(10,92,240,.10);
}
.pay-method-btn.active {
  border-color: var(--highlight);
  background: rgba(10,92,240,.18);
  transform: scale(1.03);
}

/* ── Import Dropzone ───────────────────────────────────────────────────────── */
.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.import-dropzone:hover,
.import-dropzone.drag-over {
  border-color: var(--highlight);
  background: rgba(10,92,240,.10);
  color: var(--text);
}

/* ── Scan-Bar ──────────────────────────────────────────────────────────────── */
.scan-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1.5px solid var(--highlight);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.scan-bar-icon { font-size: 1.35rem; flex-shrink: 0; }
.scan-bar-input {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
.scan-bar-input:focus {
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px rgba(78,139,245,.28);
}
.scan-bar-status {
  font-size: .82rem;
  white-space: nowrap;
  min-width: 180px;
  text-align: right;
  color: var(--text-muted);
}
@media (max-width: 600px) {
  .scan-bar { flex-wrap: wrap; }
  .scan-bar-status { min-width: unset; width: 100%; text-align: left; }
}
@media (min-width: 601px) and (max-width: 1199px) {
  /* Tablet/Mid: leerer Status reserviert keine 180px → EAN-Feld füllt die Zeile (flex:1) */
  .scan-bar-status { min-width: 0; }
}

/* ── POS / Kasse ───────────────────────────────────────────────────────────── */
.kasse-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  align-items: start;
}

.kasse-left,
.kasse-right {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.kasse-left  { display: flex; flex-direction: column; gap: 14px; }
.kasse-right {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
}

/* Tablet Hochformat / Mid-Size: schmalere rechte Spalte */
@media (max-width: 1023px) {
  .kasse-layout { grid-template-columns: 1fr 300px; }
}

.cart-items { min-height: 50px; }
.cart-empty, #cartEmpty {
  padding: 16px;
  text-align: center;
  font-size: .85rem;
}

.recent-sales, .letzte-verkaeufe {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}
.recent-sales li, .letzte-verkaeufe li {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cat-tab {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
  min-height: 36px;
}
.cat-tab:hover  { border-color: var(--highlight); color: #fff; }
.cat-tab.active { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  align-content: start;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 4px;
}
.product-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  transition: all .15s;
  min-height: 110px;
  color: var(--text);
}
.product-btn:hover {
  border-color: var(--highlight);
  background: rgba(10,92,240,.10);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(10,92,240,.28);
}
.product-btn:active { transform: scale(.96); }
.product-btn.out-of-stock { opacity: .4; pointer-events: none; }
.product-btn-name {
  font-size: clamp(.75rem, 1.5vw, .9rem);
  font-weight: 600;
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
}
.product-btn-price {
  font-size: clamp(.95rem, 2vw, 1.1rem);
  font-weight: 700;
  color: var(--highlight);
  margin-top: 4px;
}
.product-btn-stock { font-size: .7rem; color: var(--text-muted); opacity: .7; margin-top: 2px; }

/* Cart */
.cart-header {
  padding: 14px 16px;
  font-weight: 700;
  font-size: .95rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cart-items { flex: 1; overflow-y: auto; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.cart-item-name { flex: 1; font-weight: 500; }
.cart-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qty-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s;
}
.qty-btn:hover { background: var(--accent); border-color: var(--accent); }
.qty-num { min-width: 24px; text-align: center; font-weight: 600; }
.cart-item-price { font-weight: 700; color: var(--highlight); min-width: 60px; text-align: right; }
.cart-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .1s;
}
.cart-remove:hover { color: var(--danger); }

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 8px;
  color: var(--text-muted);
  font-size: .9rem;
  padding: 40px;
}
.cart-empty-icon { font-size: 2.5rem; opacity: .4; }

.cart-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cart-total-label { font-size: .85rem; color: var(--text-muted); }
.cart-total-value { font-size: 1.7rem; font-weight: 700; color: #fff; }

/* Payment Modal */
#payModal .modal { width: min(420px, 95vw); }
.payment-total {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--highlight);
  margin-bottom: 20px;
}
.payment-total small { font-size: 1rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
.quick-cash { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.quick-cash-btn {
  flex: 1;
  min-width: 70px;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  transition: all .15s;
  min-height: 44px;
}
.quick-cash-btn:hover {
  border-color: var(--success);
  background: rgba(0,200,150,.1);
  color: var(--success);
}
.change-display {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  margin-top: 14px;
}
.change-display .change-label { font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; }
.change-display .change-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--success);
}
.change-display .change-value.negative { color: var(--danger); }

/* ── Low Stock Alerts ──────────────────────────────────────────────────────── */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(233,69,96,.1);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  font-size: .88rem;
}
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}
.alert-name { flex: 1; font-weight: 600; }
.alert-qty  { color: var(--danger); font-weight: 700; font-size: .85rem; }

/* ── Top Products List ─────────────────────────────────────────────────────── */
.top-product-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.top-product-item:last-child { border-bottom: none; }
.top-rank {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.top-rank.gold   { background: #f7b731; color: #1a1a2e; }
.top-rank.silver { background: #8892b0; color: #1a1a2e; }
.top-rank.bronze { background: #cd7f32; color: #fff; }
.top-rank.rank-rest {
  background: rgba(136, 146, 176, .18);
  color: var(--text-muted);
  border: 1px solid rgba(136, 146, 176, .35);
}
.top-product-name { flex: 1; font-weight: 500; }
.top-product-qty  { color: var(--text-muted); font-size: .82rem; }

/* ── Klickbare Dashboard-Elemente ──────────────────────────────────────────── */
.kpi-card.clickable,
.card.clickable,
.top-product-item.clickable,
.alert-item.clickable {
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.kpi-card.clickable:hover,
.card.clickable:hover {
  border-color: var(--highlight);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.top-product-item.clickable:hover {
  background: rgba(10, 92, 240, .10);
}
.alert-item.clickable:hover {
  background: rgba(233, 69, 96, .18);
}

/* ── Reports ───────────────────────────────────────────────────────────────── */
.period-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  width: fit-content;
}
.period-tab {
  padding: 8px 18px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .88rem;
  font-weight: 600;
  transition: all .15s;
  min-height: 36px;
}
.period-tab.active { background: var(--brand-primary); color: #fff; }
.period-tab:hover:not(.active) { color: #fff; background: rgba(255,255,255,.08); }

.chart-wrap {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.chart-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 14px;
}

/* ── Password toggle ───────────────────────────────────────────────────────── */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap .form-control { padding-right: 44px; }
.pw-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity .15s;
  line-height: 1;
}
.pw-eye:hover { opacity: 1; }

/* ── Settings ──────────────────────────────────────────────────────────────── */
.settings-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  max-width: 600px;
}
.settings-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.fw-bold       { font-weight: 700; }
.mt-4          { margin-top: 4px; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mb-16         { margin-bottom: 16px; }
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.gap-8         { gap: 8px; }
.gap-16        { gap: 16px; }
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 10px;
  text-align: center;
}
.empty-state-icon { font-size: 3rem; opacity: .3; }


/* ── Hamburger ─────────────────────────────────────────────────────────────── */
.hamburger {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  padding: 6px 8px;
  border-radius: 8px;
  line-height: 1;
  flex-shrink: 0;
  transition: background .15s;
}
.hamburger:hover { background: rgba(255,255,255,.1); }

/* ── Hide Utilities ────────────────────────────────────────────────────────── */
.hide-tablet { }
.hide-mobile { }

/* ── Sidebar Backdrop ──────────────────────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 999;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.active { display: block; }

/* ── Bottom Navigation (Mobile base — hidden by default) ───────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: var(--accent);
  border-top: 1px solid var(--border);
  z-index: 1100;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.4);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 10px;
  color: rgba(255,255,255,.55);
  font-size: .62rem;
  font-weight: 600;
  text-decoration: none;
  transition: color .15s, background .15s;
  min-height: 52px;
  letter-spacing: .2px;
}
.bottom-nav-item .bnav-icon { font-size: 1.35rem; line-height: 1; }
.bottom-nav-item.active { color: #fff; }
.bottom-nav-item.active .bnav-icon { filter: drop-shadow(0 0 6px rgba(78,139,245,.9)); }
.bottom-nav-item:active { background: rgba(255,255,255,.1); }

/* ════════════════════════════════════════════════════════════════════════════ */
/* RESPONSIVE — MOBILE FIRST                                                  */
/* ════════════════════════════════════════════════════════════════════════════ */

/* ── Mobile (<768px) — Base: sidebar off-screen, full-width content ─────────── */
/* (these are the DEFAULT styles — no media query needed for mobile) */

/* Sidebar open overlay on mobile */
/* .sidebar.open { left: 0; }  ← already in .sidebar base */

/* Bottom nav on mobile */
/* shown via @media block below */

/* ── @media ≥768px — Tablet: sidebar 64px icon-strip ───────────────────────── */
@media (min-width: 768px) {
  /* Sidebar: always visible, icon-only */
  .sidebar {
    left: 0;
    width: 64px;
    overflow: hidden;
  }
  .sidebar .logo-text,
  .sidebar .nav-text,
  .sidebar .sidebar-footer,
  .sidebar .sidebar-toggle { display: none; }
  .sidebar .nav-link { justify-content: center; }

  /* Hamburger: temporary expand to 230px */
  .sidebar.expanded {
    width: 230px;
  }
  .sidebar.expanded .logo-text,
  .sidebar.expanded .nav-text,
  .sidebar.expanded .sidebar-footer { display: unset; }
  .sidebar.expanded .nav-link { justify-content: flex-start; }
  .sidebar.expanded ~ .main-content { margin-left: 230px; }

  /* Main content: 64px left margin */
  .main-content { margin-left: 64px; }

  /* Hamburger visible on tablet */
  .hamburger { display: inline-flex; }

  /* Table columns hidden on tablet */
  .hide-tablet { display: none !important; }

  /* Slightly tighter padding */
  .page-body   { padding: 18px 20px; }
  .page-header { padding: 14px 20px; }

  /* Reports charts: 2 columns on tablet */
  .reports-chart-grid { grid-template-columns: 1fr 1fr; }
}

/* ── @media 768–1199px — Tablet-Hochformat: gesamte Ansicht sichtbar einpassen ─ */
@media (min-width: 768px) and (max-width: 1199px) {
  /* Inhalt nie breiter als der Bereich rechts der 64px-Sidebar (sonst rechts abgeschnitten) */
  .main-content { max-width: calc(100vw - 64px); overflow-x: hidden; }
  .page-body    { max-width: 100%; }

  /* Tabelle bleibt im Container und scrollt horizontal in sich (Aktionen-Spalte per Scroll erreichbar) */
  .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Obere Leiste darf umbrechen — alle Buttons bleiben sichtbar + tappbar */
  .page-header    { flex-wrap: wrap; }
  .page-title     { flex: 1 1 auto; min-width: 0; }
  .header-actions { flex-wrap: wrap; }
  .header-actions .btn { padding: 8px 12px; font-size: .82rem; }
}

/* ── @media ≥1200px — Desktop: sidebar 230px full ──────────────────────────── */
@media (min-width: 1200px) {
  .sidebar {
    width: 230px;
    overflow: hidden;
  }
  .sidebar .logo-text,
  .sidebar .nav-text,
  .sidebar .sidebar-footer,
  .sidebar .sidebar-toggle { display: unset; }
  .sidebar .nav-link { justify-content: flex-start; }

  .main-content { margin-left: 230px; }

  /* Hamburger hidden on desktop */
  .hamburger { display: none; }

  /* Full padding */
  .page-body   { padding: 24px 28px; }
  .page-header { padding: 20px 28px; }

  /* Reports charts: 2 columns */
  .reports-chart-grid { grid-template-columns: 1fr 1fr; }
}

/* ── @media <768px — Mobile-only overrides ──────────────────────────────────── */
@media (max-width: 767px) {
  /* Bottom nav */
  .bottom-nav { display: flex; }

  .main-content { margin-left: 0; padding-bottom: 80px; }

  /* Page spacing (room for bottom nav) */
  .page-body   { padding: 12px 14px 80px; }
  .page-header { padding: 12px 14px; position: sticky; top: 0; }
  .page-title  { font-size: 1.1rem; }
  .header-actions { gap: 6px; }
  .header-actions .btn { padding: 7px 10px; font-size: .8rem; }

  /* KPI: engerer Abstand auf Mobile */
  .kpi-grid, .stats-grid {
    gap: 8px;
    margin-bottom: 14px;
  }
  .kpi-card { padding: 10px 8px; min-height: 90px; }
  .kpi-card::before { width: 100%; height: 3px; top: auto; bottom: 0; left: 0; }
  .kpi-icon  { font-size: 1.4rem; }
  .kpi-value { font-size: clamp(1rem, 4vw, 1.5rem); }
  .kpi-label { font-size: .7rem; }

  /* Reports charts: 1 column on mobile */
  .reports-chart-grid { grid-template-columns: 1fr; }

  /* Kasse: single column on mobile, rechte Spalte wird zum Bottom-Sheet-Drawer */
  .kasse-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: auto;
  }
  .kasse-left {
    overflow: visible;
    padding-bottom: 70px;
  }
  .kasse-right {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1150;
    max-height: 80vh;
    transform: translateY(100%);
    transition: transform .25s ease;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,.45);
    top: auto;
  }
  .kasse-right.open { transform: translateY(0); }

  /* Product buttons: smaller grid */
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
  .product-btn { min-height: 80px; padding: 10px 6px; }
  .product-btn-name  { font-size: .8rem; }
  .product-btn-price { font-size: .95rem; }

  /* Tables */
  .table-wrap { font-size: .82rem; }
  thead th, tbody td { padding: 8px 10px; }
  .hide-mobile { display: none !important; }

  /* Modal: full-screen sheet */
  .modal {
    width: 100vw;
    max-width: 100vw;
    margin: 0;                  /* Bottom-Sheet: keine auto-Zentrierung */
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    max-height: 92vh;
    max-height: 92dvh;          /* dyn. Hoehe (Tastatur) */
  }
  .modal-overlay { align-items: flex-end; }

  /* Toast */
  .toast-container { right: 12px; left: 12px; bottom: 72px; }
  .toast { min-width: unset; max-width: 100%; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }

  /* Charts */
  .chart-wrap { padding: 14px; }
}

@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); }
  .page-title { font-size: 1rem; }
  .btn-lg { padding: 12px 20px; font-size: .95rem; }
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Loading spinner ───────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

html, body { overflow-x: hidden; max-width: 100vw; }

/* ── Mobile: horizontales Überlaufen verhindern ────────────────────────────── */
@media (max-width: 767px) {
  .main-content     { max-width: 100vw; overflow-x: hidden; }
  .page-body        { max-width: 100%; }
  .table-wrap       { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  canvas            { max-width: 100% !important; width: 100% !important; height: auto !important; }
  .chart-wrap       { overflow: hidden; }
}

/* ── Cart Sticky-Footer + Drawer (Mobile only) ─────────────────────────────── */
.cart-sticky-footer {
  display: none;
}
.cart-drawer-overlay {
  display: none;
}

@media (max-width: 767px) {
  .cart-sticky-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 62px;
    z-index: 1095;
    padding: 10px 16px;
    background: var(--brand-primary);
    color: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0,0,0,.35);
    cursor: pointer;
    font-weight: 600;
    user-select: none;
  }
  .cart-sticky-icon  { font-size: 1.15rem; }
  .cart-sticky-count { font-size: .85rem; opacity: .9; }
  .cart-sticky-total { margin-left: auto; font-size: 1rem; font-weight: 700; }
  .cart-sticky-arrow { font-size: 1.1rem; opacity: .85; margin-left: 4px; }

  .cart-drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1140;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .cart-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
}
