:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #374151;
  --primary: #38bdf8;
  --danger: #f87171;
  --ok: #34d399;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(17,24,39,.9);
}
.brand a { font-size: 22px; font-weight: 800; color: var(--text); }
nav { display: flex; align-items: center; gap: 16px; }
main { max-width: 1180px; margin: 0 auto; padding: 28px; }
h1 { margin-top: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin: 18px 0;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
.card.small { max-width: 420px; margin: 80px auto; }
.card.success { border-color: var(--ok); background: rgba(52, 211, 153, .08); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid .card strong { display: block; font-size: 32px; }
.grid .card span { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
input {
  width: 100%;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
label { display: grid; gap: 6px; color: var(--muted); }
button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
button.primary {
  background: var(--primary);
  color: #082f49;
  border: 0;
  font-weight: 700;
}
.error { color: var(--danger); }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }
code, pre {
  background: #020617;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  overflow: auto;
}
.token {
  display: block;
  font-size: 16px;
  word-break: break-all;
}
@media (max-width: 800px) {
  .grid, .grid.two { grid-template-columns: 1fr; }
  header { display: block; }
  nav { margin-top: 12px; flex-wrap: wrap; }
}

.card.danger {
  border-color: rgba(248, 113, 113, .6);
  background: rgba(248, 113, 113, .06);
}

.hint {
  color: var(--muted);
}

.success-text {
  color: var(--ok);
  font-weight: 600;
}

.good {
  color: var(--ok);
  font-weight: 700;
}

.bad {
  color: var(--danger);
  font-weight: 700;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkline input {
  width: auto;
}

.warn {
  color: #fbbf24;
  font-weight: 700;
}

select {
  width: 100%;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.audit-table {
  table-layout: fixed;
}

.audit-table th:nth-child(1) { width: 220px; }
.audit-table th:nth-child(2) { width: 120px; }
.audit-table th:nth-child(3) { width: 150px; }
.audit-table th:nth-child(4) { width: 230px; }
.audit-table th:nth-child(5) { width: 140px; }

.audit-details {
  max-width: 520px;
}

.detail-summary {
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.json-details {
  max-height: 180px;
  max-width: 520px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.35;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.small {
  font-size: 13px;
}

.audit-list {
  display: grid;
  gap: 14px;
}

.audit-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,.14);
}

.audit-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.audit-action {
  display: inline-block;
  background: #020617;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.audit-time {
  margin-top: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.audit-actor {
  color: var(--muted);
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.audit-grid {
  display: grid;
  grid-template-columns: 1.2fr .7fr 2fr;
  gap: 18px;
}

.audit-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}

.audit-value {
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.audit-json-wrap {
  margin-top: 14px;
}

.audit-json-wrap summary {
  cursor: pointer;
  color: var(--primary);
  user-select: none;
}

.audit-json {
  margin-top: 10px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .audit-card-head {
    display: block;
  }

  .audit-actor {
    text-align: left;
    margin-top: 10px;
  }

  .audit-grid {
    grid-template-columns: 1fr;
  }
}

.host-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.host-actions button[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.inline-delete {
  position: relative;
}

.inline-delete > summary {
  list-style: none;
  cursor: pointer;
  background: rgba(248, 113, 113, .10);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, .55);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
}

.inline-delete > summary::-webkit-details-marker {
  display: none;
}

.delete-form {
  margin-top: 10px;
  min-width: 360px;
  background: var(--panel);
  border: 1px solid rgba(248, 113, 113, .55);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.delete-form button {
  color: var(--danger);
  border-color: rgba(248, 113, 113, .55);
}

.danger-action {
  background: rgba(248, 113, 113, .10);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, .55);
}

.toast-stack {
  position: fixed;
  right: 24px;
  top: 24px;
  z-index: 9999;
  display: grid;
  gap: 10px;
  max-width: min(420px, calc(100vw - 48px));
}

.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  animation: toast-in .18s ease-out;
}

.toast-error {
  border-color: rgba(248, 113, 113, .65);
  color: var(--danger);
}

.toast-out {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .25s ease, transform .25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast-stack {
  position: fixed;
  right: 24px;
  top: 24px;
  z-index: 9999;
  display: grid;
  gap: 10px;
  max-width: min(440px, calc(100vw - 48px));
}

.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  animation: toast-in .18s ease-out;
  font-weight: 700;
  line-height: 1.35;
}

.toast-success {
  border-color: rgba(52, 211, 153, .75);
  color: var(--ok);
}

.toast-error {
  border-color: rgba(248, 113, 113, .75);
  color: var(--danger);
}

.toast-out {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .25s ease, transform .25s ease;
}

.danger-action {
  background: rgba(248, 113, 113, .10);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, .55);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .92em;
  font-weight: 800;
  border: 1px solid transparent;
}

.status-active {
  color: var(--ok);
  background: rgba(52, 211, 153, .10);
  border-color: rgba(52, 211, 153, .45);
}

.status-inactive {
  color: var(--danger);
  background: rgba(248, 113, 113, .10);
  border-color: rgba(248, 113, 113, .45);
}

.btn-success {
  color: var(--ok);
  border-color: rgba(52, 211, 153, .50);
  background: rgba(52, 211, 153, .10);
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, .55);
  background: rgba(248, 113, 113, .10);
}

/* Strong status badges override */
.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 900;
  letter-spacing: .01em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.status-active {
  color: #052e1b;
  background: #34d399;
  border-color: #34d399;
}

.status-inactive {
  color: #450a0a;
  background: #f87171;
  border-color: #f87171;
}

/* Final readable status badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-weight: 800;
}

.status-pill::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.status-active {
  color: #34d399;
  background: transparent;
  border: 0;
}

.status-active::before {
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .16);
}

.status-inactive {
  color: #f87171;
  background: transparent;
  border: 0;
}

.status-inactive::before {
  background: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, .16);
}

/* Status spacing fix */
.status-pill {
  margin-left: 10px;
  gap: 9px;
}

.status-pill::before {
  flex: 0 0 auto;
}

.token-copy-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.token-copy-input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .02em;
}

.copy-token-button {
  min-width: 54px;
  font-size: 22px;
  line-height: 1;
  padding: 12px 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.info-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,.02);
}

.info-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.info-value {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.notice-danger {
  border: 1px solid rgba(248, 113, 113, .55);
  background: rgba(248, 113, 113, .08);
  color: var(--danger);
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0 20px;
}

.details-box {
  margin-top: 14px;
}

.details-box summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
}

@media (max-width: 1100px) {
  .info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .section-head {
    display: block;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

.row-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.row-form select {
  min-width: 190px;
}

.row-form button {
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.assign-form {
  margin: 0 0 18px 0;
}

.assign-form select {
  min-width: min(620px, 100%);
}

.section-head .hint {
  margin: 0;
}

.assign-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(360px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 0 0 18px 0;
}

.assign-grid label {
  margin: 0;
}

.assign-grid button {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .assign-grid {
    grid-template-columns: 1fr;
  }
}

.subcard {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-top: 18px;
  background: rgba(255,255,255,.025);
}

.subcard h3 {
  margin: 0;
}

/* Public landing page */
.public-landing {
  max-width: 1120px;
  margin: 0 auto;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 28px;
  align-items: stretch;
  margin: 26px 0 22px;
}

.hero-copy,
.hero-panel,
.feature-card,
.landing-card {
  border: 1px solid var(--border, #2f3b4d);
  border-radius: 18px;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), transparent 34%),
    rgba(15, 23, 42, 0.72);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.hero-copy {
  padding: 38px;
}

.hero-panel {
  padding: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #38bdf8;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.hero-text {
  max-width: 720px;
  margin: 22px 0 0;
  color: #cbd5e1;
  font-size: 1.12rem;
  line-height: 1.65;
}

.hero-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.85);
  color: #e5e7eb;
  font-weight: 700;
  text-decoration: none;
}

.btn:hover,
.button:hover {
  border-color: rgba(56, 189, 248, 0.7);
  color: #ffffff;
}

.btn-primary,
.button.primary {
  border-color: rgba(56, 189, 248, 0.85);
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  color: #06111f;
}

.btn-ghost,
.button.secondary {
  background: transparent;
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  color: #a7f3d0;
  font-size: 0.92rem;
}

.trust-row span {
  padding: 7px 10px;
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 999px;
  background: rgba(6, 78, 59, 0.22);
}

.terminal-card {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 16px;
  background: #020617;
}

.terminal-head {
  display: flex;
  gap: 7px;
  padding: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.terminal-head span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #475569;
}

.terminal-card pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: #d1fae5;
}

.mini-status-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mini-status-grid div {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.55);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.feature-card {
  padding: 20px;
}

.feature-card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.feature-card p {
  color: #cbd5e1;
  line-height: 1.55;
}

.section-heading h2 {
  margin-top: 0;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0;
}

@media (max-width: 900px) {
  .landing-hero,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .hero-copy {
    padding: 24px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}


/* Final admin shell layout */
body.admin-shell-body {
  min-height: 100vh;
}

body.admin-shell-body header.topbar {
  height: 56px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

body.admin-shell-body .brand a {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

body.admin-shell-body .topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

body.admin-shell-body .topbar-actions a {
  color: var(--link);
  text-decoration: none;
}

body.admin-shell-body .link-button {
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.72);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  padding: 0.48rem 0.75rem;
  border-radius: 0.7rem;
}

body.admin-shell-body .admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
  width: 100%;
}

body.admin-shell-body .admin-sidebar {
  border-right: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.56);
  padding: 18px 14px;
}

body.admin-shell-body .sidebar-nav {
  display: grid;
  gap: 6px;
  align-content: start;
}

body.admin-shell-body .sidebar-group {
  display: grid;
  gap: 3px;
  margin-top: 18px;
}

body.admin-shell-body .sidebar-group-title {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 7px 8px 4px;
}

body.admin-shell-body .sidebar-link {
  display: block;
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  padding: 8px 9px;
  line-height: 1.25;
}

body.admin-shell-body .sidebar-link:hover,
body.admin-shell-body .sidebar-link.active {
  color: var(--link);
  background: rgba(56, 189, 248, 0.12);
}

body.admin-shell-body .sidebar-link.active {
  border: 1px solid rgba(56, 189, 248, 0.28);
  font-weight: 800;
}

body.admin-shell-body .admin-content {
  min-width: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 26px 32px 48px;
}

body.admin-shell-body .admin-content > h1 {
  margin-top: 0;
  margin-bottom: 22px;
}

body.admin-shell-body .admin-content > .card,
body.admin-shell-body .admin-content > section.card {
  width: 100%;
  max-width: 1120px;
}

body.admin-shell-body .admin-content > .metric-grid,
body.admin-shell-body .admin-content > .stats-grid {
  width: 100%;
  max-width: 1120px;
}

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

  body.admin-shell-body .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  body.admin-shell-body .sidebar-nav {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  body.admin-shell-body .sidebar-group {
    margin-top: 0;
  }

  body.admin-shell-body .admin-content {
    padding: 18px;
  }
}

/* Admin Ops jobs */
.ops-summary-grid {
  margin-bottom: 18px;
}

.ops-jobs-table td {
  vertical-align: top;
}

.ops-job-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  white-space: nowrap;
}

.ops-job-badge::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.ops-status-queued .ops-job-badge,
.ops-job-badge.ops-status-queued {
  color: var(--muted);
}

.ops-status-queued .ops-job-badge::before,
.ops-job-badge.ops-status-queued::before {
  background: var(--muted);
}

.ops-status-running .ops-job-badge,
.ops-job-badge.ops-status-running {
  color: var(--primary);
}

.ops-status-running .ops-job-badge::before,
.ops-job-badge.ops-status-running::before {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .18);
}

.ops-status-done .ops-job-badge,
.ops-job-badge.ops-status-done {
  color: var(--ok);
}

.ops-status-done .ops-job-badge::before,
.ops-job-badge.ops-status-done::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .16);
}

.ops-status-failed .ops-job-badge,
.ops-job-badge.ops-status-failed {
  color: var(--danger);
}

.ops-status-failed .ops-job-badge::before,
.ops-job-badge.ops-status-failed::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, .16);
}

.ops-output-box {
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
}

.ops-line-warn {
  color: #fbbf24;
}

.ops-line-section {
  color: var(--primary);
  font-weight: 900;
  margin-top: 8px;
}

/* Admin Ops: Zeitspalte stabil halten */
.admin-ops-table th:first-child,
.admin-ops-table td:first-child,
.ops-jobs-table th:first-child,
.ops-jobs-table td:first-child {
  min-width: 360px;
  width: 360px;
  white-space: nowrap;
  vertical-align: top;
}

.admin-ops-table td:first-child *,
.ops-jobs-table td:first-child * {
  white-space: nowrap;
}

.admin-ops-table,
.ops-jobs-table {
  table-layout: auto;
}
