:root {
  --bg: #0b0d12;
  --bg-2: #10131a;
  --card: #141821;
  --card-hi: #191e29;
  --line: #232a37;
  --line-2: #2d3545;
  --text: #e7eaf0;
  --muted: #8b94a7;
  --faint: #5c6578;
  --accent: #7c6cff;
  --accent-2: #a395ff;
  --accent-bg: rgba(124, 108, 255, .14);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, .12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --bad: #fb7185;
  --bad-bg: rgba(251, 113, 133, .12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, .12);
  --console: #07090d;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --bg-2: #eef0f5;
    --card: #ffffff;
    --card-hi: #fafbff;
    --line: #e3e6ee;
    --line-2: #d4d9e4;
    --text: #151a24;
    --muted: #5d6679;
    --faint: #98a0b1;
    --accent: #5b4cf0;
    --accent-2: #4a3bd8;
    --accent-bg: rgba(91, 76, 240, .09);
    --ok: #059669;
    --ok-bg: rgba(5, 150, 105, .1);
    --warn: #b7791f;
    --warn-bg: rgba(217, 119, 6, .1);
    --bad: #e11d48;
    --bad-bg: rgba(225, 29, 72, .08);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, .08);
    --console: #0f1219;
    --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 18px rgba(16,24,40,.05);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 10% -10%, var(--accent-bg), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text);
  font: 500 13px Inter, system-ui, sans-serif; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--card-hi); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-danger:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); background: var(--bad-bg); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn-block { width: 100%; height: 40px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-lg { font-size: 22px; justify-content: center; margin-bottom: 6px; }
.logo {
  width: 26px; height: 26px; border-radius: 8px; background: var(--accent); position: relative; flex: none;
  box-shadow: 0 4px 14px var(--accent-bg);
  background-image:
    linear-gradient(#fff,#fff), linear-gradient(rgba(255,255,255,.55),rgba(255,255,255,.55)),
    linear-gradient(rgba(255,255,255,.55),rgba(255,255,255,.55)), linear-gradient(#fff,#fff);
  background-size: 7px 7px; background-repeat: no-repeat;
  background-position: 5px 5px, 14px 5px, 5px 14px, 14px 14px;
}
.brand-lg .logo { width: 34px; height: 34px; background-size: 9px 9px; background-position: 7px 7px, 18px 7px, 7px 18px, 18px 18px; }
.host { font: 500 12px var(--mono); color: var(--faint); padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; padding: 32px 28px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card p { margin: 0 0 4px; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
input {
  height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); font: 14px Inter, system-ui, sans-serif; outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.error { color: var(--bad); font-size: 13px; min-height: 1em; margin: 0 !important; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.search { flex: 1; max-width: 520px; margin: 0 auto; position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { width: 100%; height: 36px; padding-left: 34px; background: var(--card); }
.top-actions { display: flex; gap: 2px; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 24px 80px; }

/* summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  padding: 14px 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.stat-n { font-size: 24px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.stat-l { font-size: 12px; color: var(--muted); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: 500 12.5px Inter, sans-serif; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.on { background: var(--accent-bg); color: var(--accent-2); border-color: transparent; }
.chip .n { opacity: .6; margin-left: 4px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 18px;
  border-radius: 12px; background: var(--info-bg); color: var(--text); border: 1px solid transparent; font-size: 13px;
}
.notice svg { color: var(--info); margin-top: 2px; }
.notice code { font-family: var(--mono); font-size: 12px; }

/* groups */
.group { margin-bottom: 30px; }
.group-h { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group-h .n { color: var(--faint); font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }

/* card */
.card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 14px;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color .15s;
  overflow: hidden;
}
.card:hover { border-color: var(--line-2); }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--state-c, transparent); opacity: .8; }
.card[data-state="running"] { --state-c: var(--ok); }
.card[data-state="partial"] { --state-c: var(--warn); }
.card[data-state="stopped"] { --state-c: var(--bad); }
.card[data-state="busy"] { --state-c: var(--accent); }
.card.dim { opacity: .78; }

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-title { flex: 1; min-width: 0; }
.card-name { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card-desc { color: var(--muted); font-size: 13px; margin-top: 2px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.running { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.partial { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.dot.stopped { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.dot.busy { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px;
  font: 500 11.5px Inter, sans-serif; background: var(--bg-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-bg); color: var(--accent-2); border-color: transparent; }

.domains { display: flex; flex-wrap: wrap; gap: 6px; }
.domain {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 7px;
  background: var(--bg-2); border: 1px solid var(--line); font: 500 12.5px var(--mono);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.domain:hover { border-color: var(--accent); color: var(--accent-2); }
.domain .hc { font-size: 11px; color: var(--faint); }
.domain .hc.ok { color: var(--ok); }
.domain .hc.bad { color: var(--bad); }
.domain svg { width: 12px; height: 12px; color: var(--faint); }

.meta { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); }
.row > svg { color: var(--faint); }
.row .val { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path { font-family: var(--mono); font-size: 12px; color: var(--text); cursor: copy; }
.path:hover { color: var(--accent-2); }

.git-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }
.git-link:hover { color: var(--accent-2); }
.git-link svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.commit { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commit .h { font-family: var(--mono); font-size: 11.5px; color: var(--accent-2); }

.parts { display: flex; flex-wrap: wrap; gap: 6px; }
.part { display: inline-flex; align-items: center; gap: 6px; font: 11.5px var(--mono); color: var(--muted); padding: 2px 8px; border-radius: 6px; background: var(--bg-2); }
.part .dot { width: 6px; height: 6px; box-shadow: none; }

.card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.card-actions .spacer { flex: 1; }
.card-note { font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 6px; }

/* drawer */
.drawer {
  position: fixed; z-index: 40; right: 16px; bottom: 16px; width: min(760px, calc(100vw - 32px)); height: min(520px, 70vh);
  display: flex; flex-direction: column; border-radius: 16px; overflow: hidden;
  background: var(--console); border: 1px solid #1f2633; box-shadow: 0 24px 60px rgba(0,0,0,.45);
  color: #d7dce6; animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #1f2633; }
.drawer .btn-ghost { color: #8b94a7; }
.drawer .btn-ghost:hover { background: #151a24; color: #e7eaf0; border-color: #232a37; }
.drawer-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.drawer-sub { font-size: 12px; color: #8b94a7; }
.drawer-actions { display: flex; gap: 4px; }
.console {
  flex: 1; margin: 0; padding: 12px 16px 18px; overflow: auto; font: 12px/1.6 var(--mono);
  white-space: pre-wrap; word-break: break-word; color: #c9d1de;
}
.console .cmd { color: #a395ff; font-weight: 500; }
.console .err { color: #fb7185; }
.console .done { color: #34d399; }

.panel {
  position: fixed; z-index: 35; top: 0; right: 0; bottom: 0; width: min(420px, 100vw);
  background: var(--card); border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(0,0,0,.25);
  display: flex; flex-direction: column; animation: slide .18s ease-out;
}
.panel .drawer-head { border-bottom-color: var(--line); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.activity-list { list-style: none; margin: 0; padding: 8px 0; overflow: auto; }
.activity-list li { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity-list .when { color: var(--faint); font-size: 12px; margin-left: auto; white-space: nowrap; }
.activity-list button { all: unset; cursor: pointer; }

/* dialog */
.dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(460px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.dialog::backdrop { background: rgba(5,7,12,.6); backdrop-filter: blur(3px); }
.dialog h3 { margin: 0 0 6px; font-size: 17px; }
.dialog p { margin: 0 0 12px; }
.steps { margin: 0 0 18px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font: 12px/1.6 var(--mono); white-space: pre-wrap; word-break: break-all; color: var(--muted); }
.steps:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog .btn-primary.danger { background: var(--bad); border-color: var(--bad); }

/* toasts */
.toasts { position: fixed; z-index: 60; left: 50%; top: 16px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; padding: 10px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13px; display: flex; gap: 8px; align-items: center; animation: rise .18s ease-out; }
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--bad); }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.skeleton { height: 220px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 0%, var(--card-hi) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; gap: 8px; flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .brand { flex: 1; }
  .host, .hide-sm { display: none; }
  .wrap { padding: 16px 16px 80px; }
  .grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .drawer { right: 8px; left: 8px; bottom: 8px; width: auto; height: 70vh; }
}
