/* ============================================================
   Portfolio Hub Admin — "Command Center" design system
   Synthesis: Raycast (dark chrome ladder, compact, palette),
   Framer (spotlight moments), Apple (one blue, scale press,
   tight tracking), Cal (light theme, nav-pill-group).
   ============================================================ */

:root {
  /* dark theme = default (Raycast ladder) */
  --canvas: #07080a;
  --surface: #0d0d0d;
  --surface-elev: #101111;
  --surface-card: #121212;
  --button-fg: #18191a;
  --hairline: #242728;
  --hairline-soft: rgba(255,255,255,0.08);
  --hairline-strong: rgba(255,255,255,0.16);

  --ink: #f4f4f6;
  --body: #cdcdcd;
  --mute: #9c9c9d;
  --ash: #6a6b6c;

  --accent: #2997ff;
  --accent-soft: rgba(41,151,255,0.15);
  --green: #59d499;
  --green-soft: rgba(89,212,153,0.15);
  --red: #ff6161;
  --red-soft: rgba(255,97,97,0.15);
  --yellow: #ffc533;
  --yellow-soft: rgba(255,197,51,0.15);
  --violet: #b18cff;
  --violet-soft: rgba(177,140,255,0.15);

  --primary-bg: #f4f4f6;
  --primary-ink: #000000;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-pill: 9999px;

  --font: "Inter", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);

  --ease-spring: cubic-bezier(.22,1,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --dur-fast: .12s;
  --dur: .18s;
  --dur-slow: .28s;
}

:root[data-theme="light"] {
  --canvas: #f8f9fa;
  --surface: #ffffff;
  --surface-elev: #ffffff;
  --surface-card: #f5f5f5;
  --button-fg: #f5f5f5;
  --hairline: #e5e7eb;
  --hairline-soft: #f3f4f6;
  --hairline-strong: #d4d7db;

  --ink: #111111;
  --body: #374151;
  --mute: #6b7280;
  --ash: #898989;

  --accent: #0066cc;
  --accent-soft: rgba(0,102,204,0.10);
  --green: #0e9f6e;
  --green-soft: rgba(16,185,129,0.12);
  --red: #e02424;
  --red-soft: rgba(224,36,36,0.10);
  --yellow: #b7791f;
  --yellow-soft: rgba(245,158,11,0.14);
  --violet: #7c3aed;
  --violet-soft: rgba(139,92,246,0.12);

  --primary-bg: #111111;
  --primary-ink: #ffffff;

  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.14);
}

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

html { scrollbar-color: var(--hairline-strong) transparent; }

body {
  font-family: var(--font);
  font-feature-settings: "calt", "kern", "liga", "ss03";
  font-size: 14px;
  line-height: 1.5;
  color: var(--body);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) ease, color var(--dur) ease;
}

a { color: var(--ink); text-decoration: none; }
button { font-family: var(--font); }
::selection { background: var(--accent-soft); }

/* ================= top command bar ================= */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--hairline);
}
.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  transition: opacity var(--dur) ease;
}
.brand:hover { opacity: 0.7; }
.brand span { color: var(--accent); }

.crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  min-width: 0;
}
.crumb-root { color: var(--ash); }
.crumb-sep { color: var(--ash); }
.crumb-page {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-trigger {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px 0 14px;
  min-width: 200px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  color: var(--ash);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--dur) ease, transform var(--dur-fast) ease;
}
.palette-trigger:hover { border-color: var(--hairline-strong); }
.palette-trigger:active { transform: scale(0.97); }
.palette-hint { flex: 1; text-align: left; }
.palette-trigger kbd,
.palette-input-row kbd {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--mute);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 2px 6px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--mute);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease, transform var(--dur-fast) ease;
}
.icon-btn:hover { background: var(--surface-card); color: var(--ink); }
.icon-btn:active { transform: scale(0.92); }

/* ================= workbench: rail + stage ================= */

.workbench {
  display: grid;
  grid-template-columns: 60px 1fr;
  min-height: 100vh;
  padding-top: 52px;
  transition: grid-template-columns var(--dur-slow) var(--ease-spring);
}
body.rail-open .workbench { grid-template-columns: 216px 1fr; }

