/* ==========================================================================
   Docker Dashboard — dark glass UI with motion
   ========================================================================== */
:root {
  --bg: #07080f;
  --bg-2: #0d0f1c;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-solid: #12142a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8eaf6;
  --muted: #8b90b3;
  --faint: #5b5f82;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #60a5fa;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --sidebar: 248px;

  /* theme-dependent surfaces */
  --dots: rgba(255, 255, 255, 0.06);
  --blob-opacity: 1;
  --sidebar-bg: linear-gradient(180deg, rgba(13, 15, 28, 0.85), rgba(7, 8, 15, 0.6));
  --topbar-bg: rgba(7, 8, 15, 0.8);
  --panel-bg: rgba(13, 15, 28, 0.85);
  --toast-bg: rgba(18, 20, 42, 0.92);
  --hover-bg: rgba(255, 255, 255, 0.1);
  --hover-border: rgba(255, 255, 255, 0.28);
  --track: rgba(255, 255, 255, 0.06);
  --input-bg: rgba(0, 0, 0, 0.25);
  --input-bg-focus: rgba(0, 0, 0, 0.35);
  --label: #c7cae6;
  --backdrop: rgba(3, 4, 10, 0.7);
  --icon-l: 78%;
  --fg-cyan: #67e8f9;
  --fg-blue: #93c5fd;
  --fg-pink: #f9a8d4;
  --fg-violet: #a5b4fc;
  --fg-violet-2: #c4b5fd;
  --fg-err: #fecaca;
  --fg-warn: #fde68a;
  --fg-info: #bfdbfe;
  /* terminals stay dark in both themes */
  --term-bg: #04050a;
  --term-fg: #cbd5f5;
  --term-border: rgba(255, 255, 255, 0.08);
  --term-bar: rgba(255, 255, 255, 0.03);
  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Light theme
   -------------------------------------------------------------------------- */
:root[data-theme="light"] {
  --bg: #f3f4fb;
  --bg-2: #e9ebf7;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(22, 26, 64, 0.05);
  --surface-solid: #ffffff;
  --border: rgba(22, 26, 64, 0.09);
  --border-strong: rgba(22, 26, 64, 0.17);
  --text: #161a33;
  --muted: #565c82;
  --faint: #8a8fb0;
  --accent: #6d4aff;
  --accent-2: #0891b2;
  --accent-3: #db2777;
  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --info: #2563eb;
  --shadow: 0 10px 30px -14px rgba(30, 34, 90, 0.25);
  --dots: rgba(22, 26, 64, 0.07);
  --blob-opacity: 0.55;
  --sidebar-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.6));
  --topbar-bg: rgba(255, 255, 255, 0.8);
  --panel-bg: rgba(255, 255, 255, 0.9);
  --toast-bg: rgba(255, 255, 255, 0.95);
  --hover-bg: rgba(22, 26, 64, 0.07);
  --hover-border: rgba(22, 26, 64, 0.28);
  --track: rgba(22, 26, 64, 0.08);
  --input-bg: rgba(255, 255, 255, 0.85);
  --input-bg-focus: #ffffff;
  --label: #2d3256;
  --backdrop: rgba(30, 34, 70, 0.35);
  --icon-l: 42%;
  --fg-cyan: #0e7490;
  --fg-blue: #1d4ed8;
  --fg-pink: #be185d;
  --fg-violet: #5b3fd6;
  --fg-violet-2: #6d4aff;
  --fg-err: #991b1b;
  --fg-warn: #92400e;
  --fg-info: #1e40af;
  --term-border: rgba(22, 26, 64, 0.2);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
code, pre, .mono { font-family: var(--mono); }
::selection { background: rgba(124, 92, 255, 0.4); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--track); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--border-strong); }

/* --------------------------------------------------------------------------
   Animated background
   -------------------------------------------------------------------------- */
