/* Review Agent — shared dashboard styles.
   Single source of truth for palette (light + dark via CSS variables), typography, and
   components. Linked by every server-rendered page; dark mode is just a variable swap on
   <html class="dark">. Accent stays blue per design. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --surface-3: #eef2f7;
  --text: #1f2733;
  --text-strong: #0b1f3a;
  --text-muted: #5a6b7b;
  --text-faint: #8696a7;
  --border: #e2e8f0;
  --border-strong: #c3cedb;
  --accent: #1558d6;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fe;
  --accent-soft-ink: #1346b8;
  --success: #16a34a;
  --success-ink: #ffffff;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --danger-border: #f3c9c2;
  --warn-soft: #fff8e1;
  --warn-border: #e7c65a;
  --star: #e8a000;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 10px 30px rgba(16, 24, 40, 0.16);
  --radius: 10px;
  --radius-sm: 7px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html.dark {
  --bg: #0f1623;
  --surface: #161f2e;
  --surface-2: #1a2434;
  --surface-3: #222e44;
  --text: #dfe7f1;
  --text-strong: #f1f6fc;
  --text-muted: #9db0c5;
  --text-faint: #76879d;
  --border: #2a3750;
  --border-strong: #3a4a66;
  --accent: #4d8bff;
  --accent-ink: #0b1320;
  --accent-soft: #1b2a4a;
  --accent-soft-ink: #cfe0ff;
  --success: #3ddc84;
  --success-ink: #052e16;
  --danger: #ff8a80;
  --danger-soft: #2c1d20;
  --danger-border: #5c3a38;
  --warn-soft: #2b2510;
  --warn-border: #5c5022;
  --star: #f0b429;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 12px 34px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { color: var(--text-strong); line-height: 1.25; letter-spacing: -0.012em; }
h2 { font-size: 1.2rem; font-weight: 680; }
h3 { font-size: 0.95rem; font-weight: 660; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); font-size: 0.88rem; }
.stars { color: var(--star); font-weight: 700; letter-spacing: 0.5px; }
.flags { color: var(--danger); font-size: 0.84rem; }
.name { font-weight: 620; color: var(--text-strong); }
.row { display: flex; gap: 0.5rem; align-items: center; }

/* --- header / top bar --- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .lockup { display: flex; align-items: center; gap: 0.6rem; }
.topbar .logo { height: 32px; width: auto; display: block; }
.topbar .namewrap { display: flex; flex-direction: column; line-height: 1.15; }
.topbar .brand { font-weight: 700; font-size: 1.02rem; color: var(--text-strong); letter-spacing: -0.01em; }
.topbar .tagline { font-size: 0.66rem; color: var(--text-muted); font-weight: 500; }

/* --- account menu --- */
.acct { position: relative; }
.acct-btn {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.2rem 0.5rem 0.2rem 0.25rem; cursor: pointer;
  color: var(--text); font: inherit;
}
.acct-btn:hover { border-color: var(--border-strong); }
.acct-btn .avatar {
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 0.82rem;
}
.acct-btn .chev { color: var(--text-faint); font-size: 0.7rem; }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); padding: 0.35rem; z-index: 40;
}
.acct-menu[hidden] { display: none; }
.acct-menu .acct-id { padding: 0.5rem 0.6rem 0.4rem; }
.acct-menu .acct-name { font-weight: 640; color: var(--text-strong); word-break: break-all; }
.acct-menu hr { border: 0; border-top: 1px solid var(--border); margin: 0.35rem 0; }
.menu-item {
  display: flex; align-items: center; gap: 0.55rem; width: 100%; text-align: left;
  padding: 0.5rem 0.6rem; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-item .ic { width: 1.1rem; text-align: center; opacity: 0.85; }
.menu-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); padding: 0.5rem 0.6rem 0.15rem; }
.theme-on { display: none; }
html.dark .theme-on { display: inline; }
html.dark .theme-off { display: none; }

