/* Technical Minimalist Design System — Base
 *
 * Shared reset, layout, components, and neutral tokens.
 * Style-specific overrides live in theme-product.css / theme-citadel.css.
 */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@400;500;600;700&family=Inter+Tight:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ── CSS Custom Properties ── */
:root,
[data-theme="light"] {
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', monospace;
  --bg: #F8FAFC;
  --bg-rgb: 248, 250, 252;
  --surface: #FFFFFF;
  --surface-rgb: 255, 255, 255;
  --text: #0F172A;
  --text-secondary: #475569;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --accent: #10B981;
  --accent-hover: #059669;
  --accent-pulse: #34D399;
  --accent-bg: rgba(16, 185, 129, 0.08);
  --accent-glow: rgba(16, 185, 129, 0.25);
  --muted: #94A3B8;
  --card: var(--surface);
  --blue: #3B82F6;
  --blue-bg: rgba(59, 130, 246, 0.08);
  --orange: #F59E0B;
  --orange-bg: rgba(245, 158, 11, 0.08);
  --red: #EF4444;
  --red-bg: rgba(239, 68, 68, 0.08);
  --purple: #8B5CF6;
  --purple-bg: rgba(139, 92, 246, 0.08);
  --danger: var(--red);
  --danger-bg: var(--red-bg);
  --info: var(--blue);
  --info-bg: var(--blue-bg);
  --warning: var(--orange);
  --warning-bg: var(--orange-bg);
  --success-bg: rgba(16, 185, 129, 0.08);
  --sidebar-bg: #FFFFFF;
  --sidebar-active: rgba(16, 185, 129, 0.06);
  --sidebar-border: #E2E8F0;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 16px rgba(0,0,0,0.04);
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --scrollbar-track: #F4F4F5;
  --scrollbar-thumb: #D4D4D8;
}

[data-theme="dark"] {
  --bg: #0B0F1A;
  --bg-rgb: 11, 15, 26;
  --surface: #111827;
  --surface-rgb: 17, 24, 39;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --border: #1E293B;
  --border-light: #1E293B;
  --accent: #10B981;
  --accent-hover: #34D399;
  --accent-pulse: #34D399;
  --accent-bg: rgba(16, 185, 129, 0.12);
  --accent-glow: rgba(16, 185, 129, 0.3);
  --muted: #64748B;
  --card: var(--surface);
  --blue: #60A5FA;
  --blue-bg: rgba(96, 165, 250, 0.12);
  --orange: #FBBF24;
  --orange-bg: rgba(251, 191, 36, 0.12);
  --red: #F87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --purple: #A78BFA;
  --purple-bg: rgba(167, 139, 250, 0.12);
  --danger: var(--red);
  --danger-bg: var(--red-bg);
  --info: var(--blue);
  --info-bg: var(--blue-bg);
  --warning: var(--orange);
  --warning-bg: var(--orange-bg);
  --success-bg: rgba(16, 185, 129, 0.12);
  --sidebar-bg: #0F1320;
  --sidebar-active: rgba(16, 185, 129, 0.08);
  --sidebar-border: #1E293B;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 6px 16px rgba(0,0,0,0.15);
  --topbar-bg: rgba(11, 15, 26, 0.85);
  --scrollbar-track: #111827;
  --scrollbar-thumb: #334155;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.015;
}
[data-theme="dark"] body::after {
  opacity: 0.03;
}

/* ── Typography ── */
h1 {
  font-size: 64px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.section-header {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-family: var(--font-body);
}

.param-group-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: var(--font-mono);
  padding: 6px 0 2px;
  margin-top: 4px;
}

.input-sm {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  outline: none;
}

.input-sm:focus {
  border-color: var(--accent);
}

.combo-header-row:hover {
  background: var(--accent-bg);
}

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

.text-muted {
  color: var(--muted) !important;
}

.text-accent {
  color: var(--accent);
}

.text-danger {
  color: var(--danger) !important;
}

.text-small {
  font-size: 12px;
}

/* ── Scrollbar ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Layout: Sidebar + App Shell ── */
:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 52px;
}