.bg-scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-scene::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at 50% 30%, black 20%, transparent 75%);
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: calc(0.35 * var(--blob-opacity));
  animation: float 22s ease-in-out infinite alternate;
}
.blob.b1 { width: 520px; height: 520px; background: var(--accent); top: -160px; left: 10%; }
.blob.b2 { width: 460px; height: 460px; background: var(--accent-2); bottom: -180px; right: -60px; animation-duration: 28s; opacity: calc(0.22 * var(--blob-opacity)); }
.blob.b3 { width: 360px; height: 360px; background: var(--accent-3); top: 40%; left: 55%; animation-duration: 34s; opacity: calc(0.14 * var(--blob-opacity)); }
@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(80px, 60px) scale(1.12); }
  100% { transform: translate(-60px, 30px) scale(0.95); }
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 16px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--grad); box-shadow: 0 6px 24px -4px rgba(124, 92, 255, 0.7);
  animation: logo-glow 4s ease-in-out infinite;
}
.brand-logo svg { width: 22px; height: 22px; color: white; }
@keyframes logo-glow {
  0%, 100% { box-shadow: 0 6px 24px -4px rgba(124, 92, 255, 0.7); }
  50% { box-shadow: 0 6px 30px -2px rgba(34, 211, 238, 0.7); }
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); padding: 14px 12px 6px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--muted); font-weight: 500;
  transition: color .25s var(--ease), background .25s var(--ease), transform .25s var(--ease);
}
.nav-link svg { width: 18px; height: 18px; }
.nav-link:hover { color: var(--text); background: var(--surface); transform: translateX(3px); }
.nav-link.active { color: var(--text); background: var(--surface-2); }
.nav-link.active::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--grad);
  animation: grow-y .4s var(--ease);
}
@keyframes grow-y { from { transform: scaleY(0); } }
.sidebar-footer { margin-top: auto; padding: 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.sidebar-footer .user { display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); font-weight: 700; font-size: 12px; }

.main { padding: 32px 40px 60px; min-width: 0; animation: page-in .6s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(12px); } }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; font-weight: 750; }
.page-header p { margin: 4px 0 0; color: var(--muted); }
.gradient-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.breadcrumb { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.breadcrumb a:hover { color: var(--text); }

.mobile-bar { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; width: var(--sidebar); transform: translateX(-100%);
    transition: transform .35s var(--ease);
  }
  body.nav-open .sidebar { transform: none; }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px; position: sticky; top: 0; z-index: 40;
    background: var(--topbar-bg); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
  }
  .main { padding: 20px 16px 60px; }
}

/* --------------------------------------------------------------------------
   Surfaces
   -------------------------------------------------------------------------- */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 15px; font-weight: 650; }
.card-title svg { width: 18px; height: 18px; color: var(--accent-2); }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat {
  position: relative; overflow: hidden; padding: 18px 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms);
}
.stat::before {
  content: ""; position: absolute; inset: auto -40% -60% auto; width: 140px; height: 140px; border-radius: 50%;
  background: var(--c, var(--accent)); filter: blur(50px); opacity: .25; transition: opacity .4s;
}
.stat:hover::before { opacity: .5; }
.stat .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .label svg { width: 16px; height: 16px; color: var(--c, var(--accent)); }
.stat .value { font-size: 30px; font-weight: 750; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--faint); }

@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* --------------------------------------------------------------------------
   Service cards
   -------------------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 20px; }
