/* ============================================================
   crates/ui/static/app.css — local-panel design system
   ALL ASSETS ARE LOCAL: fonts loaded from /fonts/inter.css
   Zero CDN dependencies.
   ============================================================ */

/* ── 0. Local fonts ──────────────────────────────────────────── */
@import url('/fonts/inter.css');
@import url('/compat.css');

/* ── 1. Design tokens ────────────────────────────────────────── */
:root {
  /* Palette — dark theme  */
  --bg-base:      #0d0f14;
  --bg-surface:   #13161e;
  --bg-elevated:  #1a1e2a;
  --bg-overlay:   #20253480;  /* translucent for glassmorphism */

  --border:       #2a3045;
  --border-focus: #5b6af0;

  /* Accent — indigo-violet gradient */
  --accent:       #5b6af0;
  --accent-light: #7c88f5;
  --accent-dark:  #4051e8;
  --accent-glow:  #5b6af040;

  /* Semantic colours */
  --healthy:      #34c87a;
  --healthy-bg:   #34c87a18;
  --degraded:     #f0a025;
  --degraded-bg:  #f0a02518;
  --unhealthy:    #f0455a;
  --unhealthy-bg: #f0455a18;
  --unknown:      #767c94;
  --unknown-bg:   #767c9418;

  /* Text */
  --text-primary:   #e8ecf5;
  --text-secondary: #8890aa;
  --text-muted:     #4e5568;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Typography */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, 'Cascadia Code',
               'Consolas', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-4xl:  2.25rem;

  --leading-tight:  1.25;
  --leading-normal: 1.5;

  /* Radii */
  --radius-sm:   0.375rem;
  --radius-md:   0.625rem;
  --radius-lg:   0.875rem;
  --radius-xl:   1.25rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px #00000040;
  --shadow-md:  0 4px 16px #00000060;
  --shadow-lg:  0 8px 32px #00000080;
  --shadow-glow: 0 0 24px var(--accent-glow);

  /* Nav */
  --nav-width: 220px;

  /* Transitions */
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 2. Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--text-primary); }

ul { list-style: none; }

/* ── 3. Layout ────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.content {
  display: flex;
  flex-direction: column;
  padding: var(--space-8);
  gap: var(--space-6);
  overflow-x: hidden;
}

/* ── 4. Sidebar nav ───────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: var(--space-5);
  gap: var(--space-6);
  overflow-y: auto;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.nav-logo {
  font-size: var(--text-xl);
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent));
}

.nav-title {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.nav-links li a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.nav-links li a:hover,
.nav-links li a.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-links li a.active {
  color: var(--accent-light);
  background: var(--accent-glow);
}

.nav-footer {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ── 5. Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.page-header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.op-id {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* ── 6. Services grid ─────────────────────────────────────────── */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}

/* ── 7. Service card ──────────────────────────────────────────── */
.service-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: border-color var(--transition), box-shadow var(--transition),
              transform var(--transition);
}

.service-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
}

.meta-label { color: var(--text-muted); }
.meta-value {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.card-actions {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* ── Port chips ───────────────────────────────────────────────── */
.card-ports {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-top: var(--space-2);
}

.port-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  cursor: default;
  transition: color var(--transition), border-color var(--transition);
}
.port-chip:hover {
  color: var(--accent-light);
  border-color: var(--accent);
}

/* ── Process table ────────────────────────────────────────────── */
.card-procs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border);
  margin-top: var(--space-1);
}

.proc-row {
  display: grid;
  grid-template-columns: 1rem 1fr auto;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
}
.proc-row:hover { background: var(--bg-elevated); }

.proc-up   { color: var(--healthy);  font-size: 0.65rem; }
.proc-down { color: var(--unhealthy); font-size: 0.65rem; }
.proc-name { color: var(--text-secondary); }
.proc-pid  { color: var(--text-muted); font-size: 0.65rem; }
.proc-summary { color: var(--text-muted); font-size: var(--text-xs); }


