/* Kontora – Basis-Stylesheet (kein Build-Schritt, CSP-konform) */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e2e5ea;
  --text: #1b2430;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-dark: #1739a8;
  --accent-soft: #e8eeff;
  --ok-bg: #e7f6ec;
  --ok-text: #146c33;
  --err-bg: #fdeaea;
  --err-text: #a11919;
  --sidebar: #111827;
  --sidebar-text: #c6ccd8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
p { margin: .4rem 0 .8rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 246px;
  flex: 0 0 246px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.1rem .9rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: .65rem; padding: .2rem .35rem 1.1rem; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, #2563eb, #1e3a8a);
  color: #fff; font-weight: 700;
}
.brand strong { display: block; color: #fff; font-size: .98rem; }
.brand small { display: block; color: #8b93a3; font-size: .76rem; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  color: var(--sidebar-text);
  padding: .5rem .6rem;
  border-radius: 7px;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav a:hover { background: #1b2434; color: #fff; text-decoration: none; }
.nav a.active { background: #1f2b40; color: #fff; box-shadow: inset 2px 0 0 #3b82f6; }
.nav a.disabled { color: #6b7484; cursor: default; }
.nav a.disabled:hover { background: transparent; color: #6b7484; }
.nav a em { font-style: normal; font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; color: #59616f; }
.nav-group {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: #6b7484; padding: .9rem .6rem .25rem;
}

.sidebar-footer { border-top: 1px solid #1f2735; padding-top: .8rem; margin-top: .8rem; }
/* Abmelden: eigener Kontrast auf dunkler Seitenleiste (war vorher dunkel auf dunkel) */
.sidebar-footer .btn {
  width: 100%;
  color: #e5e7eb;
  background: #1b2434;
  border-color: #374151;
}
.sidebar-footer .btn:hover {
  color: #ffffff;
  background: #2a364b;
  border-color: #4b5563;
}
.userbox { padding: 0 .6rem .4rem; }
.userbox strong { display: block; color: #fff; font-size: .86rem; }
.userbox small { color: #8b93a3; font-size: .74rem; }

.main { flex: 1; min-width: 0; padding: 1.5rem 2rem 3rem; max-width: 1180px; }

.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem;
}
.topbar h1 { margin: 0; }
.topbar-meta { color: var(--muted); font-size: .84rem; }

/* ---------- Karten & Raster ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.1rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat { display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.15rem; }
.stat-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.85rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-link { font-size: .82rem; }

/* ---------- Formulare ---------- */
label { display: block; font-size: .82rem; color: #374151; font-weight: 550; margin-bottom: .8rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem;
  font: inherit; font-size: .92rem; font-weight: 400; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .65rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
  background: #fff;
}
textarea { resize: vertical; }
.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 400; }
.check input { width: auto; margin: .2rem 0 0; }
.fieldset { border: 1px solid var(--border); border-radius: 9px; padding: .9rem 1rem .2rem; margin: 0 0 1rem; }
.fieldset legend { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 .35rem; text-transform: uppercase; letter-spacing: .05em; }
.actions { display: flex; gap: .6rem; margin-top: .4rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-size: .88rem; font-weight: 600;
  padding: .55rem 1rem; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  text-decoration: none;
}
.btn:hover { text-decoration: none; background: #eef0f4; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-dark); border-color: #cddafc; }
.btn-secondary:hover { background: #dae5ff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }
.btn-block { width: 100%; }
.btn:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.sidebar-footer .btn:focus-visible { outline-color: #bfdbfe; }
.inline { display: inline; }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: .45rem .5rem; border-bottom: 1px solid var(--border);
}
.table td { padding: .55rem .5rem; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table-compact td { padding: .35rem .5rem; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .right { text-align: right; }
.row-muted td { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .82rem; }

/* ---------- Diverses ---------- */
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  background: #eef1f6; color: #4b5563; font-size: .72rem; font-weight: 600;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-muted { background: #f1f2f4; color: #6b7280; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .8rem; }
.empty { color: var(--muted); font-style: italic; padding: .8rem 0; }
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-err { background: var(--err-bg); color: var(--err-text); }
.kv { display: grid; grid-template-columns: 10rem 1fr; gap: .35rem .9rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); font-size: .82rem; }
.kv dd { margin: 0; font-size: .9rem; }
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; }
.tabs a {
  padding: .45rem .85rem; border-radius: 8px; font-size: .88rem; color: var(--muted);
  border: 1px solid transparent;
}
.tabs a.active { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.steps { margin: .3rem 0 0; padding-left: 1.2rem; color: var(--muted); font-size: .88rem; }
.steps li { margin-bottom: .3rem; }
.steps li.done { color: var(--ok-text); }
.steps li.done::marker { content: "✓ "; }

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .8rem;
  padding: 2rem 1rem;
  background: radial-gradient(1200px 600px at 50% -10%, #e3e9f8, var(--bg));
}
.auth-card { width: 100%; max-width: 390px; padding: 1.6rem 1.6rem 1.2rem; }
.auth-card h1 { font-size: 1.25rem; margin: .9rem 0 1rem; }
.auth-foot { color: var(--muted); font-size: .74rem; text-align: center; max-width: 390px; }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { width: 100%; padding-bottom: 0; }
  .main { padding: 1.1rem 1rem 2.5rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: .1rem; }
  .kv dd { margin-bottom: .5rem; }
}

/* ---------- Mandanten-Umschalter ---------- */
.switcher { position: relative; }
.switcher summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem;
  padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); box-shadow: var(--shadow); font-size: .9rem;
}
.switcher summary::-webkit-details-marker { display: none; }
.switcher summary::after { content: "▾"; color: var(--muted); font-size: .7rem; }
.switcher summary .switcher-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.switcher-menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20;
  min-width: 250px; padding: .35rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 24, 40, .14);
}
.switcher-item {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  width: 100%; text-align: left; padding: .45rem .55rem; border: 0; border-radius: 7px;
  background: transparent; font: inherit; font-size: .88rem; color: var(--text); cursor: pointer;
}
.switcher-item:hover { background: var(--surface-2); text-decoration: none; }
.switcher-item.is-active { background: var(--accent-soft); color: var(--accent-dark); }
.switcher-item small { display: block; color: var(--muted); font-size: .72rem; }
.switcher-check { color: var(--accent); font-weight: 700; }
.switcher-manage { color: var(--accent); font-size: .8rem; border-top: 1px solid var(--border); border-radius: 0; margin-top: .25rem; padding-top: .5rem; }

/* ---------- Mandantenliste ---------- */
.tenant-row-actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-block; padding: .1rem .45rem; border-radius: 6px; background: #eef1f6; font-size: .72rem; font-weight: 600; color: #4b5563; }
.chip-lead { background: #e8eeff; color: var(--accent-dark); }
.chip-muted { background: #f1f2f4; color: #6b7280; }
details.inline-form summary { cursor: pointer; font-size: .82rem; color: var(--accent); }
details.inline-form summary:hover { text-decoration: underline; }

/* ---------- Prüf-Workflow ---------- */
.queue { display: flex; flex-direction: column; gap: 2px; }
.queue-item {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .4rem .5rem; border-radius: 7px; font-size: .82rem;
  color: var(--text); border: 1px solid transparent;
}
.queue-item:hover { background: var(--surface-2); text-decoration: none; }
.queue-item.is-active { background: var(--accent-soft); border-color: #cddafc; color: var(--accent-dark); font-weight: 600; }
.queue-item small { color: var(--muted); font-size: .7rem; font-weight: 400; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; }
.review-preview img { width: 100%; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 900px) {
  .review-grid { grid-template-columns: 1fr; }
  .grid[style*="280px"] { grid-template-columns: 1fr !important; }
}

.ocr-text {
  white-space: pre-wrap; font-family: var(--mono); font-size: .74rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: .7rem; max-height: 16rem; overflow: auto;
}

/* ---------- Hermes-Chat ---------- */
.chat-bubble { border-radius: 10px; padding: .7rem .9rem; margin-bottom: .6rem; font-size: .9rem; }
.chat-bubble div { white-space: pre-wrap; }
.chat-bubble strong { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .2rem; }
.chat-user { background: var(--accent-soft); }
.chat-assistant { background: var(--surface-2); border: 1px solid var(--border); }
.chat-sources { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.chat-sources a { font-size: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .5rem; }
.chat-tool { margin: .2rem 0 .6rem; font-size: .8rem; }
.chat-tool summary { cursor: pointer; color: var(--muted); }
