/* EM Blueprint — Admin Panel Styles */
:root {
  --blueprint-blue: #0041BA;
  --deep-navy: #001E5F;
  --academic-blue: #3057E1;
  --clinical-light: #CFD8E8;
  --white: #FFFFFF;
  --charcoal: #1C1C1C;
  --amber-gold: #D38A00;
  --amber-light: #FFF3D6;
  --correct: #22c55e;
  --correct-light: #f0fdf4;
  --incorrect: #ef4444;
  --incorrect-light: #fef2f2;
  --grey-50: #f9fafb;
  --grey-100: #f3f4f6;
  --grey-200: #e5e7eb;
  --grey-400: #9ca3af;
  --grey-600: #6b7280;
  --grey-800: #1f2937;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,30,95,0.10);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--grey-50); color: var(--charcoal); min-height: 100vh; }
a { color: var(--blueprint-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT ── */
.admin-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--deep-navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}
.sidebar-logo-sub {
  font-size: 0.75rem;
  color: var(--clinical-light);
  margin-top: 2px;
}
.sidebar-badge {
  display: inline-block;
  background: var(--amber-gold);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  letter-spacing: 0.5px;
}
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.sidebar-section {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  padding: 16px 20px 6px;
  text-transform: uppercase;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar-link.active { background: rgba(255,255,255,0.1); color: #fff; border-right: 3px solid var(--blueprint-blue); }
.sidebar-link-icon { width: 18px; height: 18px; opacity: 0.7; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
}
.sidebar-footer strong { color: rgba(255,255,255,0.7); display: block; margin-bottom: 2px; }

/* Main content */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--grey-200);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--deep-navy); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-body { padding: 32px; flex: 1; }

/* ── CARDS ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-200);
  padding: 24px;
  margin-bottom: 24px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--deep-navy);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title-icon { font-size: 1.1rem; }

/* ── STATS ROW ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-box { background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius-sm); padding: 16px 20px; }
.stat-box-label { font-size: 0.75rem; font-weight: 600; color: var(--grey-600); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-box-value { font-size: 1.75rem; font-weight: 800; color: var(--deep-navy); margin: 4px 0 2px; }
.stat-box-sub { font-size: 0.8rem; color: var(--grey-600); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary   { background: var(--blueprint-blue); color: #fff; border-color: var(--blueprint-blue); }
.btn-secondary { background: transparent; color: var(--blueprint-blue); border: 2px solid var(--blueprint-blue); }
.btn-secondary:hover { background: #eef2ff; }
.btn-success   { background: var(--correct); color: #fff; }
.btn-danger    { background: var(--incorrect); color: #fff; }
.btn-ghost     { background: transparent; color: var(--grey-600); border: 1px solid var(--grey-200); }
.btn-gold      { background: var(--amber-gold); color: #fff; }
.btn-sm  { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }
.btn-xl  { padding: 14px 32px; font-size: 1.1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--grey-800); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--charcoal);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--blueprint-blue); box-shadow: 0 0 0 3px rgba(0,65,186,0.08); }
textarea.form-control { resize: vertical; min-height: 100px; font-family: inherit; line-height: 1.6; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 0.8rem; color: var(--grey-600); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th { background: var(--grey-50); padding: 10px 12px; text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--grey-600); text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--grey-200); white-space: nowrap; }
tbody td { padding: 12px; border-bottom: 1px solid var(--grey-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--grey-50); cursor: pointer; }
tbody tr.selected { background: #EBF0FF; }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-blue   { background: #EBF0FF; color: var(--blueprint-blue); }
.badge-green  { background: #f0fdf4; color: #16a34a; }
.badge-red    { background: #fef2f2; color: #dc2626; }
.badge-gold   { background: var(--amber-light); color: var(--amber-gold); }
.badge-grey   { background: var(--grey-100); color: var(--grey-600); }
.badge-navy   { background: var(--deep-navy); color: #fff; }

/* ── PIPELINE SPECIFIC ── */
.pipeline-grid { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }

.agent-pipeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 16px 0;
}
.agent-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  position: relative;
}
.agent-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 44px;
  bottom: -12px;
  width: 2px;
  background: var(--grey-200);
}
.agent-step.running::after { background: var(--blueprint-blue); }
.agent-step.done::after { background: var(--correct); }

