/* ==========================================================================
   WebDep — Minimal Dark Design System
   Flat surfaces, hairline borders, one accent colour, no glow / gradients.
   Single source of truth (all legacy override layers removed).
   ========================================================================== */

:root {
  --bg-canvas: #0a0a0b;
  --bg-sidebar: #0a0a0b;
  --bg-header: #0a0a0b;
  --bg-card: #111113;
  --bg-card-hover: #17171a;
  --bg-card-elevated: #141416;
  --bg-input: #0d0d0f;
  --bg-terminal: #08080a;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-focus: #3b82f6;

  --accent: #3b82f6;
  --accent-light: #7ab0fa;
  --accent-hover: #2f6fd8;
  --accent-glow: rgba(59, 130, 246, 0.18);

  --success: #22c55e;
  --success-light: #4ade80;
  --success-bg: rgba(34, 197, 94, 0.1);
  --success-border: rgba(34, 197, 94, 0.25);

  --warning: #eab308;
  --warning-light: #facc15;
  --warning-bg: rgba(234, 179, 8, 0.1);
  --warning-border: rgba(234, 179, 8, 0.25);

  --danger: #ef4444;
  --danger-light: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.25);

  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.1);

  --text-main: #ededee;
  --text-normal: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --text-inverse: #0a0a0b;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --radius-full: 9999px;

  --sidebar-w: 224px;
  --header-h: 56px;
  --transition-fast: 0.12s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(59, 130, 246, 0.35); color: #fff; }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

code { font-family: var(--font-mono); font-size: 12px; color: var(--text-normal); }

a { color: var(--accent-light); }

/* ---------- Layout ---------- */
#app { display: flex; height: 100vh; height: 100dvh; width: 100%; max-width: 100vw; overflow: hidden; }

.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; min-width: 0; max-width: 100%; }

.content-area { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 28px 32px 40px; position: relative; }

.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
}

.brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 10px;
}

.brand-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-md);
  background: var(--text-main);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}

.brand-name { font-weight: 600; font-size: 14px; color: var(--text-main); display: flex; align-items: center; gap: 8px; }

.brand-badge {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  border: 1px solid var(--border-medium);
  letter-spacing: 0.04em;
}

.nav-menu { flex: 1; padding: 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }

.nav-section-title {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-main); }
.nav-item.active { background: rgba(255, 255, 255, 0.07); color: var(--text-main); }
.nav-item svg { width: 16px; height: 16px; stroke-width: 1.8; opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  min-width: 0;
}
.user-snippet:hover { background: rgba(255, 255, 255, 0.05); }

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 10.5px;
  color: var(--text-normal);
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--text-main); line-height: 1.2; }
.user-role { font-size: 10.5px; color: var(--text-dim); text-transform: capitalize; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 19; }

/* ---------- Top header ---------- */
.top-header {
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 10;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 12px; }

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
}
.mobile-menu-btn:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.05); }

.breadcrumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.crumb-section { color: var(--text-main); font-weight: 500; }
.crumb-separator { color: var(--text-dim); }

.server-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Status dot ---------- */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--text-dim);
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); }
.status-dot.maintenance { background: var(--warning); }
.status-dot.building { background: var(--warning); animation: dotBlink 1.2s ease-in-out infinite; }
@keyframes dotBlink { 50% { opacity: 0.35; } }

/* ---------- View header ---------- */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.view-title-group h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.view-title-group p { color: var(--text-muted); font-size: 13px; margin-top: 4px; max-width: 720px; }
.view-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn svg { width: 14px; height: 14px; stroke-width: 2; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary { background: transparent; border-color: var(--border-medium); color: var(--text-normal); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.2); color: var(--text-main); }

.btn-danger { background: transparent; border-color: var(--danger-border); color: var(--danger-light); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-light); }
.btn-success:hover { background: var(--success); border-color: var(--success); color: #05200f; }

.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 38px; padding: 0 18px; font-size: 14px; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); display: flex; align-items: center; justify-content: space-between; }
.stat-label svg { opacity: 0.5; }
.stat-value { font-size: 24px; font-weight: 600; color: var(--text-main); letter-spacing: -0.02em; }
.stat-meta { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }

.progress-bar { height: 4px; background: rgba(255, 255, 255, 0.07); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }
.progress-fill.green { background: var(--success); }
.progress-fill.amber { background: var(--warning); }
.progress-fill.rose { background: var(--danger); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }

