/* ============================================================================
   QuorieAI Admin — the ONE look of every back-office console.

   Super Hub, each company's operations console (/ops), the gateway's /console and
   the marketplace admin used to wear four palettes (teal, steel blue, two indigos),
   so moving between them felt like changing product. They now share this file.

   ⚠️ CANONICAL COPY: ops/admin_theme/admin-theme.css. Each console ships a
   byte-identical copy beside its own index.html (the services are separate images
   and cannot reach each other's files — the totp.py / throttle.py precedent).
   tests/test_admin_theme.py fails when a copy drifts; edit HERE and copy out.

   The tokens are the customer WORKSPACE's own (frontend/styles.css): indigo
   #6d6af8, the same neutrals and status colours, so a member moving from their
   workspace to an admin page sees one product. Everything is prefixed `--qa-` /
   `.qa-` so nothing here can collide with a console's own names — a console
   aliases its old variable names onto these instead of being rewritten.

   What changes between consoles is the PLACE LABEL under the logo (Super Hub,
   Krobox, Marketplace…), never the colour.
   ========================================================================= */

:root {
  --qa-bg: #101014;
  --qa-rail: #141419;
  --qa-panel: #17171c;
  --qa-sunk: #131318;
  --qa-raise: #232329;
  --qa-hover: #2b2b33;
  --qa-line: #26262e;
  --qa-line-2: #33333c;
  --qa-text: #ececf1;
  --qa-dim: #b9b9c6;
  --qa-faint: #94949f;
  --qa-accent: #6d6af8;
  --qa-accent-2: #a5a3ff;
  --qa-accent-fill: #5b57f0;   /* a button fill white text reads on at 13px */
  --qa-accent-soft: rgba(109, 106, 248, .16);
  --qa-on-accent: #ffffff;
  --qa-ok: #34c37e;   --qa-ok-soft: rgba(52, 195, 126, .13);
  --qa-warn: #e0a458; --qa-warn-soft: rgba(224, 164, 88, .13);
  --qa-bad: #f06464;  --qa-bad-soft: rgba(239, 68, 68, .14);
  --qa-info: #6aa0f8; --qa-info-soft: rgba(79, 143, 247, .14);
  --qa-muted: #a0a0ab; --qa-muted-soft: rgba(148, 148, 159, .14);
  --qa-shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --qa-shadow-2: 0 12px 32px rgba(0, 0, 0, .5);
  --qa-backdrop: rgba(0, 0, 0, .6);
  --qa-radius: 12px;
  --qa-radius-sm: 8px;
  --qa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --qa-mono: "Cascadia Code", "Fira Code", "SF Mono", ui-monospace, Consolas, monospace;
  --qa-rail-w: 248px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --qa-bg: #f6f6f8;
  --qa-rail: #fafafc;
  --qa-panel: #ffffff;
  --qa-sunk: #f3f3f7;
  --qa-raise: #f0f0f4;
  --qa-hover: #e9e9ef;
  --qa-line: #e6e6ee;
  --qa-line-2: #d9d9e3;
  --qa-text: #1e2026;
  --qa-dim: #565b66;
  --qa-faint: #6f7480;
  --qa-accent: #5a55ee;
  --qa-accent-2: #4640c8;
  --qa-accent-fill: #5a55ee;
  --qa-accent-soft: rgba(90, 85, 238, .10);
  --qa-ok: #17915b;   --qa-ok-soft: rgba(23, 145, 91, .10);
  --qa-warn: #b45309; --qa-warn-soft: rgba(180, 83, 9, .10);
  --qa-bad: #d92d20;  --qa-bad-soft: rgba(217, 45, 32, .09);
  --qa-info: #2563eb; --qa-info-soft: rgba(37, 99, 235, .09);
  --qa-muted: #6f7480; --qa-muted-soft: rgba(111, 116, 128, .12);
  --qa-shadow-1: 0 1px 2px rgba(16, 18, 28, .06);
  --qa-shadow-2: 0 12px 32px rgba(16, 18, 28, .14);
  --qa-backdrop: rgba(16, 18, 28, .35);
  color-scheme: light;
}

/* ⚠️ The browser's `[hidden] { display: none }` is a USER-AGENT rule, and any author rule
   that sets `display` beats it outright — specificity never enters into it. Every class
   below that sets `display` would otherwise ignore `el.hidden = true`: the place menu
   stayed open on /ops and could not be collapsed, because that console's own sheet has no
   `[hidden]` reset (Super Hub's has, which is why it only showed on one console). The
   guard lives HERE, and matches EVERY shared class — a list of them was already a dozen
   short the day it was written — so no console has to remember it. */