/* --- main / cards / forms --- */
main { max-width: 820px; margin: 1.5rem auto; padding: 0 1.25rem; }
main.wide { max-width: none; margin: 0; padding: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin: 0.75rem 0; box-shadow: var(--shadow-sm);
}
.card.warn { background: var(--warn-soft); border-color: var(--warn-border); }
.card.danger { background: var(--danger-soft); border-color: var(--danger-border); }
textarea, input, select {
  font: inherit; color: var(--text); background: var(--surface);
  padding: 0.5rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea {
  width: 100%; min-height: 150px; field-sizing: content; max-height: 360px;
  line-height: 1.5; box-sizing: border-box;
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button {
  font: inherit; padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
button:hover { border-color: var(--border-strong); }
button.primary { background: var(--success); color: var(--success-ink); border-color: var(--success); font-weight: 600; }
button.primary:hover { filter: brightness(1.05); }
button.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* Labelled form rows (admin settings, manual review entry). Stacked label / control /
   hint, so long explanatory hints don't crowd the input. */
.field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.9rem 0; }
.field > label { font-weight: 600; font-size: 0.9rem; color: var(--text-strong); }
.field > label > input[type="checkbox"] { margin-right: 0.4rem; }
.field > input, .field > select { max-width: 32rem; }
/* These textareas are short prose lists, not reply drafts — don't inherit the tall default. */
.field > textarea { min-height: 0; max-width: 32rem; }
.hint { color: var(--text-muted); font-size: 0.8rem; line-height: 1.45; }
.ok-note {
  color: var(--success); font-weight: 600; font-size: 0.9rem;
  background: var(--success-soft, transparent); margin: 0.75rem 0;
}
details > summary { cursor: pointer; margin: 0.9rem 0 0.3rem; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.55rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--text-muted); font-weight: 600; }

/* --- 3-pane approval queue --- */
.three-pane { display: grid; grid-template-columns: 220px minmax(260px, 1fr) minmax(330px, 1.25fr); gap: 0.8rem; padding: 0.8rem; height: calc(100vh - 53px); }
.three-pane.no-rail { grid-template-columns: minmax(260px, 1fr) minmax(330px, 1.25fr); }
.three-pane > section {
  overflow-y: auto; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.rail { background: var(--surface-2); }
.rail h3 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin: 0.2rem 0 0.6rem; }
.rail a { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; padding: 0.45rem 0.6rem; border-radius: var(--radius-sm); color: var(--text); }
.rail a:hover { background: var(--surface-3); text-decoration: none; }
.rail a.active { background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 640; }
.rail a.paused .lname { color: var(--text-faint); }
.rail .badge-n { min-width: 1.35rem; text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 0.06rem 0.42rem; }
.rail .badge-n.zero { background: var(--border-strong); color: var(--surface); }
.rail .manage { display: inline-block; margin-top: 0.7rem; font-size: 0.82rem; }

.qheader { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.65rem; }
.railtoggle { font: inherit; line-height: 1; padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.railtoggle:hover { border-color: var(--border-strong); color: var(--text); }
.railtoggle::before { content: "❮ Locations"; }
html.rail-collapsed .railtoggle::before { content: "❯ Locations"; }
.qcontext { font-weight: 660; color: var(--text-strong); font-size: 1.02rem; }
html.rail-collapsed .rail { display: none; }

.pills { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.6rem; }
.pill { font-size: 0.8rem; padding: 0.28rem 0.65rem; border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); background: var(--surface); white-space: nowrap; }
.pill:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill .n { font-weight: 700; margin-left: 0.25rem; opacity: 0.85; }
.sortbar { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.6rem; }
.sortbar label { font-size: 0.8rem; }
.sortbar select { width: auto; font-size: 0.8rem; padding: 0.25rem 0.5rem; }

.date-group h4 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 1rem 0 0.4rem; font-weight: 700; }
.qitem { display: block; padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.45rem; color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.qitem:hover { border-color: var(--border-strong); text-decoration: none; }
.qitem.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.qitem .top { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.qitem .who { font-weight: 640; color: var(--text-strong); }
.qitem .snip { color: var(--text-muted); font-size: 0.86rem; margin: 0.25rem 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qitem .meta { font-size: 0.72rem; color: var(--text-faint); margin: 0.3rem 0 0; }

.badge { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.08rem 0.42rem; border-radius: 5px; background: var(--surface-3); color: var(--text-muted); }
.badge.attn { background: var(--danger-soft); color: var(--danger); }

.flag-band { background: var(--danger-soft); border: 1px solid var(--danger-border); border-radius: var(--radius); padding: 0.6rem 0.7rem 0.3rem; margin-bottom: 0.6rem; }
.flag-band h4 { color: var(--danger); font-size: 0.78rem; margin: 0 0 0.45rem; text-transform: uppercase; letter-spacing: 0.04em; }
.flag-band .qitem { box-shadow: none; }

.detail .empty { color: var(--text-faint); padding: 3rem 0.5rem; text-align: center; }
/* the detail content sits in its own inner container (a card within the detail pane) */
.review-detail { margin: 0; background: var(--surface-2); padding: 1.1rem 1.25rem; }
.review-detail .posted-at { font-size: 0.8rem; margin: 0.2rem 0 0; }
.rd-sep { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

@media (min-width: 1001px) {
  html.rail-collapsed .three-pane:not(.no-rail) { grid-template-columns: minmax(260px, 1fr) minmax(330px, 1.25fr); }
}
@media (max-width: 1000px) {
  .three-pane { grid-template-columns: 1fr; height: auto; }
  .three-pane > section { overflow: visible; }
  .rail { display: flex; gap: 0.4rem; overflow-x: auto; }
  .rail h3, .rail .manage { display: none; }
  .rail a { white-space: nowrap; }
}

/* --- centered auth pages (login / check email) --- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 1.75rem; }
.auth-card .logo { height: 38px; display: block; margin: 0 auto 0.75rem; }
.auth-card h1 { font-size: 1.15rem; text-align: center; margin: 0 0 1rem; }
.auth-card label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.auth-card input[type="email"] { width: 100%; }
.auth-card button[type="submit"] { width: 100%; margin-top: 0.85rem; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.auth-card .hint { font-size: 0.82rem; color: var(--text-muted); text-align: center; margin-top: 0.8rem; }
.auth-card .dev { margin-top: 1rem; padding: 0.75rem; background: var(--warn-soft); border: 1px solid var(--warn-border); border-radius: var(--radius-sm); font-size: 0.85rem; word-break: break-all; }
.auth-card .err { background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger); border-radius: var(--radius-sm); padding: 0.55rem 0.7rem; margin-bottom: 0.8rem; font-size: 0.88rem; }

/* --- login: side-by-side brand lockup + colorful (token-based) polish --- */
/* Rich brand-blue backdrop so the white card floats — same idea as the Social
   Content Agent page, in review-agent's blue palette. Dark gradient reads well in
   both light and dark themes. */
.auth-wrap {
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--accent) 9%, var(--bg)) 0%,
    color-mix(in srgb, var(--accent) 16%, var(--bg)) 100%);
}
/* Accent strip across the top of the card + a soft float shadow (light bg). */
.auth-card { border-top: 3px solid var(--accent); box-shadow: var(--shadow-pop); }
/* Logo + "Review Agent" on one row, centered. */
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-bottom: 0.55rem; }
.auth-brand .logo { height: 34px; width: auto; margin: 0; display: block; }
.auth-brand h1 { margin: 0; font-size: 1.35rem; }
/* Promise line in the brand accent; supporting line stays muted + readable width. */
.auth-tag { text-align: center; font-weight: 700; font-size: 0.95rem; color: var(--success); margin: 0 0 0.45rem; }
.auth-tag .hl, .topbar .tagline .hl { color: var(--accent); }
/* Supporting line as a soft rounded callout — pale accent tint, readable ink.
   To revert to plain text, drop background/color/border-radius/padding here. */