/* ---------- Project cards ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; margin-bottom: 22px; }

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color var(--transition-fast);
}
.project-card:hover { border-color: var(--border-medium); }

.project-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.project-info-title { font-size: 15px; font-weight: 600; color: var(--text-main); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.project-info-domains { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.project-meta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-muted); }
.project-meta-item { display: flex; align-items: center; gap: 5px; }
.project-meta-item svg { width: 13px; height: 13px; opacity: 0.6; }
.project-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.6;
}
.badge-success { background: var(--success-bg); color: var(--success-light); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-light); border: 1px solid var(--warning-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger-light); border: 1px solid var(--danger-border); }
.badge-neutral { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.badge-info { background: var(--accent-glow); color: var(--accent-light); border: 1px solid rgba(59, 130, 246, 0.3); }

.domain-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--accent-light);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.domain-badge:hover { border-color: var(--border-medium); }

.sha-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  color: var(--text-normal);
}

.filter-pills { display: inline-flex; background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 2px; gap: 2px; }
.filter-pills .pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.filter-pills .pill:hover { color: var(--text-main); }
.filter-pills .pill.active { background: rgba(255, 255, 255, 0.09); color: var(--text-main); }

/* ---------- Pipeline ---------- */
.pipeline-track {
  display: flex;
  align-items: center;
  background: transparent;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.card .pipeline-track { border: none; margin-bottom: 0; padding: 8px 0 12px; }

.water-pipeline-wrapper { display: flex; align-items: center; width: 100%; min-width: 820px; position: relative; }
.water-stage-unit { display: flex; align-items: center; flex: 1; position: relative; min-width: 120px; }
.water-stage-unit:last-child { flex: 0 0 auto; min-width: auto; }

.water-node-vial {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border-medium);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.25s ease;
  z-index: 2;
}
.water-vial-bg { position: absolute; inset: 0; z-index: 1; }
.water-vial-liquid { position: absolute; bottom: 0; left: 0; right: 0; height: 0%; background: var(--accent); opacity: 0.35; z-index: 2; transition: height 0.06s linear; }
.water-node-vial.completed .water-vial-liquid { background: var(--success); opacity: 0.25; }
.water-node-vial.failed .water-vial-liquid { background: var(--danger); opacity: 0.25; }
.water-wave-surface { display: none; }

.water-vial-content { position: relative; z-index: 3; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.water-vial-num { font-size: 11px; font-weight: 600; color: var(--text-dim); line-height: 1; transition: color 0.2s ease; }
.water-node-vial.active .water-vial-num { color: var(--text-main); }
.water-vial-icon { display: none; }
.water-node-vial.completed .water-vial-check { display: block; stroke: var(--success-light); stroke-width: 3; }
.water-node-vial.failed .water-vial-cross { display: block; stroke: var(--danger-light); stroke-width: 3; }
.water-node-vial.completed .water-vial-num, .water-node-vial.failed .water-vial-num { display: none; }

.water-node-vial.active { border-color: var(--accent); }
.water-node-vial.completed { border-color: var(--success); }
.water-node-vial.failed { border-color: var(--danger); }
.water-node-vial.queued { border-color: var(--border-medium); }

.water-node-info { display: flex; flex-direction: column; gap: 0; margin-left: 9px; flex-shrink: 0; }
.water-node-name { font-size: 12.5px; font-weight: 500; color: var(--text-dim); white-space: nowrap; transition: color 0.2s ease; }
.water-node-name.active { color: var(--text-main); font-weight: 600; }
.water-node-name.completed { color: var(--text-normal); }
.water-node-name.failed { color: var(--danger-light); font-weight: 600; }
.water-node-sub { font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); }
.water-node-sub.active { color: var(--accent-light); }
.water-node-sub.completed { color: var(--success-light); }
.water-node-sub.failed { color: var(--danger-light); }
.water-node-sub.queued { color: var(--text-dim); }

.water-pipe-segment { flex: 1; margin: 0 10px; position: relative; height: 4px; display: flex; align-items: center; }
.water-pipe-glass { width: 100%; height: 2px; background: var(--border-medium); border-radius: 1px; position: relative; }
.water-pipe-liquid { height: 100%; width: 0%; border-radius: 1px; position: relative; transition: width 0.06s linear; }
.water-pipe-liquid.flowing { background: var(--accent); }
.water-pipe-liquid.filled { background: var(--success); }
.water-pipe-liquid.empty { background: transparent; }
.water-pipe-meniscus { display: none; }