/* ── 8. Status badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-healthy   { color: var(--healthy);  background: var(--healthy-bg); }
.badge-degraded  { color: var(--degraded); background: var(--degraded-bg); }
.badge-unhealthy { color: var(--unhealthy);background: var(--unhealthy-bg); }
.badge-unknown   { color: var(--unknown);  background: var(--unknown-bg); }

/* ── 9. Buttons ───────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-5);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition),
              transform var(--transition), opacity var(--transition);
  font-family: var(--font-sans);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-light);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition),
              background var(--transition);
  font-family: var(--font-sans);
  text-decoration: none;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
}

.btn-sm { padding: var(--space-1) var(--space-2); font-size: var(--text-xs); }

/* ── 10. Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, #2d3af030, transparent),
    var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.login-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.login-logo h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-logo .subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 400;
}

/* ── 11. Forms ────────────────────────────────────────────────── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-field input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-field input::placeholder { color: var(--text-muted); }

.field-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.login-form .btn-primary {
  width: 100%;
  padding: var(--space-4);
  font-size: var(--text-base);
  margin-top: var(--space-2);
}

/* ── Password field with show/hide toggle ────────────────────── */
.password-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field-wrap input {
  flex: 1;
  padding-right: 2.8rem;
}
.password-toggle {
  position: absolute;
  right: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--text-muted);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.password-toggle:hover {
  color: var(--accent-light);
  background: var(--bg-elevated);
}

/* ── CAPTCHA widget ──────────────────────────────────────────── */
.captcha-widget {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.captcha-widget label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.captcha-image-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.captcha-image {
  flex: 1;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  image-rendering: pixelated;
}

.captcha-loading {
  flex: 1;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
  animation: pulse 1.5s ease-in-out infinite;
}

.captcha-refresh {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-lg);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition);
}
.captcha-refresh:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-light);
  transform: rotate(90deg);
}