.svc-card {
  position: relative; display: flex; flex-direction: column; gap: 16px; padding: 20px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  transition: transform .45s var(--ease), border-color .3s, box-shadow .45s var(--ease), background .3s;
  overflow: hidden; isolation: isolate;
}
.svc-card.animate { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.svc-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .4s;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 0%), rgba(124, 92, 255, 0.18), transparent 50%);
}
.svc-card:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: 0 20px 50px -20px rgba(124, 92, 255, 0.45); }
.svc-card:hover::before { opacity: 1; }
.svc-card[data-state="running"] { --state: var(--ok); }
.svc-card[data-state="stopped"], .svc-card[data-state="restarting"] { --state: var(--err); }
.svc-card[data-state="partial"] { --state: var(--warn); }
.svc-card[data-state="absent"], .svc-card[data-state="unknown"] { --state: var(--faint); }
.svc-card::after {
  content: ""; position: absolute; top: 0; left: 20px; right: 20px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--state), transparent); opacity: .8;
}
.svc-head { display: flex; gap: 14px; align-items: center; }
.svc-icon {
  flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; overflow: hidden;
  background: hsl(var(--h, 260) 70% 55% / .18); border: 1px solid hsl(var(--h, 260) 70% 60% / .35);
  color: hsl(var(--h, 260) 70% var(--icon-l)); font-weight: 800; font-size: 16px;
  transition: transform .5s var(--spring);
}
.svc-icon { position: relative; }
.svc-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 6px; background: var(--surface-solid); }
.svc-card:hover .svc-icon { transform: rotate(-6deg) scale(1.08); }
.svc-name { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; }
.svc-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.svc-desc { color: var(--muted); font-size: 13.5px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.svc-ports { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.svc-links { display: flex; gap: 6px; }

.empty {
  text-align: center; padding: 70px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); animation: rise .7s var(--ease);
}
.empty .icon-ring {
  width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); position: relative;
}
.empty .icon-ring::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid transparent;
  border-top-color: var(--accent); border-right-color: var(--accent-2); animation: spin 3s linear infinite;
}
.empty .icon-ring svg { width: 34px; height: 34px; color: var(--accent-2); }
.empty h3 { margin: 0 0 6px; }
.empty p { color: var(--muted); margin: 0 0 22px; }

/* --------------------------------------------------------------------------
   Badges & status
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; }
.badge.official { color: var(--fg-blue); background: rgba(96, 165, 250, .1); border-color: rgba(96, 165, 250, .25); }
.badge.compose { color: var(--fg-pink); background: rgba(244, 114, 182, .1); border-color: rgba(244, 114, 182, .25); }
.badge.image { color: var(--fg-violet); background: rgba(124, 92, 255, .12); border-color: rgba(124, 92, 255, .3); }
.chip { font-family: var(--mono); font-size: 11.5px; padding: 3px 8px; border-radius: 6px; background: rgba(34, 211, 238, .08); color: var(--fg-cyan); border: 1px solid rgba(34, 211, 238, .2); }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; }
.dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; }
.status.running { --c: var(--ok); color: var(--ok); }
.status.partial { --c: var(--warn); color: var(--warn); }
.status.stopped, .status.restarting { --c: var(--err); color: var(--err); }
.status.absent, .status.unknown { --c: var(--faint); color: var(--muted); }
.status.running .dot::after, .status.partial .dot::after, .status.restarting .dot::after, .status.busy .dot::after { animation: ping 1.8s cubic-bezier(0, 0, .2, 1) infinite; }
.status.busy { --c: var(--info); color: var(--info); }
@keyframes ping { 75%, 100% { transform: scale(2.6); opacity: 0; } }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  --b: var(--surface-2);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--b);
  color: var(--text); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .3s var(--ease), background .25s, border-color .25s, opacity .2s;
  overflow: hidden;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { transform: translateY(-1px); border-color: var(--hover-border); background: var(--hover-bg); }
.btn:active { transform: translateY(0) scale(.97); }
.btn:disabled, .btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--grad); border-color: transparent; color: white; box-shadow: 0 8px 24px -8px rgba(124, 92, 255, .8); }
.btn.primary::before {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
}
.btn.primary:hover::before { animation: shine .9s var(--ease); }
.btn.primary:hover { box-shadow: 0 12px 30px -8px rgba(34, 211, 238, .7); }
@keyframes shine { to { transform: translateX(100%); } }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--err); border-color: rgba(248, 113, 113, .3); background: rgba(248, 113, 113, .08); }
.btn.danger:hover { background: rgba(248, 113, 113, .16); border-color: rgba(248, 113, 113, .5); }
.btn.success { color: var(--ok); border-color: rgba(52, 211, 153, .3); background: rgba(52, 211, 153, .08); }
.btn.success:hover { background: rgba(52, 211, 153, .16); }
.btn.web { color: var(--fg-cyan); border-color: rgba(34, 211, 238, .3); background: rgba(34, 211, 238, .08); }
.btn.web:hover { background: rgba(34, 211, 238, .16); box-shadow: 0 8px 24px -10px rgba(34, 211, 238, .8); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn.icon { padding: 8px; width: 36px; height: 36px; }
.btn.sm.icon { width: 32px; height: 32px; padding: 6px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* HTMX request feedback */
.btn .spinner { display: none; }
.btn.htmx-request .spinner, form.htmx-request .btn .spinner { display: inline-block; }
.btn.htmx-request > svg, form.htmx-request .btn > svg { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: currentColor; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* top progress bar during any HTMX request */
#progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 100; background: var(--grad); box-shadow: 0 0 12px var(--accent-2); opacity: 0; transition: width .4s var(--ease), opacity .4s; }
#progress.active { opacity: 1; width: 70%; transition: width 8s cubic-bezier(.1, .7, .1, 1); }
#progress.done { opacity: 0; width: 100%; transition: width .2s, opacity .5s .2s; }

/* HTMX swap transitions */
.fade-in, .htmx-settling .fade-in { animation: fade-in .45s var(--ease) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--label); }
.field .help { font-size: 12px; color: var(--faint); margin-top: 6px; }
.field .errors { color: var(--err); font-size: 12.5px; margin-top: 6px; animation: shake .4s; white-space: pre-wrap; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
input[type=text], input[type=number], input[type=url], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--input-bg); color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b90b3' stroke-width='2'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
select option { background: var(--surface-solid); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--input-bg-focus); box-shadow: 0 0 0 4px rgba(124, 92, 255, .18); }
.field.has-error input, .field.has-error textarea { border-color: rgba(248, 113, 113, .6); }
textarea.code { background: var(--term-bg); color: #c4f1ff; tab-size: 2; }
.checkbox { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--muted); }
.checkbox input { accent-color: var(--accent); width: 16px; height: 16px; }
.form-section { margin-bottom: 22px; animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 80ms); }
.form-actions { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--panel-bg); backdrop-filter: blur(16px); border: 1px solid var(--border); z-index: 5; }

