/* ============================================================
   TANKSTELLEN PORTAL — Artikel-Mapping & Warenbestandsvergleich
   Dark Dashboard CSS
   ============================================================ */

:root {
  --bg-root:       #0d1018;
  --bg-sidebar:    #111420;
  --bg-card:       #171b2a;
  --bg-card-hover: #1e2335;
  --bg-input:      #1a1e2e;
  --bg-table-alt:  #131726;
  --bg-overlay:    rgba(0,0,0,0.72);

  --accent:        #4f8ef7;
  --accent-dark:   #3a6fcc;
  --accent-purple: #9c6af7;
  --green:         #3ecf8e;
  --yellow:        #f7c44f;
  --red:           #f05252;
  --orange:        #f07850;

  --text-primary:  #e2e6f3;
  --text-secondary:#9ca8c8;
  --text-muted:    #5a6585;

  --border:        #252b3f;
  --border-light:  #2f374f;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);

  --sidebar-w:     230px;
  --header-h:      56px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout Shell ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  transition: transform 0.25s ease;
  overflow-y: auto;
}
#app-shell {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
#topbar {
  height: var(--header-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  gap: 0.8rem;
  flex-shrink: 0;
}
#content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  -webkit-overflow-scrolling: touch;
  /* Seitenwechsel-Übergang */
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.13s ease, transform 0.13s ease;
  will-change: opacity, transform;
}

/* ── Sidebar ── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}
.logo-icon { font-size: 1.2rem; }
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.sidebar-nav { padding: 0.5rem 0.5rem; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
  background: rgba(79,142,247,0.15);
  color: var(--accent);
  font-weight: 600;
}
.nav-badge {
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.nav-badge-blue { background: var(--accent); }
.sidebar-footer {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Hamburger ── */
#hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.3rem;
}
#topbar-title { font-size: 0.9rem; color: var(--text-secondary); flex: 1; }

/* ── Page Header ── */
.page-header { margin-bottom: 1.2rem; }
.page-header h1 { font-size: 1.45rem; font-weight: 700; }
.page-sub { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.2rem; }

/* ── Section Cards ── */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  margin-bottom: 1rem;
}
.section-card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  color: var(--text-primary);
}

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border-light);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-green::before { background: var(--green); }
.kpi-yellow::before { background: var(--yellow); }
.kpi-red::before { background: var(--red); }
.kpi-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1; margin-bottom: 0.3rem; }
.kpi-sub { font-size: 0.72rem; color: var(--text-secondary); }
.kpi-sub a { color: var(--accent); }

