:root {
  --blau: #003781;
  --blau-dunkel: #002a63;
  --blau-hell: #e8eef7;
  --gruen: #1faa53;        /* Versand-/Erfolgsgrün, gedeckter als WhatsApp-Neon */
  --rot: #c0392b;
  --tinte: #1c2333;
  --grau: #5d6675;
  --linie: #d9dee8;
  --papier: #f7f8fb;
  --weiss: #ffffff;
  --radius: 10px;
  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--body); color: var(--tinte); background: var(--papier); }
.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; margin-bottom: 1.2rem; color: var(--blau); }
h3 { font-size: 1.05rem; margin-bottom: 0.7rem; }
.muted { color: var(--grau); font-size: 0.9rem; line-height: 1.5; }
code { background: var(--blau-hell); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--blau);
}
.login-box {
  background: var(--weiss); border-radius: var(--radius); padding: 2.5rem;
  width: min(380px, 90vw); text-align: center;
}
.login-mark {
  font-family: var(--display); font-weight: 700; color: var(--blau);
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 1rem; line-height: 1.5;
}
.login-box h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.login-box input {
  width: 100%; padding: 0.75rem; border: 1px solid var(--linie); border-radius: var(--radius);
  font-size: 1rem; margin-bottom: 0.8rem; font-family: var(--body);
}
.login-box .btn { width: 100%; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--blau); color: var(--weiss);
  display: flex; flex-direction: column; padding: 1.5rem 0.9rem; gap: 0.3rem;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-mark {
  font-family: var(--display); font-weight: 700; font-size: 1.1rem;
  line-height: 1.25; padding: 0 0.8rem 1.4rem;
}
.nav-btn {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: rgba(255,255,255,0.82); font-family: var(--body); font-size: 0.95rem; font-weight: 500;
  padding: 0.65rem 0.8rem; border-radius: 8px; cursor: pointer;
}
.nav-btn:hover { background: rgba(255,255,255,0.1); color: var(--weiss); }
.nav-btn.active { background: var(--weiss); color: var(--blau); font-weight: 600; }
.nav-btn:focus-visible { outline: 2px solid var(--weiss); outline-offset: -2px; }
.nav-logout { margin-top: auto; color: rgba(255,255,255,0.55); }

.content { flex: 1; padding: 2rem 2.5rem; max-width: 900px; }
.view-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; gap: 0.7rem; }
.view-head h2 { margin-bottom: 0; }

.testmode {
  background: #fff4d6; border: 1px solid #e6c96a; color: #7a5c00;
  padding: 0.6rem 1rem; border-radius: var(--radius); margin-bottom: 1.2rem; font-size: 0.9rem;
}

/* ---------- Versandampel (Signature) ---------- */
.ampel-card {
  background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 1.4rem 1.6rem; margin-bottom: 1.2rem;
  border-left: 5px solid var(--blau);
}
.ampel-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--grau); font-weight: 600; }
.ampel-number { font-family: var(--display); font-weight: 700; font-size: 2.6rem; color: var(--blau); margin: 0.2rem 0 0.6rem; }
.ampel-of { font-family: var(--body); font-weight: 400; font-size: 1rem; color: var(--grau); }
.ampel-bar { height: 10px; background: var(--blau-hell); border-radius: 5px; overflow: hidden; }
.ampel-fill { height: 100%; background: var(--blau); border-radius: 5px; width: 0; transition: width 0.6s ease; }
.ampel-fill.low { background: var(--rot); }
.ampel-hint { margin-top: 0.7rem; font-size: 0.85rem; color: var(--grau); line-height: 1.5; }

/* ---------- Stats & Panels ---------- */
.stat-row { display: flex; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 130px; background: var(--weiss); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 1rem 1.2rem;
}
.stat-num { font-family: var(--display); font-weight: 700; font-size: 1.7rem; color: var(--blau); }
.stat-label { font-size: 0.85rem; color: var(--grau); }

.panel {
  background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; margin-bottom: 1.2rem;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--body); font-weight: 600; font-size: 0.92rem;
  padding: 0.6rem 1.1rem; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--blau); color: var(--weiss); }
