/* ==========================================================================
   admin.css — pieces specific to this panel: users, help viewer, colour
   editor, embed box, test frame. Colours come from tokens.css only.
   ========================================================================== */

/* ------------------------------- top bar -------------------------------- */
.whoami { font-size: var(--mah-fs-sm); color: var(--mah-on-brand-2); white-space: nowrap; }
.whoami b { color: var(--mah-on-brand); font-weight: 600; }
.side-item.is-active .icon { color: var(--mah-brand); }

/* -------------------------------- panels -------------------------------- */
.panel.narrow { max-width: 620px; }
.sub-head {
  margin: var(--mah-6) 0 var(--mah-3);
  font-size: var(--mah-fs-h3);
  color: var(--mah-ink);
}
.panel-head + .sub-head { margin-top: 0; }
.help-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex: 0 0 28px;
  border: 1px solid var(--mah-line-strong);
  border-radius: 50%;
  color: var(--mah-ink-3);
  font-weight: 700;
  text-decoration: none;
}
.help-link:hover { border-color: var(--mah-brand); color: var(--mah-brand); background: var(--mah-t50); }
.limit-note { margin: 6px 0 var(--mah-4); }
.callout.bad {
  background: var(--mah-bad-bg);
  border-color: var(--mah-bad-bg);
  border-left-color: var(--mah-bad);
  color: var(--mah-bad-fg);
}
.callout.bad .icon { color: var(--mah-bad); }
.callout a { color: inherit; font-weight: 600; }