/* --------------------------------------------------------------------------
   Hub search
   -------------------------------------------------------------------------- */
.search-hero { position: relative; margin-bottom: 26px; }
.search-box {
  display: flex; align-items: center; gap: 14px; padding: 6px 6px 6px 20px; border-radius: 18px;
  background: var(--input-bg); border: 1px solid var(--border-strong);
  transition: border-color .3s, box-shadow .3s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 5px rgba(124, 92, 255, .15), 0 20px 50px -20px rgba(124, 92, 255, .6); }
.search-box > svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.search-box input { border: 0; background: transparent; box-shadow: none !important; font-size: 17px; padding: 12px 0; }
.search-box input:focus { background: transparent; }
.search-opts { display: flex; gap: 16px; align-items: center; margin-top: 12px; padding-left: 4px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.suggestion { padding: 6px 12px; border-radius: 999px; font-size: 13px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); cursor: pointer; transition: all .25s var(--ease); }
.suggestion:hover { color: var(--text); border-color: var(--accent); transform: translateY(-2px); }

.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.hub-card {
  display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  animation: rise .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms);
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s;
}
.hub-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: 0 18px 40px -20px rgba(34, 211, 238, .4); }
.hub-card .title { display: flex; gap: 12px; align-items: center; }
.hub-card .name { font-weight: 650; word-break: break-all; }
.hub-card .desc { color: var(--muted); font-size: 13.5px; margin: 0; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hub-card .metrics { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; }
.hub-card .metrics span { display: inline-flex; gap: 5px; align-items: center; }
.hub-card .metrics svg { width: 14px; height: 14px; }

.skeleton { position: relative; overflow: hidden; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); height: 170px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--track), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
#hub-loading { display: none; }
#hub-loading.htmx-request { display: grid; }
#hub-loading.htmx-request + #hub-results { display: none; }

/* --------------------------------------------------------------------------
   Detail page
   -------------------------------------------------------------------------- */
