:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #dde3ea;
  --text: #1c2733;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --teal: #0d9488;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 54px;
  background: #0f1e33;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand-icon { font-size: 18px; }
nav { display: flex; gap: 4px; flex: 1; }
nav a {
  color: #c3d0e0;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.header-actions { display: flex; gap: 8px; }

.pill {
  background: var(--red);
  color: #fff;
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { color: #fff; opacity: .9; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #c3d0e0; }
.btn-ghost:hover { color: #fff; border-color: #fff; }
header .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #e6edf5; }
header .btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ---------- Layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { display: flex; justify-content: center; padding: 9vh 20px 0; }
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 30px 34px; width: 360px;
  box-shadow: 0 10px 30px rgba(15,30,51,.08);
}
.login-card h2 { margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; }
.login-card input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-card .btn-primary { width: 100%; margin-top: 18px; padding: 10px; font-size: 14px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

h2 { margin: 0 0 14px; font-size: 18px; }
h3 { margin: 22px 0 10px; font-size: 15px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* ---------- Kacheln ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
}
.tile:hover { border-color: var(--accent); }
.tile .num { font-size: 26px; font-weight: 700; }
.tile .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Tabellen ---------- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f0f6ff; }
td.wrap { white-space: normal; }

/* ---------- Status-Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.badge.OPEN        { background: #eef1f5; color: #556; }
.badge.PENDING     { background: #fef3c7; color: #92400e; }
.badge.TRANSMITTED { background: var(--accent-soft); color: #1e40af; }
.badge.CONFIRMED   { background: #dcfce7; color: #166534; }
.badge.PARTIAL     { background: #ccfbf1; color: #0f766e; }
.badge.MISMATCH    { background: #fee2e2; color: #991b1b; }
.badge.COMPLETED   { background: #166534; color: #fff; }
.badge.ARCHIVED    { background: #e2e8f0; color: #64748b; }
.badge.MATCH       { background: #dcfce7; color: #166534; }
.badge.SENT        { background: #dcfce7; color: #166534; }
.badge.FAILED      { background: #fee2e2; color: #991b1b; }
.badge.test        { background: #f3e8ff; color: #7e22ce; }

.ok    { color: var(--green); }
.warn  { color: var(--amber); }
.err   { color: var(--red); }
.muted { color: var(--muted); }

/* ---------- Filterleiste ---------- */
.filterbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filterbar input[type=text], .filterbar select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel);
  font-size: 13px;
}
.filterbar label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 5px; }

/* ---------- Detail ---------- */
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-head h2 { margin: 0; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 20px; }
.kv div .k { color: var(--muted); font-size: 12px; }
.kv div .v { font-weight: 500; }

pre.json {
  background: #0f1e33; color: #d7e3f4;
  padding: 14px; border-radius: var(--radius);
  overflow-x: auto; font-size: 12.5px; line-height: 1.5;
  max-height: 480px; overflow-y: auto;
}
details summary { cursor: pointer; color: var(--accent); margin: 6px 0; }

/* ---------- Timeline / Events ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .ts { color: var(--muted); font-size: 12px; min-width: 150px; }
.timeline .ev { font-weight: 600; min-width: 220px; }
.timeline .det { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #0f1e33; color: #fff;
  padding: 12px 18px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-width: 440px; z-index: 100;
  white-space: pre-line;
}
.toast.err { background: var(--red); }

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--muted); }