/* ── Action Cards ── */
.action-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.action-icon { font-size: 1.8rem; flex-shrink: 0; }
.action-card p { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.2rem; }
.action-card .btn { margin-left: auto; flex-shrink: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { background: var(--bg-card-hover); color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-secondary:hover:not(:disabled) { background: var(--border-light); }
.btn-danger { background: rgba(240,82,82,0.15); color: var(--red); border: 1px solid rgba(240,82,82,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(240,82,82,0.25); }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.action-row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.action-buttons-grid {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 500;
}
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }
.form-control-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6585' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

/* ── Filter Row ── */
.filter-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.filter-row .form-control { flex: 1; min-width: 120px; }

/* ── Tables ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.data-table th {
  background: var(--bg-root);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.data-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover td { background: var(--bg-card-hover); }
.data-table tbody tr:nth-child(even) td { background: var(--bg-table-alt); }
.data-table tbody tr:nth-child(even):hover td { background: var(--bg-card-hover); }
.row-unknown td { background: rgba(247,196,79,0.04); }

/* ── Badges & Chips ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
}
.badge-green { background: rgba(62,207,142,0.15); color: var(--green); border: 1px solid rgba(62,207,142,0.3); border-radius: 4px; padding: 1px 6px; font-size: 0.72rem; }
.badge-yellow { background: rgba(247,196,79,0.15); color: var(--yellow); border: 1px solid rgba(247,196,79,0.3); border-radius: 4px; padding: 1px 6px; font-size: 0.72rem; }
.badge-red { background: rgba(240,82,82,0.15); color: var(--red); border: 1px solid rgba(240,82,82,0.3); border-radius: 4px; padding: 1px 6px; font-size: 0.72rem; }
.badge-blue { background: rgba(79,142,247,0.15); color: var(--accent); border: 1px solid rgba(79,142,247,0.3); border-radius: 4px; padding: 1px 6px; font-size: 0.72rem; }
.badge-gray { background: var(--bg-card-hover); color: var(--text-secondary); border: 1px solid var(--border-light); border-radius: 4px; padding: 1px 6px; font-size: 0.72rem; }

/* ── File Drop Zone ── */
.file-drop {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--text-secondary);
}
.file-drop:hover, .file-drop.drag-over {
  border-color: var(--accent);
  background: rgba(79,142,247,0.05);
}
.file-drop-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.file-drop p { font-size: 0.85rem; margin-bottom: 0.8rem; }
.file-info {
  margin-top: 0.8rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ── Location Row ── */
.location-select-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.location-select-row select { flex: 1; min-width: 140px; }
.new-loc-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
  width: 100%;
}
.new-loc-form .form-control { flex: 1; min-width: 100px; }

/* ── Column Mapping Table ── */
.col-map-table .col-name { font-weight: 500; }
.col-map-table .col-sample { font-size: 0.78rem; color: var(--text-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Column Map Summary ── */
.col-map-summary { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.col-map-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.col-map-type { font-weight: 600; color: var(--text-primary); }
.col-map-orig { color: var(--text-muted); font-style: italic; }

/* ── Header Row Preview ── */
.header-row-preview { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.header-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ── Info & Warning Banners ── */
.info-banner {
  background: rgba(79,142,247,0.08);
  border: 1px solid rgba(79,142,247,0.25);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.warning-banner {
  background: rgba(247,196,79,0.08);
  border: 1px solid rgba(247,196,79,0.25);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.82rem;
  color: var(--yellow);
  margin-bottom: 1rem;
}

/* ── Mapping Page ── */
.mapping-progress {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.mapping-article-card { border-left: 3px solid var(--accent); }
.mapping-article-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.article-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}
.detail-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.3rem;
}
.detail-val { font-size: 0.85rem; }

/* ── Match Cards ── */
.match-list { display: flex; flex-direction: column; gap: 0.6rem; }
.match-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  transition: border-color 0.15s;
}
.match-high { border-left: 3px solid var(--green); }
.match-medium { border-left: 3px solid var(--yellow); }
.match-low { border-left: 3px solid var(--red); }
.match-score { text-align: center; flex-shrink: 0; }
.score-ring {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.match-high .score-ring { background: rgba(62,207,142,0.15); color: var(--green); border: 2px solid rgba(62,207,142,0.4); }
.match-medium .score-ring { background: rgba(247,196,79,0.15); color: var(--yellow); border: 2px solid rgba(247,196,79,0.4); }
.match-low .score-ring { background: rgba(240,82,82,0.12); color: var(--red); border: 2px solid rgba(240,82,82,0.3); }
.score-label { font-size: 0.62rem; color: var(--text-muted); margin-top: 2px; }
.match-info { flex: 1; min-width: 0; }
.match-name { font-size: 0.9rem; margin-bottom: 0.2rem; }
.match-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.match-locations { margin-bottom: 0.3rem; }
.match-reasons { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.reason-chip {
  background: rgba(79,142,247,0.1);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.7rem;
}
.match-action { flex-shrink: 0; padding-top: 0.2rem; }
.no-matches-hint {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}

/* ── Master Search Dialog ── */
.master-search-results { max-height: 350px; overflow-y: auto; margin-top: 0.5rem; }
.master-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}
.master-search-item:last-child { border-bottom: none; }
.master-search-item:hover { background: var(--bg-card-hover); border-radius: var(--radius-sm); }

/* ── Empty State ── */
.empty-state { font-size: 3rem; margin-bottom: 0.5rem; display: block; }
.center-content { text-align: center; padding: 2rem; }

/* ── Debug Pre ── */
.debug-pre {
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  font-size: 0.75rem;
  overflow-x: auto;
  color: var(--green);
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.5;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ── Notification Toast ── */
.notif {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.8rem 1.2rem;
  font-size: 0.83rem;
  box-shadow: var(--shadow);
  z-index: 9999;
  transform: translateY(120%);
  transition: transform 0.3s ease;
  max-width: 320px;
}
.notif.show { transform: translateY(0); }
.notif-success { border-left: 3px solid var(--green); }
.notif-error { border-left: 3px solid var(--red); }
.notif-info { border-left: 3px solid var(--accent); }
.notif-warning { border-left: 3px solid var(--yellow); }

/* ── Modal ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#modal-overlay.active { display: flex; }
#modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#modal-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#modal-title { font-weight: 600; font-size: 0.95rem; }
#modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}
#modal-body { padding: 1.2rem; overflow-y: auto; flex: 1; }
#modal-footer {
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.3rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Text Utilities ── */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.82em; }

/* ── Comparison Table ── */
.comp-diff-positive { color: var(--green); }
.comp-diff-negative { color: var(--red); }

/* ── Sheet Buttons ── */
.sheet-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* ── Responsive: Mobile ── */
@media (max-width: 768px) {
  body { overflow: auto; }

  #sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: block; }

  #app-shell { margin-left: 0; }

  #hamburger { display: block; }

  #content { padding: 1rem; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }

  .action-card { flex-wrap: wrap; }
  .action-card .btn { margin-left: 0; }

  .match-card { flex-wrap: wrap; }

  .article-details-grid { grid-template-columns: 1fr 1fr; }

  .data-table th, .data-table td { padding: 0.5rem 0.6rem; }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.6rem; }
}

/* ================================================================
   MOBILE OPTIMIERUNGEN — iPhone / PWA
   Ergänzungen für Touch-Bedienung, Bottom-Nav, Card-Layouts
   ================================================================ */

/* ── Basis-Touch ─────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Mindest-Touch-Target 44px für alle interaktiven Elemente */
  .btn {
    min-height: 44px;
    padding: 0.65rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 10px;
  }
  .btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
  }

  /* Formulare: größere Felder */
  .form-control {
    min-height: 44px;
    font-size: 1rem;         /* verhindert Auto-Zoom auf iOS */
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
  }
  select.form-control { min-height: 44px; }
  textarea.form-control { min-height: 80px; font-size: 1rem; }

  /* Filter-Zeilen: untereinander stapeln */
  .filter-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  .filter-row .form-control { min-width: 0; width: 100%; }

  /* Tabellen: horizontales Scrollen mit Hinweis */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }
  .data-table { font-size: 0.82rem; }
  .data-table th, .data-table td {
    padding: 0.55rem 0.65rem;
    white-space: nowrap;
  }

  /* Kein unnötiges horizontales Overflow */
  #content { padding: 0.85rem; overflow-x: hidden; }

  /* Abstand unten für Bottom-Navigation */
  #content { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

  /* KPI-Grid: 2 Spalten auf Mobil */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .kpi-card { padding: 0.75rem; }
  .kpi-value { font-size: 1.5rem; }

  /* Section-Cards: weniger Padding */
  .section-card { padding: 0.85rem; margin-bottom: 0.75rem; }
  .section-card h2 { font-size: 0.92rem; }

  /* Page-Header kompakter */
  .page-header { margin-bottom: 0.85rem; }
  .page-header h1 { font-size: 1.2rem; }
  .page-sub { font-size: 0.78rem; }

  /* Action-Cards: gestapelt */
  .action-card { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .action-card .btn { width: 100%; justify-content: center; }

  /* Modals: volle Breite, von unten */
  #modal-box {
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 88vh;
    overflow-y: auto;
  }
  #modal-overlay {
    align-items: flex-end;
  }

  /* Topbar: Titel sichtbarer */
  #topbar { padding: 0 1rem; min-height: 52px; }
  #topbar-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
  #hamburger { min-width: 44px; min-height: 44px; font-size: 1.1rem; }

  /* Sidebar-Overlay dunkler */
  #sidebar.open { box-shadow: 0 0 0 100vw rgba(0,0,0,0.6); }

  /* Toast unten, über Bottom-Nav */
  #notif { bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; }

  /* iOS-Install-Banner: über Bottom-Nav */
  #ios-install-banner { bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ── Mobile Bottom Navigation ────────────────────────────────── */

#mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  #mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.3);
  }
}

