:root {
  --bg: #0b1220;
  --panel: #121a2e;
  --panel2: #17223a;
  --border: #24304d;
  --text: #e5ecf8;
  --muted: #8b9ab8;
  --accent: #38bdf8;
  --red: #e11d48;
  --green: #34d399;
  --amber: #fbbf24;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
.mono { font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace; font-size: 0.86rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #101a30, #0b1220);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 700;
  box-shadow: 0 0 24px rgba(225, 29, 72, 0.45);
}
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: 0.2px; }
.brand-sub { color: var(--muted); font-size: 0.8rem; }
.topbar-right { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.role-switch {
  display: flex; border: 1px solid var(--border); border-radius: 999px;
  overflow: hidden; background: var(--panel);
}
.role-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 0.45rem 0.9rem; cursor: pointer; font-size: 0.82rem;
  display: flex; align-items: center; gap: 0.4rem; font-family: inherit;
}
.role-btn.active { background: var(--panel2); color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.lang-btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 0.42rem 0.75rem; cursor: pointer; font-weight: 700;
  font-family: inherit; font-size: 0.82rem;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 0.3rem; padding: 0.6rem 1.4rem 0;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 0.6rem 1rem; cursor: pointer; font-size: 0.92rem; font-family: inherit;
  border-bottom: 2px solid transparent; font-weight: 600;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

main { flex: 1; padding: 1.6rem 1.4rem 3rem; max-width: 1240px; width: 100%; margin: 0 auto; }
.tabpane { display: none; }
.tabpane.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 2.2rem 1rem 2.4rem; max-width: 860px; margin: 0 auto; }
.hero-badge {
  display: inline-block; font-size: 0.78rem; color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35); background: rgba(56, 189, 248, 0.08);
  padding: 0.3rem 0.85rem; border-radius: 999px; margin-bottom: 1.1rem;
}
.hero h1 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); line-height: 1.2; margin-bottom: 1rem; }
.hero-lead { color: var(--muted); font-size: 1.02rem; margin-bottom: 1.5rem; }
.hero-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  padding: 0.65rem 1.2rem; font-size: 0.92rem; font-weight: 700; font-family: inherit;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); color: #04121f; border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.35);
}
.btn-ghost { background: var(--panel); color: var(--text); }
.btn-ghost:hover { background: var(--panel2); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.8rem; margin-top: 0.8rem; }
.btn[disabled] { opacity: 0.5; cursor: wait; }

/* ---------- architecture ---------- */
.arch {
  display: grid; grid-template-columns: 1fr 110px 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  margin: 1rem 0 2.4rem; background: var(--panel);
}
.arch-side { padding: 1.2rem; }
.arch-ch { background: linear-gradient(160deg, rgba(52, 211, 153, 0.06), transparent); }
.arch-abroad { background: linear-gradient(200deg, rgba(225, 29, 72, 0.07), transparent); }
.arch-flag { font-weight: 800; margin-bottom: 0.9rem; font-size: 0.95rem; }
.arch-boxes { display: flex; flex-direction: column; gap: 0.7rem; }
.arch-box {
  border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.9rem;
  background: var(--panel2); font-size: 0.85rem;
}
.arch-box b { display: block; }
.arch-box span { color: var(--muted); font-size: 0.78rem; }
.arch-box-main { border-color: var(--accent); box-shadow: 0 0 18px rgba(56, 189, 248, 0.18); }
.arch-box-vault { border-color: var(--amber); }
.arch-box-vault span { font-family: ui-monospace, monospace; font-size: 0.7rem; }
.arch-border { position: relative; display: grid; place-items: center; }
.arch-border-line {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 3px;
  background: repeating-linear-gradient(var(--red) 0 12px, transparent 12px 22px);
  opacity: 0.85;
}
.arch-border-label {
  position: relative; z-index: 1; background: var(--red); color: #fff;
  font-size: 0.7rem; font-weight: 800; padding: 0.25rem 0.5rem; border-radius: 6px;
  writing-mode: vertical-rl; text-orientation: mixed; letter-spacing: 1px;
}
.arch-border-tokens {
  position: absolute; bottom: 0.7rem; left: 50%; transform: translateX(-50%);
  font-family: ui-monospace, monospace; font-size: 0.55rem; color: var(--amber);
  white-space: nowrap; background: var(--bg); padding: 2px 4px; border-radius: 4px;
}

/* ---------- coverage grid ---------- */
.sect-title { font-size: 1.25rem; margin: 0.4rem 0 0.9rem; }
.cov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0.9rem; margin-bottom: 1.6rem; }
.cov-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.1rem;
  background: var(--panel);
}
.cov-ico { font-size: 1.3rem; margin-bottom: 0.4rem; }
.cov-card b { display: block; margin-bottom: 0.3rem; }
.cov-card p { color: var(--muted); font-size: 0.86rem; }
.note {
  border-left: 3px solid var(--amber); background: rgba(251, 191, 36, 0.06);
  padding: 0.8rem 1rem; border-radius: 0 10px 10px 0; color: var(--muted); font-size: 0.85rem;
}