.btn-primary:hover { background: var(--blau-dunkel); }
.btn-ghost { background: var(--weiss); color: var(--blau); border-color: var(--linie); }
.btn-ghost:hover { border-color: var(--blau); }
.btn-danger { background: var(--weiss); color: var(--rot); border-color: var(--linie); }
.btn-danger:hover { border-color: var(--rot); }
.btn:focus-visible { outline: 2px solid var(--blau); outline-offset: 2px; }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

/* ---------- Kontakte ---------- */
.search {
  width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--linie); border-radius: var(--radius);
  font-size: 0.95rem; margin-bottom: 1rem; font-family: var(--body); background: var(--weiss);
}
.contact-row {
  display: flex; align-items: center; gap: 1rem; background: var(--weiss);
  border: 1px solid var(--linie); border-radius: var(--radius); padding: 0.7rem 1rem; margin-bottom: 0.5rem;
}
.contact-main { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; }
.contact-sub { font-size: 0.83rem; color: var(--grau); }
.badge {
  font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-ok { background: #e4f5ea; color: var(--gruen); }
.badge-no { background: #fbeaea; color: var(--rot); }
.badge-wait { background: #fff4d6; color: #7a5c00; }

/* ---------- Vorlagen ---------- */
.template-card {
  background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; margin-bottom: 0.8rem;
}
.template-body, .template-preview {
  background: #f0f4ee; border-radius: 8px; padding: 0.7rem 0.9rem;
  font-size: 0.88rem; line-height: 1.5; margin-top: 0.5rem; white-space: pre-wrap;
  border-left: 3px solid var(--gruen);
}
.template-preview { margin: -0.3rem 0 0.8rem; }

/* ---------- Kampagnen ---------- */
.campaign-card {
  background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; margin-bottom: 0.8rem;
}
.campaign-top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.campaign-name { font-weight: 600; font-size: 1.02rem; }
.campaign-meta { font-size: 0.83rem; color: var(--grau); margin: 0.25rem 0 0.6rem; }
.progress { height: 8px; background: var(--blau-hell); border-radius: 4px; overflow: hidden; margin-bottom: 0.4rem; }
.progress-fill { height: 100%; background: var(--gruen); transition: width 0.5s ease; }
.campaign-stats { font-size: 0.83rem; color: var(--grau); display: flex; gap: 1rem; flex-wrap: wrap; }

/* ---------- Protokoll ---------- */
.log-row {
  display: flex; gap: 0.9rem; align-items: baseline; padding: 0.55rem 0.2rem;
  border-bottom: 1px solid var(--linie); font-size: 0.88rem;
}
.log-time { color: var(--grau); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 0.8rem; }
.log-name { font-weight: 500; flex: 1; }
.log-type { color: var(--grau); font-size: 0.8rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.dot-gesendet, .dot-zugestellt, .dot-gelesen { background: var(--gruen); }
.dot-fehler { background: var(--rot); }
.log-status { font-size: 0.8rem; white-space: nowrap; }
.log-error { color: var(--rot); font-size: 0.78rem; }

/* ---------- Formulare & Modals ---------- */
label { display: block; font-size: 0.88rem; font-weight: 500; margin-bottom: 0.8rem; }
label input, label select, textarea {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.6rem 0.7rem;
  border: 1px solid var(--linie); border-radius: 8px; font-size: 0.95rem; font-family: var(--body);
  background: var(--weiss);
}
textarea { resize: vertical; }
.check-label { display: flex; align-items: center; gap: 0.5rem; }
.check-label input { width: auto; margin: 0; }
.form-panel { max-width: 420px; }

.modal {
  position: fixed; inset: 0; background: rgba(15,25,50,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal-box {
  background: var(--weiss); border-radius: var(--radius); padding: 1.6rem;
  width: min(460px, 100%); max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { color: var(--blau); margin-bottom: 1rem; }
.modal-box .muted { margin-bottom: 0.8rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

.error { color: var(--rot); font-size: 0.88rem; margin-top: 0.5rem; }
.success { color: var(--gruen); font-size: 0.88rem; margin-top: 0.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.7rem; }
  .sidebar-mark { display: none; }
  .sidebar nav { display: flex; flex: 1; gap: 0.2rem; overflow-x: auto; }
  .nav-btn { white-space: nowrap; padding: 0.5rem 0.7rem; }
  .nav-logout { margin-top: 0; }
  .content { padding: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ampel-fill, .progress-fill { transition: none; }
}
