/* ═══════════════════════════════════════════════════════════════════════════
   Markthelfer – Global Stylesheet
   Colors: Primary #2E75B6 | OK #27AE60 | Warn #E74C3C
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --primary: #2E75B6;
  --primary-d: #235e92;
  --primary-l: #e8f1fb;
  --ok: #27AE60;
  --ok-l: #e9f7ef;
  --warn: #E74C3C;
  --warn-l: #fdecea;
  --yellow: #f39c12;
  --yellow-l: #fff8e1;
  --bg: #f0f4f8;
  --sidebar-bg: #1a2744;
  --sidebar-w: 240px;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .08);
  --transition: .18s ease;
  --bottom-nav: 56px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #cbd5e0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .02em;
}

.sidebar-brand .icon {
  font-size: 1.5rem;
}

.sidebar-section {
  padding: .5rem 1rem .25rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #4a6080;
  margin-top: .5rem;
}

.sidebar-nav {
  flex: 1;
  padding: .5rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .6rem 1rem;
  color: #a0aec0;
  font-size: .9rem;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .07);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(46, 117, 182, .3);
  color: #fff;
  border-left: 3px solid var(--primary);
}

.nav-item .nav-icon {
  font-size: 1.05rem;
  min-width: 20px;
  text-align: center;
}

.nav-item .nav-label {
  flex: 1;
}

/* Locked module */
.nav-item.locked {
  opacity: .45;
  cursor: default;
}

.nav-item.locked:hover {
  background: none;
  color: #a0aec0;
}

.nav-item.locked::after {
  content: '🔒';
  font-size: .75rem;
  margin-left: auto;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: .8rem;
  color: #4a6080;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top header ────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
}

/* App-Name neben Hamburger – nur auf Mobile sichtbar */
.topbar-brand {
  display: none;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .875rem;
}

.topbar-user a {
  color: var(--warn);
  font-size: .8rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: .25rem;
}

/* ── Page content ──────────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.page-sub {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: .1rem;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* ── Detail view helpers ────────────────────────────────────────────────────── */
.detail-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .6rem;
}

.detail-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem .75rem;
  font-size: .9rem;
}

.detail-dl dt {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.detail-dl dd {
  color: var(--text);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-weight: 600;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Grid ──────────────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 1rem;
}

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

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

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

/* ── Stat cards ────────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: var(--primary-l);
}

.stat-icon.green {
  background: var(--ok-l);
}

.stat-icon.red {
  background: var(--warn-l);
}

.stat-icon.yellow {
  background: var(--yellow-l);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  background: #f7fafc;
  font-weight: 600;
  text-align: left;
  padding: .75rem 1rem;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th:hover {
  background: #edf2f7;
}

.data-table th .sort-icon {
  margin-left: .25rem;
  opacity: .4;
}

.data-table th.sort-asc .sort-icon::after {
  content: ' ↑';
  opacity: 1;
}

.data-table th.sort-desc .sort-icon::after {
  content: ' ↓';
  opacity: 1;
}

.data-table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: #f7fafc;
}

.data-table .actions,
.row-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

.form-inline {
  display: inline;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  min-height: 44px;
  /* Touch target */
  text-decoration: none;
}