/* ---------- docs ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } .arch { grid-template-columns: 1fr; } .arch-border { min-height: 70px; } .arch-border-line { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 3px; background: repeating-linear-gradient(90deg, var(--red) 0 12px, transparent 12px 22px); } .arch-border-label { writing-mode: horizontal-tb; } .arch-border-tokens { display: none; } }
.input {
  width: 100%; background: var(--panel); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 0.65rem 0.8rem;
  font-size: 0.92rem; margin-bottom: 0.7rem; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
.textarea { resize: vertical; line-height: 1.5; }
.row-btns { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.preview-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.preview {
  border: 1px dashed var(--border); border-radius: 10px; padding: 0.8rem;
  min-height: 60px; white-space: pre-wrap; word-break: break-word; background: rgba(255,255,255,0.02);
}
.ent {
  border-radius: 5px; padding: 0 3px; font-weight: 600;
  border: 1px solid transparent;
}
.ent-PERSON  { background: rgba(244,114,182,.18); color: #f9a8d4; border-color: rgba(244,114,182,.4); }
.ent-AHV     { background: rgba(248,113,113,.18); color: #fca5a5; border-color: rgba(248,113,113,.4); }
.ent-IBAN    { background: rgba(251,191,36,.15); color: #fcd34d; border-color: rgba(251,191,36,.4); }
.ent-EMAIL   { background: rgba(96,165,250,.18); color: #93c5fd; border-color: rgba(96,165,250,.4); }
.ent-TEL     { background: rgba(167,139,250,.18); color: #c4b5fd; border-color: rgba(167,139,250,.4); }
.ent-VERTRAG { background: rgba(52,211,153,.15); color: #6ee7b7; border-color: rgba(52,211,153,.4); }
.ent-BETRAG  { background: rgba(251,146,60,.16); color: #fdba74; border-color: rgba(251,146,60,.4); }
.ent-ADRESSE { background: rgba(45,212,191,.15); color: #5eead4; border-color: rgba(45,212,191,.4); }
.ent-DATUM   { background: rgba(148,163,184,.18); color: #cbd5e1; border-color: rgba(148,163,184,.4); }
.ent-FIRMA   { background: rgba(129,140,248,.18); color: #a5b4fc; border-color: rgba(129,140,248,.4); }
.ent-ID      { background: rgba(232,121,249,.15); color: #f0abfc; border-color: rgba(232,121,249,.4); }
.tok { color: var(--amber); font-weight: 700; }

.flow {
  border: 1px solid var(--border); border-radius: 12px; margin-top: 0.6rem;
  overflow: hidden;
}
.flow-step { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); font-size: 0.83rem; }
.flow-step:last-child { border-bottom: 0; }
.flow-step b { display: block; margin-bottom: 0.2rem; font-size: 0.8rem; }
.flow-ch b { color: var(--green); }
.flow-abroad { background: rgba(225, 29, 72, 0.05); }
.flow-abroad b { color: #fb7185; }
.flow-step .mono { white-space: pre-wrap; word-break: break-word; color: var(--muted); }

.searchbar { display: flex; gap: 0.6rem; }
.searchbar .input { margin-bottom: 0; }
.search-result {
  border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.9rem;
  margin: 0.7rem 0; font-size: 0.84rem; background: var(--panel);
}
.doc-list { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1rem; }
.doc-card { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; }
.doc-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  padding: 0.65rem 0.9rem; background: var(--panel2); cursor: pointer;
}
.doc-head b { font-size: 0.9rem; word-break: break-word; }
.doc-meta { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.doc-body { padding: 0.8rem 0.9rem; white-space: pre-wrap; word-break: break-word; }
.doc-viewtag { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 700; }
.viewtag-cloud { background: rgba(225,29,72,.15); color: #fb7185; }
.viewtag-internal { background: rgba(52,211,153,.15); color: var(--green); }

/* ---------- AI ---------- */
.ai-inputrow { max-width: 900px; }
.ai-flow { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.2rem; max-width: 900px; }
.ai-card { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; }
.ai-card-head {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.9rem;
  font-size: 0.85rem; border-bottom: 1px solid var(--border);
}
.ai-card-head.ch { background: rgba(52, 211, 153, 0.07); }
.ai-card-head.abroad { background: rgba(225, 29, 72, 0.08); }
.ai-card-body { padding: 0.8rem 0.9rem; white-space: pre-wrap; word-break: break-word; }
.ai-card-sub { padding: 0.4rem 0.9rem 0; color: var(--muted); font-size: 0.75rem; border-top: 1px dashed var(--border); }
.pill {
  margin-left: auto; font-size: 0.68rem; background: var(--panel2);
  border: 1px solid var(--border); padding: 0.1rem 0.5rem; border-radius: 999px; color: var(--muted);
}
.denied {
  margin: 0.8rem 0.9rem; padding: 0.7rem 0.9rem; border-radius: 10px;
  background: rgba(225, 29, 72, 0.1); border: 1px solid rgba(225, 29, 72, 0.4);
  color: #fda4af; font-size: 0.86rem;
}

/* ---------- vault ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
.table th { background: var(--panel2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.table td:first-child { font-family: ui-monospace, monospace; color: var(--amber); white-space: nowrap; }
.audit-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 480px; overflow-y: auto; }
.audit-item {
  font-size: 0.78rem; border: 1px solid var(--border); border-radius: 8px;
  padding: 0.4rem 0.7rem; background: var(--panel);
}
.audit-item .muted { font-size: 0.68rem; }

.footer {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.4rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted);
}

.spin { display: inline-block; animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
