:root {
  /* ==========================================================================
     INSTITUTIONAL LIGHT THEME (SWISS BANKING & ENTERPRISE FINTECH TERMINAL)
     ========================================================================== */
  --bg-canvas: #f8fafc;          /* Pure alabaster canvas (slate-50) */
  --bg-surface: #ffffff;         /* Crisp pure white cards and panels */
  --bg-surface-alt: #f1f5f9;     /* Slate-100: headers, secondary cards */
  --bg-surface-hover: #f8fafc;   /* Slate-50 hover */
  
  --border-subtle: #e2e8f0;      /* Slate-200: Elegant hairline borders */
  --border-strong: #cbd5e1;      /* Slate-300: Strong structural borders */
  --border-accent: #2563eb;      /* Electric cobalt accent */
  --border-gold: #f59e0b;        /* Sovereign amber/gold accent */

  --text-main: #0f172a;          /* Slate-900: High-contrast primary text */
  --text-secondary: #334155;     /* Slate-700: Section headers and readable copy */
  --text-muted: #64748b;         /* Slate-500: Subtitles, column headers */
  --text-dim: #94a3b8;           /* Slate-400: Micro tags, timestamps */

  /* Sovereign Institutional Accents */
  --brand-navy: #0a2540;         /* Sovereign deep navy */
  --brand-cobalt: #2563eb;       /* Institutional electric cobalt */
  --brand-cobalt-light: #eff6ff; /* Soft blue tint */
  --accent-cyan: #0284c7;        /* Sky-600 */
  --accent-blue: #2563eb;        /* Cobalt blue */
  --accent-emerald: #059669;     /* Emerald-600: Clearing & Solvency */
  --accent-emerald-light: #ecfdf5;
  --accent-amber: #d97706;       /* Amber-600: Collateral & Yield */
  --accent-amber-light: #fffbeb;
  --accent-rose: #dc2626;        /* Red-600: Danger / Circuit Breaker */
  --accent-rose-light: #fef2f2;
  --accent-purple: #4f46e5;      /* Indigo-600: Senior Notes & UCC */
  --accent-purple-light: #eef2ff;

  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.09), 0 8px 10px -6px rgba(15, 23, 42, 0.04);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

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

body {
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* App Container */
#app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.brand-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--brand-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  background: #0f172a;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.nav-links {
  list-style: none;
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  margin-bottom: 3px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 13px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
}

.nav-btn:hover {
  background: var(--bg-surface-alt);
  color: var(--brand-navy);
}

.nav-btn.active {
  background: var(--brand-cobalt-light);
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--brand-cobalt);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08);
}

.nav-icon {
  font-size: 16px;
  display: inline-flex;
  width: 20px;
  justify-content: center;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
  animation: pulse 2s infinite;
}

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

/* Main Content Area */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-canvas);
}

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
  z-index: 5;
}

.page-headline {
  font-size: 17px;
  font-weight: 800;
  color: var(--brand-navy);
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.2px;
}

.tag-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--brand-cobalt-light);
  color: var(--brand-cobalt);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

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

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  font-family: var(--font-sans);
}

.btn-primary {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-surface-alt);
  border-color: #94a3b8;
  color: var(--brand-navy);
}

.btn-danger {
  background: var(--accent-rose-light);
  border-color: #fecaca;
  color: var(--accent-rose);
  font-weight: 700;
}

.btn-danger:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* Modules View Switching */
.view-panel {
  display: none;
  animation: fadeIn 0.2s ease forwards;
}

.view-panel.active {
  display: block;
}

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

/* Common Grid & Cards */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1024px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 20px;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-navy);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}

/* Stat Widgets */
.stat-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.stat-widget:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--brand-navy);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.stat-sub {
  font-size: 11px;
  color: var(--accent-emerald);
  margin-top: 3px;
  font-weight: 600;
}

/* Code Display & Terminal */
pre.code-block {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #f8fafc;
  overflow-x: auto;
  line-height: 1.6;
}

.code-keyword { color: #f43f5e; font-weight: 600; }
.code-func { color: #38bdf8; }
.code-type { color: #818cf8; }
.code-comment { color: #94a3b8; font-style: italic; }
.code-string { color: #34d399; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-emerald { 
  background: var(--accent-emerald-light); 
  color: #065f46; 
  border: 1px solid #a7f3d0; 
}
.badge-amber { 
  background: var(--accent-amber-light); 
  color: #92400e; 
  border: 1px solid #fde68a; 
}
.badge-cyan { 
  background: var(--brand-cobalt-light); 
  color: #1e40af; 
  border: 1px solid #bfdbfe; 
}
.badge-red { 
  background: var(--accent-rose-light); 
  color: #991b1b; 
  border: 1px solid #fecaca; 
}
.badge-purple { 
  background: var(--accent-purple-light); 
  color: #3730a3; 
  border: 1px solid #c7d2fe; 
}

/* Table Styling */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--bg-surface);
}

table.data-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
}

table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  background: var(--bg-surface);
}

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

table.data-table tr:hover td {
  background: #f8fafc;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: all 0.18s;
  box-shadow: var(--shadow-xs);
  font-family: var(--font-sans);
}

.form-input:focus, .form-select:focus {
  border-color: var(--brand-cobalt);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Range Slider */
input[type="range"] {
  accent-color: var(--brand-cobalt);
  cursor: pointer;
}

/* Notifications Toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brand-navy);
  border: 1px solid #1e293b;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  font-size: 13px;
  color: #ffffff;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   INSTITUTIONAL GLASS & 3D ELEVATIONS (LIGHT THEME)
   ========================================================================== */
.liquid-glass-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.liquid-glass-panel:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.perspective-vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.vault-card-3d {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 18px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.vault-card-3d:hover {
  transform: translateY(-3px);
  border-color: #94a3b8;
  box-shadow: var(--shadow-lg);
}

.vault-card-gold {
  border-top: 3px solid var(--accent-amber);
}

.vault-card-gold:hover {
  border-color: var(--accent-amber);
  box-shadow: 0 10px 20px -3px rgba(217, 119, 6, 0.12);
}

.vault-card-cyan {
  border-top: 3px solid var(--brand-cobalt);
}

.vault-card-cyan:hover {
  border-color: var(--brand-cobalt);
  box-shadow: 0 10px 20px -3px rgba(37, 99, 235, 0.12);
}

.vault-card-emerald {
  border-top: 3px solid var(--accent-emerald);
}

.vault-card-emerald:hover {
  border-color: var(--accent-emerald);
  box-shadow: 0 10px 20px -3px rgba(5, 150, 105, 0.12);
}

.vault-card-purple {
  border-top: 3px solid var(--accent-purple);
}

.vault-card-purple:hover {
  border-color: var(--accent-purple);
  box-shadow: 0 10px 20px -3px rgba(79, 70, 229, 0.12);
}

.sub-account-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* Institutional Terminal Console */
.terminal-window {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.terminal-header {
  background: #1e293b;
  padding: 8px 14px;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.terminal-body {
  padding: 16px;
  color: #38bdf8;
  max-height: 240px;
  overflow-y: auto;
  line-height: 1.6;
  background: #0f172a;
}

.glow-pill-emerald {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-emerald-light);
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.glow-pill-cyan {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-cobalt-light);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}