/* ---------- Tables ---------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.table th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); vertical-align: middle; }
.table tr:hover td { background: rgba(255, 255, 255, 0.02); color: var(--text-normal); }
.table tr:last-child td { border-bottom: none; }
.table td strong { color: var(--text-main); font-weight: 600; }
.env-table input.form-control { min-width: 140px; }

/* ---------- Logs ---------- */
.log-console-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 230px);
  min-height: 360px;
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.log-toolbar {
  padding: 8px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.log-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-terminal {
  flex: 1;
  padding: 14px 18px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-normal);
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
}
.log-line { display: flex; gap: 10px; padding: 1px 0; }
.log-ts { color: var(--text-dim); flex-shrink: 0; font-size: 11px; }
.log-chan { color: var(--accent-light); font-weight: 600; flex-shrink: 0; font-size: 11px; text-transform: uppercase; }
.log-lvl-info { color: var(--text-normal); }
.log-lvl-warn { color: var(--warning-light); }
.log-lvl-error { color: var(--danger-light); font-weight: 600; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-normal); display: flex; align-items: center; justify-content: space-between; }
.form-hint { font-size: 11.5px; color: var(--text-dim); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.form-control {
  width: 100%;
  height: 32px;
  padding: 5px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:hover { border-color: rgba(255, 255, 255, 0.2); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { height: auto; min-height: 76px; padding: 8px 11px; font-family: var(--font-mono); font-size: 12px; resize: vertical; }
select.form-control { cursor: pointer; }
select option, .form-control option { background-color: #141416 !important; color: var(--text-main) !important; }

.form-group > div[style*="display: flex"] > .form-control,
.form-group > div > input.form-control,
.form-row > .form-control,
.input-flex-row > .form-control { flex: 1; min-width: 0; }

input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; flex-shrink: 0; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  padding: 20px;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-container {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(8px);
  transition: transform 0.18s ease;
  overflow: hidden;
}
.modal-overlay.active .modal-container { transform: translateY(0); }

.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title { font-size: 15px; font-weight: 600; color: var(--text-main); }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.07); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.modal-tabs { display: flex; gap: 2px; background: var(--bg-input); padding: 2px; border-radius: var(--radius-md); border: 1px solid var(--border-subtle); margin-bottom: 18px; }
.modal-tab-btn {
  flex: 1;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.modal-tab-btn:hover:not(.active) { color: var(--text-main); }
.modal-tab-btn.active { background: rgba(255, 255, 255, 0.09); color: var(--text-main); }

/* Legacy env modal tabs (inline-styled in markup) */
.env-mode-tabs { border-radius: var(--radius-md) !important; background: var(--bg-input) !important; padding: 2px !important; border: 1px solid var(--border-subtle) !important; }
.env-mode-tab { border-radius: var(--radius-sm) !important; font-size: 12.5px !important; font-weight: 500 !important; padding: 6px 12px !important; }

.preset-selector { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chip {
  padding: 4px 11px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.preset-chip:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-main); }
.preset-chip.active { background: rgba(255, 255, 255, 0.08); border-color: var(--border-medium); color: var(--text-main); }

.minimal-details { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; }
.minimal-details summary {
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.minimal-details summary::-webkit-details-marker { display: none; }
.minimal-details summary::after { content: '▾'; font-size: 12px; color: var(--text-dim); transition: transform 0.15s ease; }
.minimal-details[open] summary::after { transform: rotate(180deg); }
.minimal-details summary:hover { color: var(--text-main); }
.minimal-details-body { padding: 12px 14px 14px; border-top: 1px solid var(--border-subtle); }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-medium);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  min-width: 260px;
  max-width: 420px;
  pointer-events: auto;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-info { border-left-color: var(--info); }
.toast.toast-warning { border-left-color: var(--warning); }

/* ---------- Login ---------- */
#login-view { position: fixed; inset: 0; background: var(--bg-canvas); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); padding: 32px 28px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; text-align: center; }
.login-brand .brand-icon { width: 40px; height: 40px; font-size: 15px; border-radius: var(--radius-lg); }
.login-brand h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.login-brand p { font-size: 13px; color: var(--text-muted); }

/* ---------- Website workspace banner ---------- */
.ws-banner { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); margin-bottom: 22px; overflow: hidden; }
.ws-banner-header { padding: 18px 22px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.ws-banner-identity { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }

.ws-breadcrumbs { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.ws-back-crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); cursor: pointer; text-decoration: none; font-weight: 500; }
.ws-back-crumb:hover { color: var(--text-main); }
.ws-crumb-sep { color: var(--text-dim); }
.ws-crumb-current { color: var(--text-main); font-weight: 500; }

.ws-title-row { display: flex; align-items: center; gap: 10px; }
.ws-title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-main); line-height: 1.2; }

.ws-meta-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.ws-meta-sep { color: var(--text-dim); font-size: 10px; }
.ws-meta-item { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); }
.ws-meta-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--accent-light); text-decoration: none; }
.ws-meta-link:hover { text-decoration: underline; }
.ws-meta-link.offline { color: var(--text-dim); cursor: not-allowed; text-decoration: none !important; }
.ws-meta-sha { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-normal); background: rgba(255, 255, 255, 0.05); padding: 0 6px; border-radius: var(--radius-xs); border: 1px solid var(--border-subtle); }