.captcha-widget input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-mono);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}
.captcha-widget input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.captcha-widget input::placeholder {
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

/* ── Auth loading (AuthGuard) ────────────────────────────────── */
.auth-loading {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: var(--text-sm);
  animation: pulse 1.5s ease-in-out infinite;
}

/* ── Responsive: login ───────────────────────────────────────── */
@media (max-width: 768px) {
  .login-card {
    max-width: 90%;
    padding: var(--space-8) var(--space-6);
  }
}

@media (max-width: 480px) {
  .login-card {
    max-width: 100%;
    margin: 0 var(--space-4);
    padding: var(--space-6) var(--space-5);
    border-radius: var(--radius-lg);
  }
  .login-logo h1 { font-size: var(--text-xl); }
  .form-field input { font-size: var(--text-base); padding: var(--space-4); }
  .captcha-widget input { font-size: var(--text-base); padding: var(--space-4); }
  .login-form .btn-primary { padding: var(--space-4); font-size: var(--text-base); }
  .captcha-refresh { width: 44px; height: 44px; }
}

/* ── 12. Error banner ─────────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--unhealthy-bg);
  border: 1px solid var(--unhealthy);
  border-left: 3px solid var(--unhealthy);
  border-radius: var(--radius-md);
  color: var(--unhealthy);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
  animation: shake 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.error-banner::before {
  content: '⚠';
  font-size: var(--text-base);
  flex-shrink: 0;
  margin-top: 1px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

/* ── 13. 404 page ─────────────────────────────────────────────── */
.not-found {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
  gap: var(--space-4);
  background: var(--bg-base);
}

.not-found h1 {
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.not-found p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
}

/* ── 14. Scrollbar — see compat.css ──────────────────────── */

/* ── 15. Selection ────────────────────────────────────────────── */
::selection {
  background: var(--accent-glow);
  color: var(--text-primary);
}

/* ── 16. Focus visible ring ───────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── 17. Summary strip ────────────────────────────────────────── */
.summary-strip {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.summary-card {
  flex: 1;
  min-width: 110px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.summary-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.summary-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.summary-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-healthy { color: var(--healthy); }
.status-warn    { color: var(--degraded); }
.status-err     { color: var(--unhealthy); }
.status-muted   { color: var(--unknown); }

/* ── 18. Services table ───────────────────────────────────────── */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.services-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.services-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.services-table td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.table-row:last-child td { border-bottom: none; }

.table-row:hover td {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.svc-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary) !important;
}

.mono { font-family: var(--font-mono); }

.actions-cell {
  display: flex;
  gap: var(--space-2);
}

/* ── 19. Log pane ─────────────────────────────────────────────── */
.log-filter {
  flex: 1;
  max-width: 380px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition);
}
.log-filter:focus { border-color: var(--border-focus); }

.log-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.8;
  overflow-y: auto;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-line {
  display: grid;
  grid-template-columns: 6rem 8rem 4rem 1fr;
  gap: var(--space-3);
  align-items: baseline;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}
.log-line:hover { background: var(--bg-elevated); }

.log-ts    { color: var(--text-muted); }
.log-svc   { color: var(--accent-light); font-weight: 600; }
.log-level { font-weight: 700; }
.log-msg   { color: var(--text-secondary); word-break: break-all; }

.log-warn  .log-level { color: var(--degraded); }
.log-warn  .log-msg   { color: var(--degraded); opacity: 0.85; }
.log-err   .log-level { color: var(--unhealthy); }
.log-err   .log-msg   { color: var(--unhealthy); opacity: 0.85; }

/* ── 20. Nav link active state ────────────────────────────────── */
/* leptos_router A sets aria-current="page" on the active link */
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.nav-link[aria-current="page"] {
  background: var(--accent-glow);
  color: var(--accent-light);
}
.nav-icon {
  font-size: var(--text-base);
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── 21. Architecture note ────────────────────────────────────── */
.arch-note {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.arch-note code {
  background: var(--bg-elevated);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  font-family: var(--font-mono);
}
.arch-icon { font-size: var(--text-base); color: var(--accent); }

/* ── 22. Loading state ────────────────────────────────────────── */
.loading {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-8);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── 23. Profile page ─────────────────────────────────────────── */
.profile-page-header {
  margin-bottom: var(--space-6);
}
.profile-page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.profile-page-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.profile-grid {
  display: grid;
  grid-template-columns: 260px 1fr 1fr;
  gap: var(--space-5);
  align-items: start;
}

.profile-card {
  background: var(--bg-card, var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  backdrop-filter: blur(8px);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.profile-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 8%, transparent);
}

.profile-card--full {
  grid-column: 1 / -1;
}

.profile-card--span-right {
  grid-column: 2 / -1;
}

.card-section-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.card-section-title::before {
  content: '';
  width: 3px;
  height: 1em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Avatar */
.avatar-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.avatar-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.avatar-circle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow), inset 0 0 24px var(--accent-glow);
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--accent-light);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
}

.avatar-upload-btn {
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.avatar-upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
}

.avatar-file-input {
  display: none;
}

/* form-row: input + button on same line */
.form-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}
.form-row .form-input { flex: 1; }

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Password form */
.pw-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Password field wrapper — input + toggle in a row */
.password-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field-wrap .form-input {
  padding-right: var(--space-10);
}
.password-toggle {
  position: absolute;
  right: var(--space-2);
  background: none;
  border: none;
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.password-toggle:hover {
  color: var(--accent-light);
  background: var(--accent-glow);
}

.help-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0;
}

/* Feedback */
.feedback-ok  {
  font-size: var(--text-sm);
  color: var(--healthy);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--healthy-bg);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--healthy) 30%, transparent);
}
.feedback-err {
  font-size: var(--text-sm);
  color: var(--unhealthy);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--unhealthy-bg);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--unhealthy) 30%, transparent);
}

/* Form field labels */
.profile-card .form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.profile-card .form-field label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── 24. Nav profile footer ───────────────────────────────────── */
.nav-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