[class*="qa-"][hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */
.qa-shell {
  display: grid; grid-template-columns: var(--qa-rail-w) minmax(0, 1fr);
  height: 100vh; height: 100dvh; min-height: 0;
  background: var(--qa-bg); color: var(--qa-text); font-family: var(--qa-font);
}
.qa-rail {
  background: var(--qa-rail); border-right: 1px solid var(--qa-line);
  display: flex; flex-direction: column; gap: 14px; padding: 18px 12px 14px;
  min-height: 0; overflow-y: auto;
}
.qa-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--qa-text);
  text-decoration: none; }
.qa-brand:hover { text-decoration: none; }
.qa-brand .qa-mark { width: 26px; height: 26px; color: var(--qa-accent); flex-shrink: 0; }
.qa-word { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.qa-word b { color: var(--qa-accent-2); font-weight: inherit; }
.qa-tag { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--qa-faint);
  border: 1px solid var(--qa-line-2); border-radius: 6px; padding: 1px 6px; }

/* Where you are — and, when the page knows other places, the way to them. */
.qa-place { position: relative; }
.qa-place-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border-radius: 10px; border: 1px solid var(--qa-line-2); background: var(--qa-raise);
  color: var(--qa-text); font: inherit; text-align: left;
}
button.qa-place-btn { cursor: pointer; }
button.qa-place-btn:hover { border-color: var(--qa-faint); }
.qa-place-ico { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--qa-accent-soft); color: var(--qa-accent-2);
  display: grid; place-items: center; }
.qa-place-ico svg { width: 17px; height: 17px; }
.qa-place-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.qa-place-t { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-place-s { font-size: 12px; color: var(--qa-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-place-btn .qa-chev { width: 16px; height: 16px; color: var(--qa-faint); flex-shrink: 0; }
.qa-place-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--qa-raise); border: 1px solid var(--qa-line-2); border-radius: 10px;
  box-shadow: var(--qa-shadow-2); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.qa-place-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; color: var(--qa-text); text-decoration: none; }
.qa-place-item:hover { background: var(--qa-hover); text-decoration: none; }
.qa-place-item.on { background: var(--qa-accent-soft); }
.qa-place-item svg { width: 17px; height: 17px; color: var(--qa-dim); flex-shrink: 0; }
.qa-place-item .qa-place-txt .qa-place-t { font-size: 13px; }
.qa-place-note { font-size: 11.5px; color: var(--qa-faint); padding: 6px 10px 2px; }

.qa-search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px;
  border-radius: var(--qa-radius-sm); border: 1px solid var(--qa-line); background: var(--qa-sunk); }
.qa-search:focus-within { border-color: var(--qa-accent); }
.qa-search svg { width: 15px; height: 15px; color: var(--qa-faint); flex-shrink: 0; }
.qa-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--qa-text);
  font: inherit; font-size: 13px; outline: none; padding: 0; }
.qa-search input::placeholder { color: var(--qa-faint); }
.qa-kbd { font-family: var(--qa-mono); font-size: 11px; color: var(--qa-faint);
  border: 1px solid var(--qa-line-2); border-radius: 4px; padding: 0 5px; }

.qa-nav { display: flex; flex-direction: column; gap: 1px; }
.qa-nav-h { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--qa-faint); padding: 12px 10px 4px; }
.qa-nav-item {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 10px; width: 100%;
  border: 0; border-radius: var(--qa-radius-sm); background: none; color: var(--qa-dim);
  font: inherit; font-size: 13.5px; text-align: left; text-decoration: none; cursor: pointer;
}
.qa-nav-item:hover { background: var(--qa-hover); color: var(--qa-text); text-decoration: none; }
.qa-nav-item.on, .qa-nav-item[aria-current="page"] {
  background: var(--qa-accent-soft); color: var(--qa-text); font-weight: 600; }
.qa-nav-item .qa-ico { width: 17px; height: 17px; flex-shrink: 0; color: currentColor; }
.qa-nav-item.on .qa-ico, .qa-nav-item[aria-current="page"] .qa-ico { color: var(--qa-accent-2); }
.qa-nav-item .qa-ext { width: 13px; height: 13px; margin-left: auto; color: var(--qa-faint); }
.qa-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  background: var(--qa-muted-soft); color: var(--qa-muted); }

