:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-muted: #8b9eb0;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius: 8px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ----- Login ----- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.login-card .subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dsgvo-hinweis {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

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

.dsgvo-hinweis a:hover { text-decoration: underline; }

#login-form label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

#login-form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

#login-form input:focus {
  outline: none;
  border-color: var(--primary);
}

#login-form button {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

#login-form button:hover { background: var(--primary-hover); }
#login-form button:disabled { opacity: 0.6; cursor: not-allowed; }

.error { color: var(--danger); font-size: 0.9rem; margin-top: 0.5rem; }
.success { color: var(--success); font-size: 0.9rem; margin-top: 0.5rem; }
.login-register-hint { margin-top: 1rem; font-size: 0.9rem; }
.login-register-hint a { color: var(--primary); text-decoration: none; }
.login-register-hint a:hover { text-decoration: underline; }

/* ----- App Shell ----- */
#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

.nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--primary); background: rgba(59,130,246,0.15); }

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
}

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

.dsgvo-footer-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.4rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  z-index: 10;
}

.dsgvo-footer-fixed a { color: var(--primary); text-decoration: none; }
.dsgvo-footer-fixed a:hover { text-decoration: underline; }

.content {
  flex: 1;
  padding: 1.5rem;
  padding-bottom: 3rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ----- Buttons ----- */
.btn-primary {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-secondary:hover { background: rgba(255,255,255,0.05); }

.btn-ghost {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.btn-warning {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-warning:hover { background: rgba(245, 158, 11, 0.3); }
.btn-danger {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.3); }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }

/* ----- Tables & Cards ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2, .card h3 { margin: 0 0 0.75rem; font-size: 1.1rem; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th { color: var(--text-muted); font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-draft   { background: var(--text-muted); color: var(--bg); }
.badge-sent    { background: var(--success); color: #fff; }
.badge-delivered { background: var(--success); color: #fff; }
.badge-opened  { background: var(--success); color: #fff; }
.badge-bounced { background: var(--danger); color: #fff; }
.badge-failed { background: var(--danger); color: #fff; }
.badge-blocked { background: #6b4c9a; color: #fff; }
.badge-pending { background: var(--warning); color: var(--bg); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

/* ----- Forms in content ----- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.checkbox-label {
  display: inline-flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-bottom: 0 !important;
}
.checkbox-label input[type="checkbox"] { width: auto; max-width: none; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.form-group textarea { min-height: 120px; resize: vertical; }

/* ----- Modal ----- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.modal-content ul { margin: 0 0 1rem; padding-left: 1.25rem; }
.modal-content li { margin-bottom: 0.5rem; }

/* Vorlagen: Live-Vorschau */
.template-preview-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .template-preview-wrap { grid-template-columns: 1fr; }
}
.template-preview-pane {
  position: sticky;
  top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.template-preview-pane label {
  display: block;
  padding: 0.5rem 1rem;
  background: var(--bg);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.template-preview-pane iframe {
  display: block;
  width: 100%;
  min-height: 280px;
  height: 320px;
  border: none;
  background: #fff;
}
.modal-preview .modal-content {
  max-width: 90vw;
  width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-preview-iframe-wrap {
  flex: 1;
  min-height: 400px;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
}
.modal-preview-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  min-height: 400px;
  border: none;
}

/* Geplanter Versand: Countdown-Uhr */
.scheduled-countdown {
  background: rgba(0, 212, 170, 0.1);
  border: 1px solid rgba(0, 212, 170, 0.3);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
  font-size: 1.1rem;
}
.scheduled-countdown .countdown-timer {
  font-family: var(--font);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.scheduled-countdown .countdown-done { color: var(--success); }
.scheduled-countdown .countdown-sent { color: var(--text-muted); font-weight: 400; }

/* Neue Kampagne: Vorlage auf Handy immer sichtbar (großer Touch-Bereich) */
.campaign-new-template-wrap {
  margin-bottom: 1rem;
}
.campaign-new-section-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.1rem;
}
.campaign-new-template-hint {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
}
.campaign-new-template-wrap select {
  display: block;
  width: 100%;
  max-width: 100%;
}
@media (max-width: 640px) {
  .campaign-new-template-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.25rem;
  }
  .campaign-new-template-wrap label { display: block; margin-bottom: 0.5rem; }
  .campaign-new-template-wrap select {
    min-height: 44px;
    font-size: 16px;
    width: 100%;
    padding: 0.5rem;
    -webkit-appearance: none;
    appearance: none;
  }
}
@media (min-width: 641px) {
  .campaign-new-template-wrap select { min-height: 2.25rem; max-width: 24rem; }
}
.sr-only-focus:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

@media (max-width: 640px) {
  .header { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; }
}
.user-limit-info {
  font-size: 0.85rem;
  margin-right: 0.75rem;
  white-space: nowrap;
}
.user-limit-info.limit-unlimited,
.user-limit-info.limit-remaining { color: #0a7b0a; }
.user-limit-info.limit-used-up { color: #c00; }
@media (max-width: 640px) {
  .user-limit-info { display: block; margin-bottom: 0.25rem; white-space: normal; }
}
.limit-revoked-banner {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.limit-revoked-banner.hidden { display: none !important; }

/* Kontaktbuch: Schrift der Kontakte weiß */
.contacts-table td,
.contact-list-wrap td { color: #fff; }
/* Kontakte auswählen: heller Kasten mit dunkler Schrift (gut lesbar auf weiß) */
#contact-picker-wrap {
  background: #fff !important;
  color: #1a1a1a !important;
  border: 1px solid #ccc !important;
}
#contact-picker-wrap *,
#contact-picker-wrap p,
#contact-picker-wrap label,
#contact-picker-wrap span,
#contact-picker-wrap .subtitle,
#contact-picker-list,
#contact-picker-list *,
#contact-picker-list label,
#contact-picker-list span,
#contact-picker-list .subtitle {
  color: #1a1a1a !important;
}
#contact-picker-wrap input,
#contact-picker-wrap input::placeholder {
  color: #1a1a1a !important;
  background: #f5f5f5 !important;
  border-color: #999 !important;
}
#contact-picker-wrap input::placeholder {
  color: #555 !important;
}
#contact-picker-wrap .btn-primary,
#contact-picker-wrap .btn-ghost {
  color: #fff !important;
}
#contact-picker-wrap .btn-ghost {
  color: #1a1a1a !important;
  border-color: #999 !important;
}