.btn:hover {
  opacity: .88;
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-ok,
.btn-success {
  background: var(--ok);
  color: #fff;
}

.btn-warning {
  background: var(--yellow);
  color: #fff;
}

.btn-danger {
  background: var(--warn);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-secondary {
  background: #edf2f7;
  color: var(--text);
}

.btn-sm {
  padding: .35rem .75rem;
  font-size: .8rem;
  min-height: 36px;
}

.btn-icon {
  padding: .5rem;
  border-radius: 8px;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: #4a5568;
}

.form-control {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: #fff;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 117, 182, .15);
}

.form-control.is-invalid {
  border-color: var(--warn);
}

.form-text {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.form-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-primary {
  background: var(--primary-l);
  color: var(--primary);
}

.badge-ok {
  background: var(--ok-l);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-l);
  color: var(--warn);
}

.badge-err {
  background: #FED7D7;
  color: #C53030;
}

.badge-yellow {
  background: var(--yellow-l);
  color: var(--yellow);
}

.badge-gray {
  background: #edf2f7;
  color: var(--text-muted);
}

/* ── Alerts / Flash ────────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.alert-success {
  background: var(--ok-l);
  border-left: 4px solid var(--ok);
  color: #1a5c38;
}

.alert-success {
  background: var(--ok-l);
  border-left: 4px solid var(--ok);
  color: #1a5c38;
}

.alert-error {
  background: var(--warn-l);
  border-left: 4px solid var(--warn);
  color: #7b1c1c;
}

.alert-info {
  background: var(--primary-l);
  border-left: 4px solid var(--primary);
  color: #1a3a60;
}

.alert-warning {
  background: var(--yellow-l);
  border-left: 4px solid var(--yellow);
  color: #7d4e00;
}

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  justify-content: center;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  transition: background var(--transition);
  text-decoration: none;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.pagination a:hover {
  background: var(--primary-l);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination .disabled {
  opacity: .4;
  cursor: default;
  pointer-events: none;
}

/* ── Table search bar ──────────────────────────────────────────────────────── */
.table-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}

.table-search {
  flex: 1;
  min-width: 200px;
  padding: .55rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
}

.table-search:focus {
  outline: none;
  border-color: var(--primary);
}

.upgrade-banner {
  background: linear-gradient(135deg, #1a2744 0%, #2E75B6 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 500px;
  margin: 3rem auto;
}

.upgrade-banner h2 {
  font-size: 1.4rem;
  margin-bottom: .5rem;
}

.upgrade-banner p {
  opacity: .85;
  margin-bottom: 1.25rem;
  font-size: .95rem;
}

.upgrade-price {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -.02em;
}

.upgrade-actions {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.upgrade-banner .btn {
  background: #fff;
  color: var(--primary);
  font-weight: 700;
}

/* ── License expiry warning banner ──────────────────────────────────────────── */
.expiry-banner {
  background: var(--yellow-l);
  border-left: 4px solid var(--yellow);
  border-radius: 0;
  padding: .6rem 1.25rem;
  font-size: .85rem;
  margin-bottom: 0;
}

.expiry-banner-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  max-width: 1200px;
  margin: 0 auto;
}

.expiry-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.expiry-text {
  flex: 1;
  color: #7d4e00;
  line-height: 1.4;
}

.expiry-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #a07000;
  line-height: 1;
  padding: .1rem .3rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.expiry-close:hover {
  background: rgba(0, 0, 0, .06);
}

/* ── Status colors ─────────────────────────────────────────────────────────── */
.status-geplant {
  color: var(--primary);
}

.status-bestaetigt {
  color: var(--ok);
}

.status-abgesagt {
  color: var(--warn);
}

.status-abgeschlossen {
  color: var(--text-muted);
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .2);
  transform: scale(.96);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.mt-1 {
  margin-top: .5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: .5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: .875rem;
}

.fw-bold {
  font-weight: 700;
}

.d-flex {
  display: flex;
}

.gap-1 {
  gap: .5rem;
}

.gap-2 {
  gap: 1rem;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.w-100 {
  width: 100%;
}

/* ── Bottom Nav (Mobile) ────────────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--sidebar-bg);
  border-top: 1px solid rgba(255, 255, 255, .1);
  z-index: 200;
  height: var(--bottom-nav);
}

.bottom-nav-items {
  display: flex;
  height: 100%;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #718096;
  font-size: .6rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
  transition: color var(--transition);
}

.bottom-nav-item .bn-icon {
  font-size: 1.2rem;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item:hover {
  color: #fff;
  text-decoration: none;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    padding-bottom: var(--bottom-nav);
  }

  .menu-toggle {
    display: block;
  }

  .topbar-title {
    display: none;
  }

  .topbar-brand {
    display: block;
  }

  .bottom-nav {
    display: block;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 199;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .page-content {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2744 0%, #2E75B6 100%);
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .2);
}

.login-logo {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: .5rem;
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .25rem;
}

.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: 1.75rem;
}

/* ── Dark Mode ─────────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2d3148;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --primary-l: #1a2744;
  --ok-l: #0d2b1a;
  --warn-l: #2d1010;
  --yellow-l: #2a2000;
  --shadow: 0 2px 12px rgba(0, 0, 0, .4);
  --sidebar-bg: #0d1020;
}

[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] .card {
  background: var(--card);
  border-color: var(--border);
}

[data-theme="dark"] .topbar {
  background: var(--card);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .form-control {
  background: #252840;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .data-table thead th {
  background: #1f2235;
}

[data-theme="dark"] .data-table tbody tr:hover {
  background: #1f2235;
}

[data-theme="dark"] .btn-ghost {
  color: var(--text-muted);
}

[data-theme="dark"] .menu-toggle {
  color: var(--text);
}

[data-theme="dark"] .alert {
  border-color: var(--border);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #252840;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .btn-secondary {
  background: #2d3148;
  color: #e2e8f0;
  border-color: #3d4265;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #3a4060;
}

[data-theme="dark"] .btn-ghost {
  color: #93a3c0;
  border-color: #3d4265;
}

[data-theme="dark"] .btn-ghost:hover {
  background: #1f2235;
  color: #e2e8f0;
}

/* ── Compact table view ────────────────────────────────────────────────────── */
.table-wrap.compact .data-table td,
.table-wrap.compact .data-table th {
  padding: .3rem .6rem;
  font-size: .8rem;
}

.table-wrap.compact .data-table td img {
  width: 22px !important;
  height: 22px !important;
}

/* ── Toast notifications ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1.1rem;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .18);
  border-left: 4px solid var(--primary);
  font-size: .9rem;
  pointer-events: auto;
  max-width: 360px;
  animation: toastIn .3s cubic-bezier(.34, 1.3, .64, 1) both;
  transition: opacity .4s, transform .4s;
}

.toast.toast-success {
  border-color: var(--ok);
}

.toast.toast-error {
  border-color: var(--warn);
}

.toast.toast-warning {
  border-color: var(--yellow);
}

.toast.toast-out {
  opacity: 0;
  transform: translateX(1.5rem);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(2rem);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Dark Mode toggle button ───────────────────────────────────────────────── */
.topbar-tools {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: .3rem .4rem;
  border-radius: 6px;
  transition: background var(--transition);
  line-height: 1;
  color: var(--text-muted);
}

.btn-icon:hover {
  background: var(--border);
  color: var(--text);
}

/* ── Form-hint tooltips ─────────────────────────────────────────────────────── */
/* .form-hint spans are transformed to ⓘ icons by app.js automatically.        */

/* Hide the raw text when JS has run */
.form-hint {
  display: none;
}

/* Wrapper injected by JS next to the label */
.fh-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: .3rem;
}

/* The ⓘ icon button */
.fh-tip__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 700;
  font-style: normal;
  cursor: help;
  user-select: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}

.fh-tip__icon:hover,
.fh-tip__icon:focus-visible {
  background: var(--primary);
  color: #fff;
  outline: none;
}

/* The tooltip bubble */
.fh-tip__bubble {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 280px;
  background: #2d3748;
  color: #f7fafc;
  font-size: .78rem;
  line-height: 1.5;
  padding: .5rem .75rem;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  z-index: 500;
  pointer-events: none;

  /* Arrow */
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2d3748;
  }
}