.auth-sub {
  text-align: center; margin: 0 auto 1.25rem; max-width: 20rem;
  background: var(--accent-soft); color: var(--accent-soft-ink);
  border-radius: 12px; padding: 0.7rem 0.95rem; font-size: 0.86rem;
}
/* Gradient CTA built from the accent token (solid fallback first for old browsers). */
.auth-card button[type="submit"] {
  background: var(--accent);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 72%, #001a4d));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 32%, transparent);
}
.auth-card button[type="submit"]:hover { filter: brightness(1.06); }

/* Assisted mode: the by-hand posting path, kept visually secondary to Approve & post
   so it reads as the fallback it is. */
.assisted { margin-top: 0.8rem; }
.assisted > summary { font-size: 0.85rem; margin: 0 0 0.4rem; }
.assisted .hint { margin: 0 0 0.5rem; }

/* --- stats drawer (above the queue) ---
   The queue is a fixed-height grid, so this panel must stay bounded: collapsed it is a
   single line, expanded it is capped and scrolls rather than squeezing the queue away. */
.statbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.8rem; font-size: 0.88rem;
}
.statbar > summary { cursor: pointer; margin: 0; list-style-position: inside; }
.statbar .sb-line { color: var(--text-muted); }
.statbar .sb-line strong { color: var(--accent); }
.sb-body { max-height: 38vh; overflow-y: auto; padding: 0.7rem 0.2rem 0.2rem; }
.sb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.2rem; }
.sb-grid h4 { margin: 0 0 0.4rem; font-size: 0.78rem; text-transform: uppercase;
              letter-spacing: 0.05em; color: var(--text-faint); }
