:root {
  --bg-app: #262b3a;
  --bg-topbar: #10121a;
  --bg-sidebar: #191c28;
  --bg-card: #2b3040;
  --bg-input: #1a1d29;
  --border: #3a4058;
  --text: #e4e6ec;
  --muted: #868da3;
  --accent: #c3d600;
  --accent-dark: #14161f;
  --success: #6fae3a;
  --running: #2f80ed;
  --warning: #e5a723;
  --failed: #d6423f;
  --silent: #6b7086;
  --radius: 3px;
}

* { box-sizing: border-box; }

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

a { color: #5fa8dd; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App shell ---- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  padding: 0 18px;
  background: var(--bg-topbar);
  border-bottom: 1px solid #000;
  flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-icon { color: var(--accent); display: flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 0.82rem; letter-spacing: 0.03em; }
.brand-text small { color: var(--muted); font-size: 0.68rem; }
.topbar-icon { color: var(--muted); display: flex; }

.user-menu { position: relative; }
.user-menu-trigger {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text);
  font-size: 0.82rem; padding: 6px 8px; cursor: pointer; text-transform: none; letter-spacing: normal; font-weight: 400;
}
.user-menu-trigger:hover { background: rgba(255,255,255,0.05); }
.avatar { background: #363c4f; border-radius: 50%; padding: 5px; display: flex; color: var(--muted); }
.chevron-down { display: flex; color: var(--muted); }
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 190px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  z-index: 50;
  overflow: hidden;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown a, .user-menu-dropdown .link-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.82rem;
  text-align: left;
  background: none;
  border: none;
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
  cursor: pointer;
}
.user-menu-dropdown a:hover, .user-menu-dropdown .link-btn:hover { background: rgba(255,255,255,0.06); text-decoration: none; }