.mob-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 4px;
  min-height: 56px;
  font-family: inherit;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s;
}
.mob-tab:active { opacity: 0.7; }
.mob-tab.mob-active { color: var(--accent); }
.mob-tab.mob-active .mob-icon { transform: translateY(-1px); }

.mob-icon {
  font-size: 1.3rem;
  line-height: 1;
  transition: transform 0.12s;
}
.mob-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.mob-badge {
  position: absolute;
  top: 5px;
  right: 50%;
  transform: translateX(10px);
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1.5px solid var(--bg-sidebar);
}

/* ── Card-Layout für Differenz/Transfer-Listen ───────────────── */

@media (max-width: 600px) {

  /* Diff-Tabelle → Card-Ansicht */
  .diff-row-mobile {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem;
    margin-bottom: 0.6rem;
    gap: 0.4rem;
  }
  .diff-card-name {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-primary);
  }
  .diff-card-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
  }
  .diff-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .diff-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.3rem;
  }
  .diff-card-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Transfer-Karten: Vollbreite, übersichtlich */
  .transfer-mobile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
  }
  .transfer-mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
  }
  .transfer-mobile-route {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
  }
  .transfer-mobile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }
  .transfer-mobile-actions .btn {
    justify-content: center;
  }

  /* FAB — Floating Action Button */
  #fab-btn {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 8px) + 12px);
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(79,142,247,0.45);
    cursor: pointer;
    z-index: 85;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, box-shadow 0.15s;
  }
  #fab-btn:active { transform: scale(0.92); }
}