.detail-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 24px; }
.detail-hero .svc-icon { width: 68px; height: 68px; border-radius: 20px; font-size: 22px; }
.detail-hero h1 { margin: 0; font-size: 28px; letter-spacing: -0.03em; }
.access-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.access {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); transition: all .35s var(--ease);
}
.access.live { border-color: rgba(34, 211, 238, .35); background: linear-gradient(135deg, rgba(34, 211, 238, .08), rgba(124, 92, 255, .06)); }
.access.live:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -16px rgba(34, 211, 238, .7); }
.access .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.access.live .ic { background: rgba(34, 211, 238, .15); color: var(--fg-cyan); }
.access .ic svg { width: 20px; height: 20px; }
.access .txt { min-width: 0; flex: 1; }
.access .txt strong { display: block; font-size: 14px; }
.access .txt span { display: block; color: var(--muted); font-size: 12.5px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { position: relative; display: flex; gap: 4px; padding: 5px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); width: fit-content; margin-bottom: 22px; max-width: 100%; overflow-x: auto; }
.tab { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; border: 0; background: none; font-family: inherit; transition: color .3s; white-space: nowrap; }
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab-indicator { position: absolute; z-index: 0; top: 5px; bottom: 5px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border-strong); transition: left .45s var(--spring), width .45s var(--spring); }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--faint); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 0 10px 10px; }
.tbl td { padding: 11px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tr { transition: background .2s; }
.tbl tbody tr:hover { background: var(--surface); }

.meter { height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--grad); transition: width .8s var(--ease); }
.meter.mem > span { background: linear-gradient(90deg, var(--accent-3), var(--accent)); }

