/* Gemeinsames Layout: index, llm, admin */
:root {
  --font: system-ui, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f6;
  --surface: #ffffff;
  --text: #1c1c1c;
  --muted: #5c5c5c;
  --border: #e2e2e2;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --nav-active-bg: #e8eefc;
  --danger: #b91c1c;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111;
  --surface: #1a1a1a;
  --text: #ececec;
  --muted: #a3a3a3;
  --border: #2e2e2e;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --nav-active-bg: #1e293b;
  --danger: #f87171;
}
html {
  scroll-behavior: smooth;
  /* Gleiche sichtbare Breite auf allen Seiten (LLM ist laenger → sonst Scrollbar schmaler) */
  scrollbar-gutter: stable;
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
main.page {
  max-width: 64rem;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 1.75rem clamp(1.25rem, 4vw, 2.5rem) 3.5rem;
  overflow-x: clip;
}
.card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 0;
  box-shadow: var(--shadow);
}
.card-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}
.card-body {
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
  padding: clamp(1.75rem, 3vw, 2.5rem) clamp(1.5rem, 4vw, 2.75rem) clamp(2rem, 3vw, 2.75rem);
}
.site-nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav::-webkit-scrollbar {
  display: none;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.95rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.site-nav a:hover {
  background: var(--nav-active-bg);
  text-decoration: none;
}
.site-nav a.is-active {
  border-color: transparent;
  background: var(--nav-active-bg);
  color: var(--accent);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.95rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover {
  background: var(--nav-active-bg);
  text-decoration: none;
}
.btn--primary {
  border-color: transparent;
  background: var(--nav-active-bg);
  color: var(--accent);
}
.btn--danger {
  border-color: var(--danger);
  color: var(--danger);
}
.btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--icon {
  padding: 0.45rem;
  min-width: 2.25rem;
}
.settings-wrap {
  position: relative;
  flex: 0 0 auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
a.github-link.btn {
  color: #24292f;
  text-decoration: none;
}
a.github-link.btn:hover {
  background: var(--nav-active-bg);
  color: #24292f;
  text-decoration: none;
}
.github-link__icon {
  display: block;
  fill: currentColor;
}
[data-theme="dark"] a.github-link.btn {
  color: #f0f6fc;
}
[data-theme="dark"] a.github-link.btn:hover {
  background: var(--nav-active-bg);
  color: #f0f6fc;
}
/* Hide legacy settings submenu (cache) */
.settings-panel,
.theme-segments {
  display: none !important;
}
#btn-auth[hidden],
html[data-auth-config="missing"] #btn-auth {
  display: none !important;
}
#btn-auth.btn-auth {
  min-width: 5.75rem;
}
#btn-auth.btn-auth .btn-auth__when-in {
  display: none;
}
html[data-auth-signed-in="true"] #btn-auth.btn-auth .btn-auth__when-in {
  display: inline;
}
html[data-auth-signed-in="true"] #btn-auth.btn-auth .btn-auth__when-out {
  display: none;
}
html[data-auth-signed-in="false"] #btn-auth.btn-auth {
  border-color: transparent;
  background: var(--nav-active-bg);
  color: var(--accent);
}
.theme-toggle {
  position: relative;
}
.theme-toggle__icon {
  display: block;
}
.theme-toggle__icon--sun {
  display: none;
}
[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}
[data-theme="dark"] .theme-toggle__icon--sun {
  display: block;
}
@media (max-width: 520px) {
  html {
    scrollbar-gutter: auto;
  }
  main.page {
    padding: 1rem 0.75rem 2.5rem;
  }
  .card-toolbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.85rem;
    min-width: 0;
  }
  .site-nav {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    overflow-x: visible;
    padding-bottom: 0;
  }
  .site-nav a {
    flex: 0 1 auto;
    padding: 0.38rem 0.7rem;
    font-size: 0.84rem;
  }
  .settings-wrap {
    flex: 0 0 auto;
    flex-shrink: 0;
    margin-left: auto;
    gap: 0.35rem;
  }
  .btn--icon {
    padding: 0.38rem;
    min-width: 2rem;
  }
  .card-body {
    padding: 1.25rem 0.85rem 1.75rem;
  }
  .card-body--tight {
    padding-top: 1rem;
  }
  .admin-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-bar__actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
  .btn--toggle-start,
  .btn--toggle-stop {
    min-width: 0;
  }
  .admin-section .admin-table:not(.admin-table--compact),
  .admin-k8s-panel {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-section .admin-table:not(.admin-table--compact)::-webkit-scrollbar,
  .admin-k8s-panel::-webkit-scrollbar {
    display: none;
  }
}

