:root {
  --bg: #0b0d10;
  --surface: #12151b;
  --surface-2: #181c24;
  --surface-3: #202531;
  --border: #2a2f3a;
  --text: #e6edf7;
  --text-2: #9aa4b2;
  --text-3: #6c7686;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 248px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
}

.brand-title { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
  transition: all .15s ease;
  text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-icon { font-size: 15px; width: 22px; text-align: center; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
}
.conn-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.conn-pill.online .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.conn-pill.online { color: var(--success); }
.side-meta { color: var(--text-3); font-size: 11px; margin-top: 8px; padding-left: 4px; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 21, 27, 0.85);
  backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; }
.page-desc { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.top-actions { display: flex; gap: 10px; }

section.page {
  display: none;
  flex: 1;
  padding: 24px 28px 40px;
  overflow-y: auto;
}
section.page.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat-label { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 8px; }
.stat-value.mono { font-family: var(--mono); font-size: 18px; }
.stat-hint { color: var(--text-3); font-size: 12px; margin-top: 6px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-head.tight { margin-top: 20px; }

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-2);
}
.badge.soft { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.badge.warn { background: rgba(245, 158, 11, 0.12); color: var(--warn); }
.badge.danger { background: rgba(239, 68, 68, 0.12); color: var(--danger); }

.health-list, .event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.health-item, .event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.health-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.health-dot.warn { background: var(--warn); }
.health-dot.error { background: var(--danger); }
.health-meta { color: var(--text-3); font-size: 12px; }

.event-item { flex-direction: column; align-items: flex-start; gap: 4px; }
.event-title { font-size: 13px; }
.event-meta { color: var(--text-3); font-size: 11px; }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2563eb; }
.btn.ghost { background: transparent; }
.btn.danger-outline { color: var(--danger); border-color: var(--danger); }
.btn.danger-outline:hover { background: rgba(239, 68, 68, 0.12); }
.btn.tiny { padding: 5px 10px; font-size: 12px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { color: var(--text-2); font-size: 13px; font-weight: 500; }
.field input, .field select, .field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input[readonly] { color: var(--text-3); cursor: not-allowed; }

.input-with-action { display: flex; gap: 8px; }
.input-with-action input { flex: 1; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.switch-title { font-weight: 600; }
.switch-desc { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.switch-row input[type="checkbox"] {
  appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  transition: background .15s ease;
}
.switch-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform .15s ease;
}
.switch-row input[type="checkbox"]:checked { background: var(--accent); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.num-inline { width: 80px; text-align: center; }

.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .stats { grid-template-columns: 1fr; }
}

.banner {
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.6;
}
.banner.warn { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.25); color: #fde68a; }
.banner.info { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.25); color: #bfdbfe; }
.banner.info code { background: var(--surface); padding: 2px 6px; border-radius: 6px; font-family: var(--mono); }
.banner.danger { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); color: #fecaca; }

.disk-bar { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; position: relative; }
.disk-fill { height: 100%; transition: width .3s ease; }
.disk-bar span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

.stat-value.online { color: var(--success); }

.progress-wrap { margin: 12px 0; }
.progress-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #8b5cf6); transition: width .3s ease; }
.progress-meta { color: var(--text-2); font-size: 13px; margin-top: 10px; font-family: var(--mono); }

.changelog { background: var(--surface-2); border-radius: 10px; padding: 14px; min-height: 140px; max-height: 320px; overflow-y: auto; }
.changelog p { margin: 4px 0; color: var(--text-2); font-size: 13px; }

.quota-visual { display: flex; align-items: center; gap: 26px; padding: 10px 0; }
.quota-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--ratio, 0) * 360deg), var(--surface-2) 0deg);
  display: grid;
  place-items: center;
  position: relative;
}
.quota-ring::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--surface);
}
.quota-center { position: relative; text-align: center; }
.quota-num { font-size: 28px; font-weight: 700; line-height: 1; }
.quota-den { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.quota-meta { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.kv span { color: var(--text-2); font-size: 13px; }
.kv strong { font-weight: 600; }

.artifact-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 18px;
}
.artifact-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.artifact-name { font-size: 16px; }
.artifact-meta { color: var(--text-3); font-size: 12px; margin-top: 4px; }

.detail-list { display: grid; gap: 10px; }
.detail-list dt { color: var(--text-3); font-size: 12px; margin-top: 8px; }
.detail-list dd { margin: 0; font-family: var(--mono); font-size: 13px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--text-2); font-weight: 500; padding: 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.table tr:last-child td { border-bottom: none; }
.table td .mono { font-family: var(--mono); }

.link-btn { background: none; border: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.help-text { color: var(--text-3); font-size: 12px; margin-top: 14px; }

.log-console {
  background: #0a0c0f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.log-line { margin: 0; padding: 2px 0; }
.log-line.info { color: var(--text-2); }
.log-line.warn { color: var(--warn); }
.log-line.error { color: var(--danger); }

.select-inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 10px;
  font: inherit;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 500;
  z-index: 100;
}
.toast.show { animation: slideUp .25s ease; }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 200;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 560px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .btn.icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
}

.modal form { padding: 20px; }
.modal .field-hint {
  color: var(--text-3);
  font-size: 12px;
  margin-top: 4px;
}
.modal .field textarea.mono { font-family: var(--mono); font-size: 12px; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 18px 18px;
}

.empty-state {
  color: var(--text-3);
  text-align: center;
  padding: 40px;
  font-size: 13px;
}
