:root {
  color-scheme: dark;
  --bg: #060a0f;
  --bg-soft: #0a1018;
  --panel: #0f1722;
  --panel-2: #121c29;
  --line: rgba(148, 163, 184, .14);
  --line-strong: rgba(148, 163, 184, .24);
  --text: #e8eef7;
  --muted: #94a3b8;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --emerald: #34d399;
  --amber: #fbbf24;
  --red: #fb7185;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, .9);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
        "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(900px 520px at 8% -12%, rgba(34, 211, 238, .13), transparent 62%),
    radial-gradient(760px 460px at 100% 0%, rgba(167, 139, 250, .11), transparent 58%),
    radial-gradient(700px 500px at 50% 120%, rgba(52, 211, 153, .05), transparent 65%),
    var(--bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
}

#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .85;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.2rem; letter-spacing: .2px; }
h2 { font-size: 1.08rem; letter-spacing: .2px; }
h3 { font-size: 1rem; }

.muted { color: var(--muted); font-size: .85rem; }
.sep { opacity: .35; margin: 0 4px; }
.link { color: var(--cyan); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px max(20px, calc((100vw - 1180px) / 2));
  background: rgba(6, 10, 15, .72);
  border-bottom: 1px solid rgba(148, 163, 184, .1);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #061018;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 8px 24px -10px rgba(34, 211, 238, .65);
}
.brand-mark svg { width: 25px; height: 25px; }

.brand-text { min-width: 0; }
.brand-text h1 { font-size: 1.05rem; }
.brand-text p {
  margin: 2px 0 0;
  font-size: .76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid rgba(52, 211, 153, .28);
  border-radius: 999px;
  background: rgba(52, 211, 153, .07);
  color: #a7f3d0;
  font-size: .76rem;
  white-space: nowrap;
}
.status-pill.error {
  border-color: rgba(251, 113, 133, .35);
  background: rgba(251, 113, 133, .08);
  color: #fecdd3;
}
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .55);
  animation: pulse 2.2s ease-out infinite;
}
.status-pill.error .pulse { background: var(--red); animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .45); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ---------- layout ---------- */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 20px 44px;
  display: grid;
  gap: 30px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-sub { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(148, 163, 184, .05);
  font-size: .74rem;
  white-space: nowrap;
}
.pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 9px var(--cyan);
}

.grid { display: grid; gap: 14px; }
.grid.metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.containers { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- cards ---------- */
.card {
  position: relative;
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(23, 34, 48, .9), rgba(12, 19, 28, .94));
  box-shadow: var(--shadow);
}

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

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, .4), rgba(167, 139, 250, .28), transparent);
  opacity: .7;
  pointer-events: none;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
}
.metric:hover { border-color: var(--line-strong); }

