:root {
  --bg: #0b0d12;
  --surface: #14171f;
  --surface-2: #1a1e28;
  --surface-3: #222735;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e6e9ef;
  --muted: #8b93a7;
  --faint: #5b6478;
  --accent: #6d8bff;
  --accent-2: #8b7bff;
  --accent-soft: rgba(109, 139, 255, 0.14);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 70% -10%, rgba(109,139,255,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(139,123,255,0.07), transparent 55%),
    var(--bg);
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code, .mono { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace; font-size: .92em; }
::selection { background: var(--accent-soft); }

/* ---------- Layout ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 18, 0.72);
  backdrop-filter: blur(14px) saturate(1.3);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: #fff; font-size: 17px; letter-spacing: -.01em; }
.brand .logo {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 15px; box-shadow: 0 3px 12px rgba(109,139,255,.4);
}
nav.main { display: flex; gap: 2px; font-size: 14px; }
nav.main a { padding: 7px 13px; border-radius: 9px; color: var(--muted); font-weight: 500; transition: .15s; }
nav.main a:hover { color: var(--text); background: var(--surface-2); }
nav.main a.active { color: #fff; background: var(--accent-soft); }

main { max-width: 1120px; margin: 0 auto; padding: 40px 24px 80px; }

/* ---------- Typography ---------- */
h1 { font-size: 27px; font-weight: 680; color: #fff; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 620; color: #fff; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 16px; font-weight: 600; color: #fff; margin: 0; letter-spacing: -.01em; }
.subtitle { color: var(--muted); font-size: 14.5px; margin-top: 6px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-6 { margin-bottom: 28px; }

/* ---------- Cards & layout helpers ---------- */
.card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface));
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card.hover { transition: border-color .16s, transform .16s; }
.card.hover:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
/* keep wide/nowrap content (e.g. install command) from stretching its column */
.grid > * { min-width: 0; }
@media (max-width: 760px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.flex { display: flex; gap: 14px; align-items: center; }
.wrap { flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 17px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 550;
  cursor: pointer; border: 1px solid transparent; transition: .15s; white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 3px 14px rgba(109,139,255,.32);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 5px 20px rgba(109,139,255,.42); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; filter: none; }
.btn-ghost { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--muted); }
.btn.full { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Forms ---------- */
label.label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.input, select.input {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: #fff; font-size: 14px; outline: none; transition: .15s; font-family: inherit;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  letter-spacing: .02em; border: 1px solid; text-transform: capitalize;
}
.badge .dot { width: 6px; height: 6px; border-radius: 999px; box-shadow: 0 0 6px currentColor; }
.badge.RUNNING, .badge.ONLINE, .badge.admin { color: var(--good); background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.28); }
.badge.READY { color: #60c5fb; background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.28); }
.badge.BUILDING, .badge.DEPLOYING, .badge.DEGRADED { color: var(--warn); background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.28); }
.badge.FAILED { color: var(--bad); background: rgba(251,113,133,.12); border-color: rgba(251,113,133,.28); }
.badge.DRAFT, .badge.OFFLINE { color: var(--muted); background: rgba(139,147,167,.12); border-color: rgba(139,147,167,.25); }
.badge.PENDING { color: var(--warn); background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.28); }
.badge.VALID { color: var(--good); background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.28); }
.badge.WARNING { color: var(--warn); background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.28); }
.badge.INVALID { color: var(--bad); background: rgba(251,113,133,.12); border-color: rgba(251,113,133,.28); }
/* validation report rows */
.chk { display:flex; gap:10px; align-items:flex-start; padding:8px 0; border-bottom:1px solid var(--line); font-size:13.5px; }
.chk:last-child { border-bottom:none; }
.chk .ic { width:18px; text-align:center; flex:none; }
.chk .pass { color: var(--good); } .chk .warn { color: var(--warn); } .chk .fail { color: var(--bad); }
.chk .k { color:#fff; font-weight:600; width:80px; flex:none; text-transform:capitalize; }
.copybox { display:flex; gap:8px; align-items:stretch; }
.copybox code { flex:1; background:var(--surface-2); border:1px solid var(--line-strong); border-radius:8px; padding:10px 12px; overflow-x:auto; white-space:nowrap; color:#cdd5e6; }
.badge.ROLLED_BACK { color: #e879f9; background: rgba(232,121,249,.12); border-color: rgba(232,121,249,.28); }

/* ---------- Meter ---------- */
.meter-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.meter { height: 7px; width: 100%; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.meter > span.emerald { background: linear-gradient(90deg, #10b981, #34d399); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 28px; overflow-x: auto; }
.tabs a { padding: 10px 16px; font-size: 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: #fff; border-bottom-color: var(--accent); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 13px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
tbody td { padding: 13px 18px; border-bottom: 1px solid var(--line); color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
.card.tablewrap { padding: 0; overflow-x: auto; }

/* ---------- Stat tiles ---------- */
.stat .num { font-size: 34px; font-weight: 700; color: #fff; letter-spacing: -.02em; }
.mini { text-align: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 8px; }
.mini .v { color: #fff; font-family: ui-monospace, monospace; font-weight: 600; font-size: 15px; }
.mini .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Selection pills (deploy) ---------- */
.pick {
  width: 100%; text-align: left; border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 14px 16px; background: var(--surface-2); cursor: pointer;
  color: var(--text); transition: .15s; font-family: inherit; font-size: 14px;
}
.pick:hover { border-color: var(--muted); }
.pick.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.step-num {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px;
}
.section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.section-title h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }

/* ---------- Notices ---------- */
.notice { border-radius: 12px; padding: 14px 16px; border: 1px solid; font-size: 14px; }
.notice.error { border-color: rgba(251,113,133,.35); color: #fecdd3; background: rgba(251,113,133,.08); }
.notice.success { border-color: rgba(52,211,153,.35); color: #a7f3d0; background: rgba(52,211,153,.08); }

.hr { height: 1px; background: var(--line); margin: 18px 0; }
.sticky { position: sticky; top: 88px; }
.deploy-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 920px) { .deploy-grid { grid-template-columns: 1fr; } }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; overflow-x: auto; font-size: 13px; color: #cbd5e1; }

.pv-code { max-height: 60vh; overflow: auto; counter-reset: line; font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace; }
.pv-code .ln { counter-increment: line; position: relative; padding-left: 3.6em; white-space: pre-wrap; word-break: break-word; line-height: 1.6; min-height: 1.6em; }
.pv-code .ln::before {
  content: counter(line); position: absolute; left: 0; width: 2.8em; text-align: right;
  color: var(--muted); opacity: .55; font-size: 12px;
}
.tok-key { color: var(--accent); }
.tok-str { color: var(--good); }
.tok-num { color: var(--warn); }
.tok-bool { color: var(--accent-2); }
.tok-null { color: var(--muted); }
.tok-comment { color: var(--muted); font-style: italic; }

dialog { border: none; }
dialog::backdrop { background: rgba(6, 8, 12, 0.66); backdrop-filter: blur(3px); }
dialog.dlg {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 0; max-width: 460px; width: 94%;
}

/* ---------- Toolbar / filters / pagination (scale to many items) ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar .input { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  background: var(--surface-2); color: var(--muted); border: none; cursor: pointer;
  padding: 9px 14px; font-size: 13px; font-family: inherit; font-weight: 550;
}
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.active { background: var(--accent-soft); color: #fff; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--muted);
  border-radius: 999px; padding: 5px 13px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: #fff; }
.chip span { color: var(--faint); margin-left: 4px; font-size: 12px; }
.chip.active span { color: #cdd5f5; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; }
.tagpill { background: var(--surface-3); padding: 4px 9px; border-radius: 7px; font-size: 12px; color: #cdd5e6; flex: none; }

/* Compact list mode */
.listwrap { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.listrow {
  display: grid; grid-template-columns: minmax(0,2fr) 1fr 90px 80px 80px 80px;
  gap: 12px; align-items: center; padding: 12px 18px; font-size: 14px;
  border-bottom: 1px solid var(--line); background: var(--surface); transition: background .12s;
}
.listrow:last-child { border-bottom: none; }
.listrow:hover { background: var(--surface-2); }
.lr-name { color: #fff; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-num { text-align: right; font-size: 13px; }
@media (max-width: 760px) {
  .listrow { grid-template-columns: minmax(0,1fr) 80px; }
  .listrow .lr-task, .listrow .lr-num:nth-child(n+4) { display: none; }
}

/* ---------- Searchable picker (deploy wizard) ---------- */
.picker { position: relative; }
.picker-list { max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.picker-empty { color: var(--faint); font-size: 13.5px; padding: 8px 2px; }
.count-hint { font-size: 12px; color: var(--faint); }

/* ---------- Compact server cards ---------- */
.card.compact { padding: 16px 18px; }
.card.compact h3 { font-size: 15px; }
.clickable { cursor: pointer; }
.clickable:hover { border-color: var(--line-strong); }

/* one-line meter: label | bar | value — four of these fit where one used to */
.mini-meter { display: grid; grid-template-columns: 42px 1fr 92px; align-items: center; gap: 10px; margin-bottom: 7px; }
.mini-meter:last-child { margin-bottom: 0; }
.mini-meter .mm-l { font-size: 11.5px; color: var(--muted); }
.mini-meter .mm-v { font-size: 11.5px; color: var(--text); text-align: right; }
.mini-meter .meter { height: 5px; }

.statchip {
  font-size: 11.5px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 2px 8px;
  font-family: ui-monospace, monospace;
}
/* pulsing dot = live push channel connected */
.livedot {
  display: inline-block; width: 7px; height: 7px; border-radius: 999px;
  background: var(--good); box-shadow: 0 0 0 0 rgba(52,211,153,.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,.6); }
  70%  { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* ---------- Per-model statistics table (Triton detail) ---------- */
table.stats { font-size: 12.5px; }
table.stats thead th { padding: 9px 12px; font-size: 10.5px; }
table.stats tbody td { padding: 9px 12px; }
table.stats .num, table.stats th.num { text-align: right; }

/* ---------- Triton instance blocks on server cards ---------- */
.triton {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 12px 14px; margin-top: 10px;
}
.triton h4 { margin: 0; font-size: 13.5px; color: #fff; font-weight: 600; }
.triton .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.portlist { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.port { font-family: ui-monospace, monospace; font-size: 11.5px; background: var(--surface-3); color: #cdd5e6; border-radius: 6px; padding: 2px 7px; }
.modelline { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.modelline:first-of-type { border-top: none; }
.iconbtn {
  background: transparent; border: 1px solid var(--line-strong); color: var(--muted);
  border-radius: 7px; padding: 3px 9px; font-size: 11.5px; cursor: pointer; font-family: inherit;
}
.iconbtn:hover { color: #fff; border-color: var(--muted); }
.iconbtn.danger:hover { color: var(--bad); border-color: var(--bad); }

/* thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { height: 9px; width: 9px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 9px; }
