:root {
  --bg: #111114;
  --surface: #1a1a1f;
  --surface-2: #222229;
  --border: #2c2c34;
  --text: #e7e7ea;
  --text-dim: #9a9aa3;
  --accent: #5b8cff;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---- Auth / login ---- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.auth-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}
.auth-logo {
  display: block;
  width: 150px;
  height: auto;
  margin-bottom: 24px;
}
.sidebar-logo {
  display: block;
  width: 120px;
  height: auto;
  margin-bottom: 8px;
}
.auth-field { margin-bottom: 12px; }
.auth-field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.auth-btn {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.auth-btn:disabled { opacity: 0.6; cursor: default; }
.auth-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.4);
  border-radius: 8px;
  color: #ff9b9b;
  font-size: 13px;
}

/* ---- Layout ---- */
/* Viewport-locked layout: the sidebar stays put (scrolling its own nav if needed) while the
   main content scrolls independently. */
.admin-body { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.sidebar-nav a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
}
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav a.active { background: var(--surface-2); color: var(--text); }
.sidebar-footer { margin-top: auto; font-size: 12px; color: var(--text-dim); }
.sidebar-user { display: block; margin-bottom: 6px; word-break: break-all; }
.sidebar-logout { color: var(--accent); text-decoration: none; }

/* Collapsible nav group */
.nav-group { display: flex; flex-direction: column; }
.nav-group-toggle {
  display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-weight: 500; font-size: 14px;
  padding: 9px 12px; border-radius: 8px; text-align: left;
  font-family: inherit;
}
.nav-group-toggle:hover { background: var(--surface-2); color: var(--text); }
.nav-caret { transition: transform 0.15s; font-size: 16px; line-height: 1; }
.nav-group.open .nav-caret { transform: rotate(90deg); }
.nav-group-items { display: none; flex-direction: column; gap: 2px; padding-left: 10px; }
.nav-group.open .nav-group-items { display: flex; }

.main-content { flex: 1; padding: 32px 40px; overflow-x: auto; overflow-y: auto; height: 100%; }
.page-header h1 { margin: 0 0 24px; font-size: 22px; font-weight: 600; }

/* ---- Dashboard cards ---- */
.stat-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  min-width: 180px;
  text-decoration: none;
  color: var(--text);
}
.stat-card:hover { border-color: var(--accent); }
.stat-value { font-size: 32px; font-weight: 700; }
.stat-label { color: var(--text-dim); margin-top: 4px; }

