:root {
  --bg-0: #0a0e13;
  --bg-1: #0f1620;
  --bg-2: #16202c;
  --glass: rgba(24, 34, 47, 0.55);
  --glass-border: rgba(120, 160, 200, 0.14);
  --text: #e8eef5;
  --muted: #8ba0b6;
  --brand: #38e08b;
  --brand-2: #1fb877;
  --accent: #ff8a3d;
  --danger: #ff5964;
  --danger-2: #d63d47;
  --warn: #ffcf5c;
  --info: #4aa3ff;
  --purple: #b98bff;
  --save: #5cc8ff;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 15% -10%, #12324a 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, #1a3d2a 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 60%, var(--bg-0));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

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

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: var(--shadow);
}

/* ===================== LOGIN ===================== */
#login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  padding: 38px 34px;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.brand {
  text-align: center;
  margin-bottom: 26px;
}

.brand-logo {
  font-size: 54px;
  line-height: 1;
  filter: drop-shadow(0 6px 18px rgba(56, 224, 139, 0.35));
}

.brand-logo.sm {
  font-size: 34px;
}

.brand h1 {
  font-size: 22px;
  margin: 12px 0 6px;
  letter-spacing: 0.3px;
}

.field {
  margin-bottom: 16px;
}

input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(8, 13, 19, 0.6);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="password"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(56, 224, 139, 0.15);
}

/* ===================== BUTTONS ===================== */
.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s;
  user-select: none;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #04150c;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-start {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #04150c;
}

.btn-stop {
  background: linear-gradient(135deg, var(--danger), var(--danger-2));
}

.btn-restart {
  background: linear-gradient(135deg, #4aa3ff, #2f7fe0);
}

.btn-start:hover:not(:disabled),
.btn-stop:hover:not(:disabled),
.btn-restart:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
}

.ico {
  font-size: 13px;
}

.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
  text-align: center;
}

.footer-note {
  font-size: 12px;
}

/* ===================== DASHBOARD ===================== */
#dash-view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.title {
  font-size: 17px;
  font-weight: 700;
}

.subtitle {
  font-size: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(8, 13, 19, 0.5);
  border: 1px solid var(--glass-border);
  font-size: 13px;
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}

.status-pill.running .dot,
.log-status.connected .dot {
  background: var(--brand);
  animation: pulse 1.8s infinite;
}

.status-pill.stopped .dot {
  background: var(--danger);
}

.status-pill.pending .dot {
  background: var(--warn);
  animation: pulse 1.2s infinite;
}

.grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
}

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

.card {
  border-radius: var(--radius);
  padding: 22px;
}

.card-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin: 0 0 18px;
  font-weight: 700;
}

/* ---- Control card ---- */
.status-hero {
  display: flex;
  justify-content: center;
  margin: 6px 0 24px;
}

.status-ring {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
}

/* Colored ring layer — THIS is the only part that spins */
.status-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ring-bg, conic-gradient(var(--muted) 1turn, rgba(255, 255, 255, 0.05) 0));
  transition: background 0.6s ease;
}

/* Static dark inner disc — sits on top of the ring, never rotates */
.status-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, var(--bg-2), var(--bg-0));
  border: 1px solid var(--glass-border);
  z-index: 1;
}

/* Spin the colored layer only, for indeterminate startup phases */
.status-ring.phase-bootstrap::before,
.status-ring.phase-launching::before,
.status-ring.phase-starting::before,
.status-ring.phase-pending::before,
.status-ring.phase-updating::before {
  animation: rotate 1.5s linear infinite;
}

/* When a real progress value is shown, keep the arc still */
.status-ring.determinate::before {
  animation: none;
}

/* Text stays perfectly still, above both layers */
.status-ring-inner {
  position: relative;
  z-index: 2;
  text-align: center;
}