.app-body { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  color: #b7bccb;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
  background: none;
  border-top: none; border-right: none; border-bottom: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  list-style: none;
}
.nav-item::-webkit-details-marker { display: none; }
.nav-item:hover { background: rgba(255,255,255,0.04); text-decoration: none; color: var(--text); }
.nav-item.active { background: rgba(195,214,0,0.09); border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.nav-icon { display: flex; flex-shrink: 0; }
.nav-form { margin: 0; }
.nav-item-btn { font-family: inherit; }
.sidebar-footer { margin-top: auto; padding: 14px 20px; color: var(--muted); font-size: 0.68rem; }

.nav-section-label {
  margin-top: 14px;
  padding: 6px 20px 4px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.nav-group summary.nav-item { cursor: pointer; }
.nav-chevron { margin-left: auto; display: flex; transition: transform 0.15s; }
.nav-group[open] summary .nav-chevron { transform: rotate(180deg); }
.nav-subitem {
  display: block;
  padding: 8px 20px 8px 51px;
  font-size: 0.82rem;
  color: var(--muted);
  border-left: 3px solid transparent;
}
.nav-subitem:hover { color: var(--text); background: rgba(255,255,255,0.03); text-decoration: none; }
.nav-subitem.active { color: var(--accent); }

.content { flex: 1; padding: 20px 26px 60px; overflow-x: auto; min-width: 0; }

.breadcrumb { color: var(--muted); font-size: 0.75rem; margin-bottom: 12px; }
.breadcrumb a { color: var(--muted); }
.crumb-sep { margin: 0 6px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }

.page-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}
.page-icon { color: var(--accent); display: flex; }

/* ---- Stat tiles (KPI row) ---- */
.stat-row { display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-tile {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.stat-value {
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: proportional-nums;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

/* ---- Cards ---- */
.card-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.card-row .card { flex: 1; min-width: 320px; margin-bottom: 0; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.card-title {
  margin: 0;
  padding: 12px 16px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 14px 16px; }
.card-body.no-pad { padding: 0; }

.scroll-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

.activity-item, .history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.activity-item:last-child, .history-item:last-child { border-bottom: none; }
.status-icon { flex-shrink: 0; margin-top: 2px; display: flex; }

.small { font-size: 0.74rem; }
.muted { color: var(--muted); }

/* ---- Data tables (Integritätsstatus, Kundenliste, Jobs, Repos) ---- */
.data-table, .status-table, .job-table { width: 100%; border-collapse: collapse; }
.data-table th, .status-table th, .job-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.data-table td, .status-table td, .job-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
  font-size: 0.85rem;
}
.data-table tbody tr:hover, .status-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tr:last-child td, .status-table tr:last-child td { border-bottom: none; }

.company-row td { font-weight: 500; }
.sites-row td { padding: 0 14px 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.col-name { font-weight: 600; }
.actions-col { white-space: nowrap; text-align: right; }

.site-link { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.site-link:hover { color: var(--accent); text-decoration: none; }
.site-link-indent { padding-left: 18px; font-weight: 400; }

.company-group-row td {
  padding: 10px 14px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.company-group-row:first-child td { padding-top: 2px; }

.bar-cell { width: 38%; }
.stacked-bar {
  display: flex;
  height: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
  min-width: 110px;
  border: 1px solid var(--border);
}
.bar-seg { height: 100%; border-right: 2px solid var(--bg-card); }
.bar-seg:last-child { border-right: none; }

.capacity-bar {
  height: 8px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
  border: 1px solid var(--border);
  margin-bottom: 4px;
  min-width: 140px;
}
.capacity-fill { height: 100%; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---- Auth / login ---- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-topbar);
}
.login-box {
  width: 100%;
  max-width: 370px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .brand-icon { color: var(--accent); }
.login-box h1 { font-size: 1.05rem; margin: 0 0 16px; font-weight: 600; }
.login-box form, .stack-form { display: flex; flex-direction: column; gap: 13px; }
.login-box label, .stack-form label, .profile-box label { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; color: var(--muted); }

/* ---- Forms / inputs ---- */
input {
  font-family: inherit;
  font-size: 0.87rem;
  padding: 8px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}
input:focus { outline: none; border-color: var(--accent); }

button, .btn-primary, .btn-secondary {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button, .btn-primary {
  background: var(--accent);
  color: var(--accent-dark);
  border-color: var(--accent);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.05); }
.btn-sm { padding: 5px 10px; font-size: 0.7rem; }
button.danger, .danger { background: var(--failed); color: white; border-color: var(--failed); }
button:hover, .btn-primary:hover { filter: brightness(1.08); }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
  padding: 0;
}

.inline-form { display: flex; gap: 8px; margin: 4px 0 14px; flex-wrap: wrap; }

.error { color: #ff8f8c; }
.success { color: var(--success); }

.token-box {
  background: rgba(111,174,58,0.12);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.85rem;
}
.token-box code { display: block; margin-top: 6px; word-break: break-all; color: var(--text); font-size: 0.8rem; }

.instance-meta { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }

.subsection-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 18px 0 6px;
}
.subsection-title:first-child { margin-top: 4px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius);
  font-size: 0.66rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-revoked { background: var(--silent); }

.site-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-list li { padding: 2px 0; }
.site-list a { color: var(--text); }

.help-steps { margin: 0; padding-left: 20px; line-height: 1.9; }

.button-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: var(--accent);
  color: var(--accent-dark);
  padding: 5px 11px;
  border-radius: var(--radius);
  text-decoration: none;
  vertical-align: middle;
  margin-left: 10px;
}
.button-like:hover { filter: brightness(1.08); text-decoration: none; }

.profile-box {
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.qr-wrap { background: white; padding: 16px; border-radius: var(--radius); display: inline-block; margin: 12px 0; }
.qr-wrap svg { display: block; width: 220px; height: 220px; }

/* ---- Modals (native <dialog>) ---- */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  padding: 0;
  width: 420px;
  max-width: 90vw;
}
.modal::backdrop { background: rgba(8,9,14,0.65); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); padding: 2px; }
.modal-close:hover { color: var(--text); background: none; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; color: var(--muted); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .sidebar { width: 56px; }
  .nav-item span:not(.nav-icon), .brand-text, .nav-subitem, .nav-chevron { display: none; }
  .card-row { flex-direction: column; }
}