.terminal {
  position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--term-border);
  background: var(--term-bg); box-shadow: var(--shadow);
}
.terminal-bar { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: var(--term-bar); border-bottom: 1px solid var(--term-border); font-size: 12.5px; color: #8b90b3; }
.terminal-bar .lights { display: flex; gap: 6px; margin-right: 8px; }
.terminal-bar .lights i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.terminal-bar .lights i:nth-child(2) { background: #febc2e; }
.terminal-bar .lights i:nth-child(3) { background: #28c840; }
.terminal-bar .grow { flex: 1; }
.terminal pre { margin: 0; padding: 16px 18px; max-height: 560px; overflow: auto; font-size: 12.5px; line-height: 1.65; color: var(--term-fg); white-space: pre-wrap; word-break: break-word; }
.terminal .prompt { color: var(--accent-2); }
.terminal .cmd { color: #fff; }
.terminal .exit-ok { color: var(--ok); }
.terminal .exit-err { color: var(--err); }
.console-input { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--term-border); background: var(--term-bar); }
.console-input span { color: var(--accent-2); font-family: var(--mono); font-weight: 700; }
.console-input input { border: 0; background: transparent; color: var(--term-fg); font-family: var(--mono); box-shadow: none !important; padding: 8px 0; }
.console-entry { animation: fade-in .3s var(--ease); }
.console-entry + .console-entry { margin-top: 10px; }
.cursor-blink::after { content: "▋"; color: var(--accent-2); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.op-panel { margin-bottom: 24px; }
.op-panel.enter { animation: rise .5s var(--ease); }
.op-panel .terminal pre { max-height: 300px; }
.op-progress { height: 3px; background: var(--term-bar); overflow: hidden; }
.op-progress span { display: block; height: 100%; width: 40%; background: var(--grad); animation: indeterminate 1.4s var(--ease) infinite; }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.source-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.source-option { display: flex; gap: 14px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: all .35s var(--ease); animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 80ms); }
.source-option:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 18px 40px -20px rgba(124, 92, 255, .7); }
.source-option .ic { width: 46px; height: 46px; border-radius: 14px; background: rgba(124, 92, 255, .15); display: grid; place-items: center; color: var(--fg-violet-2); flex: none; }
.source-option strong { display: block; margin-bottom: 4px; }
.source-option span { color: var(--muted); font-size: 13.5px; }

/* --------------------------------------------------------------------------
   Alerts, toasts, dialog
   -------------------------------------------------------------------------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; border: 1px solid; margin-bottom: 20px; font-size: 14px; animation: rise .5s var(--ease); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.alert.error { background: rgba(248, 113, 113, .08); border-color: rgba(248, 113, 113, .3); color: var(--fg-err); }
.alert.warn { background: rgba(251, 191, 36, .08); border-color: rgba(251, 191, 36, .3); color: var(--fg-warn); }
.alert.info { background: rgba(96, 165, 250, .08); border-color: rgba(96, 165, 250, .3); color: var(--fg-info); }

#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; min-width: 260px; max-width: 420px;
  padding: 13px 16px; border-radius: 14px; background: var(--toast-bg); backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong); box-shadow: 0 20px 40px -12px rgba(0,0,0,.7); font-size: 14px;
  animation: toast-in .5s var(--spring) both; position: relative; overflow: hidden;
}
.toast.out { animation: toast-out .35s var(--ease) forwards; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.success svg { color: var(--ok); }
.toast.error svg { color: var(--err); }
.toast.info svg { color: var(--info); }
.toast.warning svg { color: var(--warn); }
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: currentColor; opacity: .5; transform-origin: left; animation: toast-timer 4.5s linear forwards; }
.toast.success::after { color: var(--ok); } .toast.error::after { color: var(--err); } .toast.info::after { color: var(--info); } .toast.warning::after { color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.9); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px) scale(.9); } }
@keyframes toast-timer { to { transform: scaleX(0); } }

dialog { border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface-solid); color: var(--text); padding: 26px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 40px 80px -20px rgba(0,0,0,.8); }
dialog[open] { animation: dialog-in .4s var(--spring); }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(6px); animation: fade-in .3s; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(20px) scale(.95); } }
dialog h3 { margin: 0 0 8px; }
dialog p { color: var(--muted); margin: 0 0 18px; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; padding: 36px; animation: rise .8s var(--ease); }
.login-card .brand { justify-content: center; padding-bottom: 8px; }
.login-card h2 { text-align: center; margin: 0 0 24px; font-weight: 600; color: var(--muted); font-size: 15px; }
.login-card .field { margin-bottom: 16px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt-0 { margin-top: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 0 16px; }
.section-title h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.hidden { display: none !important; }

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

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; max-height: 120px; overflow: auto; }
.tag-chip { cursor: pointer; transition: all .2s var(--ease); }
.tag-chip:hover { transform: translateY(-1px); border-color: rgba(34, 211, 238, .5); }
.tag-chip.selected { background: var(--grad); color: white; border-color: transparent; }

/* --------------------------------------------------------------------------
   Theme toggle
   -------------------------------------------------------------------------- */
.theme-toggle {
  position: relative; display: inline-flex; align-items: center; width: 58px; height: 30px; padding: 3px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2);
  cursor: pointer; flex: none; transition: background .3s, border-color .3s;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(124, 92, 255, .25); }
.theme-toggle .knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--grad); box-shadow: 0 4px 12px -2px rgba(124, 92, 255, .6);
  transition: transform .5s var(--spring);
}
:root[data-theme="light"] .theme-toggle .knob { transform: translateX(28px); background: linear-gradient(135deg, #fbbf24, #f97316); box-shadow: 0 4px 12px -2px rgba(249, 115, 22, .6); }
.theme-toggle svg { position: relative; z-index: 1; width: 14px; height: 14px; margin: 0 4px; transition: color .3s, transform .5s var(--spring); }
.theme-toggle .moon { color: #fff; }
.theme-toggle .sun { margin-left: auto; color: var(--faint); }
:root[data-theme="light"] .theme-toggle .moon { color: var(--faint); transform: rotate(-90deg) scale(.8); }
:root[data-theme="light"] .theme-toggle .sun { color: #fff; transform: rotate(180deg); }
.sidebar-theme { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.login-theme { position: fixed; top: 18px; right: 18px; z-index: 10; }
.mobile-bar .theme-toggle { margin-left: auto; }

/* smooth colour change when switching (fallback without View Transitions) */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color .45s var(--ease), border-color .45s var(--ease), color .45s var(--ease), fill .45s, box-shadow .45s !important;
}
/* circular reveal with the View Transitions API */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-reveal .7s var(--ease); }
@keyframes theme-reveal { from { clip-path: circle(0 at var(--tx, 50%) var(--ty, 50%)); } to { clip-path: circle(var(--tr, 150vmax) at var(--tx, 50%) var(--ty, 50%)); } }
.terminal-bar select { background-color: rgba(255, 255, 255, .06); color: var(--term-fg); border-color: var(--term-border); }
.terminal-bar select option { background: #12142a; color: var(--term-fg); }

/* settings saved but not applied yet */
.pending-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; border-radius: var(--radius);
  background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .35); color: var(--fg-warn);
}
.pending-banner .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(251, 191, 36, .15); flex: none; animation: pulse-warn 2.4s ease-in-out infinite; }
.pending-banner .ic svg { width: 19px; height: 19px; }
.pending-banner .txt { flex: 1; min-width: 0; }
.pending-banner .txt strong { display: block; color: var(--text); }
.pending-banner .txt span { font-size: 13px; }
@keyframes pulse-warn { 50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, .12); } }
@media (max-width: 720px) { .pending-banner { flex-wrap: wrap; } }
.badge.pending { color: var(--fg-warn); background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .35); }

