*, *::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;
}

/* ── 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;
}

/* ── KI-Generator ── */
.ai-generate-row {
  display: flex;
  gap: 8px;
}
.ai-generate-row input {
  flex: 1;
}

/* ── 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);
}

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

/* ── Credentials Page ── */
.creds-intro {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.creds-card-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.creds-card-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.creds-icon {
  font-size: 22px;
  margin-top: 1px;
  flex-shrink: 0;
}

.creds-card-title h2 { margin-bottom: 3px; }

.creds-card-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.cred-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.cred-label-row label { margin-bottom: 0; }

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.input-pw-wrap {
  position: relative;
}
.input-pw-wrap input {
  padding-right: 42px;
}
.btn-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  opacity: .6;
  transition: opacity .15s;
}
.btn-eye:hover { opacity: 1; }

.creds-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 600px) {
  .creds-row { grid-template-columns: 1fr; gap: 0; }
}

/* ── 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%; }

  .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; }
}

/* ── Filter Buttons ── */
.filter-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.filter-btn:hover { border-color: #c7d2fe; color: var(--primary); }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Post Cards (mobile/tablet ≤900px) ── */
@media (max-width: 900px) {
  .table-wrap { overflow-x: visible; }
  .table-wrap table { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: block; }

  .table-wrap tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "status    info"
      "channels  channels"
      "text      text"
      "datum     datum"
      "actions   actions";
    row-gap: 8px;
    padding: 14px 14px 12px 16px;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--border);
    transition: background .1s;
  }
  .table-wrap tr:last-child { border-bottom: none; }
  .table-wrap tr:hover td { background: transparent; }

  /* ── Status-based card styling ── */
  .table-wrap tr[data-status="gepostet"] {
    border-left-color: #10b981;
    background: linear-gradient(to right, #f0fdf4 0%, #fff 60%);
  }
  .table-wrap tr[data-status="ausstehend"] {
    border-left-color: #f59e0b;
  }
  .table-wrap tr[data-status="fehler"] {
    border-left-color: #ef4444;
    background: linear-gradient(to right, #fff5f5 0%, #fff 60%);
  }

  .table-wrap td {
    padding: 0;
    border: none;
    font-size: 13px;
    vertical-align: middle;
  }

  /* Status badge: bigger and bolder */
  .table-wrap td[data-label="Status"]         { grid-area: status; align-self: center; }
  .table-wrap td[data-label="Status"] .badge  { font-size: 13px; padding: 5px 13px; font-weight: 700; letter-spacing: .2px; }

  .table-wrap td[data-label="Info"]    { grid-area: info; align-self: center; justify-self: end; }
  .table-wrap td[data-label="Kanäle"] { grid-area: channels; }
  .table-wrap td[data-label="Text"]    { grid-area: text; color: #374151; line-height: 1.5; font-size: 13.5px; }
  .table-wrap td[data-label="Datum"]  {
    grid-area: datum;
    font-size: 11.5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 1px solid #f1f5f9;
    padding-top: 6px;
  }
  .table-wrap td[data-label="Datum"]::before { content: "🗓"; font-size: 11px; }

  .table-wrap .td-actions {
    grid-area: actions;
    display: flex !important;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid #f1f5f9;
    padding-top: 8px;
  }
  .table-wrap .td-actions:not(:has(a, button)) { display: none !important; }
  .table-wrap td[data-label="Bild"] { display: none !important; }

  /* Touch-friendly action buttons */
  .table-wrap .td-actions .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    min-height: 40px;
    font-size: 13px;
  }
}
