/* VChat admin UI — one stylesheet, no framework, no CDN.
 *
 * Written as tokens plus a small set of components, in the order a page uses them: the shell,
 * then typography, then the pieces (cards, tables, forms, badges, buttons), then the four
 * places that need something of their own (the wizard, the uploader, the widget preview and
 * the transcript view).
 *
 * One accent colour, a system font stack, and no dark mode — an admin panel that a business
 * owner opens twice a month should look like the same product every time, and every extra
 * theme is another surface to keep honest.
 */

:root {
  --accent: #1264a3;
  --accent-dark: #1b2d50;
  --accent-soft: #e8f1f8;
  --ink: #0c1018;
  --ink-soft: #3b414d;
  --muted: #646c7a;
  --faint: #8b93a3;
  --line: #e4e7ee;
  --line-soft: #eef0f5;
  --bg: #f6f7fa;
  --surface: #ffffff;
  --ok: #146c43;
  --ok-soft: #e7f4ec;
  --warn: #8a5300;
  --warn-soft: #fdf2e0;
  --bad: #b02318;
  --bad-soft: #fdece9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 35, .04), 0 6px 20px rgba(20, 24, 35, .05);
  --font: 'Manrope', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute has to win. Half the toggles on these pages are a badge or a button
 * whose visibility the scripts flip with `node.hidden = true`, and the UA rule that implements
 * it (`[hidden] { display: none }`) loses to any author rule that sets `display` — including
 * the `display: inline-flex` on every `.badge` and every `button` below. Without this, a
 * "Held back" badge shows on documents that are not, and an "Undo my edit" link offers to undo
 * an edit nobody made. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

code, pre, .mono { font-family: var(--mono); font-size: 13px; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px; top: 12px; z-index: 50;
  background: var(--surface); padding: 10px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- shell -- */

/* The sidebar is `position: sticky` so the nav follows a long page down. That leaves its
 * column unpainted below one screen's worth, so the column itself is painted here, on the
 * frame, and the sticky element rides on top of it. */
.frame {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
  background: linear-gradient(
    to right,
    var(--surface) 0 234px, var(--line) 234px 235px, var(--bg) 235px
  );
}

.side {
  position: sticky;
  top: 0;
  flex: 0 0 234px;
  width: 234px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px 18px 22px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(140deg, var(--accent), #7a6bf0);
}
.brand-word { font-weight: 650; font-size: 17px; letter-spacing: -.02em; }

.side-business { padding: 0 8px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.side-business-name {
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: block; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: 14px; font-weight: 500;
}
.side-link:hover { background: var(--bg); text-decoration: none; }
.side-link.is-active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.side-foot {
  margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.side-email {
  font-size: 12px; color: var(--faint); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.main { flex: 1 1 auto; min-width: 0; padding: 36px 44px 88px; max-width: 1120px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; margin-bottom: 26px;
}
.page-title { font-size: 25px; font-weight: 650; }
.page-lead { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }
.page-actions { display: flex; gap: 10px; flex: none; padding-top: 4px; }

/* ---------------------------------------------------------------- cards -- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }

.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 650; }
.card-note { color: var(--muted); font-size: 13px; margin: -8px 0 16px; max-width: 66ch; }

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { flex: 1 1 auto; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 27px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-note { font-size: 12px; color: var(--faint); }

/* --------------------------------------------------------------- pieces -- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--line-soft); color: var(--muted);
  white-space: nowrap;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge--accent { background: var(--accent-soft); color: var(--accent-dark); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

button, .button {
  font: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 14px; font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
button:hover, .button:hover { background: var(--bg); text-decoration: none; }
button:disabled, .button.is-disabled { opacity: .5; cursor: not-allowed; }
button:disabled:hover { background: var(--surface); }

.button--primary, button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.button--primary:hover, button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.primary:disabled:hover { background: var(--accent); }

.button--small, button.small { padding: 5px 11px; font-size: 13px; }
.button--danger, button.danger { color: var(--bad); }
.button--danger:hover, button.danger:hover { background: var(--bad-soft); }

.link-button {
  border: 0; background: none; padding: 0;
  color: var(--accent); font-size: 13px; font-weight: 550; cursor: pointer;
}
.link-button:hover { background: none; text-decoration: underline; }
.link-button.danger { color: var(--bad); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.hint { font-size: 12.5px; color: var(--faint); margin: 5px 0 0; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], textarea, select {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--faint);
  padding: 0 12px 8px 0; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td:last-child, .table th:last-child { padding-right: 0; text-align: right; }
.table--tight td { padding: 8px 12px 8px 0; }

.truncate { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 24px;
  text-align: center;
  color: var(--muted);
  background: #fbfcfd;
}
.empty-title { font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.empty .button { margin-top: 14px; }

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.notice--warn { border-left-color: #d99b1a; background: #fffdf7; }
.notice--bad { border-left-color: var(--bad); background: #fffbfa; }

.snippet {
  display: block;
  background: #171a21;
  color: #e6e9f2;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.key-mask { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }

/* --------------------------------------------------------------- wizard -- */

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.step {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 4px; border-bottom: 1px solid var(--line-soft);
}
.step:last-child { border-bottom: 0; }
.step-mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--faint);
  margin-top: 1px;
}
.step-body { min-width: 0; flex: 1 1 auto; }
.step-label { font-weight: 600; font-size: 14.5px; }
.step-note { color: var(--muted); font-size: 13px; }
.step-error { color: var(--bad); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.step-side { flex: none; }

.step.is-done .step-mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.is-running .step-mark { border-color: var(--accent); color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.step.is-failed .step-mark { background: var(--bad); border-color: var(--bad); color: #fff; }
.step.is-pending .step-label { color: var(--muted); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .step.is-running .step-mark { animation: none; } }

.bar { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }

/* ------------------------------------------------------------- knowledge -- */

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px 24px;
  text-align: center;
  background: #fbfcfd;
  transition: border-color .12s ease, background .12s ease;
}
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font-weight: 600; margin-bottom: 4px; }
.drop input[type=file] { display: none; }

.search-form { display: flex; gap: 10px; align-items: flex-end; }
.search-form .field { flex: 1 1 auto; margin: 0; }

.result { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.result:last-child { border-bottom: 0; }
.result-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.result-rank {
  flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft);
  color: var(--accent-dark); font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
/* Clamped with an ellipsis rather than cut mid-word: a passage is an excerpt either way, and
 * the ellipsis is what says so. */
.result-text {
  color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;
  max-height: 6.4em; overflow: hidden;
}
.result-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--faint); }

/* --------------------------------------------------------------- widget -- */

.preview-frame {
  width: 100%; height: 560px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); display: block;
}

.swatches { display: flex; gap: 14px; flex-wrap: wrap; }
.swatch { display: flex; align-items: center; gap: 9px; }
.swatch-chip { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); flex: none; }
.swatch-name { font-size: 13px; font-weight: 600; }
.swatch-value { font-family: var(--mono); font-size: 12px; color: var(--faint); }

/* -------------------------------------------------------------- profile -- */

.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.field-actions { display: flex; align-items: center; gap: 12px; }

.competitor {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface);
}
.competitor.is-approved { border-color: #c8d2f7; background: #fcfdff; }
.competitor-name { font-weight: 650; }
.competitor-summary { font-size: 13px; color: var(--muted); }
.competitor-foot { display: flex; align-items: center; gap: 12px; margin-top: 2px; }

/* -------------------------------------------------------- conversations -- */

.chat-layout { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } }

.thread-list { list-style: none; margin: 0; padding: 0; }
.thread {
  display: block; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; color: inherit;
}
.thread:hover { background: var(--bg); text-decoration: none; }
.thread.is-active { background: var(--accent-soft); border-color: #ccd3f8; }
.thread-question { font-size: 13.5px; font-weight: 550; overflow-wrap: anywhere; }
.thread-meta { font-size: 12px; color: var(--faint); margin-top: 3px; }

.turn { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.turn:last-child { border-bottom: 0; }
.turn-who { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.turn--user .turn-who { color: var(--accent-dark); }
.turn-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.turn-foot { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--faint); }

.sources { margin-top: 10px; border-left: 2px solid var(--line); padding-left: 14px; display: flex; flex-direction: column; gap: 10px; }
.source-head { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); overflow-wrap: anywhere; }
.source-text {
  font-size: 12.5px; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  max-height: 4.7em; overflow: hidden;
}

/* --------------------------------------------------------------- toasts -- */

.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: #1c2029; color: #fff;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; max-width: 380px;
  box-shadow: 0 8px 24px rgba(20, 24, 35, .18);
  overflow-wrap: anywhere;
}
.toast--bad { background: var(--bad); }
.toast--ok { background: var(--ok); }

/* ------------------------------------------------------------ auth pages -- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(1000px 500px at 50% -180px, #e9ecfd 0%, rgba(233, 236, 253, 0) 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card--wide { max-width: 520px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-title { font-size: 21px; font-weight: 650; margin-bottom: 4px; }
.auth-lead { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-error {
  display: none;
  margin-bottom: 16px; padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bad-soft); color: var(--bad);
  font-size: 13.5px;
}
.auth-error.is-shown { display: block; }
.auth form button[type=submit] { width: 100%; margin-top: 4px; }

.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .two-up { grid-template-columns: 1fr; } }

@media (max-width: 760px) {
  .frame { flex-direction: column; background: var(--bg); }
  .side { position: static; width: 100%; flex: none; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 0; flex-direction: row; align-items: center; gap: 14px; }
  .main { padding: 24px 20px 60px; }
}

/* --- Vtero brand (2026-09-04): the black wide logo on the light shell --- */
.brand-logo { height: 20px; width: auto; display: block; }