/* ------------------------------ editor rail ----------------------------- */
a.rail-item, a.btn { text-decoration: none; }
.editor-grid { grid-template-columns: var(--mah-editor-rail-w) minmax(0, 1fr); }
@media (max-width: 1279px) { .editor-grid { grid-template-columns: var(--mah-editor-rail-w) minmax(0, 1fr); } }
@media (max-width: 1023px) { .editor-grid { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------ item rows ------------------------------- */
.item { flex-wrap: wrap; }
.item .item-actions { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.item .row-pbar { flex: 1 0 100%; }
.item .item-error { flex: 1 0 100%; margin: 4px 0 0; font-size: var(--mah-fs-sm); color: var(--mah-bad-fg); }
.items:empty::before {
  content: attr(data-empty);
  display: block;
  padding: 14px;
  border: 1px dashed var(--mah-line-strong);
  border-radius: var(--mah-r-lg);
  color: var(--mah-ink-4);
  font-size: var(--mah-fs-sm);
  text-align: center;
}
.faq-form { margin-bottom: var(--mah-4); }
.qa-answer .qa-text { white-space: pre-wrap; }

/* ------------------------------ users table ----------------------------- */
.user-cell b { display: block; color: var(--mah-ink); font-weight: 600; }
.user-cell span { font-size: var(--mah-fs-sm); color: var(--mah-ink-4); }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn { margin-right: 4px; }
.data-table.compact td, .data-table.compact th { padding: 6px 12px; font-size: var(--mah-fs-sm); }
.detail-cell { font-family: var(--mah-font-mono); font-size: var(--mah-fs-xs); color: var(--mah-ink-3); word-break: break-all; }

/* ----------------------------- colour editor ---------------------------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--mah-3);
  margin-bottom: var(--mah-5);
}
.theme-field {
  display: flex;
  align-items: center;
  gap: var(--mah-3);
  padding: 8px 10px;
  border: 1px solid var(--mah-line);
  border-radius: var(--mah-r-lg);
}
.theme-field input[type="color"] {
  width: 38px; height: 32px;
  flex: 0 0 38px;
  padding: 2px;
  border: 1px solid var(--mah-line-strong);
  border-radius: var(--mah-r-md);
  background: #fff;
  cursor: pointer;
}
.theme-field span { font-size: var(--mah-fs-sm); color: var(--mah-ink-2); line-height: 1.3; }
.theme-field code { display: block; font-size: var(--mah-fs-2xs); color: var(--mah-ink-4); }

/* ------------------------------- embed ---------------------------------- */
.snippet-box { display: flex; align-items: flex-start; gap: var(--mah-3); flex-wrap: wrap; }
.snippet-box .snippet { flex: 1 1 360px; margin: 0; font-size: var(--mah-fs-sm); }
.embed-controls { display: grid; gap: var(--mah-4); }
.switch-row { display: flex; align-items: flex-start; gap: var(--mah-3); cursor: pointer; }
.switch-row b { color: var(--mah-ink); font-weight: 600; }
.switch-row .switch { margin-top: 3px; }

/* -------------------------------- test ---------------------------------- */
.test-frame-wrap { display: flex; justify-content: center; }
.test-frame {
  width: min(420px, 100%);
  height: 640px;
  border: 1px solid var(--mah-line);
  border-radius: var(--mah-r-xl);
  box-shadow: var(--mah-sh-raised);
  background: #fff;
}

/* ------------------------------ listings -------------------------------- */
.stat-strip { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.columns-help { margin-top: var(--mah-5); }
.columns-help summary { cursor: pointer; font-weight: 600; color: var(--mah-ink-2); }
.columns-list code {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 2px 8px;
  border-radius: var(--mah-r-pill);
  background: var(--mah-n100);
  font-size: var(--mah-fs-xs);
}
.columns-list code.req { background: var(--mah-a100); color: var(--mah-accent-deep); }
#listings-job { margin: var(--mah-3) 0; }

/* ------------------------------ help viewer ----------------------------- */
.help-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--mah-5); align-items: start; }
.help-nav { display: grid; gap: 2px; position: sticky; top: calc(var(--mah-topnav-h) + var(--mah-6)); }
.help-nav p { margin: var(--mah-3) 0 4px; padding: 0 10px; font-size: var(--mah-fs-2xs); font-weight: 700;
  letter-spacing: var(--mah-track-caps); text-transform: uppercase; color: var(--mah-n500); }
.help-nav a { padding: 6px 10px; border-radius: var(--mah-r-md); color: var(--mah-ink-2); text-decoration: none; font-size: var(--mah-fs-base); }
.help-nav a:hover { background: var(--mah-n100); color: var(--mah-ink); }
.help-nav a.is-active { background: var(--mah-t50); color: var(--mah-brand); font-weight: 600; }
@media (max-width: 1023px) {
  .help-grid { grid-template-columns: minmax(0, 1fr); }
  .help-nav { position: static; }
}

.doc { padding: var(--mah-7) var(--mah-8); color: var(--mah-ink-2); font-size: var(--mah-fs-lg); line-height: 1.7; }
.doc h1 { font-size: 26px; margin-bottom: var(--mah-4); }
.doc h2 { font-size: 20px; margin: var(--mah-7) 0 var(--mah-3); }
.doc h3 { margin: var(--mah-5) 0 var(--mah-2); }
.doc p, .doc ul, .doc ol { margin: 0 0 var(--mah-4); max-width: 72ch; }
.doc li { margin-bottom: 4px; }
.doc code { padding: 1px 5px; border-radius: var(--mah-r-sm); background: var(--mah-n100); font-size: .88em; }
.doc pre { padding: var(--mah-3) var(--mah-4); border-radius: var(--mah-r-lg); background: var(--mah-n750); color: #E2E8F0; overflow: auto; font-size: var(--mah-fs-13); line-height: 1.55; }
.doc pre code { padding: 0; background: none; color: inherit; }
.doc blockquote { margin: 0 0 var(--mah-4); padding: var(--mah-3) var(--mah-4); border-left: 4px solid var(--mah-accent); background: var(--mah-a50); border-radius: var(--mah-r-md); }
.doc blockquote p:last-child { margin: 0; }
.doc table { border-collapse: collapse; margin: 0 0 var(--mah-4); font-size: var(--mah-fs-base); }
.doc th, .doc td { border: 1px solid var(--mah-line); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--mah-surface-2); }
.doc img { max-width: 100%; border: 1px solid var(--mah-line); border-radius: var(--mah-r-lg); }
@media (max-width: 767px) { .doc { padding: var(--mah-5); font-size: var(--mah-fs-md); } }

/* ------------------------------- modal form ------------------------------ */
.modal .form-grid { margin-bottom: var(--mah-2); }
.modal .check { display: flex; align-items: center; gap: 8px; margin-bottom: var(--mah-3); }
.modal { max-height: calc(100vh - 40px); overflow-y: auto; }
.input-with-btn { display: flex; gap: 6px; align-items: center; }
.input-with-btn input { flex: 1; }

/* Phones: the rail is a row of labelled chips that scrolls sideways. */
@media (max-width: 1023px) {
  .rail-item { width: auto; }
  /* The drawer is a fixed grid child: "start" would shrink it to its content. */
  .sidebar { align-self: stretch; }
}
@media (max-width: 767px) {
  .rail-text { display: inline; }
  .rail-num, .rail-count { display: none; }
  .rail-item { padding: 6px 12px; border-color: var(--mah-line); border-radius: var(--mah-r-pill); white-space: nowrap; }
}

/* -------------------------------- usage --------------------------------- */
.usage-filters { display: flex; gap: var(--mah-4); flex-wrap: wrap; margin-bottom: var(--mah-5); }
.usage-filters .field { margin: 0; min-width: 220px; }
#usage-stats { margin-bottom: var(--mah-5); }
.text-bad { color: var(--mah-bad-fg); }