.rail {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 14px 10px;
  border-right: 1px solid var(--hairline);
  background: var(--surface);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-gap { height: 10px; }
.rail-spring { flex: 1; }

.rail-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 40px;
  min-height: 40px;
  border-radius: var(--r-lg);
  border: 0;
  background: transparent;
  color: var(--mute);
  font-size: 17px;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease, transform var(--dur-fast) ease;
}
.rail-link .rl-icon { width: 22px; text-align: center; flex: none; }
.rail-link .rl-label {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  overflow: hidden;
  opacity: 0;
  max-width: 0;
  transition: opacity var(--dur) ease;
}
body.rail-open .rail-link { justify-content: flex-start; padding: 0 12px; }
body.rail-open .rail-link .rl-label { opacity: 1; max-width: 160px; }
.rail-link:hover { background: var(--surface-card); color: var(--ink); }
.rail-link:active { transform: scale(0.97); }
.rail-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.rail-link.active::before {
  content: "";
  position: absolute;
  left: -10px;
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.rail-toggle { color: var(--ash); font-weight: 600; }
.rail-toggle .rl-label { font-size: 12.5px; }

/* tooltip — collapsed only */
.rail-link::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--surface-elev);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) ease, transform var(--dur) var(--ease-out);
  z-index: 400;
  box-shadow: var(--shadow-md);
}
.rail-link:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
body.rail-open .rail-link::after { display: none; }

.stage {
  min-width: 0;
  padding: 30px 34px 90px;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.page-sub { font-size: 13px; color: var(--mute); margin-top: 3px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ================= buttons ================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  border-radius: var(--r-pill);
  padding: 9px 18px;
  height: 36px;
  white-space: nowrap;
  transition: background var(--dur) ease, color var(--dur) ease,
              border-color var(--dur) ease, transform var(--dur-fast) ease, opacity var(--dur) ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary-bg);
  color: var(--primary-ink);
}
.btn-primary:hover { opacity: 0.88; }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline);
}
.btn-secondary:hover { border-color: var(--hairline-strong); background: var(--surface-card); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--mute); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-card); }
.btn-sm { height: 30px; padding: 5px 13px; font-size: 12px; }
.btn-xs { height: 26px; padding: 3px 10px; font-size: 11px; border-radius: var(--r-md); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ================= cards ================= */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 20px;
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out),
              border-color var(--dur) ease;
}
.card + .card { margin-top: 16px; }
@media (hover: hover) {
  .card:hover { border-color: var(--hairline-strong); }
}
.card-title { font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.card-sub { font-size: 12.5px; color: var(--mute); margin-top: 4px; line-height: 1.5; }

/* dashboard stat tiles — Framer spotlight */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.tile {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 18px;
  transition: transform var(--dur) var(--ease-out), border-color var(--dur) ease;
}
.tile::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto;
  height: 120%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 75%);
  opacity: 0;
  transition: opacity var(--dur-slow) ease;
  pointer-events: none;
}
@media (hover: hover) {
  .tile:hover { transform: translateY(-2px); border-color: var(--accent); }
  .tile:hover::before { opacity: 1; }
}
.tile .k { font-size: 11px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; }
.tile .v {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.tile .d { font-size: 12px; color: var(--mute); margin-top: 3px; }
.tile.featured { border-color: var(--accent); }
.tile.featured::before { opacity: 0.7; }

/* ================= tables ================= */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ash);
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-card);
  white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--hairline-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--dur-fast) ease; }
.tbl tr:hover td { background: var(--surface-card); }
.tbl .num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }

/* ================= pills & status ================= */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--button-fg);
  color: var(--body);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  white-space: nowrap;
}
.pill.success { background: var(--green-soft); color: var(--green); }
.pill.error { background: var(--red-soft); color: var(--red); }
.pill.warning { background: var(--yellow-soft); color: var(--yellow); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.dark { background: var(--hairline-strong); color: var(--ink); }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 9999px;
  display: inline-block;
  background: var(--hairline-strong);
}
.status-dot.up { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.down { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.status-dot.unknown { background: var(--ash); }

/* ================= forms ================= */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--body);
  margin-bottom: 6px;
}
.input, .textarea, .select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 13px;
  height: 38px;
  transition: border-color var(--dur) ease, box-shadow var(--dur) ease;
}
.textarea { height: auto; min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { appearance: none; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 10px 0; }
.checkbox-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-msg { font-size: 13px; min-height: 1.2em; margin-top: 8px; }
.form-msg.ok { color: var(--green); }
.form-msg.err { color: var(--red); }
.form-hint { font-size: 12px; color: var(--mute); margin-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-card);
  border-radius: var(--r-pill);
  padding: 4px 10px;
}
.chip button { background: none; border: 0; cursor: pointer; color: var(--mute); font-size: 13px; line-height: 1; padding: 0; }
.chip button:hover { color: var(--red); }