/* Admin */
.admin-status {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  color: var(--muted);
}
.admin-status--error { color: var(--danger); }
.admin-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.admin-panel {
  margin: 0 0 1.25rem;
  padding: 0 0 1.25rem;
  border-bottom: 1px solid var(--border);
}
.admin-panel:last-child { border-bottom: 0; }
.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.admin-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.admin-table-wrap::-webkit-scrollbar {
  display: none;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table th {
  color: var(--muted);
  font-weight: 600;
}
.admin-section-title {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 650;
}
.admin-subtitle {
  margin: 0.9rem 0 0.45rem;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--muted);
}
.admin-note {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.86rem;
}
.admin-note p {
  margin: 0.25rem 0;
}
.admin-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}
.admin-table--compact th {
  width: 10rem;
  white-space: nowrap;
}
.admin-table--compact td {
  word-break: break-word;
}
.gpu-pipeline {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-elevated, rgba(0, 0, 0, 0.04));
}
.gpu-pipeline__title {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  font-weight: 650;
}
.gpu-pipeline__detail {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.gpu-pipeline__steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.gpu-pipeline__step {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.gpu-pipeline__step--done {
  border-color: var(--success, #2a7);
  color: var(--success, #2a7);
}
.gpu-pipeline__step--active {
  border-color: var(--accent, #38f);
  color: var(--accent, #38f);
  font-weight: 650;
}
.gpu-pipeline--error { border-color: var(--danger, #e55); }
.gpu-pipeline--error .gpu-pipeline__title { color: var(--danger, #e55); }
.gpu-pipeline__step--error {
  border-color: var(--danger, #e55);
  color: var(--danger, #e55);
}
.admin-gpu-log {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.7rem;
  max-height: 11rem;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.35;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: #c8e6c9;
  white-space: pre-wrap;
  word-break: break-word;
}
.admin-gpu-auto {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
@media (max-width: 860px) {
  .admin-panel-head {
    display: block;
  }
  .admin-columns {
    grid-template-columns: 1fr;
  }
}
.admin-k8s-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.admin-k8s-tab {
  font-size: 0.88rem;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-elevated, rgba(0, 0, 0, 0.04));
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}
.admin-k8s-tab:hover {
  border-color: var(--accent, #2563eb);
}
.admin-k8s-tab[aria-selected="true"] {
  background: var(--accent, #2563eb);
  border-color: var(--accent, #2563eb);
  color: #fff;
}
.admin-k8s-panels {
  margin-top: 0.25rem;
}
.admin-k8s-panel[hidden] {
  display: none;
}
.owui-state {
  text-align: center;
  padding: clamp(2rem, 6vw, 4rem) 1rem;
  max-width: 28rem;
  margin-inline: auto;
}
.owui-state--offline .owui-state__badge {
  display: inline-block;
  margin: 0 0 0.75rem;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--danger, #c0392b);
}
.owui-state__title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.owui-state__lead {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.55;
}
.owui-state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.25rem 0 0;
}

.admin-k8s-metrics-lead {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.admin-table--scroll {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.admin-table--scroll::-webkit-scrollbar {
  display: none;
}

/* architecture.html / stack.html */
.arch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.arch-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}
.status-dot--running {
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.25);
}
.status-dot--stopped {
  background: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}
.status-dot--planned {
  background: #9ca3af;
}
.status-dot--transition {
  background: #eab308;
}
.arch-live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 0.65rem;
  margin-bottom: 2rem;
}
.arch-live-section-title {
  grid-column: 1 / -1;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}
.arch-live-card {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.arch-live-card__title {
  display: block;
  font-size: 0.92rem;
}
.arch-live-card__meta {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}
.page-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 600;
}
.page-lead {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 1.25rem;
}

/* Admin — tabbed cluster control */
.card-body--tight {
  padding-top: clamp(1rem, 2vw, 1.35rem);
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

@media (max-width: 720px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
}

.admin-subnav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: sticky;
  top: 4.5rem;
}

@media (max-width: 720px) {
  .admin-subnav {
    flex-direction: row;
    flex-wrap: wrap;
    position: static;
  }
}

.admin-subnav__link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.admin-subnav__link:hover {
  background: var(--nav-active-bg);
  text-decoration: none;
}

.admin-subnav__link.is-active {
  border-color: transparent;
  background: var(--nav-active-bg);
  color: var(--accent);
}

.admin-main {
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

.admin-k8s-panels {
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.admin-view[hidden] {
  display: none;
}

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.admin-bar__stat {
  font-size: 0.9rem;
  font-weight: 600;
}

.admin-bar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.admin-node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

.admin-node-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 6.5rem;
}

.admin-node-card--gpu {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.admin-node-card__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-node-card__name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.admin-node-card__role {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-node-card__meta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.admin-node-card__state {
  margin-top: auto;
  font-size: 0.82rem;
  font-weight: 600;
}

.admin-node-card__state--running { color: #16a34a; }
.admin-node-card__state--stopped { color: #dc2626; }
.admin-node-card__state--pending { color: #ca8a04; }
.admin-node-card__state--none { color: var(--muted); }

[data-theme="dark"] .admin-node-card__state--running { color: #4ade80; }
[data-theme="dark"] .admin-node-card__state--stopped { color: #f87171; }

.admin-section {
  margin: 0 0 1rem;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.admin-section--log {
  margin-top: 0.5rem;
  border-bottom: 0;
  padding-bottom: 0;
}

.admin-log__heading {
  margin: 0 0 0.25rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.admin-log__hint {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.admin-section--log .admin-log {
  max-height: 16rem;
}

.btn--toggle-start {
  min-width: 9.5rem;
  border-color: transparent;
  background: #16a34a;
  color: #fff;
}

.btn--toggle-start:hover {
  background: #15803d;
  color: #fff;
}

.btn--toggle-stop {
  min-width: 9.5rem;
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

.btn--toggle-stop:hover {
  background: color-mix(in srgb, var(--danger) 85%, #000);
  color: #fff;
}

.admin-log {
  margin: 0;
  padding: 0.75rem 0.85rem;
  max-height: 14rem;
  overflow: auto;
  font-size: 0.76rem;
  line-height: 1.4;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: #c8e6c9;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--muted);
}

.admin-pill--ok {
  border-color: #16a34a;
  color: #16a34a;
}

.admin-pill--warn {
  border-color: #ca8a04;
  color: #ca8a04;
}

.admin-pill--err {
  border-color: var(--danger);
  color: var(--danger);
}

.admin-dropdown {
  position: relative;
}

.admin-dropdown--bar .admin-dropdown__menu {
  left: auto;
  right: 0;
}

.admin-dropdown__trigger {
  list-style: none;
  cursor: pointer;
}

.admin-dropdown__trigger::-webkit-details-marker {
  display: none;
}

.admin-dropdown__trigger::after {
  content: " ▾";
  font-size: 0.75em;
  opacity: 0.85;
}

.admin-dropdown__menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: min(100%, 22rem);
  width: max-content;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-dropdown__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
}

.admin-dropdown__item:hover {
  background: var(--nav-active-bg);
}

.admin-dropdown__item--danger .admin-dropdown__item-title {
  color: var(--danger);
}

.admin-dropdown__item-title {
  font-weight: 650;
}

.admin-dropdown__item-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
