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

:root {
  --bg: #f1f3fb;
  --card: #fff;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 24px rgba(15,23,42,.08), 0 1px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 8px 40px rgba(15,23,42,.13);
  --r: 12px;
  --r-sm: 8px;
  --r-xs: 6px;
}

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

/* ── Navigation ── */
nav {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #4c1d95 100%);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 58px;
  box-shadow: 0 2px 20px rgba(79,70,229,.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav .brand {
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  letter-spacing: -0.3px;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

nav .brand-dot {
  width: 8px;
  height: 8px;
  background: #a78bfa;
  border-radius: 50%;
  box-shadow: 0 0 8px #a78bfa;
}

nav a {
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all .15s;
}
nav a:hover, nav a.active {
  color: #fff;
  background: rgba(255,255,255,.13);
}
nav a.active { color: #fff; }

.btn-nav-logout {
  margin-left: 8px;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.75);
  border: 1px solid rgba(255,255,255,.18);
  padding: 5px 13px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-nav-logout:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
  border-color: rgba(255,255,255,.3);
}

/* ── Layout ── */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.actions { display: flex; gap: 10px; }

/* ── Typography ── */
h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: 22px;
  margin-bottom: 18px;
}

/* ── Stat Cards ── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--card);
  border-radius: var(--r);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat.stat-pending { border-top-color: #f59e0b; }
.stat.stat-posted  { border-top-color: #10b981; }
.stat.stat-failed  { border-top-color: #ef4444; }

.stat .stat-icon {
  position: absolute;
  right: 16px;
  top: 14px;
  font-size: 22px;
  opacity: .18;
}

.stat .num {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1.5px;
}
.stat.stat-pending .num { color: #d97706; }
.stat.stat-posted  .num { color: #059669; }
.stat.stat-failed  .num { color: #dc2626; }

.stat .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 7px;
  text-transform: uppercase;
  letter-spacing: .7px;
}

/* ── WA Card ── */
.wa-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.wa-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
#qr-container { display: none; margin-top: 18px; text-align: center; }
#qr-container img {
  border: 6px solid var(--border);
  border-radius: 12px;
  max-width: 220px;
}
#qr-container p { margin-top: 10px; color: var(--muted); font-size: 13px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: #fafbff; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .1px;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-green::before  { background: #10b981; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-yellow::before { background: #f59e0b; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-red::before    { background: #ef4444; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-blue::before   { background: #3b82f6; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-purple::before { background: #7c3aed; }
.badge-grey   { background: #f1f5f9; color: #475569; }
.badge-grey::before   { background: #94a3b8; }

.channel-tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--r-xs);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca, #5b21b6);
  box-shadow: 0 4px 14px rgba(79,70,229,.45);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  border-color: #c7d2fe;
  background: #f5f3ff;
  color: var(--primary);
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1.5px solid #fecaca;
}
.btn-danger:hover {
  background: #fecaca;
  border-color: #ef4444;
}

.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  margin-bottom: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: #374151;
}

input[type=text],
input[type=email],
input[type=datetime-local],
input[type=password],
textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
input:focus, textarea:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129,140,248,.2);
}

textarea { resize: vertical; min-height: 110px; }

.checkbox-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 0;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}
input[type=checkbox] {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Toasts ── */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  animation: toastIn .2s cubic-bezier(.21,.61,.35,1);
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.toast-success { background: rgba(5,150,105,.97); }
.toast-error   { background: rgba(220,38,38,.97); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px) scale(.97); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ── Login ── */
.login-wrap { max-width: 380px; margin: 72px auto; }

.login-header { text-align: center; margin-bottom: 30px; }
.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(79,70,229,.35);
  font-size: 26px;
}
.login-header h1 { font-size: 24px; font-weight: 800; letter-spacing: -.4px; }
.login-header .subtitle { color: var(--muted); font-size: 14px; margin-top: 5px; }

#login-error {
  color: #dc2626;
  font-size: 13px;
  margin-top: 10px;
  min-height: 20px;
}

/* ── Bild-Vorschau ── */
.bild-preview {
  margin-top: 10px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  max-width: 340px;
}
.bild-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}
.bild-preview-error {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
}

/* ── WhatsApp Seite ── */
.wa-connect-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.wa-connect-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  margin-bottom: 3px;
}
.wa-connect-channel {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.wa-connect-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.wa-status-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
}

.qr-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0;
}
.qr-spinner {
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

#qr-img {
  border: 8px solid var(--border);
  border-radius: 16px;
  max-width: 260px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.wa-hint {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.wa-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.wa-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  color: var(--text);
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── WA Tabs ── */
.wa-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2px;
}
.wa-tab {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color .15s;
}
.wa-tab:hover { color: var(--text); }
.wa-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Pairing Code ── */
.pair-code-display {
  background: linear-gradient(135deg, #ede9fe, #dbeafe);
  border: 2px solid #c7d2fe;
  border-radius: var(--r-sm);
  padding: 18px 24px;
  text-align: center;
  margin: 14px 0;
}
#pair-code-value {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #3730a3;
  font-variant-numeric: tabular-nums;
}

.wa-connected-box {
  text-align: center;
  padding: 24px 16px;
}
.wa-connected-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: #d1fae5;
  color: #059669;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 16px;
}
.wa-connected-box h2 { color: #059669; font-size: 20px; margin-bottom: 10px; }

/* ── Error state ── */
.table-error {
  text-align: center;
  padding: 32px;
  color: #dc2626;
  font-size: 14px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  nav {
    padding: 10px 14px;
    gap: 4px;
    flex-wrap: wrap;
    height: auto;
  }
  nav .brand { width: 100%; margin-right: 0; font-size: 15px; }
  nav a { font-size: 13px; }
  .btn-nav-logout { margin-left: auto; }

  .container { padding: 16px 12px; }
  h1 { font-size: 19px; }

  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat:last-child { grid-column: 1 / -1; }
  .stat .num { font-size: 28px; }

  .top-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }

  th:nth-child(3), td:nth-child(3),
  th:nth-child(5), td:nth-child(5) { display: none; }
  th, td { padding: 8px 10px; font-size: 13px; }
  .btn-sm { padding: 5px 8px; font-size: 12px; }
  .card { padding: 16px; }
  .checkbox-group { flex-direction: column; gap: 12px; }
  .toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { max-width: 100%; }
  .login-wrap { margin: 40px auto; }
}

@media (min-width: 601px) and (max-width: 900px) {
  .container { padding: 22px 18px; }
}