.qa-foot { margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 6px 0; border-top: 1px solid var(--qa-line); }
.qa-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--qa-accent-2); color: var(--qa-accent-2);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; text-transform: uppercase; }
.qa-who { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.qa-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-who-n { font-size: 13px; font-weight: 600; color: var(--qa-text); }
.qa-who-r { font-size: 12px; color: var(--qa-faint); }
.qa-iconbtn { width: 30px; height: 30px; border-radius: var(--qa-radius-sm); border: 0;
  background: transparent; color: var(--qa-dim); display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0; padding: 0; }
.qa-iconbtn:hover { background: var(--qa-hover); color: var(--qa-text); }
.qa-iconbtn svg { width: 17px; height: 17px; }

.qa-main { min-width: 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.qa-head {
  position: sticky; top: 0; z-index: 20; flex-shrink: 0;
  display: flex; align-items: center; gap: 16px; min-height: 76px; padding: 12px 32px;
  background: var(--qa-bg); border-bottom: 1px solid var(--qa-line);
}
.qa-head-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.qa-head-sub { font-size: 12px; color: var(--qa-faint); }
.qa-head h1, .qa-head-title { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.qa-head-tools { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.qa-stamp { font-size: 12px; color: var(--qa-faint); font-variant-numeric: tabular-nums; }
.qa-body { padding: 24px 32px 60px; display: flex; flex-direction: column; gap: 20px; }

/* ---------------------------------------------------------------- pieces */
.qa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--qa-radius-sm);
  border: 1px solid var(--qa-line-2); background: var(--qa-raise); color: var(--qa-text);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.qa-btn:hover { border-color: var(--qa-faint); text-decoration: none; }
.qa-btn svg { width: 16px; height: 16px; }
.qa-btn.primary { background: var(--qa-accent-fill); border-color: var(--qa-accent-fill);
  color: var(--qa-on-accent); font-weight: 600; }
.qa-btn.primary:hover { filter: brightness(1.08); }
.qa-btn.ghost { background: transparent; border-color: transparent; color: var(--qa-dim); }
.qa-btn.ghost:hover { background: var(--qa-hover); color: var(--qa-text); }
.qa-btn.danger { background: var(--qa-bad-soft); border-color: var(--qa-bad-soft); color: var(--qa-bad);
  font-weight: 600; }
.qa-btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.qa-btn:disabled { opacity: .5; cursor: default; }

.qa-pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--qa-muted-soft); color: var(--qa-muted); }
.qa-pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.qa-pill.ok { background: var(--qa-ok-soft); color: var(--qa-ok); }
.qa-pill.warn { background: var(--qa-warn-soft); color: var(--qa-warn); }
.qa-pill.bad { background: var(--qa-bad-soft); color: var(--qa-bad); }
.qa-pill.info { background: var(--qa-info-soft); color: var(--qa-info); }
.qa-pill.accent { background: var(--qa-accent-soft); color: var(--qa-accent-2); }

.qa-card { background: var(--qa-panel); border: 1px solid var(--qa-line); border-radius: var(--qa-radius); }
.qa-seg { display: inline-flex; padding: 3px; border-radius: 9px; border: 1px solid var(--qa-line-2);
  background: var(--qa-sunk); }
.qa-seg > * { height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent;
  color: var(--qa-dim); font: inherit; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; }
.qa-seg > .on, .qa-seg > [aria-pressed="true"] { background: var(--qa-raise); color: var(--qa-text); font-weight: 600; }

/* ---------------------------------------------------------------- sign-in */
.qa-signin { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: var(--qa-bg); color: var(--qa-text); font-family: var(--qa-font); box-sizing: border-box; }
.qa-signin-card {
  width: min(380px, 100%); box-sizing: border-box; background: var(--qa-panel);
  border: 1px solid var(--qa-line); border-radius: 16px; padding: 32px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--qa-shadow-2);
}
.qa-signin-card .qa-mark { width: 40px; height: 40px; color: var(--qa-accent); margin-bottom: 8px; }
.qa-signin-card h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.qa-signin-place { align-self: flex-start; display: inline-flex; align-items: center; height: 24px;
  padding: 0 10px; border-radius: 999px; background: var(--qa-accent-soft); color: var(--qa-accent-2);
  font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.qa-signin-card label { font-size: 12px; font-weight: 500; color: var(--qa-faint); margin-top: 6px; }
.qa-signin-card input:not([type="checkbox"]):not([type="radio"]) {
  height: 40px; box-sizing: border-box; padding: 0 12px; border-radius: var(--qa-radius-sm);
  border: 1px solid var(--qa-line-2); background: var(--qa-sunk); color: var(--qa-text);
  font: inherit; font-size: 14px; width: 100%; outline: none; }
.qa-signin-card input:focus { border-color: var(--qa-accent); box-shadow: 0 0 0 3px var(--qa-accent-soft); }
.qa-signin-card button[type="submit"], .qa-signin-card .qa-btn.primary { height: 42px; margin-top: 12px; }
.qa-signin-or { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--qa-faint);
  margin: 6px 0; }
.qa-signin-or::before, .qa-signin-or::after { content: ""; flex: 1; height: 1px; background: var(--qa-line); }

/* ---------------------------------------------------------------- narrow */
@media (max-width: 900px) {
  .qa-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    height: auto; min-height: 100vh; }
  .qa-rail { border-right: 0; border-bottom: 1px solid var(--qa-line); overflow: visible; padding: 12px; }
  .qa-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .qa-nav-item { width: auto; }
  .qa-nav-h { display: none; }
  .qa-foot { margin-top: 0; }
  .qa-main { overflow: visible; }
  .qa-head { position: static; padding: 12px 16px; flex-wrap: wrap; }
  .qa-body { padding: 16px 16px 48px; }
}