/* ── Notif-Toast Verbesserung (alle Größen) ──────────────────── */
.notif {
  max-width: calc(100vw - 32px) !important;
  word-break: break-word;
}

/* ── Tabellen auf sehr kleinen Screens: sanftes Scrollen ─────── */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-card { padding: 0.65rem 0.7rem; }

  /* Buttons in Aktions-Gruppen: volle Breite */
  .action-buttons-grid {
    flex-direction: column;
  }
  .action-buttons-grid .btn { width: 100%; justify-content: center; }
}

/* ── Portal-Rücknavigation ───────────────────────────────────── */

/* Sidebar: Portal-Link zwischen Header und Nav */
.sidebar-portal-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  margin: 0 0.5rem 0.25rem;
  border-radius: var(--radius-sm);
  background: rgba(26, 107, 255, 0.1);
  border: 1px solid rgba(26, 107, 255, 0.2);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.12s;
  flex-shrink: 0;
}
.sidebar-portal-link:hover  { background: rgba(26, 107, 255, 0.17); }
.sidebar-portal-link:active { background: rgba(26, 107, 255, 0.25); }
.sidebar-portal-arrow {
  margin-left: auto;
  font-size: 1rem;
  opacity: 0.6;
}

/* Topbar: Portal-Home-Icon rechts */
#topbar-portal-link {
  display: none; /* Desktop: Sidebar reicht */
  text-decoration: none;
  font-size: 1.15rem;
  padding: 6px 8px;
  border-radius: 8px;
  line-height: 1;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}
#topbar-portal-link:active { background: var(--bg-card-hover); }

@media (max-width: 768px) {
  #topbar-portal-link {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* Topbar-Titel zentriert zwischen Hamburger und Home */
  #topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  #topbar-title {
    flex: 1;
    text-align: center;
  }
}

/* mob-tab als <a> (Portal-Link) gleich aussehen wie <button> */
a.mob-tab {
  text-decoration: none;
  color: var(--text-muted);
}
a.mob-tab:active { opacity: 0.7; }