.agent-dot {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  background: var(--grey-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--grey-600);
  z-index: 1;
}
.agent-dot.running { background: var(--blueprint-blue); color: #fff; animation: pulse 1s infinite; }
.agent-dot.done    { background: var(--correct); color: #fff; }
.agent-dot.error   { background: var(--incorrect); color: #fff; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,65,186,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(0,65,186,0); }
}

.agent-info { flex: 1; }
.agent-name  { font-size: 0.875rem; font-weight: 700; color: var(--deep-navy); }
.agent-desc  { font-size: 0.8rem; color: var(--grey-600); margin-top: 2px; }
.agent-status { font-size: 0.75rem; font-weight: 600; margin-top: 4px; }
.agent-status.running { color: var(--blueprint-blue); }
.agent-status.done    { color: var(--correct); }
.agent-status.error   { color: var(--incorrect); }

/* Log output */
.log-output {
  background: #0d1117;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.78rem;
  color: #c9d1d9;
  height: 420px;
  overflow-y: auto;
  line-height: 1.6;
}
.log-line { margin-bottom: 2px; }
.log-line.info   { color: #79c0ff; }
.log-line.success{ color: #56d364; }
.log-line.warn   { color: #e3b341; }
.log-line.error  { color: #f85149; }
.log-line.muted  { color: #6e7681; }
.log-line.agent  { color: #d2a8ff; }

/* ── REVIEW QUEUE ── */
.review-layout { display: grid; grid-template-columns: 1fr 520px; gap: 24px; align-items: start; }

.q-preview {
  position: sticky;
  top: 80px;
}
.q-preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--grey-400);
  text-align: center;
  border: 2px dashed var(--grey-200);
  border-radius: var(--radius);
}
.q-preview-icon { font-size: 2.5rem; margin-bottom: 12px; }

.option-preview {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--grey-200);
  margin-bottom: 8px;
  font-size: 0.875rem;
}
.option-preview.correct { border-color: var(--correct); background: var(--correct-light); }
.option-preview-letter {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  background: var(--grey-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--grey-600);
}
.option-preview.correct .option-preview-letter { background: var(--correct); color: #fff; }

.key-pearl-preview {
  background: var(--amber-light);
  border-left: 3px solid var(--amber-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--charcoal);
  font-weight: 600;
  margin-top: 12px;
}

.quality-score {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.quality-score.excellent { background: var(--correct-light); color: #16a34a; }
.quality-score.good      { background: #eff6ff; color: var(--blueprint-blue); }
.quality-score.needs-edit{ background: var(--amber-light); color: var(--amber-gold); }
.quality-score.rejected  { background: var(--incorrect-light); color: #dc2626; }

/* ── SEARCH & FILTERS ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar .form-control { width: auto; min-width: 140px; }
.search-input { flex: 1; min-width: 200px; }

/* ── INLINE EDIT ── */
.inline-edit-panel {
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-top: 16px;
}

/* ── PROGRESS BAR ── */
.progress-bar-wrap { background: var(--grey-100); border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--blueprint-blue); border-radius: 999px; transition: width 0.5s ease; }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
}
.alert.visible { display: block; }
.alert-success { background: var(--correct-light); border: 1px solid #bbf7d0; color: #166534; }
.alert-error   { background: var(--incorrect-light); border: 1px solid #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-warn    { background: var(--amber-light); border: 1px solid #fde68a; color: #92400e; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,30,95,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,30,95,0.3);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--grey-200);
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--deep-navy); }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--grey-400); padding: 4px; }
.modal-close:hover { color: var(--charcoal); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--grey-200); }

/* ── AUTH ── */
.admin-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--deep-navy);
  padding: 20px;
}
.admin-auth-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.admin-auth-title { font-size: 1.5rem; font-weight: 800; color: var(--deep-navy); margin-bottom: 4px; }
.admin-auth-sub { font-size: 0.875rem; color: var(--grey-600); margin-bottom: 28px; }

/* ── EMPTY STATES ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; text-align: center; }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state-text { font-size: 1rem; font-weight: 600; color: var(--grey-800); }
.empty-state-sub  { font-size: 0.875rem; color: var(--grey-600); margin-top: 6px; }

/* ── UTILITIES ── */
.hidden { display: none !important; }
.text-muted { color: var(--grey-600); }
.text-small { font-size: 0.8rem; }
.text-success { color: var(--correct); }
.text-danger  { color: var(--incorrect); }
.text-gold    { color: var(--amber-gold); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
