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

/* Generische hidden-Klasse */
.hidden { display: none !important; }

:root {
  --red:       #EC0016;
  --bg:        #f5f4f2;
  --surface:   #ffffff;
  --border:    rgba(0,0,0,0.1);
  --border-md: rgba(0,0,0,0.15);
  --text:      #1a1a1a;
  --text-2:    #555;
  --text-3:    #888;
  --green:     #3B6D11;
  --green-bg:  #EAF3DE;
  --amber:     #854F0B;
  --amber-bg:  #FAEEDA;
  --amber-bdr: #FAC775;
  --red-text:  #A32D2D;
  --red-bg:    #FCEBEB;
  --teal:      #085041;
  --teal-bg:   #E1F5EE;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 2px 12px rgba(0,0,0,0.08);
  --nav-h:     60px;
  --top-h:     54px;
  --ubar-h:    32px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #111;
    --surface:   #1e1e1e;
    --border:    rgba(255,255,255,0.1);
    --border-md: rgba(255,255,255,0.15);
    --text:      #f0f0f0;
    --text-2:    #aaa;
    --text-3:    #666;
    --green:     #9FE1CB;
    --green-bg:  #0a2e20;
    --amber:     #FAC775;
    --amber-bg:  #2a1d07;
    --amber-bdr: #7a4e0b;
    --red-text:  #F09595;
    --red-bg:    #2a0a0a;
    --teal:      #9FE1CB;
    --teal-bg:   #0a2a25;
    --shadow:    0 2px 12px rgba(0,0,0,0.4);
  }
}

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden;
}

/* ─── Screens ───────────────────────────────────────────────────────────── */
.screen { display: none; height: 100vh; overflow: hidden; }
.screen.active { display: block; }
#screen-app { height: 100vh; overflow: hidden; }
#screen-app.active { display: flex; flex-direction: column; }

/* ─── Login ─────────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 2rem 1.5rem; gap: 0;
}
.login-logo { margin-bottom: 1rem; }
.login-logo-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 14px;
}
.topbar-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}
.login-wrap h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.login-sub { color: var(--text-3); margin-bottom: 2rem; font-size: 14px; }
.login-wrap form { width: 100%; max-width: 360px; }

.btn-forgot {
  width: 100%; background: none; border: none; color: var(--text-3);
  font-size: 13px; cursor: pointer; padding: 10px 0 0; text-align: center;
  transition: color .15s;
}
.btn-forgot:hover { color: var(--red); }

/* ─── Form elements ─────────────────────────────────────────────────────── */
.field-group { margin-bottom: 12px; }
.field-label {
  display: block; font-size: 10px; font-weight: 600;
  letter-spacing: .06em; color: var(--text-3); margin-bottom: 5px;
}
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-md);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  font-size: 15px; outline: none; transition: border-color .15s; -webkit-appearance: none;
}
input:focus, select:focus { border-color: var(--red); }
.field-row { display: flex; gap: 10px; }
.field-row .field-group { flex: 1; }
.checkbox-group label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.checkbox-group input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--red); cursor: pointer; }

.btn-primary {
  width: 100%; padding: 12px; background: var(--red); color: white;
  border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 8px; transition: opacity .15s;
}
.btn-primary:active { opacity: .85; }

.btn-small {
  padding: 6px 14px; border: 1px solid var(--border-md); border-radius: 20px;
  font-size: 13px; cursor: pointer; background: var(--surface); color: var(--text);
  font-weight: 500; transition: background .1s; white-space: nowrap;
}
.btn-small:active { background: var(--bg); }
.btn-small.danger { border-color: var(--red-text); color: var(--red-text); }
.btn-small.secondary { color: var(--text-3); }

.error-msg {
  font-size: 13px; color: var(--red-text); background: var(--red-bg);
  border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 10px;
}
.error-msg.hidden { display: none; }