.nav-profile-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--transition);
}
.nav-profile-link:hover { background: var(--bg-elevated); }
.nav-profile-link[aria-current="page"] { background: var(--accent-glow); }

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--accent-light);
  flex-shrink: 0;
}

.nav-profile-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nav-profile-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-profile-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.nav-signout {
  align-self: flex-start;
  font-size: var(--text-xs);
}

@media (max-width: 900px) {
  .profile-grid { grid-template-columns: 200px 1fr; }
  .profile-card--span-right { grid-column: 2; }
}
@media (max-width: 600px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-card--full { grid-column: 1; }
  .profile-card--span-right { grid-column: 1; }
}

/* ── 25. Accordion nav sections ───────────────────────────────── */
.nav-sections {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
}

.nav-section {
  display: flex;
  flex-direction: column;
}

.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  gap: var(--space-2);
}
.nav-section-toggle:not([disabled]):hover { background: var(--bg-elevated); }
.nav-section-toggle[disabled] { cursor: default; opacity: 0.5; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex: 1;
  text-align: left;
}

.nav-section-chevron {
  font-size: var(--text-xs);
  color: var(--text-muted);
  transition: transform 0.2s ease;
  line-height: 1;
}
.chevron-open { transform: rotate(0deg); }

/* Module list — collapsible */
.nav-links {
  list-style: none;
  padding: 0 var(--space-2);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-height: 400px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}
.nav-links--hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── 26. Live log badge + header row ──────────────────────────── */
.log-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.log-conn-badge {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}

