:root {
  --ops-bg: #0b0f17;
  --ops-surface: #131a27;
  --ops-surface-2: #1a2334;
  --ops-surface-3: #232f46;
  --ops-border: #28354e;
  --ops-text: #f1f5f9;
  --ops-muted: #94a3b8;
  --ops-accent: #7c5cff;
  --ops-accent-soft: rgba(124, 92, 255, 0.16);
  --ops-green: #10b981;
  --ops-green-soft: rgba(16, 185, 129, 0.16);
  --ops-amber: #f59e0b;
  --ops-amber-soft: rgba(245, 158, 11, 0.16);
  --ops-red: #ef4444;
  --ops-red-soft: rgba(239, 68, 68, 0.16);
  --ops-blue: #38bdf8;
  --ops-blue-soft: rgba(56, 189, 248, 0.16);
  --ops-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --ops-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--ops-bg);
  color: var(--ops-text);
  font-family: var(--ops-sans);
  font-size: 14px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Header */
.ops-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(19, 26, 39, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ops-border);
}

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

.ops-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ops-text);
}

.ops-logo img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
}

.ops-logo strong {
  display: block;
  font-size: 16px;
}

.ops-logo em {
  font-style: normal;
  color: var(--ops-accent);
}

.ops-logo span {
  display: block;
  font-size: 12px;
  color: var(--ops-muted);
}

.ops-role-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ops-accent-soft);
  color: #b7a4ff;
  border: 1px solid rgba(124, 92, 255, 0.35);
}

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

.ops-live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--ops-green-soft);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ops-green);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: opsPulse 1.6s infinite;
  display: inline-block;
}

@keyframes opsPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ops-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ops-muted);
  cursor: pointer;
}

.ops-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--ops-border);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.ops-btn-secondary {
  background: var(--ops-surface-2);
  color: var(--ops-text);
}

.ops-btn-secondary:hover {
  background: var(--ops-surface-3);
  border-color: var(--ops-accent);
}

.ops-btn-ghost {
  background: transparent;
  color: var(--ops-muted);
}

.ops-btn-ghost:hover {
  color: var(--ops-text);
  background: var(--ops-surface-2);
}

.ops-btn-xs {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--ops-surface-3);
  color: var(--ops-text);
}

.ops-btn-xs:hover {
  background: var(--ops-accent);
  color: #fff;
  border-color: var(--ops-accent);
}

/* Main container */
.ops-container {
  max-width: 1720px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* KPI Grid */
.ops-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.ops-kpi-card {
  background: var(--ops-surface);
  border: 1px solid var(--ops-border);
  border-radius: 12px;
  padding: 16px 20px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ops-muted);
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  margin: 6px 0 4px;
  font-family: var(--ops-mono);
}

.kpi-cost .kpi-value { color: #34d399; }
.kpi-tokens .kpi-value { color: #a78bfa; }
.kpi-live .kpi-value { color: #38bdf8; }

.kpi-sub {
  font-size: 12px;
  color: var(--ops-muted);
}

/* Active Banner */
.ops-active-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(56, 189, 248, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 12px;
  padding: 16px 20px;
}

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

.ops-section-header h2 {
  margin: 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ops-muted {
  color: var(--ops-muted);
  font-size: 12px;
  margin: 2px 0 0;
}

.ops-active-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

.active-op-card {
  background: var(--ops-surface);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.active-op-card:hover {
  transform: translateY(-2px);
  border-color: var(--ops-accent);
}

.active-op-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.active-op-progress {
  height: 6px;
  background: var(--ops-surface-3);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.active-op-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ops-blue), var(--ops-accent));
  transition: width 0.3s ease;
}

/* Split Workspace */
.ops-workspace {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: start;
}

.ops-sidebar {
  background: var(--ops-surface);
  border: 1px solid var(--ops-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 820px;
}

.ops-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--ops-border);
}

.ops-sidebar-header h2 {
  margin: 0;
  font-size: 16px;
}

.ops-filter-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.ops-input, .ops-select {
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  color: var(--ops-text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}

.ops-input { flex: 1; }
.ops-input:focus, .ops-select:focus {
  outline: none;
  border-color: var(--ops-accent);
}

.ops-jobs-list {
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.job-list-item {
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.job-list-item:hover {
  border-color: #475569;
  background: var(--ops-surface-3);
}

.job-list-item.selected {
  border-color: var(--ops-accent);
  background: rgba(124, 92, 255, 0.12);
  box-shadow: 0 0 0 1px var(--ops-accent);
}

.job-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.job-item-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--ops-text);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--ops-muted);
}

.job-item-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--ops-border);
  font-family: var(--ops-mono);
  font-size: 12px;
}