.sb-grid table { font-size: 0.84rem; }
.sb-grid th, .sb-grid td { padding: 0.18rem 0.35rem; border: 0; }
.sb-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.sb-star { white-space: nowrap; color: var(--star); font-weight: 700; }
.sb-track { width: 100%; background: var(--surface-3); border-radius: 999px; height: 0.5rem; }
.sb-fill { display: block; height: 100%; background: var(--success); border-radius: 999px; }
.sb-bars { width: 100%; }
.sb-more { margin: 0.7rem 0 0; font-size: 0.84rem; }
/* The grid's height is viewport-based; give the strip its share back when it is there. */
.three-pane.with-statbar { height: calc(100vh - 53px - 2.1rem); }
/* Headline figures on the full stats page. */
.statbig { font-size: 1.6rem; font-weight: 680; color: var(--text-strong); margin: 0; line-height: 1.1; }
.statbig .muted { font-size: 0.95rem; font-weight: 400; }

/* --- insights + rating sparkline --- */
.insights { margin: 0; padding-left: 1.1rem; }
.insights li { margin: 0.3rem 0; line-height: 1.5; }
.insights .ins-good { color: var(--success); }
.insights .ins-bad { color: var(--danger); }
.insights .ins-neutral { color: var(--text); }
.spark { display: flex; align-items: stretch; gap: 0.5rem; }
.spark svg { flex: 1; height: 90px; width: 100%; overflow: visible; }
/* vector-effect keeps the stroke even weight despite the non-uniform viewBox scale. */
.spark polyline {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.spark-axis {
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 0.74rem; color: var(--text-faint); padding: 0.1rem 0;
}
.spark-years { position: relative; height: 1rem; margin-top: 0.2rem; }
.spark-years span {
  position: absolute; transform: translateX(-50%);
  font-size: 0.74rem; color: var(--text-faint);
}

/* Queue filters: tabs on top, one fixed toolbar line (Filters button, sort, count), then a
   reserved row for the active-filter chips — so nothing below ever shifts. */
.pill.approve { background: var(--surface); border-color: var(--accent); color: var(--accent-soft-ink); font-weight: 640; }
.pill.approve:hover { background: var(--accent-soft); }
.qtoolbar { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.3rem; flex-wrap: nowrap; }
.qtoolbar .fl { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.qtoolbar select { width: auto; font-size: 0.8rem; padding: 0.25rem 0.5rem; }
.rcount { margin-left: auto; font-size: 0.86rem; font-weight: 700; color: var(--accent-soft-ink); background: var(--surface); border: 1px solid var(--accent); border-radius: 999px; padding: 0.15rem 0.7rem; white-space: nowrap; }
.fpanel { position: relative; }
.fbtn { list-style: none; cursor: pointer; font-size: 0.8rem; padding: 0.3rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); white-space: nowrap; user-select: none; }
.fbtn::-webkit-details-marker { display: none; }
.fbtn::before { content: "⚙ "; color: var(--text-muted); }
.fbtn:hover, .fpanel[open] > .fbtn { border-color: var(--border-strong); }
.fcount { margin-left: 0.4rem; min-width: 1.2rem; display: inline-block; text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 0.02rem 0.35rem; }
.fcount[hidden] { display: none; }
.fbody { position: absolute; z-index: 20; top: calc(100% + 0.35rem); left: 0; width: min(23rem, 80vw); padding: 0.8rem 0.9rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
.fbody fieldset { border: 0; margin: 0 0 0.7rem; padding: 0; }
.fbody legend { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); padding: 0; margin-bottom: 0.3rem; }
.fbody .opt { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0 0.8rem 0.25rem 0; font-size: 0.85rem; white-space: nowrap; }
.fbody .opt.off { color: var(--text-faint); }
.fbody .cnt { font-style: normal; font-size: 0.75rem; color: var(--text-muted); }
.fbody .cnt:not(:empty)::before { content: "("; }
.fbody .cnt:not(:empty)::after { content: ")"; }
.fbody .toggles { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.fbody .tg input { position: absolute; opacity: 0; pointer-events: none; }
.fbody .tg span { display: inline-block; font-size: 0.82rem; padding: 0.25rem 0.65rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); cursor: pointer; }
.fbody .tg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.fbody .tg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.fbody .tg .cnt { color: inherit; opacity: 0.8; }
.fbody .daterange { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.3rem; }
.fbody .daterange input { width: auto; font-size: 0.8rem; padding: 0.25rem 0.4rem; }
.factions { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 0.2rem; }
.fclear { font-size: 0.82rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 1.9rem; align-items: center; margin-bottom: 0.4rem; }
.chip { font-size: 0.76rem; padding: 0.14rem 0.55rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--accent); color: var(--accent-soft-ink); white-space: nowrap; }
.chip:hover { text-decoration: none; filter: brightness(0.96); }
.chip.clear { background: transparent; border-color: transparent; color: var(--text-muted); text-decoration: underline; }
.qcontrols { background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0.65rem 0.75rem 0.2rem; margin-bottom: 0.8rem; }
.qcontrols .pills { margin-bottom: 0.55rem; }
.qcontrols .chips { margin-bottom: 0.1rem; }