/* ================= modal (Raycast command window) ================= */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 500;
  padding: 10vh 16px 48px;
  overflow-y: auto;
  animation: fade-in 0.2s ease;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface-elev);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 24px;
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.24s var(--ease-spring);
}
.modal.wide { max-width: 860px; }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } }
.modal-head { display: flex; align-items: center; margin-bottom: 18px; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; }
.modal-close {
  margin-left: auto;
  background: none; border: 0;
  width: 30px; height: 30px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--mute);
  font-size: 15px;
  transition: background var(--dur) ease, color var(--dur) ease;
}
.modal-close:hover { background: var(--surface-card); color: var(--ink); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ================= toast ================= */

.toast-wrap {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-elev);
  border: 1px solid var(--hairline);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-pill);
  padding: 10px 18px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.26s var(--ease-spring);
  pointer-events: auto;
}
.toast.err { border-color: var(--red); color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ================= misc ================= */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.empty { padding: 44px 20px; text-align: center; color: var(--mute); font-size: 13px; }
.drag-handle { cursor: grab; color: var(--ash); user-select: none; font-size: 15px; }
tr.dragging { opacity: 0.4; }
.img-preview {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--surface-card);
}
.avatar-preview {
  width: 72px; height: 72px;
  border-radius: var(--r-lg);
  object-fit: cover;
  border: 1px solid var(--hairline);
  background: var(--surface-card);
}
.upload-row { display: flex; gap: 10px; align-items: center; }
.upload-row .input { flex: 1; }

.toggle {
  position: relative;
  width: 36px; height: 20px;
  background: var(--hairline-strong);
  border-radius: var(--r-pill);
  border: 0;
  cursor: pointer;
  transition: background 0.2s ease;
  vertical-align: middle;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 9999px;
  transition: transform 0.2s var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(16px); }
.toggle.orange { background: #fb923c; }
.toggle-label { font-size: 12px; color: var(--mute); margin-left: 6px; }

.progress {
  height: 5px;
  background: var(--hairline-soft);
  border-radius: 6px;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.6s var(--ease-out);
}

.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--mute); }
.small { font-size: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-row { padding: 10px 0; border-bottom: 1px solid var(--hairline-soft); }
.feed-row:last-child { border-bottom: 0; }
.side-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ash);
  padding: 16px 2px 8px;
}

/* ================= VPS cards ================= */

.vps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.vps-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 16px 18px;
  transition: transform var(--dur) var(--ease-out), border-color var(--dur) ease;
}
@media (hover: hover) {
  .vps-card:hover { transform: translateY(-2px); border-color: var(--hairline-strong); }
}
.vps-card.offline { opacity: 0.6; }
.vps-head { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; }
.vps-name { font-size: 13.5px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.vps-kind { margin-left: auto; }
.vps-uptime { font-size: 11px; color: var(--mute); white-space: nowrap; margin-left: auto; }
.vrow {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
}
.vrow > span { color: var(--mute); font-weight: 500; }
.vrow > b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; font-size: 12px; text-align: right; white-space: nowrap; }
.vrow.net { grid-template-columns: 56px 1fr; }
.vrow.net .net-vals { display: flex; gap: 14px; justify-content: flex-end; }
.net-io { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.net-io.in { color: var(--accent); }
.net-io.out { color: var(--green); }

.guest-actions { display: flex; gap: 4px; }
.zone-list { display: flex; flex-direction: column; gap: 8px; }
.zone-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  cursor: pointer;
  background: var(--surface);
  transition: background var(--dur) ease, border-color var(--dur) ease, transform var(--dur-fast) ease;
}
.zone-item:hover { background: var(--surface-card); }
.zone-item:active { transform: scale(0.98); }
.zone-item.active { border-color: var(--accent); background: var(--accent-soft); }

/* nav-pill-group tabs (Cal signature) */
.tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-card);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-pill);
  padding: 4px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--mute);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* ================= loading & error ================= */

.loading-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 42px 20px; text-align: center;
}
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--hairline);
  border-top-color: var(--accent);
  animation: ph-spin 0.8s linear infinite;
}
@keyframes ph-spin { to { transform: rotate(360deg); } }
.skel-lines { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.skel-line {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--hairline-soft) 25%, var(--hairline) 50%, var(--hairline-soft) 75%);
  background-size: 200% 100%;
  animation: ph-shimmer 1.4s ease-in-out infinite;
}
@keyframes ph-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.error-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 38px 20px; text-align: center;
  border: 1px dashed var(--hairline); border-radius: var(--r-xl); background: var(--surface);
}
.error-icon { font-size: 22px; }
.error-msg { color: var(--mute); font-size: 13.5px; max-width: 46ch; word-break: keep-all; }

/* ================= command palette ================= */