.ws-actions-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ws-actions-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ws-btn-stop { color: var(--danger-light) !important; border-color: var(--danger-border) !important; }
.ws-btn-stop:hover { background: var(--danger-bg) !important; }
.ws-btn-delete { background: transparent !important; border: 1px solid var(--danger-border) !important; color: var(--danger-light) !important; padding: 0 9px !important; }
.ws-btn-delete:hover { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }

.ws-tabs-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 12px;
  border-top: 1px solid var(--border-subtle);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.ws-tab-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}
.ws-tab-item svg { opacity: 0.6; flex-shrink: 0; }
.ws-tab-item:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.04); }
.ws-tab-item.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-medium);
}
.ws-tab-item.active svg { opacity: 1; stroke: var(--text-main); }

/* ---------- Pagination ---------- */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-dim); }
.pagination-bar:empty { display: none; }
.pagination-info { font-size: 12px; color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: 4px; }
.page-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.page-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); color: var(--text-main); }
.page-btn.active { background: rgba(255, 255, 255, 0.1); border-color: var(--border-medium); color: var(--text-main); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Audit ---------- */
.audit-actor-pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; color: var(--text-main); font-size: 12.5px; }
.audit-actor-dot { width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); color: var(--text-normal); font-size: 9.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; text-transform: uppercase; }

/* ---------- Environment variables ---------- */
.env-quick-add-card { padding: 14px 18px; margin-bottom: 16px; }
.env-quick-add-bar { display: grid; grid-template-columns: 1.1fr 1.9fr auto auto; gap: 12px; align-items: end; }
.env-quick-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.env-quick-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.env-mono-input { font-family: var(--font-mono); font-size: 12.5px; }

.env-visibility-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background var(--transition-fast);
}
.env-visibility-btn.is-secret { background: var(--warning-bg); color: var(--warning-light); border: 1px solid var(--warning-border); }
.env-visibility-btn.is-public { background: transparent; color: var(--text-muted); border: 1px solid var(--border-medium); }
.env-visibility-btn:hover { filter: brightness(1.15); }

.env-table td { vertical-align: middle; }
.env-key-badge { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; color: var(--text-main); display: inline-block; cursor: pointer; word-break: break-all; padding: 1px 0; border-bottom: 1px dashed transparent; }
.env-key-badge:hover { border-bottom-color: var(--text-dim); }
.env-val-box {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-normal);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.env-val-box.masked { color: var(--text-dim); letter-spacing: 0.1em; cursor: pointer; user-select: none; }
.env-val-box.masked:hover { border-color: var(--border-medium); color: var(--text-muted); }
.env-row-editing td { background: rgba(255, 255, 255, 0.03) !important; }

.env-raw-textarea {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-terminal);
  border: 1px solid var(--border-medium);
  color: var(--text-normal);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  resize: vertical;
  min-height: 300px;
  tab-size: 2;
  white-space: pre;
  height: auto;
}

/* GitHub token rows */
.gh-token-row { align-items: center; }

/* Mobile bottom navigation (hidden on desktop) */
.mobile-bottom-nav { display: none; }