/* --- Admin: client page. Header + summary tiles, then a main column and a side column. --- */
main.admin { max-width: 1120px; }
.backlink { margin: 0 0 0.4rem; font-size: 0.88rem; }
.ahead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.ahead-title { display: flex; align-items: center; gap: 0.7rem; }
.ahead h2 { margin: 0; font-size: 1.45rem; }
.statuspill { font-size: 0.74rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; }
.statuspill.on { background: var(--success-soft, #dcfce7); color: var(--success); border: 1px solid var(--success); }
.statuspill.off { background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border-strong); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 1.1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 0.85rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 0.1rem; }
.tile .tv { font-size: 1.35rem; font-weight: 700; color: var(--text-strong); line-height: 1.2; }
.tile .tl { font-size: 0.78rem; color: var(--text-muted); }
.tile.hot { border-color: var(--accent); background: var(--accent-soft); }
.tile.hot .tv { color: var(--accent-soft-ink); }
.tile.good .tv { color: var(--success); font-size: 1.05rem; }
.tile.bad { border-color: var(--danger-border); background: var(--danger-soft); }
.tile.bad .tv { color: var(--danger); font-size: 1.05rem; }
.tile.warn { border-color: var(--warn-border); background: var(--warn-soft); }
.tile.warn .tv { font-size: 1.05rem; }
.agrid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(260px, 1fr); gap: 1rem; align-items: start; }
.amain, .aside { min-width: 0; }
.aside { position: sticky; top: 4rem; }
.acard { padding: 1.05rem 1.15rem; margin: 0 0 0.9rem; }
.acard .chead { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; }
.acard .chead h3 { margin: 0; font-size: 1.02rem; }
.acard .hint { margin: 0 0 0.6rem; }
.acard .field { margin: 0.7rem 0; }
.acard .field > input:not([style]), .acard .field > select:not([style]) { max-width: none; }
.acard .field > textarea { max-width: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; align-items: start; }
.two > .field { margin-top: 0.7rem; }
.row.wrap { flex-wrap: wrap; }
.subsection { border-top: 1px solid var(--border); margin-top: 0.9rem; padding-top: 0.8rem; }
.subsection h4 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.acard code { font-size: 0.8rem; background: var(--surface-3); padding: 0.05rem 0.3rem; border-radius: 4px; }
.okpill { font-size: 0.82rem; font-weight: 700; color: var(--success); }

/* Auto-post switch. The rating menu stays enabled (so it is still submitted and never
   reset to a default) but is dimmed and inert while auto-post is off. */