/* published port chips that open the app */
.chip-link { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; transition: transform .2s var(--ease), background .2s, border-color .2s, box-shadow .3s; }
.chip-link svg { width: 12px; height: 12px; transition: transform .25s var(--spring); }
.chip-link:hover { transform: translateY(-1px); background: rgba(34, 211, 238, .16); border-color: rgba(34, 211, 238, .5); box-shadow: 0 6px 16px -8px rgba(34, 211, 238, .8); }
.chip-link:hover svg { transform: translate(2px, -2px); }

.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.input-suffix span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 12px 12px 0; background: var(--surface-2); color: var(--muted); font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.chip-proxy { background: rgba(124, 92, 255, .1); color: var(--fg-violet); border-color: rgba(124, 92, 255, .35); }
.chip-proxy:hover { background: rgba(124, 92, 255, .18); border-color: rgba(124, 92, 255, .6); box-shadow: 0 6px 16px -8px rgba(124, 92, 255, .8); }

/* --------------------------------------------------------------------------
   Images page
   -------------------------------------------------------------------------- */
.images-toolbar { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.tab .count { font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.search-mini { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--input-bg); transition: border-color .25s, box-shadow .25s; }
.search-mini:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 92, 255, .15); }
.search-mini svg { width: 16px; height: 16px; color: var(--muted); }
.search-mini input { border: 0; background: transparent; box-shadow: none !important; padding: 9px 0; width: 200px; }
.images-table tbody tr { animation: rise .5s var(--ease) both; animation-delay: calc(min(var(--i, 0), 20) * 25ms); transition: opacity .3s, transform .3s var(--ease), background .2s; }
.images-table[data-filter="used"] tr.is-orphan, .images-table[data-filter="orphan"] tr.is-used, .images-table tr.hidden-by-search { display: none; }
.images-table tr.deleting { opacity: .25; transform: translateX(16px); }
.img-name { display: flex; gap: 12px; align-items: center; min-width: 220px; }
.img-tag { font-weight: 600; word-break: break-all; }
.img-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: rgba(124, 92, 255, .12); color: var(--fg-violet); }
.img-icon svg { width: 17px; height: 17px; }
.img-icon.running { background: rgba(52, 211, 153, .12); color: var(--ok); }
.img-icon.stopped { background: rgba(248, 113, 113, .1); color: var(--err); }
.img-icon.orphan { background: rgba(251, 191, 36, .12); color: var(--warn); }
.img-container { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.img-container + .img-container { margin-top: 4px; }
.img-container a:hover { color: var(--accent-2); }
.small-badge { font-size: 11px; padding: 1px 7px; }
.orphan-badge { color: var(--fg-warn); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); }
.faint { color: var(--faint); }
