/* Router Console Styles */

:root {
  --bg: #0a0e1a;
  --bg-secondary: #0f1420;
  --bg-card: #151a2b;
  --bg-hover: #1c2236;
  --border: #1f2540;
  --text: #e8ecf5;
  --text-muted: #8b93a8;
  --text-dim: #5b6478;
  --accent: #5b8def;
  --accent-hover: #7aa0f5;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --mono: 'SF Mono', Monaco, 'Cascadia Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.logo-mark {
  color: var(--accent);
  font-size: 20px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 4px;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--bg-hover);
  color: var(--accent);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  display: inline-block;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.user-info .user-name {
  font-weight: 600;
  font-size: 13px;
}

.user-info .user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Main Content */
.main-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 24px;
}

.token-config {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.token-config select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.status-dot.offline {
  background: var(--danger);
}

/* Pages */
.page {
  display: none;
  padding: 32px;
  flex: 1;
}

.page.active {
  display: block;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 20px;
  font-weight: 600;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
}

.stat-trend {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-trend.positive {
  color: var(--success);
}

.stat-trend.negative {
  color: var(--danger);
}

/* Stat card enhancements */
.stat-card {
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #5b8def, #a78bfa);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s;
}

.stat-card:hover::before {
  transform: scaleX(1);
}

.stat-card:hover {
  border-color: rgba(91, 141, 239, 0.4);
  transform: translateY(-2px);
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.stat-icon-sm {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.stat-icon-sm.icon-blue { background: rgba(91, 141, 239, 0.15); color: #5b8def; }
.stat-icon-sm.icon-green { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.stat-icon-sm.icon-purple { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
.stat-icon-sm.icon-amber { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }

.spark {
  width: 100%;
  height: 32px;
  margin: 8px 0 6px;
  display: block;
}

.spark path.line {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark path.area {
  opacity: 0.2;
}

/* Activity Feed */
.activity-feed {
  max-height: 240px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeInUp 0.4s ease;
}

.activity-item:last-child {
  border-bottom: none;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-dot.quote { background: #5b8def; box-shadow: 0 0 6px #5b8def; }
.activity-dot.settle { background: #a78bfa; box-shadow: 0 0 6px #a78bfa; }
.activity-dot.success { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.activity-dot.warn { background: #fbbf24; box-shadow: 0 0 6px #fbbf24; }

.activity-main {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.activity-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.activity-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Mode Distribution */
.mode-distribution {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.mode-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.mode-dot-rt { background: #4ade80; }
.mode-dot-batch { background: #fbbf24; }
.mode-dot-net { background: #a78bfa; }

.mode-pct {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
}

.mode-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  overflow: hidden;
}

.mode-bar-fill {
  height: 100%;
  transition: width 0.6s ease;
  border-radius: 3px;
}

.mode-fill-rt { background: linear-gradient(90deg, #4ade80, #22d3ee); }
.mode-fill-batch { background: linear-gradient(90deg, #fbbf24, #f472b6); }
.mode-fill-net { background: linear-gradient(90deg, #a78bfa, #5b8def); }

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.info-label {
  color: var(--text-muted);
  font-size: 13px;
}

.info-value {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 13px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.form-field label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-field input,
.form-field select,
.form-field textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--sans);
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-field textarea {
  min-height: 100px;
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--sans);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.btn-secondary:hover {
  border-color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #ef4444;
}

.btn-success {
  background: var(--success);
  color: #0a0e1a;
}

.btn-success:hover {
  background: #22c55e;
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Result Box */
.result-box {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

.result-box.visible {
  display: block;
}

.result-box.success {
  border-left-color: var(--success);
}

.result-box.error {
  border-left-color: var(--danger);
}

/* Data Display */
.data-display {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: auto;
  max-height: 500px;
  white-space: pre;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.data-table td {
  font-family: var(--mono);
  font-size: 12px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-style: italic;
}

/* Circuit breaker list */
.circuit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  margin-bottom: 8px;
}

.circuit-item .status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.circuit-item .status-badge.open {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger);
}

.circuit-item .status-badge.closed {
  background: rgba(74, 222, 128, 0.2);
  color: var(--success);
}

/* Utilization bar */
.utilization-bar {
  display: inline-block;
  width: 100px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-right: 8px;
  vertical-align: middle;
}

.utilization-fill {
  height: 100%;
  background: var(--success);
  transition: width 0.3s;
}

.utilization-fill.warning {
  background: var(--warning);
}

.utilization-fill.critical {
  background: var(--danger);
}

/* Integration / connector status */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-header-row h3 { margin: 0; }
.link-muted { font-size: 13px; color: var(--text-muted); text-decoration: none; }
.link-muted:hover { color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.text-muted { color: var(--text-muted); }

.connector-list { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.connector-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.connector-main { flex: 1; min-width: 0; }
.connector-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-left: 8px;
}
.connector-msg { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.connector-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.conn-active { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.conn-configured { background: rgba(91, 141, 239, 0.15); color: var(--accent); }
.conn-stub { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.conn-offline { background: rgba(139, 147, 168, 0.15); color: var(--text-muted); }
.conn-error { background: rgba(248, 113, 113, 0.15); color: var(--danger); }

/* Responsive */
@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Portfolio bars */
.pf-bar-item {
  margin-bottom: 14px;
}
.pf-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.pf-bar-pct {
  font-family: var(--mono);
  color: var(--text-muted);
  font-size: 12px;
}
.pf-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}
.pf-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  transition: width 0.4s;
}

/* Recommendations */
.rec-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}
.rec-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border-left: 3px solid var(--text-muted);
}
.rec-item.rec-high { border-left-color: var(--danger); }
.rec-item.rec-medium { border-left-color: var(--warning); }
.rec-item.rec-low { border-left-color: var(--success); }

.rec-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-muted);
  white-space: nowrap;
}
.rec-content {
  flex: 1;
}
.rec-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  text-transform: capitalize;
}
.rec-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Yield items */
.yield-item {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-radius: 6px;
  margin-bottom: 8px;
}
.yield-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.yield-apy {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--success);
}
.yield-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}