body {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border, var(--border));
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand {
  text-decoration: none;
  color: var(--text);
}

.sidebar-brand-text {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand-text {
  display: none;
}

.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-group {
  margin-top: 8px;
}

.sidebar-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-family: var(--font-body);
  padding: 8px 12px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-group-label {
  text-align: center;
  font-size: 0;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  position: relative;
}

.sidebar-link i {
  font-size: 16px;
  width: 20px;
  line-height: 1;
  text-align: center;
  flex-shrink: 0;
}

/* Normalize BI vs FA icon sizing — FA icons tend to render slightly larger */
.fa-solid, .fa-regular, .fas, .far {
  font-size: inherit;
  line-height: inherit;
  vertical-align: baseline;
}
.bi {
  font-size: inherit;
  line-height: inherit;
  vertical-align: baseline;
}

.sidebar-link:hover {
  background: var(--sidebar-active, var(--card));
  color: var(--text);
}

.sidebar-link:active {
  opacity: 0.7;
  transition: none;
}

.sidebar-link.active {
  background: var(--sidebar-active, var(--accent-bg));
  color: var(--accent);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-link-text {
  display: none;
}

.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 8px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

/* ── App Shell ── */
.app-shell {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
}

body.sidebar-collapsed .app-shell {
  margin-left: var(--sidebar-collapsed-width);
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg, rgba(var(--bg-rgb), 0.92));
  backdrop-filter: var(--glass-blur, blur(8px));
  -webkit-backdrop-filter: var(--glass-blur, blur(8px));
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-page-title {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}

.sidebar-mobile-toggle:hover {
  background: var(--card);
  color: var(--text);
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  padding: 32px 24px;
  max-width: 1400px;
  width: 100%;
}

/* ── Responsive: Sidebar ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 70;
    box-shadow: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }

  .app-shell {
    margin-left: 0 !important;
  }

  .sidebar-mobile-toggle {
    display: inline-flex;
  }

  .sidebar-collapse-btn {
    display: inline-flex;
  }
}

/* ── Sidebar backdrop (mobile) ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 65;
}

.sidebar-backdrop.visible {
  display: block;
}

.section {
  margin-bottom: 64px;
}

.section.inactive {
  opacity: 0.5;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.section.inactive:hover,
.section.inactive:focus-within {
  opacity: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover {
  border-color: var(--muted);
  background: var(--surface);
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.85;
  transition: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #FFFFFF;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--card);
  border-color: var(--border);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* ── Form Inputs ── */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-family: var(--font-body);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

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

.form-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2371717a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 32px;
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  color: var(--text);
  --bs-card-bg: var(--surface);
  --bs-card-color: var(--text);
  --bs-card-border-color: var(--border);
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--muted);
}

.card-selected {
  border-color: var(--accent);
  background: var(--accent-bg);
  transition: none;
}

/* Instant press feedback for any clickable card (vanilla/alpine/unpoly) */
.card[style*="cursor: pointer"]:active,
.card.signal-item:active,
.card.signal-item-up:active {
  transform: scale(0.98);
  opacity: 0.85;
  transition: none;
}

/* ── KPI ── */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ── Tables ── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: var(--card);
  background: transparent;
}

.table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: var(--font-mono);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: rgba(var(--surface-rgb, var(--bg-rgb)), 0.5);
}

.table td.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  font-family: var(--font-mono);
}

.chip:hover {
  border-color: var(--accent);
}

.chip:active {
  transform: scale(0.95);
  opacity: 0.85;
  transition: none;
}

.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
  transition: none;
}

/* ── Status dots ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  position: relative;
}

.status-dot.running {
  background: var(--accent);
}

.status-dot.running::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent-pulse);
  animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.status-dot.completed {
  background: var(--accent);
}

.status-dot.failed {
  background: var(--danger);
}

.status-dot.pending {
  background: var(--warning);
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* ── Status badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
}

.badge-running {
  color: var(--accent);
  background: var(--accent-bg);
}

.badge-completed {
  color: var(--accent);
  background: var(--success-bg);
}

.badge-failed {
  color: var(--danger);
  background: var(--danger-bg);
}

.badge-pending {
  color: var(--warning);
  background: var(--warning-bg);
}

/* ── Progress bar ── */
.progress-bar-track {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Modal overrides (Bootstrap) ── */
.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

.modal-title {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 68px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideInRight 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 360px;
}

.toast.success {
  border-color: var(--accent);
}

.toast.error {
  border-color: var(--danger);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
  gap: 16px;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.3;
}

/* ── Theme toggle ── */
.theme-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
}