/* Badges */
.ops-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-running, .badge-queued {
  background: var(--ops-blue-soft);
  color: var(--ops-blue);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-completed, .badge-ok, .badge-ready {
  background: var(--ops-green-soft);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-failed, .badge-error {
  background: var(--ops-red-soft);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-retry, .badge-partiallyready {
  background: var(--ops-amber-soft);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.ops-badge-outline {
  background: transparent;
  border: 1px solid var(--ops-border);
  color: var(--ops-muted);
}

/* Detail Pane */
.ops-detail-pane {
  background: var(--ops-surface);
  border: 1px solid var(--ops-border);
  border-radius: 12px;
  min-height: 700px;
}

.ops-empty-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 100px 40px;
  color: var(--ops-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.ops-detail-content {
  padding: 20px 24px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ops-border);
}

.detail-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.detail-title-group h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--ops-muted);
}

.detail-meta-row strong {
  color: var(--ops-text);
}

.detail-cost-box {
  display: flex;
  gap: 14px;
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  border-radius: 12px;
  padding: 12px 16px;
  flex-shrink: 0;
}

.detail-cost-item {
  display: flex;
  flex-direction: column;
  padding-right: 14px;
  border-right: 1px solid var(--ops-border);
}

.detail-cost-item:last-child {
  padding-right: 0;
  border-right: none;
}

.detail-cost-item small {
  font-size: 10px;
  font-weight: 700;
  color: var(--ops-muted);
  letter-spacing: 0.05em;
}

.detail-cost-item strong {
  font-size: 18px;
  font-family: var(--ops-mono);
  margin: 2px 0;
}

.cost-highlight {
  color: #34d399;
}

.detail-cost-item span {
  font-size: 11px;
  color: var(--ops-muted);
}

.detail-error-banner {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--ops-red-soft);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 13px;
}

/* Detail Tabs */
.detail-tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  border-bottom: 1px solid var(--ops-border);
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.detail-tab {
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  color: var(--ops-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.detail-tab:hover {
  color: var(--ops-text);
  background: var(--ops-surface-3);
}

.detail-tab.active {
  background: var(--ops-accent);
  border-color: var(--ops-accent);
  color: #fff;
}

/* Steps Timeline & Waterfall */
.steps-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.step-card {
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  border-radius: 10px;
  padding: 14px 16px;
}

.step-card.step-running {
  border-color: var(--ops-blue);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.step-card.step-failed {
  border-color: var(--ops-red);
}

.step-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.step-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-order-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ops-surface-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  font-family: var(--ops-mono);
}

.step-metrics-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--ops-mono);
  font-size: 12px;
}

.metric-pill {
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--ops-surface-3);
  border: 1px solid var(--ops-border);
}

.metric-pill-cost {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.metric-pill-tokens {
  color: #c4b5fd;
}

.metric-pill-time {
  color: #38bdf8;
}

/* Waterfall Bar */
.waterfall-track {
  position: relative;
  height: 8px;
  background: var(--ops-surface);
  border-radius: 999px;
  margin: 10px 0;
  overflow: hidden;
}

.waterfall-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--ops-accent), var(--ops-blue));
  border-radius: 999px;
  min-width: 6px;
}

/* Step inner calls */
.step-calls-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--ops-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-call-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(11, 15, 23, 0.55);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--ops-border);
  flex-wrap: wrap;
}

.step-call-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}

/* User Input Grid */
.user-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.input-card {
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  border-radius: 10px;
  padding: 16px;
}

.input-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.code-box {
  background: #090d14;
  border: 1px solid var(--ops-border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--ops-mono);
  font-size: 12px;
  line-height: 1.55;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
}

.code-box-large {
  max-height: 450px;
}

.code-box-sm {
  max-height: 110px;
}

.code-box-tall {
  max-height: 520px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.ops-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.ops-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ops-muted);
  background: var(--ops-surface-2);
}

.ops-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.mono {
  font-family: var(--ops-mono);
}

/* Global Calls section */
.ops-global-calls {
  background: var(--ops-surface);
  border: 1px solid var(--ops-border);
  border-radius: 12px;
  padding: 20px 24px;
}

/* Generated Sections List */
.generated-sections-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gen-section-card {
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  border-radius: 10px;
  padding: 16px;
}

.gen-section-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

/* Modal */
.ops-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ops-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.ops-modal-dialog {
  position: relative;
  z-index: 101;
  width: 100%;
  max-width: 1440px;
  max-height: 90vh;
  background: var(--ops-surface);
  border: 1px solid var(--ops-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
}

.ops-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--ops-border);
}

.ops-modal-header h2 {
  margin: 6px 0 2px;
  font-size: 18px;
}

.ops-modal-close {
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-border);
  color: var(--ops-text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}

.ops-modal-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px;
  background: var(--ops-surface-2);
  border-bottom: 1px solid var(--ops-border);
  font-family: var(--ops-mono);
  font-size: 12px;
}

.ops-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.modal-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.modal-col-header h3 {
  margin: 0;
  font-size: 15px;
}

.modal-sub-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ops-muted);
  margin: 10px 0 6px;
}

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

@media (max-width: 1150px) {
  .ops-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ops-workspace { grid-template-columns: 1fr; }
  .modal-split, .user-input-grid { grid-template-columns: 1fr; }
  .detail-header { flex-direction: column; }
}

/* Admin RBAC, Users, Courses & Audit Log Extensions */
.admin-access-denied {
  max-width: 34rem;
  margin: 4rem auto;
  padding: 2rem;
  text-align: center;
  border-radius: 1rem;
  background: #161b2e;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.admin-access-denied h2 {
  margin: 0 0 0.6rem;
  color: #fca5a5;
}

.admin-access-denied p {
  margin: 0 0 1.25rem;
  color: #cbd5e1;
}

.admin-main-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.admin-tab-btn {
  padding: 0.6rem 1.1rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.admin-tab-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

.admin-panel-card {
  background: #111827;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.95rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.admin-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.admin-panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

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

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.admin-table th,
.admin-table td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  vertical-align: middle;
}

.admin-table th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.admin-progress-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 90px;
}

.admin-progress-bar {
  width: 100%;
  height: 0.35rem;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.admin-progress-bar i {
  display: block;
  height: 100%;
  background: #22c55e;
  border-radius: 999px;
}

.admin-stat-ok { color: #4ade80; font-weight: 600; }
.admin-stat-prog { color: #38bdf8; font-weight: 600; }
.badge-admin { background: rgba(99, 102, 241, 0.25); color: #c7d2fe; border: 1px solid rgba(99, 102, 241, 0.5); }
.admin-actions-cell { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ops-btn-danger { background: #dc2626 !important; color: #fff !important; border-color: #dc2626 !important; }