/* Show on hover (desktop) or .show class (touch) */
.fh-tip:hover .fh-tip__bubble,
.fh-tip:focus-within .fh-tip__bubble,
.fh-tip.show .fh-tip__bubble {
  display: block;
}

/* Dark mode adjustment */
[data-theme="dark"] .fh-tip__icon {
  background: rgba(255, 255, 255, .12);
  color: #a0aec0;
}

[data-theme="dark"] .fh-tip__icon:hover {
  background: var(--primary);
  color: #fff;
}

/* ── Kebab / row-action menu ──────────────────────────────────────────────── */

.row-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
}

/* Hide the default disclosure triangle */
.kebab>summary {
  list-style: none;
}

.kebab>summary::-webkit-details-marker {
  display: none;
}

.kebab {
  position: relative;
  display: inline-block;
}

.kebab__menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 170px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  z-index: 300;
  padding: .3rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.kebab__item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  border-radius: 6px;
  font-size: .85rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition);
  cursor: pointer;
}

.kebab__item:hover {
  background: var(--primary-l);
  color: var(--primary);
}

.kebab__item--danger:hover {
  background: var(--warn-l);
  color: var(--warn);
}

/* button variant (for form submits) */
.kebab__item--btn {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
}

.kebab__divider {
  height: 1px;
  background: var(--border);
  margin: .25rem .5rem;
}

