:root {
  --bg: #0d1117;
  --bg-soft: #131a24;
  --panel: #161d28;
  --panel-2: #1b2432;
  --border: #253044;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--bg-soft); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #7b5cff); display: grid; place-items: center; font-weight: 700; color: #fff; }
.brand-text { font-weight: 650; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); padding: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 13.5px;
}
.nav-item:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-icon { width: 16px; text-align: center; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: rgba(13, 17, 23, 0.85);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 17px; font-weight: 620; letter-spacing: -0.2px; }
.topbar-sub { font-size: 12.5px; color: var(--muted); }
.content { padding: 24px; max-width: 1240px; width: 100%; }

/* ---------- Components ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-weight: 600; font-size: 14.5px; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.stat { padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -0.5px; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px; transition: 0.15s; font-family: inherit;
}
.btn:hover:not(:disabled) { background: #232d3d; border-color: #34405a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3d7bef; border-color: #3d7bef; }
.btn-danger { background: transparent; border-color: rgba(248, 81, 73, 0.5); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 81, 73, 0.12); border-color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-ghost { background: transparent; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], textarea, select {
  background: #0f151e; border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-size: 13.5px; font-family: inherit; width: 100%;
}
textarea { resize: vertical; min-height: 90px; }
textarea.code { min-height: 320px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; }
.badge-running { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-degraded { background: rgba(210, 153, 34, 0.15); color: var(--amber); }
.badge-stopped, .badge-not-created { background: rgba(139, 152, 169, 0.15); color: var(--muted); }
.badge-error, .badge-failed, .badge-exited, .badge-unhealthy { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.badge-unknown, .badge-unavailable, .badge-running-pending { background: rgba(139, 152, 169, 0.12); color: var(--muted); }
.badge-success { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-info { background: var(--accent-soft); color: var(--accent); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 11px 14px; border-bottom: 1px solid rgba(37, 48, 68, 0.6); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: 0.7; }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 420px; margin: 0 auto 16px; }

.alert { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: flex; gap: 9px; align-items: flex-start; }
.alert-error { background: rgba(248, 81, 73, 0.1); border: 1px solid rgba(248, 81, 73, 0.35); color: #ffb4ae; }
.alert-warn { background: rgba(210, 153, 34, 0.1); border: 1px solid rgba(210, 153, 34, 0.35); color: #f2d07a; }
.alert-info { background: var(--accent-soft); border: 1px solid rgba(76, 141, 255, 0.3); color: #b7d0ff; }
.alert-success { background: rgba(63, 185, 80, 0.1); border: 1px solid rgba(63, 185, 80, 0.3); color: #9be0a5; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; max-width: 520px; width: 100%; box-shadow: var(--shadow); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 20px; font-size: 13.5px; color: var(--muted); }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; min-width: 260px; max-width: 420px; box-shadow: var(--shadow); font-size: 13px; animation: slide-in 0.2s ease; }
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-body { color: var(--muted); font-size: 12.5px; word-break: break-word; }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.log-view { background: #0b0f16; border: 1px solid var(--border); border-radius: 8px; padding: 14px; max-height: 460px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; color: #c9d5e3; }
.log-empty { color: var(--muted); font-style: italic; }

.env-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; }
.env-row input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.secret-badge { font-size: 11px; color: var(--muted); }

.loading-screen { display: grid; place-items: center; height: 100vh; color: var(--muted); gap: 14px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.service-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.service-name { font-weight: 550; font-size: 13.5px; }
.service-meta { font-size: 11.5px; color: var(--muted); }

.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } .sidebar { display: none; } .content { padding: 16px; } }

.section-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 9px 14px; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13.5px; border-bottom: 2px solid transparent; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 550; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid rgba(37, 48, 68, 0.5); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv-key { color: var(--muted); }
.kv-val { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; text-align: right; word-break: break-all; }

.auth-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .brand-mark { margin: 0 auto 12px; width: 44px; height: 44px; font-size: 19px; }
.auth-head h1 { font-size: 19px; margin-bottom: 4px; }
.auth-head p { color: var(--muted); font-size: 13px; }
