:root {
  --bg-primary: #060913;
  --bg-secondary: #0c1222;
  --bg-card: rgba(16, 24, 45, 0.7);
  --border-cyan: rgba(0, 240, 255, 0.25);
  --border-emerald: rgba(16, 185, 129, 0.25);
  --border-glow: rgba(0, 240, 255, 0.5);
  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #00f0ff;
  --accent-cyan-glow: rgba(0, 240, 255, 0.35);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.35);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Outfit', -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background Grids & Ambient Glow */
.ambient-glow {
  position: fixed;
  top: -20%;
  left: -10%;
  width: 140vw;
  height: 140vh;
  background: radial-gradient(circle at 50% 20%, rgba(0, 240, 255, 0.08) 0%, rgba(16, 185, 129, 0.03) 40%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.grid-overlay {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 1;
}

/* Glassmorphism Cards */
.glass-panel, .glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 1px 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  transition: all 0.25s ease-in-out;
}

.glass-card:hover {
  border-color: var(--border-glow);
  box-shadow: 0 12px 40px 0 rgba(0, 240, 255, 0.15), inset 0 1px 1px 0 rgba(255, 255, 255, 0.2);
}

/* Authentication Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 0 50px rgba(0, 240, 255, 0.2);
}

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

.security-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  letter-spacing: 1px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.hud-logo {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-cyan);
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-shadow: 0 0 15px var(--accent-cyan-glow);
}

.hud-glyph {
  color: var(--accent-emerald);
}

.auth-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  background: rgba(12, 18, 34, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  transition: all 0.2s ease;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.25);
}

.error-msg {
  color: var(--accent-rose);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 14px;
  padding: 8px;
  background: rgba(244, 63, 94, 0.1);
  border-left: 3px solid var(--accent-rose);
}

.hud-button {
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  letter-spacing: 1px;
}

.primary-btn {
  background: linear-gradient(135deg, #00f0ff 0%, #00a8ff 100%);
  color: #040914;
  border: none;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.primary-btn:hover {
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.7);
  transform: translateY(-1px);
}

.outline-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.outline-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.05);
}

/* App Layout */
.app-layout {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border-top: none;
  border-left: none;
  border-right: none;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-glyph {
  font-size: 26px;
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan);
}

.logo-text .title {
  display: block;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-main);
}

.logo-text .sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
}

.cluster-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--border-emerald);
  border-radius: 20px;
  color: var(--accent-emerald);
}

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

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: rgba(8, 14, 28, 0.7);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab.active {
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.backend-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.backend-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.backend-input {
  width: 170px !important;
  font-size: 11px !important;
  padding: 6px 10px !important;
  border-color: rgba(0, 240, 255, 0.3) !important;
}

.main-content {
  flex: 1;
  padding: 28px;
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.tab-pane.active {
  display: block;
}

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

.section-title-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.section-title-bar h2 {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 1.5px;
}

.section-title-bar h2 span {
  color: var(--accent-cyan);
}

.title-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* Grid Topologies */
.grid-cards-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.node-card {
  padding: 20px;
}

.node-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.node-title {
  display: flex;
  gap: 12px;
  align-items: center;
}

.node-icon {
  font-size: 24px;
}

.node-title h3 {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 1px;
}

.node-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.status-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
}

.chip-online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald);
}

.chip-ready {
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
}

.node-stats {
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 4px;
}

.stat-row span {
  color: var(--text-dim);
}

/* Telemetry Bar */
.telemetry-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  padding: 18px 24px;
  gap: 18px;
  text-align: center;
}

.telemetry-item .label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.telemetry-item .val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
}

.highlight-cyan { color: var(--accent-cyan); text-shadow: 0 0 10px var(--accent-cyan-glow); }
.highlight-emerald { color: var(--accent-emerald); text-shadow: 0 0 10px var(--accent-emerald-glow); }

/* Pipeline Schematic */
.pipeline-schematic-card {
  padding: 24px;
  margin-bottom: 24px;
}

.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.locked-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid var(--accent-rose);
  color: var(--accent-rose);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
}

.pipeline-explainer {
  font-size: 14px;
  color: var(--text-dim);
  max-width: 900px;
  margin-bottom: 28px;
}

.pipeline-steps-grid {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.step-card {
  flex: 1;
  min-width: 220px;
  background: rgba(11, 19, 36, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 16px;
  position: relative;
}

.step-card.highlight-step {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

.step-num {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.15);
  margin-bottom: 4px;
}

.step-card h4 {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.step-card p {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
  min-height: 48px;
}

.step-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.tag-cyan { background: rgba(0, 240, 255, 0.15); color: var(--accent-cyan); }
.tag-emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.step-arrow {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: bold;
}

/* Models Registry Table */
.models-registry-card {
  padding: 24px;
}

.hud-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 14px;
}

.hud-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 1px;
}

.hud-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lock-tag {
  color: var(--accent-amber);
  font-size: 11px;
}

/* Playground */
.playground-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 960px) {
  .playground-grid { grid-template-columns: 1fr; }
}

.playground-input-card, .playground-output-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.card-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

textarea#play-prompt {
  resize: vertical;
  min-height: 140px;
  margin-bottom: 16px;
}

.prompt-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.stage-inspector {
  background: rgba(4, 10, 24, 0.95);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.stage-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 700;
  letter-spacing: 1px;
}

.inspector-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.inspector-row {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 6px;
}

.inspector-row .k {
  color: var(--text-muted);
  margin-right: 8px;
}

.enhanced-text {
  background: rgba(0, 0, 0, 0.4);
  padding: 8px;
  border-radius: 4px;
  margin-top: 4px;
  color: var(--text-main);
  white-space: pre-wrap;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stream-telemetry {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
}

.stream-console {
  flex: 1;
  min-height: 300px;
  background: #020611;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #38bdf8;
  overflow-y: auto;
  white-space: pre-wrap;
}

.stream-footer {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* API Keys & Code SDK */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 860px) {
  .grid-2-col { grid-template-columns: 1fr; }
}

.key-box {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.key-box input {
  color: var(--accent-emerald) !important;
  font-weight: 700;
}

.key-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.code-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.code-tab {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.code-tab.active {
  background: rgba(0, 240, 255, 0.2);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.code-box {
  background: #020611;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #a5f3fc;
  overflow-x: auto;
}

/* Remote Access Explainer */
.remote-explainer-card {
  padding: 28px;
}

.explainer-header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.icon-big {
  font-size: 40px;
}

.sub-lead {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 4px;
}

.remote-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 800px) {
  .remote-comparison-grid { grid-template-columns: 1fr; }
}

.comp-box {
  padding: 20px;
  border-radius: var(--radius-sm);
}

.local-box {
  background: rgba(244, 63, 94, 0.05);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.local-box h4 {
  color: var(--accent-rose);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

.remote-box {
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.remote-box h4 {
  color: var(--accent-emerald);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

.comp-box ul {
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-dim);
}

.comp-box li {
  margin-bottom: 8px;
}

.tunnel-command-box {
  background: rgba(11, 20, 42, 0.8);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  padding: 20px;
}

.tunnel-command-box h4 {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.terminal-box {
  background: #010409;
  padding: 14px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #38bdf8;
  margin: 12px 0;
  border-left: 3px solid var(--accent-cyan);
}

.note-text {
  font-size: 13px;
  color: var(--text-dim);
}

.hidden { display: none !important; }