.palette-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 700;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 14vh 16px 40px;
  animation: fade-in 0.16s ease;
}
.palette-backdrop.open { display: flex; }
.palette {
  width: 100%;
  max-width: 560px;
  background: var(--surface-elev);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 0.22s var(--ease-spring);
}
.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}
.palette-glyph { color: var(--ash); font-size: 15px; }
#palette-input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
}
#palette-input::placeholder { color: var(--ash); }
.palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--body);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) ease;
}
.palette-item .pi-icon { width: 22px; text-align: center; font-size: 15px; }
.palette-item .pi-label { flex: 1; }
.palette-item .pi-kind {
  font-size: 11px;
  color: var(--ash);
  background: var(--surface-card);
  border-radius: var(--r-pill);
  padding: 2px 8px;
}
.palette-item.sel { background: var(--accent-soft); color: var(--ink); }
.palette-item.sel .pi-kind { color: var(--accent); }
.palette-empty { padding: 24px; text-align: center; color: var(--ash); font-size: 13px; }

/* ================= mobile: tab bar + drawer ================= */

.tabbar, .nav-backdrop, .drawer { display: none; }

@media (max-width: 860px) {
  .workbench { grid-template-columns: 1fr; }
  .rail { display: none; }
  .stage { padding: 20px 16px 110px; }
  .page-title { font-size: 20px; }
  .page-actions { width: 100%; margin-left: 0; }
  .palette-trigger { min-width: 0; }
  .palette-hint { display: none; }
  .crumb { display: none; }
  .grid-2, .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .tbl { min-width: 620px; }
  .btn { height: 40px; }
  .btn-xs { height: 30px; padding: 4px 12px; font-size: 12px; }

  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 320;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--hairline);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .tab-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: var(--mute);
    font-size: 16px;
    cursor: pointer;
    border-radius: var(--r-md);
    transition: color var(--dur) ease, transform var(--dur-fast) ease;
  }
  .tab-link i { font-style: normal; font-size: 10.5px; font-weight: 600; }
  .tab-link:active { transform: scale(0.94); }
  .tab-link.active { color: var(--accent); }

  .nav-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 490;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  .drawer {
    display: block;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 500;
    max-height: 76dvh;
    overflow-y: auto;
    background: var(--surface-elev);
    border-top: 1px solid var(--hairline);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateY(102%);
    transition: transform 0.28s var(--ease-spring);
  }
  body.nav-open .drawer { transform: translateY(0); }
  .drawer-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ash);
    padding: 4px 6px 10px;
  }
  .drawer-link {
    display: block;
    padding: 12px 10px;
    border-radius: var(--r-md);
    color: var(--body);
    font-size: 14.5px;
    font-weight: 500;
  }
  .drawer-link:hover { background: var(--surface-card); }
  .drawer-link.active { color: var(--accent); background: var(--accent-soft); }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none;
    width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 14px; }
  .tile .v { font-size: 22px; }
}

@media (max-width: 420px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .vps-grid { grid-template-columns: 1fr; }
}

/* hide drag handles on touch */
@media (pointer: coarse) {
  .drag-handle { display: none; }
}

/* ================= view enter motion ================= */

#view > * {
  animation: view-in var(--dur-slow) var(--ease-spring) backwards;
}
#view > *:nth-child(1) { animation-delay: 0ms; }
#view > *:nth-child(2) { animation-delay: 40ms; }
#view > *:nth-child(3) { animation-delay: 80ms; }
#view > *:nth-child(4) { animation-delay: 120ms; }
#view > *:nth-child(5) { animation-delay: 160ms; }
#view > *:nth-child(n+6) { animation-delay: 200ms; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* live status pulse */
.status-dot.up { animation: pulse 2.4s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(89,212,153,0.35); }
  70% { box-shadow: 0 0 0 6px rgba(89,212,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(89,212,153,0); }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================= login ================= */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(60% 40% at 50% 0%, var(--accent-soft), transparent 70%),
    var(--canvas);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 36px 30px;
  box-shadow: var(--shadow-lg);
  animation: view-in var(--dur-slow) var(--ease-spring) backwards;
}
.login-logo { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); display: inline-block; text-decoration: none; }
.login-logo span { color: var(--accent); }
.login-sub { font-size: 13px; color: var(--mute); margin: 6px 0 22px; }
.login-qr { display: block; margin: 12px auto; border-radius: var(--r-md); }

/* ---------- server pack additions ---------- */
.sep { border: 0; border-top: 1px solid var(--hairline-soft); margin: 14px 0; }

.chart-card { min-width: 0; }
.core-bars { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.core-bar {
  width: 10px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--hairline-soft);
  border-radius: 3px;
  overflow: hidden;
}
.core-bar i {
  display: block;
  width: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: height 0.6s var(--ease-out);
}

.spark-wrap { margin-top: 12px; height: 34px; }
.spark { width: 100%; height: 100%; display: block; }

/* mid-size laptop tightening */
@media (max-width: 1180px) {
  .stage { padding: 22px 20px 80px; }
}