.badge-live {
  color: var(--healthy);
  border-color: var(--healthy);
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

.log-empty {
  color: var(--text-muted);
  font-size: var(--text-xs);
  padding: var(--space-4) 0;
  display: block;
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

/* ── Service card — clickable link wrapper ───────────────────── */
.service-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.service-card-link:hover .service-card {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: translateY(-2px);
}
.service-card { transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); }

/* ── DMZ IP — distinct from svc-net ─────────────────────────── */
.dmz-ip { color: var(--accent-light) !important; }

/* ── Bin version chips ───────────────────────────────────────── */
.card-versions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border);
  margin-top: var(--space-1);
}
.ver-chip {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent-light);
  white-space: nowrap;
}
/* Per-plane colour overrides */
.ver-chip-svc {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-light);
}
.ver-chip-dat {
  background: color-mix(in srgb, #34d399 10%, transparent);
  border-color: color-mix(in srgb, #34d399 32%, transparent);
  color: #34d399;
}
.ver-chip-obs {
  background: color-mix(in srgb, #22d3ee 10%, transparent);
  border-color: color-mix(in srgb, #22d3ee 32%, transparent);
  color: #22d3ee;
}
.ver-chip-agt {
  background: color-mix(in srgb, #a78bfa 10%, transparent);
  border-color: color-mix(in srgb, #a78bfa 32%, transparent);
  color: #a78bfa;
}
/* Larger chips for service detail page */
.ver-chips-lg {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
  margin-top: var(--space-1);
}
.ver-chips-lg .ver-chip {
  font-size: 0.78rem;
  padding: var(--space-1) var(--space-3);
}

/* ── Service detail page ─────────────────────────────────────── */
.detail-back { margin-bottom: var(--space-3); }
.detail-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.detail-title-row h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.status-badge-lg {
  font-size: var(--text-sm);
  padding: 4px var(--space-4);
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: var(--space-5);
  margin-top: var(--space-5);
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  backdrop-filter: blur(8px);
}
.detail-procs  { grid-column: 1 / -1; }   /* full width */
.detail-logs   { grid-column: 1 / -1; }   /* full width */

/* Stats mini-cards row */
.detail-stats {
  display: flex;
  gap: var(--space-4);
  grid-column: 1 / -1;
  flex-wrap: wrap;
}
.stat-card {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  backdrop-filter: blur(8px);
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--accent); }
.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Definition list for metadata */
.meta-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-4);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}
.meta-dl dt { color: var(--text-muted); white-space: nowrap; }
.meta-dl dd { margin: 0; color: var(--text-secondary); word-break: break-all; }

/* Section heading inside detail panel */
.section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 var(--space-3) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-link { font-size: var(--text-xs); text-transform: none; letter-spacing: 0; }

/* Embedded log pane inside detail page */
.log-embed {
  max-height: 320px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.loading { color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-4); }

/* ================================================================
   MAP PAGE — /map
   ================================================================ */

/* layout-map: lock the whole grid to viewport so the SVG fills it */
.layout.layout-map {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.layout-map .content.map-page {
  height: 100%;
  overflow: hidden;
  padding: var(--space-4);
  gap: var(--space-3);
}

.map-header {
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.map-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}
.map-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Legend */
.map-legend {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Canvas wrapper — fills remaining height */
.map-canvas-wrap {
  flex: 1;
  min-height: 0;          /* critical: allows flex child to shrink */
  display: flex;
  align-items: stretch;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.map-svg {
  width: 100%;
  height: 100%;
}

/* ── Wire styles ─────────────────────────────────────────── */
.wire {
  opacity: 0.30;
  transition: opacity 0.3s;
}
.wire:hover { opacity: 0.75; }

/* ── Particle (CSS Motion Path) ──────────────────────────── */
.pkt {
  pointer-events: none;
  /* offset-path / animation set inline per particle */
}
@keyframes pkt-move {
  0%   { offset-distance: 0%;   opacity: 0.95; }
  75%  {                         opacity: 0.90; }
  100% { offset-distance: 100%; opacity: 0;    }
}
/* .hidden used to suppress particles on unhealthy services */
.hidden { display: none; }

/* Network boundary rings */
.net-ring {
  fill: none;
  stroke-dasharray: 6 4;
  stroke-width: 1;
  opacity: 0.25;
}
.svc-net-ring  { stroke: #22d3ee; }
.dmz-net-ring  { stroke: #a78bfa; }

.net-label {
  font-size: 11px;
  fill: #6b7280;
  text-anchor: middle;
  font-family: var(--font-mono);
}
.dmz-label { fill: #a78bfa88; }

/* Connection lines */
.conn-line { opacity: 0.45; transition: opacity 0.3s; }
.conn-line:hover { opacity: 0.9; }

/* Flow animation — animates stroke-dashoffset for lines that have dasharray */
.flow { animation: flow-dash 1.6s linear infinite; }
@keyframes flow-dash {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -20; }
}

/* Nodes */
.map-node { cursor: pointer; }
.map-node:hover .node-circle { filter: brightness(1.25); }
.map-node:hover .node-halo   { opacity: 0.55 !important; }

.node-circle {
  fill: #13161e;
  filter: drop-shadow(0 0 8px #0008);
  transition: filter 0.2s;
}
.hub-circle { fill: #0d0f14; }

.node-halo { transition: opacity 0.3s; }

.node-label {
  text-anchor: middle;
  font-size: 11px;
  font-weight: 600;
  fill: #e2e8f0;
  font-family: var(--font-sans);
  pointer-events: none;
}
.hub-label { font-size: 13px; }

.node-ip {
  text-anchor: middle;
  font-size: 9px;
  fill: #64748b;
  font-family: var(--font-mono);
  pointer-events: none;
}
.node-procs {
  text-anchor: middle;
  font-size: 9px;
  fill: #94a3b8;
  font-family: var(--font-mono);
  pointer-events: none;
}
.node-status {
  text-anchor: middle;
  font-size: 9px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Pulse animations */
.pulse {
  animation: map-pulse 2.6s ease-in-out infinite;
}
.pulse-fast {
  animation: map-pulse 1.4s ease-in-out infinite;
}
@keyframes map-pulse {
  0%, 100% { opacity: 0.35; transform-origin: center; transform: scale(1); }
  50%       { opacity: 0.7;  transform: scale(1.12); }
}


/* ═══════════════════════════════════════════════════════════════════════════
   BUILD PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.page-build {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  max-width: 1200px;
}

/* Build options card */
.build-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
}

.build-form { display: flex; flex-direction: column; gap: 1rem; }

.build-form-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.build-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.build-input,
.build-select {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.75rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  min-width: 220px;
  outline: none;
  transition: border-color 0.2s;
}
.build-input:focus, .build-select:focus {
  border-color: var(--accent);
}

.build-flags-row { gap: 2rem; }

.build-flag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  transition: color 0.2s;
}
.build-flag:hover { color: var(--text); }
.build-flag input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; }

.build-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--accent), hsl(260, 80%, 55%));
  color: #fff;
  border: none;
  border-radius: 0.625rem;
  padding: 0.7rem 1.75rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  align-self: flex-start;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}
.build-trigger-btn:hover:not(.disabled) { opacity: 0.92; transform: translateY(-1px); }
.build-trigger-btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { font-size: 1rem; }

/* Phase progress strip */
.build-phase-strip {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.step-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.25s;
}

.step-num {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
}

.step-pending  { background: var(--surface-raised); border-color: var(--border); color: var(--text-muted); }
.step-running  { background: hsl(45,90%,18%); border-color: hsl(45,90%,40%); color: hsl(45,90%,70%);
                 animation: step-pulse 1.2s ease-in-out infinite; }
.step-ok       { background: hsl(142,71%,14%); border-color: hsl(142,71%,40%); color: hsl(142,71%,70%); }
.step-skipped  { background: hsl(220,20%,20%); border-color: var(--border); color: var(--text-muted); }
.step-failed   { background: hsl(0,72%,16%); border-color: hsl(0,72%,42%); color: hsl(0,80%,70%); }

@keyframes step-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* Live log pane */
.build-log-pane {
  background: hsl(220, 15%, 8%);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.65;
  scroll-behavior: smooth;
  white-space: pre;
}
.build-log-pane > div {
  display: block;
  min-width: 100%;
  width: max-content;
}
.log-line  { color: var(--text-muted); }
.log-ok    { color: hsl(142, 71%, 55%); }
.log-err   { color: hsl(0, 80%, 60%); }
.log-skip  { color: hsl(220, 20%, 55%); }


/* Build history table */
.build-history h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; }

.build-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.build-history-table th,
.build-history-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.build-history-table th  { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; }
.build-history-table .ts { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   CONTAINERS PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.page-containers {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.5rem 2rem;
  max-width: 1400px;
}

.containers-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.container-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}
.container-table th,
.container-table td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.container-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  position: sticky;
  top: 0;
}
.container-table tr:hover td { background: var(--surface-raised); }

.container-name { color: var(--accent); font-size: 0.82rem; }
.img-cell { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.75rem; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.img-id { color: var(--text-muted); font-size: 0.75rem; }
.ports-cell { font-family: var(--font-mono); font-size: 0.75rem; }
.tag-more { color: var(--text-muted); font-size: 0.72rem; margin-left: 0.25rem; }

.action-cell { white-space: nowrap; }
.action-group { display: flex; gap: 0.4rem; }

.action-btn {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  color: var(--text-muted);
}
.action-btn:hover { color: var(--text); border-color: var(--accent); }
.action-start:hover { background: hsl(142,60%,15%); border-color: hsl(142,60%,40%); color: hsl(142,60%,60%); }
.action-stop:hover  { background: hsl(45,80%,15%);  border-color: hsl(45,80%,40%);  color: hsl(45,80%,65%);  }
.action-edit:hover  { border-color: var(--accent); color: var(--accent); }
.action-log         { text-decoration: none; }
.action-log:hover   { border-color: hsl(200, 70%, 50%); color: hsl(200, 70%, 50%); }
.action-remove      { color: hsl(0,70%,55%); border-color: hsl(0,40%,30%); }
.action-remove:hover{ background: hsl(0,60%,15%);   border-color: hsl(0,60%,40%);   color: hsl(0,70%,65%);   }


.badge-warning { background: hsl(45,70%,16%); color: hsl(45,80%,60%); border-color: hsl(45,60%,40%); }

.alert-error {
  background: hsl(0,60%,14%);
  border: 1px solid hsl(0,60%,40%);
  color: hsl(0,80%,70%);
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
}


/* ── Build detail page ────────────────────────────────────────────────────── */

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.back-link {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.78rem; color: var(--text-muted); text-decoration: none;
  margin-bottom: 0.3rem; transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }
.build-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.5rem;
}
.build-meta .build-id { font-size: 0.78rem; opacity: 0.75; }
.build-meta .ts       { font-size: 0.75rem; color: var(--text-muted); }
.live-badge {
  font-size: 0.7rem; font-weight: 700; color: hsl(145, 70%, 50%);
  letter-spacing: 0.05em; animation: pulse 1.5s ease-in-out infinite;
}
.build-detail-toolbar {
  display: flex; justify-content: flex-end; margin-bottom: 0.5rem;
}
.copy-btn {
  padding: 0.3rem 0.75rem; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted);
  border-radius: 0.375rem; font-size: 0.78rem; cursor: pointer; transition: all 0.15s;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.build-log-pane--detail { max-height: 72vh; }
.log-step { color: hsl(210, 75%, 70%); font-weight: 600; padding: 0.15rem 0.5rem; }
.build-detail-link {
  color: var(--accent); text-decoration: none; font-size: 0.78rem;
  opacity: 0.8; white-space: nowrap; transition: opacity 0.15s;
}
.build-detail-link:hover { opacity: 1; text-decoration: underline; }
.build-history-table tbody tr:hover { background: rgba(255,255,255,0.04); }

/* ── Credentials / Memento page ──────────────────────────────────────────── */

.page-credentials {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
}

.credentials-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scope-select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 0.18s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}
.scope-select:hover,
.scope-select:focus { border-color: var(--accent); outline: none; }

.credential-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  animation: fade-in 0.2s ease-out;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.form-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px hsla(var(--accent-raw), 0.15);
  outline: none;
}
.form-group input::placeholder { color: var(--text-muted); opacity: 0.5; }

.form-group--checkbox {
  flex-direction: row;
  align-items: center;
  padding-top: 1.2rem;
}
.form-group--checkbox label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}
.form-group--checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.credentials-section {
  margin-top: 0.5rem;
}