/* Dark mode */
[data-theme="dark"] .kebab__menu {
  background: #1e2a3a;
  border-color: rgba(255, 255, 255, .1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

[data-theme="dark"] .kebab__item:hover {
  background: rgba(46, 117, 182, .25);
}

/* ══════════════════════════════════════════════════════════════════════════
   Mobile-first Verbesserungen  ≤ 600 px
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── Topbar: Name ausblenden, nur Abmelden-Link zeigen ── */
  .topbar-user span {
    display: none;
  }

  /* ── Page-Header: vertikal stacken ── */
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header>a.btn,
  .page-header>.btn,
  .page-header>div.d-flex {
    width: 100%;
    justify-content: center;
  }

  /* ── Filter-Bars: Inputs auf volle Breite ── */
  .table-controls .form-control,
  form.d-flex .form-control,
  form[class*="d-flex"] .form-control {
    width: 100%;
    max-width: none !important;
    min-width: 0;
  }

  /* ── Tabellen → Card-Stack-Layout ── */
  .table-wrap {
    overflow-x: unset;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .75rem;
    padding: .6rem .75rem;
    background: var(--card);
    box-shadow: var(--shadow);
  }

  .data-table tr:last-child td {
    border-bottom: none;
  }

  .data-table tr:hover td {
    background: transparent;
  }

  .data-table tr:hover {
    background: var(--primary-l);
  }

  .data-table td {
    padding: .3rem 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
  }

  /* Das data-label wird als Label vor dem Wert gezeigt */
  .data-table td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: .75rem;
    min-width: 90px;
    flex-shrink: 0;
  }

  /* Action-Zellen: kein Label, rechtsbündig */
  .data-table td[data-label=""]::before,
  .data-table td:not([data-label])::before {
    display: none;
  }

  .data-table td:not([data-label]) {
    justify-content: flex-end;
  }

  /* ── Packliste: Add-Form vertikal stacken ── */
  .packlist-add-form {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .packlist-add-form .form-control {
    max-width: none !important;
    width: 100%;
  }

  .packlist-add-form .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Buttons in btn-Actions-Zeile: Touch-Targets größer ── */
  .data-table td .btn-sm {
    min-height: 40px;
    min-width: 40px;
  }

  /* ── Bulk-Bar responsive ── */
  #bulkBar {
    flex-direction: column;
    align-items: stretch !important;
  }

  #bulkBar .btn,
  #bulkBar .d-flex {
    width: 100%;
    justify-content: center;
  }

}

@media (max-width: 480px) {

  /* Topbar: Abmelden-Text kürzen */
  .topbar-user a::before {
    content: '→';
  }

  .topbar-user a {
    font-size: 0;
    /* Text ausblenden */
    padding: .25rem .4rem;
  }

  .topbar-user a::before {
    font-size: .85rem;
  }

  /* Stand-Designer: Palette in 2 Spalten */
  .stand-palette {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
  }

  .stand-el-btn {
    width: 100% !important;
  }
}

