/* Dokumente – Oberfläche im Stil von shadcn/ui (Zinc), ohne Build-Schritt */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --card: #ffffff;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --accent: #f4f4f5;
  --ring: #a1a1aa;
  --destructive: #dc2626;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --info-bg: #e0f2fe;
  --info: #0369a1;
  --radius: 0.5rem;
  --sidebar: #fafafa;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #09090b; --foreground: #fafafa; --muted: #27272a; --muted-foreground: #a1a1aa;
    --card: #0c0c0e; --border: #27272a; --input: #3f3f46; --primary: #fafafa; --primary-foreground: #18181b;
    --secondary: #27272a; --accent: #27272a; --ring: #52525b; --sidebar: #0c0c0e;
    --warn: #fbbf24; --warn-bg: #422006; --ok: #4ade80; --ok-bg: #052e16; --info-bg: #082f49; --info: #7dd3fc;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--background); color: var(--foreground);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a.link { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .75rem; letter-spacing: -.01em; }
.muted { color: var(--muted-foreground); }
.small { font-size: 12.5px; }
.i { width: 16px; height: 16px; fill: currentColor; flex: none; vertical-align: -3px; }
.i-lg { width: 20px; height: 20px; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 600; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--primary); color: var(--primary-foreground); display: grid; place-items: center; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--muted-foreground); font-weight: 500; }
.nav a:hover { background: var(--accent); color: var(--foreground); }
.nav a.active { background: var(--accent); color: var(--foreground); }
.nav .count { margin-left: auto; font-size: 11.5px; background: var(--warn-bg); color: var(--warn); padding: 0 7px; border-radius: 999px; font-weight: 600; }
.sidebar .bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: color-mix(in srgb, var(--background) 92%, transparent); backdrop-filter: blur(6px); z-index: 5; }
.topbar form { flex: 1; max-width: 560px; position: relative; }
.topbar .i.search { position: absolute; left: 10px; top: 10px; color: var(--muted-foreground); }
.topbar input[type=search] { padding-left: 34px; }
.content { padding: 24px 28px 48px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.btn.menu-toggle { display: none; }
.grid > * { min-width: 0; }

/* Komponenten */
.card { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow); }
.card-body { padding: 18px 20px; }
.card-head { padding: 16px 20px 0; display: flex; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat .label { color: var(--muted-foreground); font-size: 13px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.stat .value { font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { opacity: .9; }
.btn-outline { background: var(--background); border-color: var(--input); color: var(--foreground); }
.btn-outline:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--accent); }
.btn-danger { background: transparent; color: var(--destructive); border-color: var(--input); }
.btn-danger:hover { background: color-mix(in srgb, var(--destructive) 8%, transparent); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }

.input, input[type=text], input[type=email], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; height: 36px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--input);
  background: var(--background); color: var(--foreground); font: inherit; outline: none;
}
textarea { height: auto; padding: 8px 12px; resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); white-space: nowrap; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-muted { background: var(--muted); color: var(--muted-foreground); border-color: transparent; }
.badge-danger { background: color-mix(in srgb, var(--destructive) 12%, transparent); color: var(--destructive); border-color: transparent; }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted-foreground); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--muted) 60%, transparent); }
.table .title { font-weight: 500; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.snippet { color: var(--muted-foreground); font-size: 12.5px; margin-top: 2px; }
.snippet mark { background: var(--warn-bg); color: inherit; border-radius: 3px; padding: 0 2px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--border); background: var(--muted); }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.flash.err { background: color-mix(in srgb, var(--destructive) 10%, transparent); color: var(--destructive); border-color: transparent; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted-foreground); }

/* Dokument-Detail */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); gap: 20px; align-items: start; }
.viewer { height: calc(100vh - 150px); min-height: 520px; border-radius: calc(var(--radius) + 4px); overflow: hidden; border: 1px solid var(--border); background: var(--muted); }
.viewer iframe { width: 100%; height: 100%; border: 0; }
.viewer.pdf { overflow: auto; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.viewer.pdf canvas { max-width: 100%; height: auto; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); border-radius: 4px; }
.viewer .loading { margin: auto; color: var(--muted-foreground); }
.viewer pre { margin: 0; padding: 20px; white-space: pre-wrap; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; height: 100%; overflow: auto; background: var(--card); }
.side-sticky { position: sticky; top: 76px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sep { height: 1px; background: var(--border); margin: 16px 0; }

/* Upload */
.dropzone { border: 1.5px dashed var(--input); border-radius: calc(var(--radius) + 4px); padding: 28px; text-align: center; color: var(--muted-foreground); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone.drag { background: var(--accent); border-color: var(--ring); color: var(--foreground); }
.drop-overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--background) 80%, transparent); display: none; place-items: center; z-index: 50; font-size: 1.1rem; font-weight: 600; }
.drop-overlay.show { display: grid; }
.drop-overlay .box { border: 2px dashed var(--ring); border-radius: 16px; padding: 48px 64px; background: var(--card); display: flex; gap: 12px; align-items: center; }

/* Kategorien */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cat-card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cat-card .kv { grid-template-columns: 92px 1fr; }
.cat-card .provider { font-size: 1.05rem; font-weight: 600; margin-top: 6px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--muted); }
.auth .card { width: 100%; max-width: 380px; }
.auth h1 { font-size: 1.3rem; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-layout { grid-template-columns: 1fr; }
  .viewer { height: 70vh; }
  .side-sticky { position: static; }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .filters select, .filters input { min-width: 0; flex: 1 1 140px; }
  .row2 { grid-template-columns: 1fr; }
}