.alert-success {
  background: hsl(142,50%,12%);
  border: 1px solid hsl(142,50%,35%);
  color: hsl(142,70%,60%);
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  animation: fade-in 0.2s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Memento stats cards ─────────────────────────────────────────────────── */

.memento-stats { margin-bottom: 0.5rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.875rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: border-color 0.18s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card--wide { grid-column: span 2; }
.stat-card--muted { opacity: 0.6; }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.1;
}
.stat-value--sm { font-size: 0.9rem; }

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Memento section headers ─────────────────────────────────────────────── */

.memento-section { margin-top: 0.25rem; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.section-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── MQTT log ────────────────────────────────────────────────────────────── */

.mqtt-log { max-height: 56vh; overflow-y: auto; }
.mqtt-payload {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 600px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Button variants ─────────────────────────────────────────────────────── */

.btn-sm { font-size: 0.78rem; padding: 0.35rem 0.75rem; }

.empty-state {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 1.25rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 0.625rem;
}

/* ── Auth page: tabs ─────────────────────────────────────────────────────── */

.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: var(--space-6) 0 var(--space-5);
}

.auth-tab {
  padding: var(--space-3) var(--space-6);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition),
              background var(--transition);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.auth-tab:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.auth-tab--active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

/* ── Auth page: form row ─────────────────────────────────────────────────── */

.auth-form-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background: var(--bg-card, var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.auth-form-row .form-field { flex: 1; }
.auth-form-row .form-field.form-field--wide { flex: 2; }

.auth-form-row .form-field input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-form-row .form-field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-form-row .form-field input::placeholder { color: var(--text-muted); }

.auth-form-row .form-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

/* ── Role assignment dropdown ────────────────────────────────────────── */

.role-assign-select {
  font-size: var(--text-xs);
  padding: 0.15rem 0.4rem;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 5rem;
}
.role-assign-select:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.role-assign-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Danger button ───────────────────────────────────────────────────────── */

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  background: transparent;
  color: var(--unhealthy);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--unhealthy);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: var(--font-sans);
}

.btn-danger:hover {
  background: var(--unhealthy-bg);
  color: #fff;
}

/* ── Auth create button ─────────────────────────────────────────────────── */
.btn-accent-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-5);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition),
              transform var(--transition);
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn-accent-sm:hover {
  background: var(--accent-light);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: translateY(-1px);
}