/* ── Mobile: Tablets (≤ 900px) ─────────────────────────────────────────────── */
@media (max-width: 900px) {

  /* 4-column stat grid → 2 columns */
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 3-column grid → 2 columns */
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Settings grid – vertical stacking */
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Mobile: Phones (≤ 600px) ──────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* All multi-column grids → single column */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  /* Page header: stack title and actions vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
  }

  .page-header .btn,
  .page-header a.btn {
    align-self: stretch;
    justify-content: center;
  }

  /* Page content padding reduction */
  .page-content {
    padding: 1rem .75rem;
  }

  /* Cards: reduce padding */
  .card {
    padding: .9rem;
  }

  /* Stat cards: smaller */
  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  /* ── Tables: Card-Layout auf Mobile (= m-card Design) ───────────────────── */
  .table-wrap {
    overflow-x: unset;
  }

  .data-table {
    min-width: unset;
    display: block;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: block;
  }

  /* Jede Zeile = eine Karte (identisch zu .m-card) */
  .data-table tr {
    display: block;
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid #e2e8f0;
    margin-bottom: .75rem;
    padding: 0;
    /* kein Padding auf tr – Padding liegt auf td */
    border-bottom: none;
    overflow: hidden;
  }

  .data-table tr:hover td {
    background: #f7fafc;
    /* dezenter Hover */
  }

  /* Jede Zelle = eine label:wert Zeile (identisch zu .m-field) */
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .35rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: .875rem;
    gap: .5rem;
    background: #ffffff;
    color: #1a202c;
  }

  .data-table td:last-child {
    border-bottom: none;
  }

  /* Label links (identisch zu .m-field__label) */
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #4a5568;
    font-size: .75rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Aktions-Spalte: kein Label, rechtsbündig, grauer Hintergrund wie m-card__actions */
  .data-table td:not([data-label]),
  .data-table td[data-label=""] {
    justify-content: flex-end;
    background: #fafbfc;
    border-top: 1px solid #e2e8f0;
    border-bottom: none;
  }

  .data-table td:not([data-label])::before,
  .data-table td[data-label=""]::before {
    display: none;
  }

  /* Verstecke unwichtige Spalten auf Mobile */
  .data-table td[data-mobile="hide"] {
    display: none;
  }

  /* Aktions-Buttons nebeneinander */
  .data-table .actions,
  .data-table .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    justify-content: flex-end;
    width: 100%;
  }

  /* Checkbox-Spalte ausblenden auf Mobile */
  .data-table td:has(input[type=checkbox]) {
    display: none;
  }

  /* d-flex wrapping on mobile */
  .d-flex.gap-1 {
    flex-wrap: wrap;
  }

  /* Filter-Formulare auf Mobile: Felder nehmen volle Breite */
  .d-flex.gap-1 .form-control {
    max-width: 100% !important;
    width: 100%;
    flex: 1 1 140px;
  }

  /* Table controls: volle Breite */
  .table-controls {
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }

  .table-search {
    min-width: unset;
    width: 100%;
  }

  /* Row-Actions: rechtsbündig, kompakte Touch-Targets */
  .row-actions {
    display: flex;
    justify-content: flex-end;
    gap: .4rem;
    width: 100%;
  }

  /* Kebab-Menü bleibt sichtbar */
  .kebab__menu {
    right: 0;
    left: auto;
  }

  /* Page title font size reduction */
  .page-title {
    font-size: 1.2rem;
  }

  /* Nav tap targets */
  .nav-item {
    padding: .8rem 1rem;
    min-height: 48px;
  }

  /* Onboarding banner: single column */
  #onboardingBanner {
    flex-direction: column;
    gap: .75rem;
  }

  #onboardingBanner>div:last-of-type {
    flex-direction: column;
    gap: .5rem;
  }

  /* ── Mobile: Sidebar Overlay ────────────────────────────────────────────── */

  /* Hide sidebar off-screen by default on phones */
  .sidebar {
    transform: translateX(-100%);
  }

  /* Visible when opened */
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, .4);
  }

  /* Main takes full width, no horizontal overflow */
  .main {
    margin-left: 0;
    overflow-x: hidden;
  }

  /* Show hamburger button */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    line-height: 1;
  }

  /* Show app brand name next to hamburger (replaces big page title) */
  .topbar-brand {
    display: block;
  }

  /* Hide page title in topbar on phones (shown in page-header below) */
  .topbar-title {
    display: none;
  }

  /* Topbar user: hide username text, keep logout link */
  .topbar-user span {
    display: none;
  }
}

/* ── Sidebar backdrop (overlay behind open sidebar) ─────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 190;
  cursor: pointer;
}

.sidebar-backdrop.visible {
  display: block;
}