:root {
  /* Curated Premium Dark HSL Palette */
  --bg-primary: #05070f;
  --bg-secondary: #090c1d;
  --card-bg: rgba(10, 14, 33, 0.65);
  --card-border: rgba(255, 255, 255, 0.07);
  
  --text-main: #f8fafc;
  --text-muted: #64748b;
  
  /* Glowing modern accents */
  --primary: #6366f1; /* Indigo */
  --cyan: #06b6d4;
  --green: #10b981;
  --red: #f43f5e;
  --yellow: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  position: relative;
  padding: 1rem 1.5rem;
}

/* Background Gradients */
.glow-bg {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
}
.glow-primary {
  top: -5%;
  left: -5%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.4) 0%, transparent 70%);
}
.glow-cyan {
  bottom: 5%;
  right: -5%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.4) 0%, transparent 70%);
}

header {
  width: 100%;
  max-width: 1200px;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
}

.brand h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #cbd5e1, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand p {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 0.15rem;
  font-weight: 600;
}

.brand .logo-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand .logo-icon {
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 3-Column Grid Layout */
.grid-layout {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 290px 1fr 320px;
  gap: 1.25rem;
  flex: 1;
}

@media (max-width: 1024px) {
  .grid-layout {
    grid-template-columns: 1fr 1fr;
    overflow-y: auto;
  }
  body {
    overflow-y: auto;
  }
}

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

.col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Glassmorphism Card style */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.card.compact {
  height: calc(50% - 0.625rem);
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: -0.01em;
}

.card-description {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-CONNECTED, .status-CONFIGURED {
  background: rgba(16, 185, 129, 0.06);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-AWAITING_QR {
  background: rgba(245, 158, 11, 0.06);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-DISCONNECTED, .status-AUTH_FAILURE, .status-UNCONFIGURED {
  background: rgba(244, 63, 94, 0.06);
  color: var(--red);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.status-INITIALIZING {
  background: rgba(6, 182, 212, 0.06);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.ai-pill {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  text-transform: uppercase;
  border: 1px solid rgba(99, 102, 241, 0.15);
}

/* QR Link Visual */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.06);
  padding: 0.75rem;
}

.qr-container img {
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  max-width: 130px;
  height: auto;
  border: 2px solid white;
}

.qr-container p {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.qr-placeholder {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* Health status list */
.status-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  justify-content: center;
}

.status-item {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: justify;
  gap: 0.75rem;
}

.status-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.status-item-title {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-main);
}

.status-item-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.stat-label {
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 0.25rem;
}

/* Center Column Cards */
.card.log-card {
  height: 280px;
}

.card.deck-card {
  flex: 1;
}

.terminal {
  background: #03040a;
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 0.85rem;
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  color: #a5b4fc;
  height: calc(100% - 2rem);
  overflow-y: auto;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8);
  line-height: 1.5;
}

.log-line {
  margin-bottom: 0.2rem;
  white-space: pre-wrap;
}

.log-info { color: #818cf8; }
.log-success { color: var(--green); }
.log-warn { color: var(--yellow); }
.log-error { color: var(--red); }

/* Simulation Deck controls */
.simulation-inputs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.simulation-inputs input {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  color: white;
  font-size: 0.8rem;
  outline: none;
  transition: all 0.3s ease;
}

.simulation-inputs input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

.diagnostic-actions-deck {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  flex: 1;
}

.deck-btn {
  flex-direction: column;
  padding: 0.75rem 0.5rem;
  border-radius: 12px;
  height: 80px;
  gap: 0.25rem;
}

.btn-num {
  font-size: 1.25rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
}

.btn-lbl {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}

.primary-num { color: var(--primary); }
.cyan-num { color: var(--cyan); }
.yellow-num { color: var(--yellow); }

.full-width-btn {
  grid-column: 1 / -1;
  height: 48px;
  flex-direction: row;
  font-weight: 700;
}

/* Right Column Card (AI Chat) */
.card.chat-card-full {
  height: 100%;
}

.chat-messages {
  background: #03040a;
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8);
  margin-bottom: 0.75rem;
  height: 400px;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: white;
  border-bottom-right-radius: 2px;
}

.chat-bubble.agent {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.02);
  border-bottom-left-radius: 2px;
}

.chat-input-row .chat-input {
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
}

.btn-icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1rem;
  border-radius: 8px;
}

/* Scrollbar tweaks */
.terminal::-webkit-scrollbar, .chat-messages::-webkit-scrollbar {
  width: 4px;
}

.terminal::-webkit-scrollbar-thumb, .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

/* Button general */
.btn {
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #4f46e5 0%, var(--primary) 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.btn-glow-green {
  background: linear-gradient(135deg, var(--green) 0%, #059669 100%);
}

.btn-glow-green:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-mini {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 4px;
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

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

.pulse {
  animation: shadowPulse 2s infinite;
}

@keyframes shadowPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}