/* ── Auth action button (lock/unlock) ────────────────────────────────────── */
.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition),
              background var(--transition);
  font-family: var(--font-sans);
}

.btn-outline-sm:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
}

/* ── Auth user avatar ────────────────────────────────────────────────────── */
.auth-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--accent-glow);
  color: var(--accent-light);
  font-size: var(--text-xs);
  font-weight: 700;
  border: 1px solid var(--accent);
  flex-shrink: 0;
}

.auth-user-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.auth-user-info {
  display: flex;
  flex-direction: column;
}

.auth-user-info .auth-username {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.auth-user-info .auth-email {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Sidebar toggle (hamburger) ────────────────────────────── */
.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,0.06);
}
.sidebar-toggle-icon {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1;
}

/* ── Collapsed sidebar ─────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease;
}
.sidebar--collapsed {
  width: 52px;
  min-width: 52px;
  padding: var(--space-3) var(--space-2);
  align-items: center;
}
.sidebar--collapsed .nav-title,
.sidebar--collapsed .nav-sections,
.sidebar--collapsed .nav-footer,
.sidebar--collapsed .nav-logo {
  display: none;
}
.sidebar--collapsed .nav-brand {
  justify-content: center;
}

/* ── Profile page polish ─────────────────────────────────────── */
.profile-page-header {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}