/* ─── Top Bar ──────────────────────────────────────────────────────────── */
.topbar {
  height: var(--top-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 14px; flex-shrink: 0;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  cursor: pointer; padding: 4px 6px 4px 0; border-radius: var(--radius-sm); transition: opacity .15s;
}
.topbar-brand:active { opacity: .7; }
.topbar-title { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.topbar-right { display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; border: none; background: transparent; color: var(--text-2);
  cursor: pointer; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.icon-btn:hover { background: var(--bg); }

/* ─── User-Info-Zeile ────────────────────────────────────────────────────── */
.user-bar {
  height: var(--ubar-h); background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 14px; flex-shrink: 0;
}
.ubar-left { display: flex; align-items: center; gap: 7px; }
.ubar-avatar {
  width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: white;
  font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ubar-name { font-size: 12px; font-weight: 600; color: var(--text-2); }
.ubar-badge { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 10px; background: var(--red-bg); color: var(--red-text); }
.ubar-version { font-size: 11px; color: var(--text-3); }

/* ─── Navbar ────────────────────────────────────────────────────────────── */
.navbar {
  order: 10; height: var(--nav-h); background: var(--surface);
  border-top: 1px solid var(--border); display: flex; flex-shrink: 0;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10px; color: var(--text-3); cursor: pointer; border: none;
  background: transparent; transition: color .15s; padding: 0;
}
.nav-item.active { color: var(--red); }
.nav-item svg { flex-shrink: 0; }

/* ─── Content Area ──────────────────────────────────────────────────────── */
.tab-content { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 80px; }
.tab-content.hidden { display: none; }
.tab-content.active { display: block; }

/* ─── Pull-to-Refresh ───────────────────────────────────────────────────── */
.ptr-indicator {
  display: flex; align-items: center; justify-content: center; height: 0; overflow: hidden; opacity: 0;
  transition: height .2s ease, opacity .2s ease; background: var(--bg); gap: 8px; color: var(--text-3); font-size: 13px;
}
.ptr-arrow { display: inline-block; font-size: 18px; color: var(--red); transition: transform .25s ease; line-height: 1; }
.ptr-spinner { display: none; width: 18px; height: 18px; border: 2px solid var(--border-md); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
.ptr-indicator.loading .ptr-arrow  { display: none; }
.ptr-indicator.loading .ptr-spinner { display: block; }
.ptr-indicator.loading { height: 48px !important; opacity: 1 !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Alert Banner ──────────────────────────────────────────────────────── */
.alert-banner {
  background: var(--amber-bg); border-bottom: 1px solid var(--amber-bdr);
  padding: 10px 14px; display: flex; align-items: flex-start; gap: 10px; flex-shrink: 0;
}
.alert-banner.hidden { display: none; }
.alert-icon { width: 18px; height: 18px; background: #EF9F27; border-radius: 50%; color: white; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.alert-text { flex: 1; font-size: 13px; color: var(--amber); line-height: 1.4; }
.alert-close { background: none; border: none; color: var(--amber); cursor: pointer; font-size: 14px; padding: 0; }

/* ─── Summary Grid ──────────────────────────────────────────────────────── */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
.sum-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 12px 14px; }
.sum-card-link { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.sum-card-link:hover  { border-color: var(--red); box-shadow: 0 2px 8px rgba(236,0,22,.1); }
.sum-card-link:active { background: var(--bg); }
.sum-label { font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.sum-value { font-size: 22px; font-weight: 600; color: var(--text); }
.sum-value.green { color: var(--green); }
.sum-value.amber { color: var(--amber); }
.sum-hint { font-size: 10px; color: var(--text-3); margin-top: 6px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .05em; color: var(--text-3); padding: 4px 14px 6px; text-transform: uppercase; }

/* ─── Card List ─────────────────────────────────────────────────────────── */
.card-list { padding: 0 12px; }
.voucher-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 12px 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: border-color .15s; position: relative; flex-wrap: wrap;
}
.voucher-card:active { background: var(--bg); }
.voucher-card.selected { border-color: var(--red); }
.voucher-card.expired { opacity: 0.6; }
.v-checkbox { width: 18px; height: 18px; border: 1.5px solid var(--border-md); border-radius: 5px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all .1s; }
.v-checkbox.checked { background: var(--red); border-color: var(--red); }
.v-checkbox.checked::after { content: '✓'; color: white; font-size: 11px; font-weight: 700; }
.v-info { flex: 1; min-width: 0; }
.v-code { font-size: 13px; font-weight: 600; font-family: monospace; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.v-right { text-align: right; flex-shrink: 0; }
.v-amount { font-size: 16px; font-weight: 700; color: var(--text); }
.v-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px; display: inline-block; margin-top: 4px; }
.badge-valid    { background: var(--green-bg); color: var(--green); }
.badge-warn     { background: var(--amber-bg); color: var(--amber); }
.badge-expired  { background: var(--red-bg);   color: var(--red-text); }
.badge-redeemed { background: var(--teal-bg);  color: var(--teal); }
.v-actions { display: flex; gap: 6px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.v-action-btn { flex: 1; padding: 7px; font-size: 12px; font-weight: 500; border: 1px solid var(--border-md); border-radius: var(--radius-sm); background: var(--bg); color: var(--text-2); cursor: pointer; text-align: center; }
.v-action-btn.primary { border-color: var(--red); color: var(--red); background: var(--red-bg); }

/* ─── List Controls ─────────────────────────────────────────────────────── */
.list-controls { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 12px 8px; flex-shrink: 0; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; align-items: center; }
.filter-row::-webkit-scrollbar { display: none; }
.chip { font-size: 12px; padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border-md); background: var(--bg); color: var(--text-2); white-space: nowrap; cursor: pointer; flex-shrink: 0; font-weight: 500; }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip-scope { font-size: 11px; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text-3); white-space: nowrap; cursor: pointer; flex-shrink: 0; font-weight: 500; }
.chip-scope.active { color: var(--red); border-color: var(--red); }
.chip-refresh { display: flex; align-items: center; gap: 5px; font-size: 11px; padding: 5px 10px; border-radius: 20px; border: 1px solid var(--border-md); background: var(--bg); color: var(--text-3); white-space: nowrap; cursor: pointer; flex-shrink: 0; font-weight: 500; margin-left: auto; transition: color .15s, border-color .15s; }
.chip-refresh:hover { color: var(--red); border-color: var(--red); }
.chip-refresh:active { opacity: .75; }
.sort-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.sort-label { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.sort-row select { width: auto; flex: 1; font-size: 13px; padding: 6px 10px; }
.multi-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--amber-bg); border-bottom: 1px solid var(--amber-bdr); font-size: 13px; color: var(--amber); font-weight: 500; flex-shrink: 0; }
.multi-bar.hidden { display: none; }
#multi-count { flex: 1; }

/* ─── FAB ───────────────────────────────────────────────────────────────── */
.fab { position: fixed; bottom: calc(var(--nav-h) + 16px); right: 16px; width: 52px; height: 52px; background: var(--red); border: none; border-radius: 50%; cursor: pointer; display: none; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(236,0,22,.35); z-index: 50; transition: transform .15s; }
.fab:active { transform: scale(.95); }
.fab-inline { display: block; width: calc(100% - 24px); margin: 8px 12px; padding: 12px; background: var(--red); color: white; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; }

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100; display: flex; flex-direction: column; justify-content: flex-end; }
.modal-overlay.hidden { display: none; }
.modal-sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 12px 16px 32px; max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-handle { width: 40px; height: 4px; background: var(--border-md); border-radius: 2px; margin: 0 auto 14px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-3); cursor: pointer; padding: 4px; }
.modal-sub { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }

/* ─── Einmalcode-Anzeige ─────────────────────────────────────────────────── */
.code-display-box {
  background: var(--bg); border: 2px solid var(--border-md); border-radius: var(--radius);
  padding: 20px; text-align: center; margin: 8px 0;
}
.code-display-value {
  font-family: monospace; font-size: 32px; font-weight: 700; letter-spacing: .15em;
  color: var(--red); margin-bottom: 8px;
}
.code-display-note { font-size: 12px; color: var(--text-3); }
.code-display-warning {
  background: var(--amber-bg); border: 1px solid var(--amber-bdr);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 12px; color: var(--amber); line-height: 1.5; margin-top: 12px;
}

/* ─── Reset-Erfolg ───────────────────────────────────────────────────────── */
.reset-success-box { text-align: center; padding: 24px 0 8px; }
.reset-success-icon {
  width: 48px; height: 48px; background: var(--green-bg); color: var(--green);
  border-radius: 50%; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
}
.reset-success-text { font-size: 16px; font-weight: 600; color: var(--green); }

/* ─── Benutzer-Aktionen ──────────────────────────────────────────────────── */
.users-list { padding: 12px; }
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border-md); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--text-2); flex-shrink: 0; }
.user-info { flex: 1; }
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-3); }
.user-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--red-bg); color: var(--red-text); }
.user-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ─── Audit Log ─────────────────────────────────────────────────────────── */
.audit-list { padding: 12px; }
.audit-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.audit-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-md); flex-shrink: 0; margin-top: 6px; }
.audit-dot.LOGIN                { background: var(--green); }
.audit-dot.ERSTELLT             { background: #378ADD; }
.audit-dot.BEARBEITET           { background: var(--amber); }
.audit-dot.EINGELÖST            { background: var(--teal); }
.audit-dot.GELÖSCHT             { background: var(--red-text); }
.audit-dot.EXPORT_CSV           { background: #534AB7; }
.audit-dot.PASSWORT_GEAENDERT   { background: #888; }
.audit-dot.PASSWORT_RESET       { background: var(--red); }
.audit-dot.RESET_CODE_GENERIERT { background: var(--amber); }
.audit-action { font-size: 13px; font-weight: 600; color: var(--text); }
.audit-detail { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.audit-meta   { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 20px; border-radius: 20px; font-size: 13px; font-weight: 500; z-index: 200; white-space: nowrap; box-shadow: var(--shadow); transition: opacity .3s; }
.toast.hidden { display: none; }

/* ─── Leer-Zustand ──────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty-state p { font-size: 14px; margin-top: 8px; }

/* ─── Scope Toggle ───────────────────────────────────────────────────────── */
.scope-toggle { display: flex; gap: 8px; }
.scope-btn { flex: 1; padding: 10px 8px; border: 1.5px solid var(--border-md); border-radius: var(--radius-sm); background: var(--bg); color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; text-align: center; transition: all .15s; }
.scope-btn.active { border-color: var(--red); background: var(--red-bg); color: var(--red-text); }