.status-big {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.status-detail {
  font-size: 12px;
  margin-top: 4px;
  max-width: 130px;
}

.actions {
  display: grid;
  gap: 10px;
}

.action-msg {
  margin: 14px 0 0;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: center;
}

.action-msg.ok {
  background: rgba(56, 224, 139, 0.12);
  color: var(--brand);
}

.action-msg.err {
  background: rgba(255, 89, 100, 0.12);
  color: var(--danger);
}

.updated {
  font-size: 11px;
  text-align: center;
  margin: 14px 0 0;
}

/* ---- Log card ---- */
.log-card {
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.log-tools {
  display: flex;
  align-items: center;
  gap: 14px;
}

.log-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.switch input {
  accent-color: var(--brand);
}

.terminal {
  flex: 1;
  background: #05090d;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: "Cascadia Code", "JetBrains Mono", "Consolas", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: #c7d3df;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 62vh;
  scrollbar-width: thin;
  scrollbar-color: #2a3949 transparent;
}

.terminal::-webkit-scrollbar {
  width: 8px;
}

.terminal::-webkit-scrollbar-thumb {
  background: #2a3949;
  border-radius: 8px;
}

.log-line {
  padding: 0;
}

.log-line.sys {
  color: var(--warn);
}

.log-line.err {
  color: var(--danger);
}

/* ===================== ANIMATIONS ===================== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(56, 224, 139, 0.5);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(56, 224, 139, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(56, 224, 139, 0);
  }
}

/* ===================== PHASE COLORS ===================== */
/* Status ring colour per phase (applied to the spinning ::before layer) */
.status-ring.phase-ready {
  --ring-bg: conic-gradient(var(--brand) 1turn, rgba(56, 224, 139, 0.1) 0turn);
  box-shadow: 0 0 50px -6px rgba(56, 224, 139, 0.35);
}
.status-ring.phase-offline {
  --ring-bg: conic-gradient(var(--danger) 1turn, rgba(255, 89, 100, 0.12) 0turn);
}
.status-ring.phase-bootstrap,
.status-ring.phase-starting,
.status-ring.phase-pending {
  --ring-bg: conic-gradient(var(--warn) 0.66turn, rgba(255, 207, 92, 0.12) 0turn);
}
.status-ring.phase-launching {
  --ring-bg: conic-gradient(var(--purple) 0.66turn, rgba(185, 139, 255, 0.14) 0turn);
}
.status-ring.phase-updating {
  --ring-bg: conic-gradient(var(--info) 0.15turn, rgba(74, 163, 255, 0.12) 0turn);
}

/* Status pill dot per phase */
.status-pill.phase-ready .dot {
  background: var(--brand);
  animation: pulse 1.8s infinite;
}
.status-pill.phase-offline .dot {
  background: var(--danger);
}
.status-pill.phase-bootstrap .dot,
.status-pill.phase-starting .dot,
.status-pill.phase-launching .dot,
.status-pill.phase-updating .dot,
.status-pill.phase-pending .dot {
  background: var(--warn);
  animation: pulse 1.2s infinite;
}
.status-pill.phase-launching .dot {
  background: var(--purple);
}
.status-pill.phase-updating .dot {
  background: var(--info);
}

/* ===================== PROGRESS BAR ===================== */
.progress {
  height: 7px;
  border-radius: 999px;
  background: rgba(74, 163, 255, 0.14);
  overflow: hidden;
  margin: -8px 0 18px;
}
.progress-inner {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--info), #7cc0ff);
  transition: width 0.5s ease;
}

/* ===================== STAT CHIPS ===================== */
.stat-chips {
  display: flex;
  gap: 8px;
  margin: 16px 0 4px;
  justify-content: center;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(8, 13, 19, 0.5);
  border: 1px solid var(--glass-border);
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.chip-ico {
  font-size: 13px;
}

/* ===================== LOG LINES ===================== */
.log-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 1px 0;
}
.lt {
  color: #4c5c6d;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.li {
  flex: 0 0 16px;
  text-align: center;
  opacity: 0.9;
}
.lx {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line.l-ok .lx {
  color: var(--brand);
  font-weight: 600;
}
.log-line.l-err .lx {
  color: var(--danger);
}
.log-line.l-warn .lx {
  color: var(--warn);
}
.log-line.l-player .lx {
  color: #6fe3c4;
}
.log-line.l-save .lx {
  color: var(--save);
}
.log-line.l-update .lx {
  color: #8fbfff;
}
.log-line.l-info .lx {
  color: #cdd9e5;
}
.log-line.l-mod .lx,
.log-line.l-gc .lx,
.log-line.l-struct .lx {
  color: #5f7183;
}
.log-line.l-boot .lx {
  color: #7a8da0;
}

/* "Nur wichtige" filter — hide noisy chatter */
.terminal.filtered .log-line.noise {
  display: none;
}