.profile-card--avatar {
  text-align: center;
  align-items: center;
}
.profile-card--avatar .avatar-circle {
  width: 140px;
  height: 140px;
  box-shadow: 0 0 32px color-mix(in srgb, var(--accent) 15%, transparent);
}
.profile-card--avatar .help-text {
  text-align: center;
  max-width: 160px;
}

/* tighter password form — 2-column on wide screens */
.pw-form .form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.pw-form .form-field label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.pw-form > .btn-primary {
  align-self: flex-end;
  min-width: 200px;
  margin-top: var(--space-2);
}

/* Display name card polish */
.profile-card--span-right {
  justify-content: center;
}
.profile-card--span-right .form-row {
  margin-top: var(--space-2);
}
.profile-card--span-right .btn-primary {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Profile page polish ─────────────────────────────────────── */
.profile-page-header {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}

.profile-card--avatar {
  text-align: center;
  align-items: center;
}
.profile-card--avatar .avatar-circle {
  width: 140px;
  height: 140px;
  box-shadow: 0 0 32px color-mix(in srgb, var(--accent) 15%, transparent);
}
.profile-card--avatar .help-text {
  text-align: center;
  max-width: 160px;
}

/* tighter password form — 2-column on wide screens */
.pw-form .form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.pw-form .form-field label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.pw-form > .btn-primary {
  align-self: flex-end;
  min-width: 200px;
  margin-top: var(--space-2);
}

/* Display name card polish */
.profile-card--span-right {
  justify-content: center;
}
.profile-card--span-right .form-row {
  margin-top: var(--space-2);
}
.profile-card--span-right .btn-primary {
  white-space: nowrap;
  flex-shrink: 0;
}
