/* Vault — ruhiges, dunkles Archiv-Interface.
   Eine Farbe als Akzent, viel Weißraum, Zahlen in Tabellenziffern. */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1d212a;
  --line: #262b36;
  --line-soft: #1f242e;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --faint: #6b7280;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, .13);
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .8rem; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Gerüst ─────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 18px;
  font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: grid; place-items: center;
  font-size: 14px;
}

.nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--faint); padding: 14px 10px 6px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: .92rem; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .badge { margin-left: auto; }

.nav-spacer { flex: 1; }

.main { flex: 1; min-width: 0; padding: 28px 32px 64px; max-width: 1180px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head p { margin: 0; }

/* ── Karten ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 1.7rem; font-weight: 600; letter-spacing: -.02em;
              font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* ── Formulare ──────────────────────────────────────────────────────── */
label { display: block; font-size: .82rem; color: var(--muted);
        margin-bottom: 5px; font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: 9px 11px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field-row > * { flex: 1; min-width: 130px; }

.check { display: flex; align-items: center; gap: 8px; color: var(--text);
         font-size: .9rem; cursor: pointer; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); font: 500 .9rem var(--font);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--line); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1220; font-weight: 600; }
.btn-primary:hover { background: #8bb9ff; border-color: #8bb9ff; }
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.btn-danger:hover { background: rgba(248, 113, 113, .12); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Marker ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  font-size: .74rem; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
}
.badge-ok { background: rgba(74, 222, 128, .12); color: var(--ok); border-color: rgba(74, 222, 128, .25); }
.badge-warn { background: rgba(251, 191, 36, .12); color: var(--warn); border-color: rgba(251, 191, 36, .25); }
.badge-danger { background: rgba(248, 113, 113, .12); color: var(--danger); border-color: rgba(248, 113, 113, .25); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: rgba(110, 168, 254, .3); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 20px; font-size: .8rem;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.chip:hover { color: var(--text); text-decoration: none; border-color: var(--faint); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(110, 168, 254, .35); }

/* ── Tabellen ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; padding: 8px 10px; font-size: .74rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--faint);
  border-bottom: 1px solid var(--line);
}
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, .015); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Listen ─────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { text-decoration: none; }
.list-item:hover .list-title { color: var(--accent); }
.list-body { min-width: 0; flex: 1; }
.list-title { font-weight: 500; font-size: .94rem; }
.list-meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-icon {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: var(--radius-sm);
  background: var(--surface-2); display: grid; place-items: center;
  font-size: 15px; border: 1px solid var(--line);
}

/* ── Meldungen ──────────────────────────────────────────────────────── */
.flash { padding: 11px 14px; border-radius: var(--radius-sm);
         margin-bottom: 12px; font-size: .9rem; border: 1px solid; }
.flash-success { background: rgba(74, 222, 128, .09); border-color: rgba(74, 222, 128, .28); color: #86efac; }
.flash-danger  { background: rgba(248, 113, 113, .09); border-color: rgba(248, 113, 113, .28); color: #fca5a5; }
.flash-warning { background: rgba(251, 191, 36, .09); border-color: rgba(251, 191, 36, .28); color: #fcd34d; }
.flash-info    { background: var(--accent-soft); border-color: rgba(110, 168, 254, .28); color: var(--accent); }

.note {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: .88rem; color: var(--muted);
}
.note.warn { border-left-color: var(--warn); }
.note strong { color: var(--text); }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-icon { font-size: 2rem; margin-bottom: 10px; opacity: .5; }

/* ── Anmeldung ──────────────────────────────────────────────────────── */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .card { padding: 26px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .brand-mark { width: 40px; height: 40px; margin: 0 auto 12px; font-size: 20px; }

.code-input {
  font-family: var(--mono); font-size: 1.7rem; text-align: center;
  letter-spacing: .35em; padding: 12px; text-indent: .35em;
}

/* ── Chat ───────────────────────────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 216px 1fr; gap: 16px;
               align-items: start; }
.chat-main { display: flex; flex-direction: column;
             height: calc(100vh - 150px); min-height: 460px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 16px;
            display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 10px; max-width: 88%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  padding: 11px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); font-size: .92rem;
}
.msg-user .msg-bubble { background: var(--accent-soft); border-color: rgba(110, 168, 254, .3); }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul { margin: .4rem 0; padding-left: 1.1rem; }
.msg-bubble li { margin-bottom: .25rem; }
.msg-avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 13px;
}

.sources { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); }
.source-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; margin: 3px 4px 0 0; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: .78rem; color: var(--muted);
}
.source-link:hover { color: var(--accent); border-color: rgba(110, 168, 254, .35);
                     text-decoration: none; }

.chat-form { display: flex; gap: 8px; padding-top: 12px;
             border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 44px; max-height: 160px; resize: none; }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--faint);
  animation: blink 1.3s infinite;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.trace { font-size: .76rem; color: var(--faint); margin-top: 8px;
         font-family: var(--mono); }

/* ── Prognose-Balken ────────────────────────────────────────────────── */
.bar-row { display: grid; grid-template-columns: 118px 1fr 108px;
           gap: 12px; align-items: center; padding: 6px 0; }
.bar-track { background: var(--surface-2); border-radius: 5px; height: 26px;
             overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #a78bfa);
            border-radius: 4px; min-width: 2px; }
.bar-fill.extra { background: linear-gradient(90deg, #fbbf24, #f59e0b); }

/* ── Sonstiges ──────────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr;
      gap: 8px 16px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.doc-text {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px;
  font-family: var(--mono); font-size: .8rem; line-height: 1.65;
  white-space: pre-wrap; max-height: 420px; overflow-y: auto; color: var(--muted);
}

.finding { border-left: 3px solid var(--line); padding-left: 14px; margin-bottom: 18px; }
.finding.hoch { border-left-color: var(--danger); }
.finding.mittel { border-left-color: var(--warn); }
.finding.niedrig { border-left-color: var(--accent); }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; background: var(--surface);
  cursor: pointer;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 12px; gap: 6px; border-right: none; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0 10px 0 4px; }
  .nav-label, .nav-spacer { display: none; }
  .nav-item { padding: 6px 10px; font-size: .85rem; }
  .main { padding: 20px 16px 48px; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
}