.metric-top { display: flex; align-items: center; gap: 9px; }

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
}
.metric-icon svg { width: 18px; height: 18px; }
.metric-icon.cyan { color: var(--cyan); background: rgba(34, 211, 238, .1); }
.metric-icon.violet { color: var(--violet); background: rgba(167, 139, 250, .1); }
.metric-icon.emerald { color: var(--emerald); background: rgba(52, 211, 153, .1); }
.metric-icon.amber { color: var(--amber); background: rgba(251, 191, 36, .1); }
.metric-icon.rose { color: #f9a8d4; background: rgba(244, 114, 182, .1); }

.metric-label {
  color: var(--muted);
  font-size: .76rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.metric-sub {
  color: var(--muted);
  font-size: .76rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.bar {
  height: 6px;
  margin-top: 2px;
  border-radius: 999px;
  background: rgba(2, 6, 12, .8);
  border: 1px solid rgba(148, 163, 184, .08);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width .4s ease;
}
.bar > span.warn { background: linear-gradient(90deg, var(--amber), var(--red)); }

/* ---------- containers ---------- */
.container-card {
  padding: 18px;
  border-left: 3px solid var(--line-strong);
}
.container-card.status-running { border-left-color: var(--emerald); }
.container-card.status-stopped { border-left-color: var(--red); }
.container-card.status-unknown { border-left-color: var(--amber); }

.container-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.container-title { min-width: 0; }
.container-title h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.02rem;
}
.container-title h3::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 8px currentColor;
}
.container-card.status-running .container-title h3::before { background: var(--emerald); color: var(--emerald); }
.container-card.status-stopped .container-title h3::before { background: var(--red); color: var(--red); }
.container-card.status-unknown .container-title h3::before { background: var(--amber); color: var(--amber); }

.image-chip {
  display: inline-block;
  max-width: 100%;
  margin-top: 5px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(2, 6, 12, .35);
  color: var(--muted);
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.badge.running { color: var(--emerald); background: rgba(52, 211, 153, .08); border-color: rgba(52, 211, 153, .24); }
.badge.stopped { color: var(--red); background: rgba(251, 113, 133, .08); border-color: rgba(251, 113, 133, .24); }
.badge.unknown { color: var(--amber); background: rgba(251, 191, 36, .08); border-color: rgba(251, 191, 36, .24); }

.kv {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0 0 16px;
  font-size: .84rem;
}
.kv dt { color: var(--muted); }
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.ports { display: flex; flex-wrap: wrap; gap: 5px; }
.port-chip {
  display: inline-flex;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(2, 6, 12, .35);
  color: #cbd5e1;
  font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(148, 163, 184, .07);
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .06s ease, color .16s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: rgba(148, 163, 184, .13); border-color: rgba(148, 163, 184, .34); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #06b6d4, #7c3aed);
  border-color: transparent;
  color: #f8fafc;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger {
  color: #ffe4e6;
  background: rgba(251, 113, 133, .12);
  border-color: rgba(251, 113, 133, .34);
}
.btn.danger:hover { background: rgba(251, 113, 133, .2); }
.btn.stop {
  color: #ffd7dd;
  background: rgba(251, 113, 133, .1);
  border-color: rgba(251, 113, 133, .3);
}
.btn.stop:hover { background: rgba(251, 113, 133, .18); }
.btn.restart {
  color: #fde9c4;
  background: rgba(251, 191, 36, .09);
  border-color: rgba(251, 191, 36, .3);
}
.btn.restart:hover { background: rgba(251, 191, 36, .16); }
.btn.start {
  color: #c7f9e5;
  background: rgba(52, 211, 153, .1);
  border-color: rgba(52, 211, 153, .3);
}
.btn.start:hover { background: rgba(52, 211, 153, .17); }

/* ---------- footer / empty ---------- */
.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px calc(30px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .76rem;
}

.empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 34px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- login ---------- */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(23, 34, 48, .94), rgba(10, 16, 24, .97));
  box-shadow: var(--shadow);
  animation: rise .35s ease both;
}
.login-logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  border-radius: 15px;
  color: #061018;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 10px 30px -12px rgba(34, 211, 238, .7);
}
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 1.5rem; }
.login-card > .muted { margin: 5px 0 22px; }
.login-card form { display: grid; gap: 9px; }
.login-card label { color: var(--muted); font-size: .8rem; }
.login-card input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(2, 6, 12, .55);
  color: var(--text);
  font: inherit;
}
.login-card input::placeholder { color: #64748b; }
.login-card input:focus { outline: 2px solid rgba(34, 211, 238, .55); outline-offset: 1px; border-color: transparent; }
.login-card .btn { margin-top: 7px; padding: 10px 14px; }
.hint { margin: 18px 0 0; color: var(--muted); font-size: .73rem; }
.alert {
  margin: 0 0 14px;
  padding: 9px 11px;
  border: 1px solid rgba(251, 113, 133, .32);
  border-radius: 9px;
  background: rgba(251, 113, 133, .09);
  color: #fecdd3;
  font-size: .82rem;
}

/* ---------- dialogs ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(165deg, #16212f, #0b121b);
  color: var(--text);
  box-shadow: 0 30px 90px -30px #000;
}
.dialog.wide { width: min(920px, calc(100vw - 24px)); }
.dialog::backdrop {
  background: rgba(3, 7, 12, .74);
  backdrop-filter: blur(3px);
}
.dialog p { margin: 8px 0 0; color: var(--muted); font-size: .88rem; }
.dialog h2 { font-size: 1.05rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-badge {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 13px;
  border-radius: 12px;
}
.dialog-badge.danger { color: var(--red); background: rgba(251, 113, 133, .1); }
.dialog-badge svg { width: 22px; height: 22px; }

.logs {
  max-height: 56vh;
  margin: 12px 0 0;
  padding: 13px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #05090e;
  color: #cbd5e1;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #16212f;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: .84rem;
}
.toast.error { border-color: rgba(251, 113, 133, .5); color: #fecdd3; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric.balance { grid-column: 1 / -1; }
  .grid.containers { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    padding: 14px 14px 12px;
    flex-wrap: wrap;
  }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .brand-text p .sep,
  .brand-text p span:last-child { display: none; }
  .layout { padding: 22px 14px 34px; gap: 24px; }
  .section-head { align-items: flex-start; flex-wrap: wrap; }
  .grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric.balance { grid-column: 1 / -1; }
  .card { padding: 14px; border-radius: 13px; }
  .metric strong { font-size: 1.28rem; }
  .metric-icon { width: 28px; height: 28px; flex-basis: 28px; border-radius: 9px; }
  .metric-icon svg { width: 16px; height: 16px; }
  .container-card { padding: 15px; }
  .dialog { padding: 19px; }
  .logs { max-height: 60vh; font-size: 11px; }
  .footer { padding: 0 14px 24px; }
}

@media (max-width: 420px) {
  .brand-text p { display: none; }
  .btn-label { display: none; }
  .grid.metrics { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 52px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

.btn.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirm-copy strong { color: var(--text); }