/* ---- Filters ---- */
.filter-bar { margin-bottom: 16px; }
.filter-search {
  width: 360px;
  max-width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 600;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.empty-row { text-align: center; color: var(--text-dim); padding: 28px; }
.row-link { color: var(--accent); text-decoration: none; }

/* ---- Buttons / misc ---- */
.btn-primary {
  display: inline-block;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary:hover { filter: brightness(1.08); }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.link-btn.accent { font-weight: 600; }
.link-btn.danger { color: #ff6b6b; }
.inline-error {
  padding: 10px 12px;
  margin-bottom: 16px;
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.4);
  border-radius: 8px;
  color: #ff9b9b;
  font-size: 13px;
}
.config-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.config-header h1 { margin: 0; }

/* ---- Config master-detail ---- */
.config-ver { font-weight: 700; }
.config-label { color: var(--text); }
.config-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
}
.config-meta { color: var(--text-dim); font-size: 12px; }
.config-json {
  margin: 0;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
  overflow: auto;
  white-space: pre;
}

.config-layout { display: flex; gap: 20px; align-items: flex-start; }

/* Left: version list */
.config-sidebar {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.version-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.version-item:hover { background: var(--surface-2); }
.version-item.selected { border-color: var(--accent); background: var(--surface-2); }
.version-item .vi-ver { font-weight: 700; flex: 0 0 auto; }
.version-item .vi-label {
  flex: 1;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Right: detail */
.config-detail {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.detail-title { display: flex; align-items: center; gap: 10px; }
.detail-actions { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.compare-ctl { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.compare-select {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  max-width: 220px;
}
.detail-json { max-height: 60vh; }

/* ---- Tree editor ---- */
.cfg-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}
.cfg-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.cfg-toggle, .cfg-toggle-spacer {
  width: 18px; height: 18px; flex: 0 0 18px;
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 11px;
}
.cfg-key, .cfg-val {
  padding: 5px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
}
.cfg-key { width: 160px; font-weight: 500; }
.cfg-val { flex: 1; min-width: 120px; }
.cfg-val.invalid { border-color: #ff5a5a; }
.cfg-bool { flex: 0 0 auto; width: 18px; height: 18px; }
.cfg-index { color: var(--text-dim); font-size: 12px; width: 160px; }
.cfg-type {
  padding: 4px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cfg-count { color: var(--text-dim); font-size: 12px; }
.cfg-del {
  margin-left: auto;
  width: 22px; height: 22px;
  background: none; border: none; color: var(--text-dim);
  font-size: 16px; cursor: pointer; border-radius: 6px;
}
.cfg-del:hover { background: rgba(255,90,90,0.15); color: #ff9b9b; }
.cfg-empty { color: var(--text-dim); font-size: 12px; font-style: italic; padding: 3px 0; }
.cfg-add-wrap { position: relative; display: inline-block; }
.cfg-add-btn, .cfg-rootadd .cfg-add-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.cfg-add-menu {
  position: absolute; z-index: 5; top: 110%; left: 0;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px;
  min-width: 110px;
}
.cfg-add-type {
  background: none; border: none; color: var(--text); text-align: left;
  padding: 6px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; text-transform: capitalize;
}
.cfg-add-type:hover { background: var(--surface-2); }
.cfg-rootadd { margin-top: 8px; }
.config-edit-actions { display: flex; align-items: center; gap: 16px; }

/* ---- Diff ---- */
.diff-pane { margin-top: 20px; }
.diff-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.diff-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.diff-label { font-weight: 600; }
.diff-arrow { color: var(--text-dim); }
.diff-confirm { margin-left: auto; }
.diff-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.diff-table td { vertical-align: top; border-bottom: 1px solid rgba(255,255,255,0.03); }
.diff-no { width: 36px; text-align: right; padding: 0 8px; color: var(--text-dim); user-select: none; }
.diff-cell { padding: 0 10px; width: 50%; }
.diff-cell pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; color: var(--text); }
.diff-cell.add { background: rgba(70, 200, 120, 0.14); }
.diff-cell.del { background: rgba(255, 90, 90, 0.14); }
.diff-cell.change { background: rgba(230, 190, 80, 0.14); }

/* ---- Resources ---- */
.resource-upload {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.resource-file { color: var(--text-dim); font-size: 13px; flex: 1; }
.resource-visibility { text-transform: none; letter-spacing: 0; }

.badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.badge-public { background: rgba(70,200,120,0.2); color: #6fdc9b; }
.badge-private { background: var(--surface-2); color: var(--text-dim); }
.badge-status-ready, .badge-status-success { background: rgba(70,200,120,0.18); color: #6fdc9b; }
.badge-status-processing, .badge-status-running, .badge-status-retry { background: rgba(230,190,80,0.18); color: #e6be50; }
.badge-status-failed { background: rgba(255,90,90,0.18); color: #ff9b9b; }
.badge-status-queued, .badge-status-revoked { background: var(--surface-2); color: var(--text-dim); }

.tasks-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin: 24px 0 10px; }
.error-log { color: #ff9b9b; white-space: pre-wrap; }

.resource-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}
.resource-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: var(--text);
}
.resource-card:hover { border-color: var(--accent); }
.resource-thumb {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg); overflow: hidden;
}
.resource-thumb img { width: 100%; height: 100%; object-fit: cover; }
.resource-thumb-ph { color: var(--text-dim); font-size: 12px; }
.resource-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; }
.resource-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.resource-rename { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.resource-rename .filter-search { width: 360px; }
.resource-row-thumb { width: 56px; }
.resource-row-thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; background: var(--bg); }
.resource-row-thumb-ph { display: block; width: 44px; height: 44px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); }
.resource-row-actions { display: flex; align-items: center; gap: 14px; white-space: nowrap; }

/* Archive folder tree */
.arch-summary { margin-bottom: 10px; }
.arch-root {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font-size: 13px; max-height: 60vh; overflow: auto;
}
.arch-tree { list-style: none; margin: 0; padding: 0; }
.arch-tree .arch-tree { padding-left: 18px; border-left: 1px solid var(--border); margin-left: 6px; }
.arch-dir > details > summary {
  cursor: pointer; padding: 3px 0; color: var(--text); list-style: none;
}
.arch-dir > details > summary::-webkit-details-marker { display: none; }
.arch-dir > details > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--text-dim); font-size: 10px; }
.arch-dir > details[open] > summary::before { content: "▾"; }
.arch-folder { font-weight: 600; }
.arch-folder::after { content: "/"; color: var(--text-dim); }
.arch-file {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 3px 0 3px 14px; color: var(--text-dim);
}
.arch-file .arch-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.arch-file .arch-size { white-space: nowrap; }
.resource-detail { max-width: 820px; }
.detail-badges { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.resource-preview {
  max-width: 100%; max-height: 60vh; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); display: block; margin-bottom: 20px;
}
.resource-meta-block { margin-bottom: 20px; }
.resource-meta-block h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin: 0 0 8px; }
.kv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.kv-table td:first-child { color: var(--text-dim); width: 180px; }
.kv-table .unit { opacity: 0.5; }
.url-code {
  display: block; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px; color: var(--accent); word-break: break-all;
}
.url-code.copyable { cursor: pointer; }
.url-code.copyable:hover { border-color: var(--accent); }

.detail-id { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.copy-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
.copy-pill:hover { border-color: var(--accent); }

/* Transient "Copied!" label shown beside/under a copy target (not replacing its content). */
.copy-flash-label { margin-left: 8px; font-size: 11px; font-weight: 600; color: #6fdc9b; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.page-btn {
  padding: 7px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.page-btn:hover { border-color: var(--accent); }
.page-info { color: var(--text-dim); font-size: 13px; }

/* ---- Tier override selector (users table) ---- */
.tier-select-wrap { margin-top: 6px; }
.tier-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  /* custom chevron */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9aa3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.tier-select:hover { border-color: var(--accent); }
.tier-select:focus { outline: none; border-color: var(--accent); }
.tier-select option { background: var(--surface); color: var(--text); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: rgba(91, 140, 255, 0.16);
  color: var(--accent);
  vertical-align: middle;
}
/* The blue base above landed AFTER the status/visibility color variants
   (equal specificity — source order decides), silently turning every
   status pill blue. Re-assert the colors here so they win again. */
.badge-public { background: rgba(70,200,120,0.2); color: #6fdc9b; }
.badge-private { background: var(--surface-2); color: var(--text-dim); }
.badge-status-ready, .badge-status-success { background: rgba(70,200,120,0.18); color: #6fdc9b; }
.badge-status-processing, .badge-status-running, .badge-status-retry { background: rgba(230,190,80,0.18); color: #e6be50; }
.badge-status-failed { background: rgba(255,90,90,0.18); color: #ff9b9b; }
.badge-status-queued, .badge-status-revoked { background: var(--surface-2); color: var(--text-dim); }

/* ------------------------------------------------------------------ */
/* Tutorials CMS                                                       */
/* ------------------------------------------------------------------ */
.page-header-actions { display: flex; align-items: center; gap: 14px; }
.version-filter { display: flex; align-items: center; gap: 6px; }
.version-filter label { color: var(--text-dim); font-size: 13px; }
.version-filter select,
.filter-bar select,
.meta-form select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px;
}
.badge-served { background: rgba(70,200,120,0.2); color: #6fdc9b; }
/* Table row title links + reorder controls */
.data-table .row-title { color: var(--text); font-weight: 600; text-decoration: none; }
.data-table .row-title:hover { color: var(--accent); }
.move-stack { display: inline-flex; flex-direction: column; gap: 3px; vertical-align: middle; }
.move-btn {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 17px; padding: 0;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 5px;
  font-size: 8px; cursor: pointer; line-height: 1;
}
.move-btn:hover { color: var(--text); border-color: var(--accent); }
.badge-draft { background: var(--surface-2); color: var(--text-dim); }
.row-subtle { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.section-title { margin: 28px 0 8px; font-size: 17px; }
.form-error {
  background: rgba(255,90,90,0.12); color: #ff9b9b; border: 1px solid rgba(255,90,90,0.35);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.meta-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.meta-form label { display: block; color: var(--text-dim); font-size: 12px; margin-bottom: 10px; }
.meta-form input[type="text"], .meta-form textarea {
  display: block; width: 100%; margin-top: 4px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px;
}
.meta-form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.meta-form-row label { flex: 1; min-width: 160px; }
.meta-form-row .check-label { display: flex; align-items: center; gap: 8px; flex: none; margin-bottom: 0; }
.danger-row { margin: 0 0 18px; }
.lesson-actions { display: flex; align-items: center; gap: 18px; margin: 0 0 14px; flex-wrap: wrap; }
.lesson-actions label { color: var(--text-dim); font-size: 13px; }
.import-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 14px 0; }
.import-box summary { cursor: pointer; color: var(--text-dim); }
.import-box textarea {
  display: block; width: 100%; margin: 10px 0; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-family: ui-monospace, monospace; font-size: 12px;
}
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.section-card-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.section-card-spacer { flex: 1; }
.section-form input, .section-form textarea {
  display: block; width: 100%; margin-bottom: 8px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px;
}
.field-hint { color: var(--text-dim); font-size: 11px; display: block; margin: -4px 0 8px; }
/* Inside a flex form row the hint sits beside a control: kill the block offsets so
   align-items centers it against the dropdown. */
.section-form-row .field-hint { display: inline; margin: 0; }
/* Stacked form rows (e.g. spacer size row above the type/save row) get breathing room. */
.section-form-row + .section-form-row { margin-top: 10px; }
.btn-small { padding: 5px 12px; font-size: 12px; }
.section-preview { border-top: 1px dashed var(--border); margin-top: 10px; padding-top: 10px; }

/* Shared tutorial-section rendering (ts-*), mirrored in the public styles.css */
.ts-heading { font-size: 22px; margin: 8px 0; }
.ts-subheading { font-size: 17px; margin: 6px 0; }
.ts-text p { margin: 8px 0; line-height: 1.6; }
.ts-list { margin: 8px 0 8px 22px; line-height: 1.6; }
.ts-quote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 4px 14px; color: var(--text-dim); }
.ts-quote cite { display: block; font-size: 12px; margin-top: 4px; }
.ts-callout { background: rgba(91,140,255,0.12); border: 1px solid rgba(91,140,255,0.35); border-radius: 8px; padding: 10px 14px; margin: 8px 0; }
.ts-callout-title { display: block; margin-bottom: 4px; }
.ts-table-wrap { overflow-x: auto; margin: 8px 0; }
.ts-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.ts-table th, .ts-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.ts-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.ts-button-row { margin: 10px 0; }
.ts-button { display: inline-block; background: var(--accent); color: #fff; border-radius: 8px; padding: 8px 16px; text-decoration: none; }
.ts-media { margin: 10px 0; }
.ts-media video { max-width: 100%; border-radius: 8px; display: block; }
.ts-media img { width: 100%; border-radius: 8px; display: block; }
.ts-media figcaption { color: var(--text-dim); font-size: 12px; margin-top: 6px; }
.ts-grid { display: grid; gap: 8px; }
.ts-grid-2 { grid-template-columns: 1fr 1fr; }
.ts-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.ts-youtube { position: relative; aspect-ratio: 16 / 9; }
.ts-youtube iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }
.section-form-row { display: flex; align-items: center; gap: 10px; }
.section-form-row select {
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; font-size: 12px;
}
.media-missing {
  border: 2px dashed var(--border); border-radius: 8px; color: var(--text-dim);
  padding: 18px 14px; text-align: center; font-size: 12px;
}
/* Full-lesson preview overlay */
.preview-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.65); padding: 30px;
}
.preview-overlay.open { display: flex; justify-content: center; }
.preview-panel {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 820px; max-height: 100%; overflow-y: auto; padding: 0 34px 34px;
}
.preview-panel-bar {
  position: sticky; top: 0; background: var(--bg); display: flex; justify-content: space-between;
  align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.preview-title { font-size: 26px; color: var(--text); margin: 6px 0 8px; }
.preview-intro { color: var(--text-dim); margin-bottom: 24px; }
.preview-page .media-missing { margin: 14px 0; padding: 40px 20px; }

/* Feature config: accordion groups + nested key tables (sameskyai-style) */
.feature-group-row { cursor: pointer; }
.accordion-caret {
  display: inline-block; color: var(--text-dim); font-size: 10px;
  transition: transform 0.15s ease;
}
.accordion-caret.expanded { transform: rotate(90deg); }
.config-key {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  background: var(--surface-2); padding: 2px 7px; border-radius: 5px;
}
.type-pill {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.type-pill--bool { background: rgba(70,200,120,0.18); color: #6fdc9b; }
.type-pill--string { background: rgba(91,140,255,0.18); color: #9ab4ff; }
.type-pill--int, .type-pill--float { background: rgba(230,190,80,0.18); color: #e6be50; }
.type-pill--dict { background: rgba(200,120,255,0.18); color: #d9a8ff; }
.keys-panel-cell { padding: 0 !important; background: var(--bg); }
.keys-panel { padding: 14px 18px 18px 44px; border-top: 1px solid var(--border); }
.keys-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.keys-panel-title { color: var(--text-dim); font-size: 13px; }
.keys-table { width: 100%; border-collapse: collapse; }
.keys-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-dim); text-align: left; padding: 6px 10px;
}
.keys-table td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: top; }
/* Values and descriptions WRAP (the upstream layout let long strings overflow) */
.config-value {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text);
  display: block; max-width: 280px;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.desc-cell { color: var(--text-dim); font-size: 12px; word-break: break-word; overflow-wrap: anywhere; }
/* Shared panel modal */
.panel-modal {
  display: none; position: fixed; inset: 0; z-index: 210;
  background: rgba(0,0,0,0.65); align-items: center; justify-content: center; padding: 24px;
}
.panel-modal.is-open { display: flex; }
.panel-modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 460px; padding: 22px 24px;
}
.panel-modal-box h2 { margin-bottom: 14px; font-size: 17px; }
.panel-modal-box label { display: block; color: var(--text-dim); font-size: 12px; margin-bottom: 12px; }
.panel-modal-box input[type="text"], .panel-modal-box input[type="datetime-local"],
.panel-modal-box select, .panel-modal-box textarea {
  display: block; width: 100%; margin-top: 4px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px;
}
.fk-key-prefix { color: var(--text-dim); font-family: ui-monospace, Menlo, monospace; }
.panel-modal-actions { display: flex; justify-content: flex-end; gap: 14px; margin-top: 6px; }

/* More menu (SameSky-style popover) */
.more-wrapper { position: relative; display: inline-block; }
.more-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 3px 9px; border-radius: 6px;
}
.more-btn:hover { background: var(--surface-2); color: var(--text); }
.more-menu {
  /* Fixed + JS-placed so .data-table's overflow:hidden (rounded corners) can't clip it */
  display: none; position: fixed; min-width: 160px;
  background: rgba(20, 20, 26, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  padding: 4px 0; z-index: 60;
}
.more-wrapper.open .more-menu { display: flex; flex-direction: column; }
.more-menu form { display: contents; }
.more-item {
  background: none; border: none; text-align: left; width: 100%;
  padding: 8px 14px; color: var(--text); font-size: 13px; cursor: pointer;
  transition: background 0.15s;
}
.more-item:hover { background: rgba(255, 255, 255, 0.07); }
.more-item--danger { color: #ff6b6b; }

/* Count stack: status pills stacked and centered in their column (tutorials counts) */
.count-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }

/* Segmented tab picker + tab panels (modal editor) */
.seg-control {
  display: inline-flex; gap: 2px; margin: 6px 0 18px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px;
}
.seg-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 7px 16px; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
/* Panels hide via CSS (not hidden attr) so their inputs still submit with the form. */
.editor-tab { display: none; }
.editor-tab.is-active { display: block; }

/* Tutorials pages: header row, toolbar, and form rhythm */
.tut-page-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 6px;
}
.tut-page-header h1 { margin: 0; }
.tut-header-links { display: flex; align-items: center; gap: 18px; }
.tut-header-links form { display: inline; }
.tut-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 14px 0 16px; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.tut-inline-form { display: flex; align-items: center; gap: 10px; }
.tut-inline-form input[type="text"] {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; width: 280px;
}
.tut-inline-form select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.tut-add-lesson { margin-bottom: 16px; }
.meta-form-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border);
}
.meta-form-actions .check-label {
  display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px;
}
.section-title { margin: 30px 0 12px; }

/* Joined input + select group (one continuous control, button separate) */
.input-join { display: flex; align-items: stretch; }
.input-join input[type="text"] {
  border-radius: 8px 0 0 8px !important; border-right: none !important; width: 280px;
}
.input-join select {
  border-radius: 0 8px 8px 0 !important; border-left: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim);
}
/* Status badge that opens a popover (served/draft dropdowns) */
.badge-menu {
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; border: none; cursor: pointer;
}
.badge-menu.badge-served { background: rgba(70,200,120,0.2); color: #6fdc9b; }
.badge-menu.badge-draft { background: var(--surface-2); color: var(--text-dim); }
.badge-menu:hover { filter: brightness(1.25); }
.more-menu a.more-item { display: block; text-decoration: none; }

/* Meta-form selects align with the stacked text inputs */
.meta-form label > select {
  display: block; width: 100%; margin-top: 4px; padding: 8px;
}

/* Feature sync modal */
.panel-modal-box--wide { max-width: 720px; max-height: 90vh; overflow-y: auto; }
.sync-section { margin-bottom: 20px; }
.sync-section-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.sync-section-header h3 { font-size: 14px; color: var(--text); }
.sync-json {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.sync-actions { display: flex; gap: 10px; margin-top: 10px; }
.sync-preview {
  margin-top: 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; font-family: ui-monospace, Menlo, monospace;
  font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow: auto;
}

/* Dashboard App Store cards */
.stat-card--chart { min-width: 210px; }
.stat-value-row { display: flex; align-items: baseline; gap: 10px; }
.stat-delta { font-size: 12px; font-weight: 700; }
.stat-delta--up { color: #6fdc9b; }
.stat-delta--down { color: #ff8b8b; }
.sparkline { width: 100%; height: 36px; margin-top: 10px; display: block; }
.sparkline polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* ---- App Store analytics drill-in (full hoverable charts) ---- */
.range-row { display: flex; gap: 6px; margin-bottom: 20px; }
.range-btn {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
}
.range-btn:hover { border-color: var(--accent); color: var(--text); }
.range-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 16px;
}
.chart-metric-label {
  color: var(--text-dim); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.chart-total { font-size: 30px; font-weight: 700; margin-top: 2px; }
.chart-plot { position: relative; margin-top: 8px; outline: none; }
.chart-plot:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 6px; }
.chart-plot svg { display: block; }

.asc-grid { stroke: var(--surface-2); stroke-width: 1; }
.asc-axis-text { fill: var(--text-dim); font-size: 11px; }
.asc-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.asc-area { fill: var(--accent); opacity: 0.1; }
.asc-hair { stroke: var(--text-dim); stroke-width: 1; }
.asc-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

.asc-tip {
  display: none; position: absolute; z-index: 20; pointer-events: none; white-space: nowrap;
  background: rgba(20, 20, 26, 0.94);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  padding: 8px 12px; font-size: 12px;
}
.asc-tip-date { color: var(--text-dim); margin-bottom: 2px; }
.asc-tip-value { font-size: 15px; font-weight: 700; color: var(--text); margin-right: 6px; }
.asc-tip-label { color: var(--text-dim); }

.asc-table-wrap { margin-top: 18px; }
.asc-table-wrap summary { cursor: pointer; color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }
.asc-table td { font-variant-numeric: tabular-nums; }

/* Tutorials import modal */
#tut-import-modal textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; margin-bottom: 8px;
}

/* Confirmation toast */
#panel-toast {
  position: fixed; bottom: 24px; right: 28px; z-index: 300;
  background: rgba(20, 20, 26, 0.94);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  color: #6fdc9b; font-size: 13px; font-weight: 600;
  padding: 9px 16px; opacity: 0; transform: translateY(6px);
  pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease;
}
#panel-toast.is-visible { opacity: 1; transform: translateY(0); }

/* Hidden sections: editable, but visibly parked */
.badge-hidden {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(230, 190, 80, 0.16); color: #e6be50;
}
.section-card--hidden { border-style: dashed; }
.section-card--hidden .section-preview { opacity: 0.45; }

.badge-failed { background: rgba(255, 107, 107, 0.18); color: #ff8b8b; font-size: 11px;
  font-weight: 700; padding: 2px 9px; border-radius: 999px; }

/* Fixed-width sections: centered, never wider than the tutorial area */
.ts-width { max-width: 100%; margin-left: auto; margin-right: auto; }
.section-width-input {
  width: 110px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px;
}

/* Spacer sections: pure vertical whitespace */
.ts-spacer--xs { height: 12px; }
.ts-spacer--s  { height: 24px; }
.ts-spacer--m  { height: 48px; }
.ts-spacer--l  { height: 80px; }
.ts-spacer--xl { height: 128px; }
.ts-spacer--xxl { height: 192px; }
/* In the editor's mini preview, make the invisible visible */
.section-preview .ts-spacer { border: 1px dashed var(--border); border-radius: 6px; }

/* Numbered pagination */
.page-btn--current {
  background: var(--accent); color: #fff; border-color: var(--accent);
  cursor: default; font-weight: 700;
}
.page-ellipsis { color: var(--text-dim); padding: 0 4px; }
.resource-filter-bar { display: flex; gap: 10px; align-items: center; }
.resource-filter-bar select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}

/* Grid/list view toggle */
.view-toggle { display: flex; gap: 2px; margin-left: auto; }
.view-toggle-btn {
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  font-size: 16px; line-height: 1; padding: 8px 12px; cursor: pointer;
}
.view-toggle-btn:first-child { border-radius: 8px 0 0 8px; }
.view-toggle-btn:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.view-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Slim resource list rows */
.resource-rows { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.resource-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 12px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.resource-row:last-child { border-bottom: none; }
.resource-row:hover { background: var(--surface-2); }
.resource-row-thumb img, .resource-row-thumb-ph {
  width: 44px; height: 25px; object-fit: cover; border-radius: 4px; display: block;
  background: var(--surface-2);
}
.resource-row-thumb-ph { border: 1px dashed var(--border); }
.resource-row-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}
.resource-row-detail { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.resource-row-copy { font-size: 12px; white-space: nowrap; }

/* Deploy page */
.deploy-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 10px; }
.deploy-targets { display: flex; gap: 2px; }
.deploy-target input { display: none; }
.deploy-target span {
  display: block; padding: 8px 14px; font-size: 13px; cursor: pointer;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
}
.deploy-target:first-child span { border-radius: 8px 0 0 8px; }
.deploy-target:last-child span { border-radius: 0 8px 8px 0; }
.deploy-target:not(:first-child) span { border-left: none; }
.deploy-target input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.deploy-commits {
  flex: 1; min-width: 320px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}

/* Drag & drop upload */
body.drop-active .resource-upload {
  outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 8px;
}
.resource-row-uploader { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* Info note: textbook-sidenote style callout for helpful tips */
.info-note {
  display: flex; align-items: flex-start; gap: 12px;
  background: rgba(91, 140, 255, 0.07);
  border: 1px solid rgba(91, 140, 255, 0.35);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px; margin: 4px 0 20px;
  color: var(--text-dim); font-size: 13px; line-height: 1.55; max-width: 860px;
}
.info-note strong { color: var(--text); font-weight: 600; }
.info-note-icon {
  flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; font-style: italic; font-family: Georgia, serif;
  display: flex; align-items: center; justify-content: center;
}
.deploy-form { margin-top: 4px; margin-bottom: 26px; }

/* Small inline spinner */
.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.deploy-loading { display: flex; align-items: center; gap: 8px; }

/* Product analytics: horizontal breakdown bars, two-column layout, chart legend. */
.analytics-cols { display: flex; gap: 32px; flex-wrap: wrap; margin-top: 24px; }
.analytics-col { flex: 1; min-width: 280px; }
.analytics-h2 { font-size: 14px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.04em; margin: 28px 0 12px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: 13px; }
.bar-label { flex: 0 0 150px; color: var(--text-dim); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-value { flex: 0 0 48px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); margin: 6px 0 10px; }
.chart-legend .legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle; }
.row-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.panel-caption { font-size: 12px; color: var(--text-dim); margin: 10px 0 12px; }
.panel-bars { display: flex; flex-direction: column; gap: 4px; }

/* Clickable table rows (Users list, sessions) — whole row navigates, interactive cells excepted. */
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--surface-2); }

/* Sub-navigation tabs on the user detail pages. */
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 4px 0 22px; }
.subnav a {
  padding: 8px 14px; font-size: 13px; color: var(--text-dim); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ */
/* Mobile / compact layout: sidebar becomes a hamburger-opened drawer */
/* ------------------------------------------------------------------ */

.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 820px) {
  /* The viewport-locked flex layout gives way to normal page scrolling. */
  .admin-body { display: block; height: auto; overflow: visible; }
  .main-content { height: auto; padding: 16px 14px 32px; overflow-x: auto; }
  .page-header h1 { font-size: 19px; }

  /* Compact top bar with the hamburger. */
  .mobile-topbar {
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 90;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .mobile-topbar-logo { height: 22px; width: auto; display: block; }
  .hamburger-btn {
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 38px; height: 34px; padding: 7px 8px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    cursor: pointer;
  }
  .hamburger-btn span {
    display: block; height: 2px; border-radius: 2px; background: var(--text);
  }

  /* The sidebar becomes an off-canvas drawer above a backdrop. */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
    width: min(280px, 82vw); height: 100%;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 110;
    background: rgba(0, 0, 0, 0.55);
  }

  /* Wide content scrolls inside its own container instead of breaking the page. */
  .data-table { min-width: 640px; }
  .stat-card { min-width: 140px; padding: 16px 18px; flex: 1 1 40%; }
  .filter-search { width: 100%; }
  .config-layout { flex-direction: column; }
  .config-sidebar { flex: none; width: 100%; }
  .two-col { flex-direction: column; }
}

/* ---- Render farm (Core > Render) ---- */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-dim); flex: none; }
.status-dot.online { background: #34c759; box-shadow: 0 0 6px rgba(52,199,89,.55); }

.farm-worker { background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.farm-worker-head { display: flex; align-items: center; gap: 10px; }
.farm-worker-head.clickable { cursor: pointer; margin: -14px -16px; padding: 14px 16px;
  border-radius: 12px; }
.farm-worker-head.clickable:hover { background: var(--surface-2); }
.farm-worker-head + .farm-job { margin-top: 22px; }

.farm-job { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.farm-job.clickable { cursor: pointer; }
.farm-job.clickable:hover { border-color: var(--accent); }
.farm-job-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.progress-track { height: 5px; border-radius: 3px; background: var(--border);
  margin-top: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px;
  transition: width .4s ease; }

.farm-request { display: flex; align-items: center; gap: 12px;
  background: rgba(230,168,40,.07); border: 1px solid rgba(230,168,40,.45);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }

.frame-chart { display: flex; align-items: flex-end; gap: 1px; height: 96px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; overflow: hidden; }
.frame-bar { flex: 1; min-width: 1px; border-radius: 1px; background: var(--accent);
  opacity: .85; }
.frame-bar.slowest { background: #ff6b6b; opacity: 1; }

.report-preview { width: 100%; max-height: 420px; border-radius: 12px;
  border: 1px solid var(--border); background: #000; display: block; object-fit: contain; }

/* ---- Communication (Outreach CRM) ---- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.btn-secondary {
  display: inline-block; padding: 8px 14px; border-radius: 8px; font-size: 13px;
  font-weight: 600; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); cursor: pointer; text-decoration: none;
}
.btn-secondary:hover { filter: brightness(1.12); }
.badge-status-replied { background: rgba(90,160,255,0.18); color: #8ec2ff; }
.comms-links { display: flex; flex-direction: column; gap: 2px; max-width: 260px; }
.comms-links .row-link { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comms-detail-grid { display: grid; grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .comms-detail-grid { grid-template-columns: 1fr; } }
.comms-side-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.comms-side-section h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-dim); margin: 0 0 10px;
}
.comms-activity-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.comms-activity-item:last-child { border-bottom: none; }
.comms-status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.comms-status-btn.is-current { cursor: default; }

/* One hue per outreach stage (badges below share them); accent-blue stays
   reserved for links/actions so current-status reads at a glance. */
.comms-status-btn--not_contacted.is-current { border-color: var(--text-dim); color: var(--text-dim); }
.comms-status-btn--contacted.is-current { border-color: #e6be50; color: #e6be50; }
.comms-status-btn--replied.is-current { border-color: #b9a0ff; color: #b9a0ff; }
.comms-status-btn--interested.is-current { border-color: #6fdc9b; color: #6fdc9b; }
.comms-status-btn--declined.is-current { border-color: #ff9b9b; color: #ff9b9b; }

.badge-contact-none { background: var(--surface-2); color: var(--text-dim); }
.badge-contact-contacted { background: rgba(230,190,80,0.18); color: #e6be50; }
.badge-contact-replied { background: rgba(150,110,255,0.2); color: #b9a0ff; }
.badge-contact-interested { background: rgba(70,200,120,0.18); color: #6fdc9b; }
.badge-contact-declined { background: rgba(255,90,90,0.18); color: #ff9b9b; }

.comms-category-count {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  background: var(--surface-2); border-radius: 999px; padding: 1px 8px;
  margin-left: 6px; letter-spacing: 0;
}

/* ---- Communication (Inbox) ---- */
.comms-search {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 12px; font-size: 13px; min-width: 280px;
}
/* Read mail reads as read: normal weight everywhere, bold only while unread. */
.comms-row-main { font-weight: 400; color: var(--text); }
.comms-unread .comms-row-main { font-weight: 700; }
.comms-unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.comms-message {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.comms-message--me { border-color: rgba(90,160,255,0.35); }
.comms-message-head {
  display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap;
}
.comms-message-date { margin-left: auto; }
.comms-message-body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; }
.comms-html-frame {
  width: 100%; height: 420px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff;
}
.comms-attachments { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; }

/* ---- Communication (Inbox: gmail-style thread) ---- */
/* Flat thread: no box around messages, just a rule above each header. */
.comms-thread { background: transparent; }
.comms-msg { border-top: 1px solid var(--border); }
.comms-msg-head {
  display: flex; gap: 12px; align-items: baseline; padding: 12px 16px;
  cursor: pointer; min-width: 0;
}
.comms-msg-head:hover { background: var(--surface-2); }
.comms-msg-sender { font-weight: 700; white-space: nowrap; }
.comms-msg--me .comms-msg-sender { color: var(--accent); }
.comms-msg-preview, .comms-msg-addr {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.comms-msg-addr { display: none; }
.comms-msg-date { margin-left: auto; white-space: nowrap; }
.comms-msg-body { display: none; padding: 4px 16px 16px; }
.comms-msg.is-open .comms-msg-body { display: block; }
.comms-msg.is-open .comms-msg-preview { display: none; }
.comms-msg.is-open .comms-msg-addr { display: block; }
.comms-html-frame { border: none; display: block; }

/* ---- Communication (gif picker + test-send row) ---- */
.comms-gif-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: -2px 0 12px; }
.comms-test-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.comms-sent-banner { border-color: rgba(70,200,120,0.45); background: rgba(70,200,120,0.08); }
.comms-sent-banner .info-note-icon { color: #6fdc9b; }
.comms-reply-cta { margin-top: 10px; }
.comms-reply-box { margin-top: 18px; }

/* ---- Communication (compose live preview) ---- */
.comms-preview-section { margin-top: 18px; }
.comms-preview-toggle { display: flex; align-items: center; gap: 8px; }
.comms-preview-subject { font-weight: 700; margin: 12px 0 2px; }
.comms-preview-subject + .row-subtle { margin-bottom: 10px; }
.comms-preview-frame {
  width: 100%; height: 200px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; display: block;
}

/* ---- Admins (capability grants) ---- */
.superadmin-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent); border: 1px solid var(--accent);
}
.caps-panel-cell { padding: 0 !important; border-bottom: none; }
.caps-panel-cell:empty { display: none; }
.caps-editor {
  display: block; padding: 14px 16px 16px;
  background: var(--surface-2); border-radius: 10px; margin: 0 0 14px;
}
.caps-readonly { color: var(--text-dim); font-size: 13px; margin: 0 0 10px; }
.caps-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px 22px;
}
.caps-group-title {
  margin: 0 0 6px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim);
}
.caps-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 3px 0; font-size: 13px; cursor: pointer;
}
.caps-row input[type="checkbox"] { flex: none; accent-color: var(--accent); }
.caps-row input[type="checkbox"]:disabled + .caps-label { color: var(--text-dim); }
.caps-label { color: var(--text); }
.caps-key { margin-left: auto; font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.caps-actions { margin-top: 14px; display: flex; align-items: center; gap: 12px; }
.caps-saved { color: #7bd88f; font-size: 13px; }

/* ---- Admins (user search to promote) ---- */
.admin-search-results { margin-bottom: 16px; }
.admin-search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); margin-bottom: 6px;
}
.admin-search-result .btn-primary { margin-left: auto; }
.admin-search-result > .row-subtle:last-child { margin-left: auto; }