/* ---------- Responsive (Minimal, Uncluttered Mobile & Tablet Layout) ---------- */
@media (max-width: 1080px) {
  .content-area { padding: 22px 20px 34px; }
  .top-header { padding: 0 20px; }
  .env-quick-add-bar { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  /* Remove top-left hamburger menu and sidebar drawer completely on mobile */
  .mobile-menu-btn,
  .sidebar,
  .sidebar-backdrop,
  #global-add-website-btn {
    display: none !important;
  }

  .projects-grid { grid-template-columns: 1fr; }
  .top-header { padding: 0 16px; height: 50px; }
  .content-area { padding: 16px 14px 78px; }
  .breadcrumbs .crumb-separator, .breadcrumbs .crumb-project { display: none !important; }
  .env-quick-add-bar { grid-template-columns: 1fr; gap: 10px; }
  .env-quick-submit .env-quick-label { display: none; }
  .gh-token-row { grid-template-columns: 1fr auto auto !important; }
  .gh-token-row .gh-token-label-input { grid-column: 1 / -1; }
  .ws-banner-header { padding: 14px 16px 14px; gap: 12px; }
  .ws-banner-identity { min-width: 0; width: 100%; }
  .ws-actions-toolbar { width: 100%; justify-content: flex-start; gap: 8px; }
  .ws-tabs-bar {
    padding: 10px 12px 14px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden !important;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  /* Clean Bottom Navigation Bar (Overview, Websites, Add Site, Settings, Log Out) */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    z-index: 25;
    flex-shrink: 0;
  }
  .mobile-nav-item {
    background: transparent;
    border: none;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 2px;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item svg { width: 17px; height: 17px; }
  .mobile-nav-item.active { color: var(--accent-light); font-weight: 600; }
  .mobile-nav-logout { color: var(--danger-light); opacity: 0.85; }
  .mobile-nav-logout:hover { opacity: 1; }
  .mobile-nav-add-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-nav-add-circle svg { width: 14px; height: 14px; }
  .mobile-nav-add { color: var(--text-normal); }
}

@media (max-width: 680px) {
  /* Collapse multi-column form grids cleanly to single column on phones */
  .modal-grid-3,
  .modal-grid-2,
  .form-row,
  .tfa-qr-grid {
    grid-template-columns: 1fr !important;
  }

  .tfa-qr-grid {
    justify-items: center;
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 20px; }

  /* Compact, uncluttered headers and toolbars */
  .view-header { gap: 10px; margin-bottom: 16px; }
  .view-title-group h1 { font-size: 18px; }
  .view-title-group p { font-size: 12px; }
  .view-actions { width: 100%; gap: 6px; }
  .filter-pills {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden !important;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
  }
  .filter-pills .pill { white-space: nowrap; flex-shrink: 0; }

  /* Hide non-essential container slug metadata in workspace banner on small screens */
  .ws-meta-optional { display: none; }
  .ws-banner { margin-bottom: 16px; }
  .ws-title { font-size: 17px; }
  .ws-meta-line { font-size: 12px; gap: 6px; }
  .ws-tabs-bar {
    padding: 10px 12px 14px;
    gap: 8px;
  }
  .ws-tab-item {
    padding: 8px 12px;
    font-size: 12.5px;
    margin: 0;
  }

  /* Ensure all horizontal scrollers on mobile never scroll vertically and have space above scrollbar */
  .table-responsive,
  .pipeline-track,
  .modal-tabs {
    overflow-x: auto;
    overflow-y: hidden !important;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }

  /* Flexible search and filter inputs on mobile */
  #projects-search-input,
  #audit-search-input,
  #audit-category-filter,
  #env-search-input,
  #log-search-input,
  #log-channel-filter,
  #log-level-filter {
    width: auto !important;
    flex: 1 1 140px;
    min-width: 0;
  }

  /* Compact cards and tables (clean horizontal scroll without stacked label clutter) */
  .card { margin-bottom: 16px; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 14px; }
  .table th, .table td { padding: 9px 12px; font-size: 12.5px; }

  /* Clean centered modals adapted for mobile screens */
  .modal-overlay { padding: 12px; }
  .modal-container {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--radius-xl);
  }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; -webkit-overflow-scrolling: touch; }
  .modal-footer { padding: 12px 16px !important; flex-wrap: wrap; gap: 8px; }
  .modal-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .modal-tab-btn { white-space: nowrap; font-size: 12px; padding: 6px 8px; }

  /* Logs console height on mobile */
  .log-console-wrapper {
    height: calc(100dvh - 210px);
    min-height: 300px;
  }
  .log-toolbar { padding: 8px 10px; gap: 8px; }
  .log-filters { width: 100%; }
  .log-terminal { padding: 10px 12px; font-size: 11.5px; }

  /* Prevent iOS Safari zoom on input focus */
  input.form-control,
  select.form-control,
  textarea.form-control {
    font-size: 16px;
  }

  /* Toasts */
  .toast-container { left: 12px; right: 12px; bottom: 66px; }
  .toast { min-width: 0; width: 100%; max-width: none; }

  /* Pagination bar */
  .pagination-bar { padding: 10px 14px; gap: 8px; }
}

@media (max-width: 440px) {
  .top-header { padding: 0 12px; height: 50px; }
  .content-area { padding: 14px 12px 78px; }
  .server-pill span#server-status-text { display: none; }
  .server-pill { padding: 5px; }
  .project-card { padding: 14px; }
  .login-card { padding: 24px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
