:root {
  --bg: #0b0f19;
  --card: #131b2e;
  --card-alt: #18233c;
  --border: #263554;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #e11d48;
  --primary-hover: #be123c;
  --accent: #6366f1;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 24px;
}

.app-shell {
  max-width: 1420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 1.9rem;
  background: rgba(225, 29, 72, 0.15);
  border: 1px solid rgba(225, 29, 72, 0.4);
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.84rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Services Status Bar */
.services-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.service-pill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.service-pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.service-pill.online .dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.service-pill.offline .dot {
  background: var(--danger);
}

.svc-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.svc-info strong {
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svc-info small {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svc-open {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.svc-open:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

/* Main Layout */
.main-grid {
  display: grid;
  grid-template-columns: 410px 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}

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

.card-header h2 {
  font-size: 1.08rem;
  font-weight: 700;
}

/* Forms & Buttons */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #cbd5e1;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.78rem;
  cursor: pointer;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  background: #0f1626;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

.help-text {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 5px;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--card-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: #475569;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: var(--success);
  color: #052e16;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.78rem;
}

.btn-full {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

.btn-link {
  background: none;
  border: none;
  color: #818cf8;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 22, 38, 0.6);
  transition: all 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(225, 29, 72, 0.06);
}

.dropzone-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.dropzone p {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 4px;
}

.profile-summary-box {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--card-alt);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Pipelines List & Stage Cards */
.pipelines-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pipeline-item {
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.pipeline-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.pipeline-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pipeline-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
}

.status-badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-running {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.status-completed {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.status-awaiting_review {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.status-failed,
.status-cancelled {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* 4-Stage Grid */
.stages-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stage-box {
  background: #0f1626;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
}

.stage-box.stage-running {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}

.stage-box.stage-completed,
.stage-box.stage-completed_with_warnings {
  border-color: rgba(34, 197, 94, 0.45);
}

.stage-box.stage-awaiting_review {
  border-color: var(--warning);
}

.stage-label {
  font-size: 0.73rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.stage-val {
  font-size: 0.85rem;
  font-weight: 700;
}

.pipeline-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-bottom: 12px;
}

.pipeline-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.pipeline-log-preview {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 480px;
}

.pipeline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-lg {
  max-width: 960px;
}

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

.modal-header h2 {
  font-size: 1.05rem;
}

.modal-body {
  padding: 22px;
}

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

.profiles-modal-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 22px;
}

.profiles-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 18px;
}

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

.profiles-list-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-list-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--card-alt);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}

.profile-list-btn.active {
  border-color: var(--primary);
  background: rgba(225, 29, 72, 0.12);
}

.form-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
}

.logs-terminal {
  background: #070a12;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: #e2e8f0;
  max-height: 480px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.badge {
  background: var(--card-alt);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid var(--accent);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.86rem;
  z-index: 200;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.hidden {
  display: none !important;
}

@media (max-width: 1024px) {
  .services-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .main-grid {
    grid-template-columns: 1fr;
  }
  .stages-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .profiles-modal-grid {
    grid-template-columns: 1fr;
  }
}

/* Brain Quick Launchers & Badges */
.brain-quick-box {
  margin-top: 18px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  padding: 14px;
}

.brain-quick-header {
  font-size: 0.84rem;
  color: #a5b4fc;
  margin-bottom: 10px;
}

.brain-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.brain-settings-panel {
  background: rgba(15, 22, 38, 0.75);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.brain-settings-panel h4 {
  font-size: 0.9rem;
  color: #a5b4fc;
  margin-bottom: 12px;
}

.brain-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.brain-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  font-weight: 600;
}

.memory-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
}

.memory-table-wrap {
  max-height: 460px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b101d;
}

.memory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.memory-table th,
.memory-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.memory-table th {
  background: var(--card-alt);
  color: #cbd5e1;
  position: sticky;
  top: 0;
}

/* Reverse-Countdown Seasonal Calculator */
.seasonal-preview-box {
  background: rgba(15, 22, 38, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.seasonal-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  color: #7dd3fc;
  margin-bottom: 10px;
}

.seasonal-cohorts-wrap {
  overflow-x: auto;
}

.cohort-calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.cohort-calc-table th,
.cohort-calc-table td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.cohort-calc-table th {
  background: rgba(30, 41, 59, 0.75);
  color: #94a3b8;
  font-weight: 600;
}

.profile-boards-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 85px;
  overflow-y: auto;
}

.board-chip {
  cursor: pointer;
  user-select: none;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #94a3b8;
  transition: all 0.15s ease;
}

.board-chip:hover {
  border-color: #818cf8;
  color: #f8fafc;
  background: rgba(99, 102, 241, 0.18);
}

.board-chip.active {
  background: rgba(99, 102, 241, 0.35);
  border-color: #818cf8;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

