:root {
  --bg: #0f1117;
  --bg-card: #171a23;
  --bg-hover: #1f2330;
  --border: #262b3a;
  --text: #e6e8ee;
  --text-dim: #9aa1b5;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --green: #3ecf8e;
  --radius: 12px;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

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

h1 { font-size: 1.6rem; margin: 0 0 0.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; letter-spacing: -0.01em; }
code { background: var(--bg-hover); padding: 0.1em 0.35em; border-radius: 5px; font-size: 0.88em; }

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding: 1.1rem 1.1rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 1.5rem; }
.brand-title { font-weight: 700; font-size: 1.02rem; }
.brand-sub { font-size: 0.72rem; color: var(--text-dim); }

.sidebar nav { padding: 0.8rem 0.6rem; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 500;
}
.sidebar nav a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-icon { width: 1.6em; text-align: center; font-size: 0.82em; opacity: 0.9; }

.sidebar-footer { margin-top: auto; padding: 1rem 1.1rem; border-top: 1px solid var(--border); }
.user-name { font-weight: 600; font-size: 0.88rem; }
.user-mail { font-size: 0.75rem; color: var(--text-dim); word-break: break-all; }
.logout { display: inline-block; margin-top: 0.5rem; font-size: 0.82rem; color: var(--text-dim); }
.logout:hover { color: var(--accent); }

.content { flex: 1; padding: 2rem 2.4rem 3rem; min-width: 0; }
.lead { color: var(--text-dim); max-width: 720px; }
.hint { color: var(--text-dim); font-size: 0.85rem; }

/* ---------- Übersicht ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.9rem; margin: 1.4rem 0; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-num { font-size: 1.7rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--text-dim); }

.pipeline { padding-left: 1.2rem; max-width: 780px; }
.pipeline li { margin-bottom: 0.55rem; }
.pipeline-planned { color: var(--text-dim); }

/* ---------- Tabellen ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}
.data-table { border-collapse: collapse; width: 100%; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 0.5rem 0.85rem; text-align: left; white-space: nowrap; }
.data-table thead th {
  background: var(--bg-hover);
  position: sticky;
  top: 0;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}
.data-table thead th:hover { color: var(--accent); }
.data-table th.sorted-asc::after { content: " ▲"; font-size: 0.7em; }
.data-table th.sorted-desc::after { content: " ▼"; font-size: 0.7em; }
.data-table tbody tr { border-top: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* ---------- Code / zweispaltige Ansichten ---------- */
.code-layout { display: flex; gap: 1.2rem; align-items: flex-start; }
.file-tree {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
  position: sticky;
  top: 1.2rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}
.tree-folder {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0.7rem 0.5rem 0.25rem;
}
.tree-file {
  display: block;
  padding: 0.32rem 0.6rem;
  border-radius: 7px;
  color: var(--text);
  font-size: 0.87rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.tree-file:hover { background: var(--bg-hover); text-decoration: none; }
.tree-file.active { background: var(--accent-soft); color: var(--accent); }

.table-link { font-family: inherit; }
.table-link-label { display: block; font-size: 0.85rem; font-weight: 500; }
.table-link-meta { display: block; font-size: 0.72rem; color: var(--text-dim); font-family: ui-monospace, Menlo, monospace; }

.code-view { flex: 1; min-width: 0; }
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}
.code-filename { font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.code-meta { font-size: 0.78rem; color: var(--text-dim); }

.code-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.84rem;
}
.code-body .highlight { background: transparent !important; }
.code-body pre { margin: 0; padding: 1rem; line-height: 1.5; }
.code-body .linenos { color: var(--text-dim); opacity: 0.5; padding-right: 0.4rem; user-select: none; }
.code-body table.highlighttable { border-collapse: collapse; width: 100%; }
.code-body table.highlighttable td { padding: 0; vertical-align: top; }

.markdown { padding: 1.2rem 1.6rem; max-width: 820px; }
.markdown h1, .markdown h2 { margin-top: 1.2rem; }
.markdown pre { background: var(--bg-hover); padding: 0.8rem 1rem; border-radius: 8px; overflow-x: auto; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 0.35rem 0.7rem; }

.placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-dim);
}

/* ---------- Grafiken ---------- */
.filter-bar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 1rem 0 0.4rem;
}
.filter-bar label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: var(--text-dim); }
.filter-bar select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
}

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; margin-top: 0.8rem; }
.fig-card {
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.fig-card img { width: 100%; height: auto; display: block; background: #fff; }
.fig-card figcaption { padding: 0.6rem 0.85rem; }
.fig-park { display: block; font-size: 0.72rem; color: var(--text-dim); }
.fig-kind { display: block; font-size: 0.85rem; font-weight: 500; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  z-index: 100;
  padding: 2rem;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 8px; background: #fff; }
#lightbox-caption { color: var(--text-dim); font-size: 0.9rem; }
#lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.4rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 2.2rem;
  cursor: pointer;
  line-height: 1;
}

/* ---------- Buttons / Alerts ---------- */
.btn-small {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-small:hover { border-color: var(--accent); text-decoration: none; }

.alert {
  background: rgba(255, 99, 99, 0.12);
  border: 1px solid rgba(255, 99, 99, 0.4);
  color: #ff9d9d;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  margin: 0.8rem 0;
}
.alert-info {
  background: var(--accent-soft);
  border-color: rgba(79, 140, 255, 0.4);
  color: #a8c6ff;
}

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #171c2b 0%, var(--bg) 60%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.6rem 2.8rem;
  max-width: 430px;
  width: calc(100% - 2rem);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.login-icon { font-size: 2.4rem; }
.login-card h1 { margin: 0.4rem 0 0.2rem; }
.login-sub { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 1.6rem; }
.login-form { display: flex; flex-direction: column; gap: 0.7rem; }
.login-form input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  text-align: center;
}
.login-form input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}
.login-form button {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
}
.login-form button:hover { filter: brightness(1.1); }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { display: flex; justify-content: space-between; align-items: center; }
  .content { padding: 1.2rem; }
  .code-layout { flex-direction: column; }
  .file-tree { width: 100%; position: static; max-height: 300px; }
}