.theme-toggle i {
  font-size: 14px;
  line-height: 1;
  width: 14px;
  text-align: center;
}

.theme-toggle:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* ── Style Toggle ── */
.style-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
}

.style-toggle i {
  font-size: 14px;
  line-height: 1;
  width: 14px;
  text-align: center;
}

.style-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Utilities ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Dev Mode Status Indicators ── */
/* Container for marking sections that need work */
[data-status-indicator] {
  position: relative;
}

/* ── Page Header ── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); }

/* ── Glass Card ── */
.glass-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.glass-card:hover { border-color: var(--muted); }
.glass-card:active { opacity: 0.9; transition: none; }
.card-sm { padding: 14px 16px; }
.card-flush { padding: 0; overflow: hidden; }

/* ── Icon Badges ── */
.icon-badge { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.icon-badge.green { background: var(--accent-bg); color: var(--accent); }
.icon-badge.blue { background: var(--blue-bg); color: var(--blue); }
.icon-badge.orange { background: var(--orange-bg); color: var(--orange); }
.icon-badge.red { background: var(--red-bg); color: var(--red); }
.icon-badge.purple { background: var(--purple-bg); color: var(--purple); }
.icon-badge-sm { width: 28px; height: 28px; border-radius: 6px; font-size: 13px; }

/* ── Additional Badge Variants ── */
.badge-cancelled { color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.badge-draft { color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.badge-live { color: var(--accent); background: var(--accent-bg); }
.badge-tested { color: var(--blue); background: var(--blue-bg); }
.badge-phase2 { color: var(--purple); background: var(--purple-bg); }
.badge-experimental { color: var(--orange); background: var(--orange-bg); }
.badge-active { color: var(--accent); background: var(--accent-bg); }
.badge-testing { color: var(--blue); background: var(--blue-bg); }

/* ── Status Dots (v4 variants) ── */
.status-dot.ok { background: var(--accent); }
.status-dot.err { background: var(--red); }
.status-dot.warn { background: var(--orange); }
.status-dot.live { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Chip Variants ── */
.chip-sm { padding: 4px 9px; font-size: 11px; }
.chip.disabled, .chip[disabled] { opacity: 0.8; cursor: default; pointer-events: none; }
.chip.chip-preset { border-style: dashed; }

/* ── Toggle Switch ── */
.toggle-switch { position: relative; display: inline-block; width: 28px; height: 16px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 8px;
  background: var(--border); transition: all 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 12px; height: 12px; left: 2px; bottom: 2px;
  border-radius: 50%; background: var(--text-secondary); transition: all 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(12px); background: #fff; }

/* ── KPI Trend ── */
.kpi-trend { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-family: var(--font-mono); font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.kpi-trend.up { color: var(--accent); background: var(--accent-bg); }
.kpi-trend.down { color: var(--red); background: var(--red-bg); }

/* ── Progress (v4) ── */
.progress-track { width: 100%; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.progress-fill.green { background: linear-gradient(90deg, var(--accent), #34D399); }
.progress-fill.blue { background: linear-gradient(90deg, var(--blue), #93C5FD); }
.progress-fill.orange { background: linear-gradient(90deg, var(--orange), #FDE68A); }
.progress-fill.red { background: linear-gradient(90deg, var(--red), #FCA5A5); }

/* ── Tabs (v4) ── */
.tab-row { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-item { padding: 8px 16px; font-size: 12px; font-weight: 600; font-family: var(--font-body); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; text-transform: uppercase; letter-spacing: 0.06em; }
.tab-item:hover { color: var(--text); }
.tab-item:active { opacity: 0.7; transition: none; }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); transition: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toggle Switch ── */
.toggle { position: relative; width: 36px; height: 20px; border-radius: 10px; background: var(--border); cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle.on::after { transform: translateX(16px); }

/* ── Select Card ── */
.select-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; transition: border-color 0.15s ease; }
.select-card:hover { border-color: var(--accent); }
.select-card:active { transform: scale(0.98); opacity: 0.85; transition: none; }
.select-card.selected { border-color: var(--accent); background: var(--accent-bg); transition: none; }
.select-card .select-card-title { font-size: 13px; font-weight: 600; }
.select-card .select-card-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ── Modal Overlay (v4 custom) ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 80; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
/* Override Bootstrap .modal styles inside custom overlay */
.modal-overlay > .modal {
  display: block;
  position: relative;
  width: auto;
  height: auto;
  inset: unset;
  overflow: visible;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 90vh;
  overflow-y: auto;
  min-width: 360px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}
.modal-overlay > .modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-overlay > .modal .modal-body {
  padding: 20px;
}
.modal-overlay > .modal .modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ── Drawer ── */
.drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 60; backdrop-filter: blur(2px); }
.drawer-overlay.open { display: block; }
.drawer { position: fixed; top: 0; right: -380px; width: 380px; height: 100vh; background: var(--bg); border-left: 1px solid var(--border); z-index: 70; transition: right 0.3s cubic-bezier(0.4,0,0.2,1); overflow-y: auto; padding: 24px; }
.drawer.open { right: 0; }

/* ── View Toggle (Admin/User) ── */
[data-view="user"] .admin-only { display: none !important; }
.view-toggle { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; transition: all 0.15s; font-size: 11px; font-family: var(--font-mono); font-weight: 500; color: var(--muted); }
.view-toggle:hover { border-color: var(--muted); color: var(--text); }
.view-toggle .view-label { text-transform: uppercase; letter-spacing: 0.04em; }
.view-toggle.is-admin { color: var(--accent); border-color: var(--accent); }
.view-toggle.is-admin .view-dot { background: var(--accent); }
.view-toggle.is-user { color: var(--blue); border-color: var(--blue); }
.view-toggle.is-user .view-dot { background: var(--blue); }
.view-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }

/* ── Accordion ── */
.acc { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; overflow: hidden; transition: border-color 0.2s; }
.acc:hover { border-color: var(--muted); }
.acc.open { border-color: var(--accent); }
.acc-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; user-select: none; transition: background 0.15s; }
.acc-head:hover { background: rgba(var(--surface-rgb, var(--bg-rgb)), 0.5); }
.acc-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.acc-icon.green { background: var(--accent-bg); color: var(--accent); }
.acc-icon.blue { background: var(--blue-bg); color: var(--blue); }
.acc-icon.orange { background: var(--orange-bg); color: var(--orange); }
.acc-icon.red { background: var(--red-bg); color: var(--red); }
.acc-icon.purple { background: var(--purple-bg); color: var(--purple); }
.acc-title { font-size: 13px; font-weight: 600; flex: 1; }
.acc-chevron { font-size: 12px; color: var(--muted); transition: transform 0.2s; }
.acc.open .acc-chevron { transform: rotate(180deg); }
.acc-body { display: none; padding: 0 16px 16px; border-top: 1px solid var(--border); }
.acc.open .acc-body { display: block; padding-top: 16px; }

/* ── Feature Toggle ── */
.feat-toggle { position: relative; width: 32px; height: 18px; border-radius: 9px; background: var(--border); cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.feat-toggle.on { background: var(--accent); }
.feat-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.feat-toggle.on::after { transform: translateX(14px); }

/* ── JSON Preview ── */
.json-preview { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.json-preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.json-preview-header .form-label { margin-bottom: 0; font-size: 10px; }
.json-preview pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; font-size: 11px; font-family: var(--font-mono); line-height: 1.5; overflow-x: auto; max-height: 280px; overflow-y: auto; color: var(--text); white-space: pre; tab-size: 2; margin: 0; }
.json-preview pre .json-key { color: var(--blue); }
.json-preview pre .json-str { color: var(--accent); }
.json-preview pre .json-num { color: var(--orange); }
.json-preview pre .json-bool { color: var(--purple); }
.json-preview pre .json-null { color: var(--muted); }

/* ── Docker Service Grid ── */
.svc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.svc-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-family: var(--font-mono); transition: border-color 0.15s; }
.svc-item:hover { border-color: var(--muted); }
.svc-item .svc-name { flex: 1; font-weight: 500; }
.svc-item .svc-meta { font-size: 11px; color: var(--muted); }
.svc-item.healthy { border-left: 3px solid var(--accent); }
.svc-item.unhealthy { border-left: 3px solid var(--red); }
.svc-item.stopped { border-left: 3px solid var(--muted); opacity: 0.6; }

/* ── Data Pipeline Steps ── */
.pipeline { display: flex; align-items: center; gap: 4px; font-size: 11px; font-family: var(--font-mono); flex-wrap: wrap; }
.pipeline-step { padding: 3px 8px; border-radius: 4px; font-size: 11px; font-family: var(--font-mono); border: 1px solid var(--border); color: var(--muted); }
.pipeline-step.done { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.pipeline-step.current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.pipeline-step.error { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.pipeline-step.active { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.pipeline-step.pending { color: var(--muted); }

/* ── Detail Row (expandable table rows) ── */
.detail-row { display: none; }
.detail-row.open { display: table-row; }
.toggle-detail { cursor: pointer; transition: transform 0.2s; display: inline-block; }
.toggle-detail.open { transform: rotate(90deg); }
.detail-inner { padding: 12px 20px; background: var(--surface); border-radius: 6px; }
.resource-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 11px; font-family: var(--font-mono); }
.resource-grid .res-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.resource-grid .res-value { color: var(--text); font-weight: 500; }

/* ── Combination Matrix ── */
.matrix-cell { text-align: center; padding: 6px; font-size: 11px; font-family: var(--font-mono); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.matrix-cell:hover { border-color: var(--accent); background: var(--accent-bg); }
.matrix-cell.best { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.matrix-cell.good { background: var(--blue-bg); border-color: transparent; }
.matrix-cell.poor { background: var(--red-bg); border-color: transparent; color: var(--red); }
.matrix-cell.empty { background: var(--surface); color: var(--muted); opacity: 0.5; }

/* ── Event Feed ── */
.event-feed { max-height: 220px; overflow-y: auto; }
.event-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.event-time { font-family: var(--font-mono); color: var(--muted); min-width: 48px; font-size: 11px; }
.event-type { font-family: var(--font-mono); font-weight: 600; min-width: 56px; text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; }
.event-type.entry { color: var(--accent); }
.event-type.exit { color: var(--blue); }
.event-type.sl { color: var(--red); }
.event-type.trail { color: var(--orange); }
.event-type.regime { color: var(--purple); }
.event-type.circuit { color: var(--red); }
.event-type.stream { color: var(--blue); }
.event-type.job { color: var(--orange); }

/* ── Exchange Badges ── */
.exchange-badge { display: inline-flex; align-items: center; justify-content: center; padding: 2px 6px; border-radius: 3px; font-size: 10px; font-weight: 700; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.4; }
.exchange-badge.binance { background: var(--accent-bg); color: var(--accent); }
.exchange-badge.bybit { background: var(--blue-bg); color: var(--blue); }
.exchange-badge.okx { background: var(--orange-bg); color: var(--orange); }

/* ── Symbol*Exchange Display ── */
.sym-ex { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }
.sym-ex .delim { color: var(--muted); margin: 0 1px; font-weight: 400; }
.sym-ex .exch { font-size: 0.85em; opacity: 0.7; }

/* ── Grid Utilities ── */
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.gap-1 { gap: 4px; }
.gap-6 { gap: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.text-red { color: var(--red); } .text-blue { color: var(--blue); } .text-orange { color: var(--orange); } .text-purple { color: var(--purple); }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: 12px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.border-t { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }

/* ── Quick Action (dashboard) ── */
.quick-action { padding: 8px 16px; border-radius: 8px; transition: background 0.15s; }
.quick-action:hover { background: rgba(var(--surface-rgb, var(--bg-rgb)), 0.5); }

/* ── Topbar Cluster & Metrics ── */
.topbar-cluster { display: flex; align-items: center; gap: 8px; padding: 5px 12px; background: var(--accent-bg); border-radius: 4px; font-size: 12px; font-family: var(--font-mono); font-weight: 500; color: var(--accent); }
.topbar-cluster .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse-dot 2s infinite; }
.topbar-metrics { display: flex; gap: 16px; }
.topbar-metric { font-size: 12px; font-family: var(--font-mono); color: var(--muted); }
.topbar-metric span { color: var(--text); font-weight: 600; }

/* ── Responsive: Grid Utilities ── */
@media (max-width: 1100px) {
  .grid-5, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .svc-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ── Navigation Loading Bar ── */
.nav-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: none;
}
.nav-loading-bar.active {
  opacity: 1;
  width: 70%;
  transition: width 8s cubic-bezier(0.1, 0.5, 0.1, 1);
}
.nav-loading-bar.done {
  width: 100%;
  transition: width 0.15s ease, opacity 0.3s ease 0.15s;
  opacity: 0;
}

/* ── Auth modal ── */
#authModal .auth-code-input {
  font-size: 24px;
  text-align: center;
  letter-spacing: 0.3em;
  font-family: var(--font-mono);
  padding: 12px;
}

/* ── Search & Filter ── */
.search-hidden { display: none !important; }
.search-box { position: relative; }
.search-box input { padding-left: 32px; width: 100%; }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); color: var(--muted);
  font-size: 14px; pointer-events: none;
}

/* ── Collapsible ── */
.collapsible-content {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.collapsible-content:not(.collapsed) { max-height: 2000px; }
[data-collapsible] { cursor: pointer; user-select: none; }
[data-collapsible] .collapse-icon { transition: transform 0.2s ease; }
[data-collapsible].expanded .collapse-icon { transform: rotate(180deg); }
/* Legacy: Bootstrap Icons chevron selectors for backward compat */
[data-collapsible] .bi-chevron-down,
[data-collapsible] .bi-chevron-right { transition: transform 0.2s ease; }
[data-collapsible].expanded .bi-chevron-down { transform: rotate(180deg); }
[data-collapsible].expanded .bi-chevron-right { transform: rotate(90deg); }

/* ── Drag Reorder ── */
[data-drag-list] [draggable="true"] { cursor: grab; }
[data-drag-list] [draggable="true"]:active { cursor: grabbing; }
[data-drag-list] .dragging { opacity: 0.4; }
[data-drag-list] .drag-over { border-top: 2px solid var(--accent); }

/* ── Page Transition ── */
@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-enter { animation: page-fade-in 0.25s ease-out; }

/* ── Split Panel Layout ── */
.split-panel {
  display: grid; grid-template-columns: 340px 1fr;
  gap: 16px; align-items: start;
}
.split-panel-list { max-height: calc(100vh - 200px); overflow-y: auto; }
@media (max-width: 1024px) { .split-panel { grid-template-columns: 1fr; } }

/* ── Chart Placeholder ── */
.chart-placeholder {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  padding: 40px 20px; color: var(--muted); font-size: 12px;
  border: 1px dashed var(--border); border-radius: 6px;
  background: var(--surface);
}
.chart-placeholder i { font-size: 24px; opacity: 0.5; }

/* ── Hero Typography ── */

/* Mono eyebrow above hero or section */
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

/* Hero h1 — display font */
.hero-h1 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px 0;
  /* sizes set per-page (40px dashboard, 56px insights) */
}

/* Quick-action grid (used on dashboard) */
.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

/* Action link tile */
.action-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  transition: border-color 120ms ease, background 120ms ease;
}
.action-link:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.action-link[data-intent="live"]   { border-left: 3px solid var(--accent); }
.action-link[data-intent="read"]   { border-left: 3px solid var(--blue); }
.action-link[data-intent="config"] { border-left: 3px solid var(--purple); }
.action-link[data-intent="maint"]  { border-left: 3px solid var(--orange); }