.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; font-weight: 640; color: var(--text-strong); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .slider { width: 2.5rem; height: 1.4rem; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .slider::after { content: ""; position: absolute; top: 0.15rem; left: 0.15rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::after { transform: translateX(1.1rem); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.autopost { margin-bottom: 0.4rem; }
.autopost:has(input[name="auto_post_enabled"]:not(:checked)) .rating { opacity: 0.45; pointer-events: none; }

/* Stays in view while editing, so Save is never a long scroll away. */
.savebar { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; justify-content: flex-end; gap: 1rem; padding: 0.7rem 1rem; margin: 0 0 0.9rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 -4px 14px rgba(16, 24, 40, 0.08); }
.dirty { color: var(--warn-border); font-size: 0.85rem; font-weight: 640; }
.dirty[hidden] { display: none; }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 0.7rem; }
.progress span { display: block; height: 100%; background: var(--success); border-radius: 999px; }
.checklist { list-style: none; margin: 0 0 0.4rem; padding: 0; }
.checklist li { display: flex; gap: 0.55rem; align-items: center; padding: 0.28rem 0; font-size: 0.92rem; }
.checklist .tick { width: 1.1rem; text-align: center; font-weight: 700; }
.checklist li.done { color: var(--text-muted); }
.checklist li.done .tick { color: var(--success); }
.checklist li.todo .tick { color: var(--text-faint); }
.adduser { margin-top: 0.8rem; }

@media (max-width: 900px) {
  .agrid { grid-template-columns: 1fr; }
  .aside { position: static; }
  .two { grid-template-columns: 1fr; }
}

/* Short bullet lines instead of paragraphs, for hints and explanations. */
.points { margin: 0.2rem 0 0.7rem; padding-left: 1.15rem; color: var(--text-muted); font-size: 0.84rem; line-height: 1.55; }
.points li { margin: 0.12rem 0; }
.points.steps { padding-left: 1.25rem; }
.card.warn .points, .card.danger .points { color: var(--text); }
.plain { font-weight: 400; color: var(--text-muted); }

/* Every button label reads in Title Case ("Sync Existing Reviews"), whatever the source text. */
button, .fbtn { text-transform: capitalize; }

/* --- Admin: collapsible blocks, the backlog picker and its progress box --- */
details.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin: 0 0 0.9rem; }
details.block > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.7rem; padding: 0.85rem 1.15rem; margin: 0; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before { content: "▸"; color: var(--text-muted); transition: transform 0.15s; font-size: 0.9rem; }
details.block[open] > summary::before { transform: rotate(90deg); }
details.block > summary h3 { margin: 0; font-size: 1.02rem; }
details.block > summary .sum { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); text-align: right; }
details.block[open] > summary { border-bottom: 1px solid var(--border); }
details.block > summary:hover h3 { text-decoration: underline; }
.bbody { padding: 0.9rem 1.15rem 1.1rem; }
.bbody > .field:first-child { margin-top: 0; }
/* Forms inside the collapsible blocks follow the same rules as the older cards. */
.bbody .field { margin: 0.7rem 0; }
.bbody .field > input:not([style]), .bbody .field > select:not([style]), .bbody .field > textarea { max-width: none; }
.bbody .hint { margin: 0 0 0.6rem; }
.bbody .field > .hint { margin: 0; }
/* Side-by-side text areas share one height, so their bottom edges line up. */
.two > .field > textarea { field-sizing: fixed; height: 12rem; resize: vertical; }
.callout { display: flex; gap: 0.7rem; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin-bottom: 0.9rem; color: var(--accent-soft-ink); font-size: 0.88rem; }
.callout .ic { font-weight: 700; line-height: 1.3; }
.callout ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.callout.mute { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
table.presets th, table.presets td { padding: 0.45rem 0.6rem; font-size: 0.88rem; text-align: right; }
table.presets th:first-child, table.presets td:first-child { text-align: left; }
table.presets tr.sel td { background: var(--accent-soft); }
.num-todo { color: var(--text-strong); font-weight: 700; }
.opts { display: grid; gap: 0.35rem; margin: 0.8rem 0; font-size: 0.9rem; }
.opts .cnt { color: var(--text-muted); font-size: 0.82rem; }
.summaryline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin-top: 0.8rem; }
.summaryline strong { font-size: 1.02rem; color: var(--text-strong); }
.summaryline button:disabled { opacity: 0.5; cursor: not-allowed; }
.progress.big { height: 9px; margin: 0.5rem 0 0.3rem; }
.jobbox { border: 1px solid var(--accent); background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin: 0 0 0.9rem; }
.jobbox .jt { font-weight: 700; color: var(--text-strong); }
.daterow { display: flex; align-items: center; gap: 0.4rem; margin: 0.25rem 0 0 1.5rem; font-size: 0.88rem; }
.daterow input { width: auto; font-size: 0.82rem; padding: 0.2rem 0.35rem; }

