/* EduQuant Kit — core design tokens, layout primitives, shared components */

:root {
  --primary: #1B4F8A;
  --primary-light: #2E75B6;
  --accent: #22D3EE;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-secondary: #64748B;
  --font: 'Inter', system-ui, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);

  /* Gate colors */
  --gate-h: #7C3AED;
  --gate-x: #DC2626;
  --gate-y: #16A34A;
  --gate-z: #2563EB;
  --gate-s: #EA580C;
  --gate-t: #0D9488;
  --gate-cnot: #9333EA;
  --gate-cz: #0369A1;
  --gate-rx: #15803D;
  --gate-ry: #15803D;
  --gate-rz: #15803D;
  --gate-ccx: #BE185D;
  --gate-measure: #475569;

  --header-h: 56px;
  --sidebar-w: 220px;
  --results-w: 320px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75em; line-height: 1.55; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre {
  background: #0F172A;
  color: #E2E8F0;
  padding: 12px;
  border-radius: var(--radius);
  overflow: auto;
  line-height: 1.5;
}

.muted { color: var(--text-secondary); }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Header ---------- */
.site-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  white-space: nowrap;
}
.brand img { width: 30px; height: 30px; }
.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 4px 2px; } /* staff see 8 links: scroll inside the bar, never the page */
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}
.main-nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.main-nav a.active { color: var(--primary); background: #EAF2FB; }
.header-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.header-right .student-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: #EAF2FB; color: var(--primary); font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--bg); border-color: #CBD5E1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #083344; }
.btn.accent:hover { background: #06B6D4; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn .ti { font-size: 1.1em; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.active { background: var(--primary); border-color: var(--primary); color: #fff; z-index: 1; }

/* ---------- Form controls ---------- */
.input, select, textarea, input[type=text], input[type=number], input[type=email] {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
select { width: auto; }
.input:focus, select:focus, textarea:focus, input:focus { outline: 2px solid rgba(34,211,238,.45); outline-offset: 1px; border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
.field-hint { font-size: 12px; color: var(--text-secondary); }
input[type=range] { width: 100%; accent-color: var(--primary); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  background: #E2E8F0;
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge.level-1 { background: #DCFCE7; color: #166534; }
.badge.level-2 { background: #DBEAFE; color: #1E40AF; }
.badge.level-3 { background: #F3E8FF; color: #6B21A8; }
.badge.source-aer { background: #DBEAFE; color: #1E40AF; }
.badge.source-aer_noisy { background: #FEF3C7; color: #92400E; }
.badge.source-ibm { background: #E0E7FF; color: #3730A3; }
.badge.success { background: #D1FAE5; color: #065F46; }
.badge.danger { background: #FEE2E2; color: #991B1B; }
.badge.warning { background: #FEF3C7; color: #92400E; }
.badge.primary { background: #EAF2FB; color: var(--primary); }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; }

.page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.tabs button {
  flex: 1 1 auto;
  white-space: nowrap;
  border: 0;
  background: transparent;
  padding: 10px 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Tables ---------- */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.data th { font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data td.num { font-family: ui-monospace, Menlo, Consolas, monospace; text-align: right; }
.prob-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; min-width: 60px; }
.prob-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.prob-bar.high > span { background: var(--warning); }

/* ---------- Progress ---------- */
.progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--success); border-radius: 4px; transition: width .3s; }
.progress.primary > span { background: var(--primary); }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius); border: 1px solid; font-weight: 500; }
.alert.success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.alert.danger { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.alert.info { background: #EAF2FB; border-color: #BFDBFE; color: var(--primary); }
.alert.warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  max-width: 380px;
}
.toast {
  background: #0F172A;
  color: #F8FAFC;
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
  animation: toast-in .18s ease-out;
  border-left: 4px solid var(--primary-light);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast button { background: none; border: 0; color: #94A3B8; cursor: pointer; font-size: 16px; line-height: 1; margin-left: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Closed-beta watermark (watermark.js; lab content pages only) ---------- */
.beta-watermark {
  position: fixed;
  right: 12px;
  bottom: 8px;
  z-index: 2000;                 /* above modals and the loading overlay: a screenshot of those is marked too */
  max-width: calc(100vw - 24px);
  font-size: 11px;
  line-height: 1.3;
  text-align: right;
  color: #374151;                /* renders as light grey (~#ADB1B6) at this opacity; a light base colour left the email unreadable in screenshots */
  opacity: .4;
  pointer-events: none;          /* never in the way of a click */
  user-select: none;
}
body.has-beta-watermark .toast-stack { bottom: 30px; }   /* toasts sit above the watermark instead of on it */
@media print { .beta-watermark { opacity: .6; } }

/* ---------- Loading overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248,250,252,.72);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 900;
  color: var(--primary);
  font-weight: 500;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #CBD5E1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 800;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(640px, 100%);
  padding: 20px;
}
.modal h3 { margin-bottom: 12px; }
.modal textarea { min-height: 220px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- Results summary bits ---------- */
.result-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 13px;
}
.result-summary .outcome { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; color: var(--primary); }
/* provenance banner between the summary and the result tabs: IBM hardware run or the fallback notice */
.result-banner { margin: 10px 14px 0; font-size: 12.5px; line-height: 1.45; font-weight: 400; }
.result-banner.hidden { display: none; }
.result-banner.ibm { background: #EEF2FF; border-color: #C7D2FE; color: #3730A3; }
.result-banner .banner-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.result-banner .banner-line { margin-top: 2px; }
.result-banner .banner-line.quota { margin-top: 6px; font-weight: 600; color: #92400E; }
.result-banner code { background: rgba(255,255,255,.7); border: 1px solid rgba(0,0,0,.08); padding: 1px 6px; border-radius: 4px; font-size: 11.5px; }
.badge.source-ibm_quantum { background: #E0E7FF; color: #3730A3; }
.chart-box { position: relative; height: 260px; width: 100%; }
.chart-box.tall { height: 300px; }
.empty-note { color: var(--text-secondary); font-size: 13px; padding: 16px 0; text-align: center; }
.raw-json { max-height: 420px; }
.copy-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.result-img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.bloch-vectors { margin-top: 10px; font-size: 12.5px; }
.bloch-vectors code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }

/* Explanation card shown instead of an empty Bloch / State Vector tab after a hardware or noisy run */
.hw-note-card { font-weight: 400; font-size: 13px; line-height: 1.55; }
.hw-note-card .hw-note-title { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; }
.hw-note-card p { margin: 0 0 8px; }
.hw-note-card .hw-note-steps-title { font-weight: 600; margin-bottom: 4px; }
.hw-note-card .hw-note-steps { margin: 0; padding: 0; list-style: none; }
.hw-note-card .hw-note-steps li { padding-left: 18px; position: relative; margin-bottom: 2px; }
.hw-note-card .hw-note-steps li::before { content: "\2192"; position: absolute; left: 0; font-weight: 700; }
/* the per-qubit (0, 0, 0) lines on the entangled-state card that replaces empty Bloch spheres */
.hw-note-card .bloch-origin-lines { margin: 0 0 10px; padding: 8px 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; white-space: pre-wrap; }

/* History tab: one row per saved simulation */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.history-item:hover { border-color: var(--primary); }
.history-main { flex: 1; min-width: 0; }
.history-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.history-line.muted { color: var(--text-secondary); font-size: 11.5px; margin-top: 3px; }
.history-outcome { font-weight: 600; }
.history-name { font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.history-item .btn { flex: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .main-nav a { padding: 8px 8px; }
  .site-header { padding: 0 12px; gap: 12px; }
  .brand span { display: none; }
}

/* =====================================================================
   Phase 2 — accounts, analytics, admin, backend selector
   ===================================================================== */

/* ---------- Header user menu ---------- */
.user-menu { position: relative; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 10px; border-radius: 999px;
  border: 1px solid transparent; background: #EAF2FB; color: var(--primary);
  font: inherit; font-weight: 500; cursor: pointer;
}
.user-chip:hover { border-color: #BFDBFE; }
.user-chip .ti-user-circle { font-size: 18px; }
.user-chip .name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.role-student { background: #DCFCE7; color: #166534; }
.badge.role-professor { background: #DBEAFE; color: #1E40AF; }
.badge.role-admin { background: #F3E8FF; color: #6B21A8; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
  display: flex; flex-direction: column;
}
.user-dropdown-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 12.5px; white-space: normal; }
.user-dropdown-head .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.user-dropdown a, .user-dropdown button {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 0; border-radius: var(--radius); background: transparent;
  font: inherit; color: var(--text); text-align: left; cursor: pointer; width: 100%;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg); text-decoration: none; }
.user-dropdown .ti { color: var(--text-secondary); }

/* ---------- Auth card (login page) ---------- */
.auth-wrap { max-width: 440px; margin: 48px auto; }
.auth-card h1 { margin-bottom: 2px; font-size: 1.35rem; }
.auth-card .tabs { margin: 14px -18px 18px; padding: 0 18px; }
.auth-card .tabs button { flex: 0 0 auto; padding: 10px 14px; font-size: 13.5px; }
.auth-card .form-error { margin-bottom: 12px; }
.auth-card .sso-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; }
.auth-card .sso-row .muted { display: block; font-size: 12px; margin-bottom: 8px; }
.password-wrap { position: relative; }
.password-wrap input { width: 100%; padding-right: 40px; }
.password-wrap .eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 16px; padding: 4px;
}

/* ---------- Page-level tabs ---------- */
.page-tabs { margin-bottom: 18px; background: transparent; }
.page-tabs button { flex: 0 0 auto; padding: 10px 16px; font-size: 13.5px; }
.page-tabs button .count { margin-left: 6px; font-size: 11px; background: var(--border); color: var(--text-secondary); border-radius: 999px; padding: 1px 7px; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .val { font-size: 1.7rem; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .lbl { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.tile .sub { font-size: 12px; color: var(--text-secondary); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.tile.accent .val { color: var(--primary); }

/* ---------- Beta tester activity timeline (admin) ---------- */
.activity-session { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; background: var(--surface); }
.activity-session > summary { cursor: pointer; font-size: 13px; }
.activity-session[open] > summary { margin-bottom: 10px; }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-event { display: grid; grid-template-columns: 84px 28px 1fr auto; gap: 10px; align-items: start; position: relative; padding-bottom: 12px; font-size: 13px; }
.activity-event:last-child { padding-bottom: 0; }
.activity-event:not(:last-child)::before { content: ''; position: absolute; left: 107px; top: 26px; bottom: 0; width: 2px; background: var(--border); }
.activity-event time { color: var(--text-secondary); font-variant-numeric: tabular-nums; font-size: 12.5px; padding-top: 4px; white-space: nowrap; }
.activity-event .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--border); color: var(--text-secondary); font-size: 14px; }
.activity-event .what { min-width: 0; padding-top: 3px; }
.activity-event .what .muted { font-size: 11.5px; overflow-wrap: anywhere; }
.activity-event .gap { font-size: 11.5px; padding-top: 5px; white-space: nowrap; }
.activity-event.start .dot { background: #D1FAE5; border-color: #A7F3D0; color: #065F46; }
.activity-event.end .dot { background: #FEF3C7; border-color: #FDE68A; color: #92400E; }
.activity-event.lab .dot { background: #DBEAFE; border-color: #BFDBFE; color: #1E40AF; }
.activity-event.algo .dot { background: #F3E8FF; border-color: #E9D5FF; color: #6B21A8; }
.activity-event.run .dot { background: #EAF2FB; border-color: #BFDBFE; color: var(--primary); }
.activity-event.feedback .dot { background: #FFEDD5; border-color: #FED7AA; color: #9A3412; }
@media (max-width: 640px) {
  .activity-event { grid-template-columns: 28px 1fr; }
  .activity-event time { grid-column: 2; grid-row: 1; padding-top: 0; }
  .activity-event .dot { grid-column: 1; grid-row: 1 / span 2; }
  .activity-event .what { grid-column: 2; }
  .activity-event .gap { grid-column: 2; padding-top: 0; }
  .activity-event:not(:last-child)::before { left: 13px; }
}

/* ---------- Beta feedback received (admin) ---------- */
.fb-stars { color: var(--warning); letter-spacing: 1px; font-size: 15px; white-space: nowrap; }
.fb-entry { border: 1px solid var(--border); border-left: 3px solid var(--primary-light); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; font-size: 13px; }
.fb-entry.reviewed { border-left-color: var(--border); background: var(--bg); }
.fb-entry > header, .fb-entry > footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-entry > footer { margin-top: 10px; font-size: 12px; }
.fb-entry .fb-text { margin-top: 10px; }
.fb-entry .fb-text b { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.fb-entry .fb-text p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-admin-note { margin-top: 10px; padding: 6px 10px; border-radius: var(--radius); background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; font-size: 12.5px; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }
.toolbar select, .toolbar input { width: auto; padding: 6px 9px; font-size: 13px; }
.toolbar input[type=search] { min-width: 200px; }
.toolbar .spacer { flex: 1; }

/* ---------- Inline forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 12px; align-items: end; }
.form-grid label.field { margin: 0; }
.form-grid .actions { display: flex; gap: 8px; align-items: end; }
.form-error { color: #991B1B; background: #FEF2F2; border: 1px solid #FECACA; border-radius: var(--radius); padding: 8px 10px; font-size: 13px; }
.form-error:empty { display: none; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; }

/* ---------- Data tables (wide) ---------- */
.table-wrap { overflow-x: auto; }
table.data.compact th, table.data.compact td { padding: 5px 6px; font-size: 12.5px; }
table.data tr.inactive td { color: var(--text-secondary); }
table.data input.inline { width: 72px; padding: 3px 6px; font-size: 12.5px; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data tbody tr:hover { background: #F8FAFC; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; }
.switch input { appearance: none; width: 30px; height: 16px; border-radius: 999px; background: #CBD5E1; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--success); }
.switch input:checked::after { left: 16px; }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Heatmap (student matrix) ---------- */
.heat-table th.lab { font-size: 10.5px; padding: 4px 2px; text-align: center; letter-spacing: 0; text-transform: none; }
.heat-table td.cell { padding: 3px 2px; }
.heat {
  display: block; width: 18px; height: 18px; margin: 0 auto; border-radius: 4px;
  background: #F1F5F9; border: 1px solid #E2E8F0;
}
.heat.s1 { background: #FCD34D; border-color: #FCD34D; }
.heat.s2 { background: #7FB2E5; border-color: #7FB2E5; }
.heat.s3 { background: #1B4F8A; border-color: #1B4F8A; }
.heat-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); align-items: center; }
.heat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.heat-legend .heat { width: 14px; height: 14px; margin: 0; }
.student-name { background: none; border: 0; padding: 0; font: inherit; font-weight: 500; color: var(--primary); cursor: pointer; text-align: left; }
.student-name:hover { text-decoration: underline; }
.student-email { font-size: 12px; color: var(--text-secondary); }

/* ---------- Analytics layout ---------- */
.chart-card .chart-box { height: 280px; }
.chart-card .chart-box.short { height: 220px; }
.analytics-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; margin-bottom: 16px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
@media (max-width: 1000px) { .analytics-grid { grid-template-columns: 1fr; } }

/* ---------- Designer: backend selector & live job status ---------- */
.backend-opts { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.backend-opts label { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.backend-opts input[type=number] { width: 72px; padding: 3px 6px; font-size: 12px; }
select.backend-select { width: auto; padding: 5px 8px; font-size: 12.5px; }
.job-status { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-status .spinner { width: 16px; height: 16px; border-width: 2px; }
.job-status .state { font-weight: 600; color: var(--primary); }
.job-status code { background: var(--surface); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; font-size: 11.5px; }
.noise-params { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.noise-params code { font-size: 11px; background: #FEF3C7; color: #92400E; padding: 1px 6px; border-radius: 4px; }

/* Export dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 170px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px;
  display: flex; flex-direction: column;
}
.dropdown-menu button { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: transparent; font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; border-radius: 6px; color: var(--text); white-space: nowrap; }
.dropdown-menu button:hover { background: var(--bg); }

/* ---------- Dashboard extras ---------- */
.staff-card { max-width: 640px; margin: 40px auto; }
.staff-links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.staff-links a { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); }
.staff-links a:hover { background: var(--bg); text-decoration: none; border-color: #CBD5E1; }
.staff-links a b { color: var(--primary); display: flex; align-items: center; gap: 6px; }
.staff-links a span { font-size: 12.5px; color: var(--text-secondary); }
@media (max-width: 900px) { .staff-links { grid-template-columns: 1fr; } }

.empty-state { text-align: center; color: var(--text-secondary); padding: 28px 10px; font-size: 13px; }
.page-error { margin: 40px auto; max-width: 560px; }

/* =====================================================================
   Phase 3 — NMR hardware path (shared by the designer, labs and the hardware console)
   ===================================================================== */
:root {
  --nmr-q0: #1B4F8A;      /* ¹H channel */
  --nmr-q0-soft: #DBEAFE;
  --nmr-q1: #B45309;      /* ³¹P channel */
  --nmr-q1-soft: #FEF3C7;
}
.badge.level-4 { background: #FFEDD5; color: #9A3412; }
.badge.source-mock_nmr { background: #FFEDD5; color: #9A3412; }
.badge.source-nmr { background: #FCE7F3; color: #9D174D; }
.badge.kind-twin { background: #FFEDD5; color: #9A3412; }
.badge.kind-nmr { background: #FCE7F3; color: #9D174D; }
.backend-tomo { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.backend-tomo input { margin: 0; }
.result-summary .nmr-cal { background: var(--surface); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; }
.hw-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hw-note .btn { margin-left: auto; }

/* histogram title for ensemble results */
.panel-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.info-icon { border: 0; background: transparent; color: var(--primary); cursor: pointer; padding: 0 2px; font-size: 15px; line-height: 1; display: inline-flex; }
.info-icon:hover { color: var(--primary-light); }

/* ---------- Pulse-program timeline ---------- */
.pulse-view { font-size: 12.5px; }
.pulse-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pulse-head .spacer { flex: 1; }
.pulse-total b { color: var(--primary); }
.budget-bar { display: inline-block; width: 90px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.budget-bar > span { display: block; height: 100%; background: var(--success); }
.budget-bar.warn > span { background: var(--warning); }
.zoom-ctl { display: inline-flex; align-items: center; gap: 2px; }
.zoom-ctl .btn { padding: 2px 6px; }
.zoom-ctl .zoom-label { min-width: 34px; text-align: center; font-size: 11.5px; }
.pulse-scroll { overflow-x: auto; overflow-y: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 4px 0; }
.pulse-svg { display: block; font-family: var(--font); }
.pulse-svg .lane-bg { fill: #F8FAFC; stroke: var(--border); }
.pulse-svg .lane-line { stroke: #CBD5E1; stroke-width: 1; stroke-dasharray: 2 3; }
.pulse-svg .lane-label { font-size: 12px; font-weight: 700; fill: var(--text); }
.pulse-svg .lane-sub { font-size: 11px; fill: var(--text-secondary); }
.pulse-svg .ev-hit { fill: transparent; }
.pulse-svg .ev-pulse .ev-rect { stroke-width: 1.2; }
.pulse-svg .ev-pulse.ch-q0 .ev-rect { fill: var(--nmr-q0); stroke: var(--nmr-q0); }
.pulse-svg .ev-pulse.ch-q1 .ev-rect { fill: var(--nmr-q1); stroke: var(--nmr-q1); }
.pulse-svg .ev-pulse.refocus .ev-rect { fill: #fff; stroke-width: 2; }
.pulse-svg .ev-pulse.refocus.ch-q0 .ev-rect { stroke: var(--nmr-q0); }
.pulse-svg .ev-pulse.refocus.ch-q1 .ev-rect { stroke: var(--nmr-q1); }
.pulse-svg .ev-pulse.readout .ev-rect { stroke-dasharray: 3 2; fill-opacity: .55; }
.pulse-svg .ev-pulse .ev-label { font-size: 10px; fill: #fff; pointer-events: none; }
.pulse-svg .ev-pulse.refocus.ch-q0 .ev-label { fill: var(--nmr-q0); }
.pulse-svg .ev-pulse.refocus.ch-q1 .ev-label { fill: var(--nmr-q1); }
.pulse-svg .ev-pulse:hover .ev-rect { filter: brightness(1.15); stroke: var(--accent); }
.pulse-svg .ev-delay rect { stroke: none; }
.pulse-svg .ev-delay:hover rect { stroke: var(--accent); stroke-width: 1; }
.pulse-svg .delay-label { font-size: 10.5px; fill: var(--text-secondary); }
.pulse-svg .ev-frame path { fill: #7C3AED; }
.pulse-svg .ev-frame line { stroke: #7C3AED; stroke-width: 1; stroke-dasharray: 2 2; }
.pulse-svg .ev-acquire path { fill: none; stroke: #0F766E; stroke-width: 2; }
.pulse-svg .acq-label { font-size: 10px; fill: #0F766E; }
.pulse-svg .axis { stroke: #94A3B8; stroke-width: 1; }
.pulse-svg .axis-label { font-size: 10.5px; fill: var(--text-secondary); }
.pulse-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 6px; font-size: 11.5px; color: var(--text-secondary); }
.pulse-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pulse-legend .sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; border: 1.5px solid transparent; }
.pulse-legend .sw.ch-q0 { background: var(--nmr-q0); }
.pulse-legend .sw.ch-q1 { background: var(--nmr-q1); }
.pulse-legend .sw.refocus { background: #fff; border-color: var(--nmr-q0); }
.pulse-legend .sw.delay { background: repeating-linear-gradient(45deg, #F1F5F9 0 3px, #CBD5E1 3px 5px); }
.pulse-legend .sw.frame { width: 10px; height: 10px; background: #7C3AED; transform: rotate(45deg); border-radius: 1px; }
.pulse-legend .sw.acquire { background: transparent; border-color: #0F766E; border-top-color: transparent; border-radius: 0; }
.native-gates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.native-gates .gate-chip { font-size: 11.5px; padding: 2px 7px; border-radius: 4px; background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.native-gates .gate-chip.gate-cz { background: #E0F2FE; color: #075985; border-color: #BAE6FD; }
.native-gates .gate-chip.gate-rz { background: #F3E8FF; color: #6B21A8; border-color: #E9D5FF; }
.pulse-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 11.5px; }
.pulse-meta code { background: var(--bg); padding: 1px 6px; border-radius: 4px; }

/* ---------- FID / spectrum ---------- */
.trace-block { margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.trace-block:last-child { border-bottom: 0; margin-bottom: 0; }
.trace-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 13.5px; }
.chan-chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; color: #fff; background: var(--nmr-q0); }
.chan-chip.q1 { background: var(--nmr-q1); }
.trace-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trace-charts.compact, .results-panel .trace-charts { grid-template-columns: 1fr; }
.trace-chart .chart-box.short { height: 200px; }
.trace-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 2px; }
.lines-table { margin-top: 8px; }
@media (max-width: 900px) { .trace-charts { grid-template-columns: 1fr; } }

/* ---------- Tomography ---------- */
.tomo-numbers { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.tomo-numbers .big { flex: 1 1 120px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.tomo-numbers .big .val { display: block; font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.tomo-numbers .big .lbl { font-size: 11.5px; color: var(--text-secondary); }
.tomo-numbers .big.good .val { color: var(--success); }
.tomo-numbers .big.ok .val { color: var(--warning); }
.tomo-numbers .big.bad .val { color: var(--danger); }
.tomo-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; margin-bottom: 6px; }
.tomo-toolbar .spacer { flex: 1; }
.heat-table-rho { border-collapse: separate; border-spacing: 3px; margin: 0 auto; font-size: 12.5px; }
.heat-table-rho th { font-weight: 600; color: var(--text-secondary); padding: 2px 6px; font-size: 12px; }
.heat-table-rho th code { font-size: 12px; }
.heat-table-rho td.cell { width: 64px; height: 44px; text-align: center; border-radius: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; border: 1px solid rgba(15,23,42,.08); }
.heat-table-rho td.cell.diag { box-shadow: inset 0 0 0 2px rgba(15,23,42,.12); }
.rho-scale { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11px; color: var(--text-secondary); margin: 8px 0 12px; }
.rho-scale .bar { width: 80px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #DC2626, #fff); }
.rho-scale .bar.pos { background: linear-gradient(90deg, #fff, #1B4F8A); }
.ideal-wrap { margin-top: 6px; }
.ideal-table tr.muted td { color: var(--text-secondary); }

/* key/value chips (routine fits, device meta) */
.kv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kv-chips .chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); font-size: 12px; }
.kv-chips .chip .k { color: var(--text-secondary); }
.kv-chips .chip b { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; color: var(--text); }
