:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.app-header {
  height: 60px;
  background-color: #0b1120;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  font-size: 1.5rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.5px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.xp-badge {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.xp-badge .stat-val {
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-action {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-action:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.btn-dispatch {
  background: #7c3aed;
  border-color: #6d28d9;
  color: #fff;
}

.btn-dispatch:hover {
  background: #6d28d9;
}

.btn-alerts {
  background: #0284c7;
  border-color: #0369a1;
  color: #fff;
}

.btn-alerts:hover {
  background: #0369a1;
}

/* Main Dual Pane Layout */
.main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left Pane: Ticket Board & Active Incident */
.left-pane {
  width: 48%;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: #0d1527;
  overflow: hidden;
}

.filter-bar {
  padding: 0.65rem 1rem;
  background: #111a2e;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  white-space: nowrap;
}

.filter-pill {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-pill:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.filter-pill.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

.ticket-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ticket-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.ticket-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.ticket-card.active {
  border-color: var(--primary);
  background: #1e3a5f;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.15);
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.ticket-tags {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.tag-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.tag-k8s { background: #0284c7; color: #fff; }
.tag-aws { background: #d97706; color: #fff; }
.tag-gcp { background: #2563eb; color: #fff; }
.tag-spark { background: #b45309; color: #fff; }
.tag-linux { background: #475569; color: #fff; }

.status-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 12px;
}

.status-idle { background: #334155; color: #94a3b8; }
.status-running { background: #eab308; color: #000; animation: pulse 1.5s infinite; }
.status-resolved { background: #22c55e; color: #000; }
.status-failed { background: #ef4444; color: #fff; }

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

.ticket-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.35rem;
}

.ticket-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Ticket Detail Card (when expanded/selected) */
.ticket-detail-card {
  border-top: 2px solid var(--border-color);
  background: #111c33;
  padding: 1rem;
  max-height: 52%;
  overflow-y: auto;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.3);
}

.detail-tags {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.urgency-tag {
  background: #991b1b;
  color: #fecaca;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.track-tag {
  background: #1e3a8a;
  color: #bfdbfe;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.points-tag {
  background: #14532d;
  color: #bbf7d0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.detail-header h2 {
  font-size: 1.15rem;
  color: #fff;
  margin-bottom: 0.5rem;
}

.detail-summary {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.45;
  margin-bottom: 0.85rem;
}

.objectives-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.85rem;
}

.objectives-box h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.objectives-box ul {
  padding-left: 1.2rem;
  font-size: 0.8rem;
  color: #e2e8f0;
}

.objectives-box li {
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.btn-lab {
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-start {
  background: #2563eb;
  color: #fff;
}
.btn-start:hover { background: #1d4ed8; }

.btn-verify {
  background: #16a34a;
  color: #fff;
}
.btn-verify:hover { background: #15803d; }

.btn-solution {
  background: #475569;
  color: #fff;
}
.btn-solution:hover { background: #334155; }

.btn-reset {
  background: #dc2626;
  color: #fff;
}
.btn-reset:hover { background: #b91c1c; }

/* Verification Log Box */
.terminal-log-box {
  background: #050914;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.log-header, .solution-header {
  background: #111a2e;
  padding: 0.35rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.btn-close-log {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-close-log:hover { color: #fff; }

.terminal-log-box pre {
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  color: #38bdf8;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.solution-box {
  background: #0f1c38;
  border: 1px solid #1e3a8a;
  border-radius: 6px;
  margin-top: 0.5rem;
}

.solution-content {
  padding: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #e2e8f0;
  max-height: 250px;
  overflow-y: auto;
}

.solution-content pre {
  background: #0b1120;
  padding: 0.5rem;
  border-radius: 4px;
  margin: 0.4rem 0;
  overflow-x: auto;
  color: #38bdf8;
}

/* RIGHT PANE: Interactive Web Terminal */
.right-pane {
  width: 52%;
  display: flex;
  flex-direction: column;
  background: #000;
}

.terminal-header {
  height: 38px;
  background: #1e293b;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.85rem;
  flex-shrink: 0;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #f59e0b; }
.terminal-dot.green { background: #22c55e; }

.terminal-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-left: 0.3rem;
}

.terminal-tools {
  display: flex;
  gap: 0.4rem;
}

.btn-term-tool {
  background: #334155;
  border: 1px solid #475569;
  color: #f1f5f9;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.btn-term-tool:hover { background: #475569; }

.cheatsheet-drawer {
  background: #0f172a;
  border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 0.85rem;
  max-height: 180px;
  overflow-y: auto;
}

.sheet-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.sheet-tab {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.sheet-tab.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: 600;
}

.sheet-content pre {
  font-family: monospace;
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.4;
}

.terminal-frame-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  background: #000;
}

.terminal-frame-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Alerts Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: #111c33;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  width: 500px;
  max-width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1rem;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.modal-close:hover { color: #fff; }

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.config-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.85rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.form-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-group input {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  color: #fff;
  font-size: 0.8rem;
}

.form-group input:focus {
  border-color: var(--primary);
  outline: none;
}

.form-group small {
  font-size: 0.68rem;
  color: #64748b;
}

.form-row {
  display: flex;
  gap: 0.5rem;
}

.form-group.half {
  flex: 1;
}

.alert-result-box {
  background: #050914;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.65rem;
  font-size: 0.75rem;
  line-height: 1.4;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-secondary {
  background: #334155;
  color: #fff;
  border: none;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-secondary:hover { background: #475569; }

.btn-primary {
  background: var(--primary);
  color: #000;
  border: none;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-primary:hover { background: var(--primary-hover); }