/* Filter-panel options sit in an aligned grid (two columns, or one for a short list). */
.fbody .optgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.8rem; }
.fbody .optgrid.one { grid-template-columns: 1fr; }
.fbody .optgrid .opt { margin: 0; }

/* "Drafting 12 of 55…" while a run is going, inside the filter container. */
.qjob { margin: 0.1rem 0 0.5rem; font-size: 0.84rem; font-weight: 640; color: var(--accent-soft-ink); }
.qjob[hidden] { display: none; }
.qjob .progress.big { height: 6px; margin: 0.3rem 0 0; }

/* The Custom Range label sits on a row of its own so it never wraps. */
table.presets tr.customhead td { text-align: left; padding-bottom: 0.1rem; border-bottom: 0; }
table.presets tr.customvals td:first-child { padding-top: 0; }
table.presets tr.customhead.sel td, table.presets tr.customvals.sel td { background: var(--accent-soft); }
table.presets .daterow { margin-top: 0; }

/* --- Drafting from the queue (operators): row checkboxes, selection bar, run status --- */
.qrow { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.45rem; }
.qrow > .qsel { margin-top: 0.85rem; width: 1.05rem; height: 1.05rem; flex: none; }
.qrow > .spacer { width: 1.05rem; flex: none; }
.qrow > .qitem { flex: 1; margin-bottom: 0; min-width: 0; }
.flag-band .qrow { margin-bottom: 0.45rem; }
.selbar { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 0.45rem 0.7rem; margin: 0.1rem 0 0.55rem; font-size: 0.86rem; color: var(--accent-soft-ink); }
.selbar[hidden] { display: none; }
.selbar strong { color: var(--text-strong); }
.selbar .push { margin-left: auto; }
.selbar a { font-size: 0.82rem; }
.selbar button:disabled { opacity: 0.5; cursor: not-allowed; }

/* A review's place in a drafting run, on its row and in its pane. */
.runbadge[hidden] { display: none; }
.qitem[data-run] .st-notdrafted { display: none; }
.runbadge.queued { background: var(--surface-3); color: var(--text-muted); }
.runbadge.current { background: var(--accent-soft); color: var(--accent-soft-ink); }
.runbadge.done { background: var(--success-soft, #dcfce7); color: var(--success); }
.runbadge.failed { background: var(--danger-soft); color: var(--danger); }
.dots::after { content: ""; display: inline-block; width: 1.1em; text-align: left; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }
.runstate { margin: 0.4rem 0; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); }
.runstate[hidden] { display: none; }
.runstate strong { color: var(--text-strong); }
.runstate.current { border-color: var(--accent); background: var(--accent-soft); }
.runstate.failed { border-color: var(--danger-border); background: var(--danger-soft); }
.runstate p { margin: 0.15rem 0 0; }
.runfail { margin: 0.5rem 0; }
.drawform { margin: 0.4rem 0 0; }
.hide-while-running { display: none; }
@media (prefers-reduced-motion: reduce) { .dots::after { animation: none; content: "..."; } }

/* On the open tab, "2,083 of 2,104": what the filters leave in view, out of the tab's total. */
.pill .of { margin-left: 0.3rem; font-weight: 500; opacity: 0.8; }

/* One row, one height: the Filters button, Sort menu and result count line up. The global
   `details > summary` rule gives summaries a top margin that pushed the button down. */
.qtoolbar .fbtn { margin: 0; height: 2.15rem; display: inline-flex; align-items: center; gap: 0.3rem; padding-top: 0; padding-bottom: 0; }
.qtoolbar select { height: 2.15rem; }
.qtoolbar .fl { height: 2.15rem; }
.qtoolbar .rcount { height: 2.15rem; display: inline-flex; align-items: center; padding-top: 0; padding-bottom: 0; }

/* Row actions in the clients list: two plain links with room between them. */
.rowlinks { white-space: nowrap; }
.rowlinks a + a { margin-left: 1rem; }

/* "Sign in with Google" on the login page, then an "or" rule before the email form. */
.gbtn { display: flex; align-items: center; justify-content: center; gap: 0.6rem; width: 100%; box-sizing: border-box; padding: 0.6rem 1rem; margin: 0.2rem 0 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-strong); font-weight: 600; text-decoration: none; }
.gbtn:hover { background: var(--surface-3); text-decoration: none; }
.or { display: flex; align-items: center; gap: 0.7rem; margin: 0.9rem 0 0.3rem; color: var(--text-faint); font-size: 0.8rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
