/* ALR Staff Panel — shell and design system.
 *
 * Builds on the public site's tokens in css/base.css so the panel reads as the
 * same product, then adds a denser working layer: tighter spacing, smaller type,
 * more rows per screen. Nothing decorative that slows routine work.
 *
 * Loaded alongside base.css, never instead of it.
 */

:root {
  /* Denser scale than the public site. */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;

  --staff-sidebar-w: 232px;
  --staff-header-h: 56px;

  --surface-1: #0d0d0d;
  --surface-2: #141414;
  --surface-3: #1c1c1c;
  --surface-raised: #212121;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);

  --ok: #3ddc84;
  --warn: #ffb020;
  --danger: #ff4d4d;
  --info: #4d9fff;

  --focus-ring: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--accent-primary);
}

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

.staff-body {
  margin: 0;
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.875rem;
  line-height: 1.45;
}

/* Hide the app until the guard has decided. Prevents a flash of staff UI. */
.staff-body[data-auth="pending"] .staff-shell { visibility: hidden; }

.staff-shell {
  display: grid;
  grid-template-columns: var(--staff-sidebar-w) 1fr;
  min-height: 100vh;
}

.staff-sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.staff-brand {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line);
}

.staff-brand-eyebrow {
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
}

.staff-brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.staff-nav { padding: var(--sp-3); display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

.staff-nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.staff-nav-link i { width: 16px; text-align: center; font-size: 0.875rem; }
.staff-nav-link:hover { background: var(--surface-3); color: var(--text-primary); }
.staff-nav-link[aria-current="page"] {
  background: rgba(255, 96, 33, 0.12);
  border-color: rgba(255, 96, 33, 0.35);
  color: var(--text-primary);
}

.staff-nav-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 700;
  background: var(--surface-raised);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  color: var(--text-secondary);
}

.staff-sidebar-foot { padding: var(--sp-3); border-top: 1px solid var(--line); }

.staff-identity { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); }
.staff-identity-text { min-width: 0; }
.staff-identity-name {
  font-size: 0.8125rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.staff-identity-role { font-size: 0.6875rem; color: var(--accent-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }

.staff-main { min-width: 0; display: flex; flex-direction: column; }

.staff-header {
  height: var(--staff-header-h);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  position: sticky;
  top: 0;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.staff-header h1 { font-size: 1rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.staff-header-sub { font-size: 0.75rem; color: var(--text-muted); }
.staff-header-actions { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; }

.staff-content { padding: var(--sp-5); flex: 1; min-width: 0; }

/* Higher specificity than .sbtn, which is defined later and would otherwise
   win at equal specificity and leave the hamburger visible on desktop. */
.staff-header .staff-menu-toggle { display: none; }

/* --------------------------------------------------------------------------
   Buttons and form controls
   -------------------------------------------------------------------------- */

.sbtn {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--text-primary);
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
}

.sbtn:hover:not(:disabled) { background: var(--surface-raised); border-color: var(--text-muted); }
.sbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.sbtn-primary { background: var(--accent-primary); border-color: var(--accent-primary); color: #140800; }
.sbtn-primary:hover:not(:disabled) { background: var(--accent-secondary); border-color: var(--accent-secondary); }
.sbtn-danger { border-color: rgba(255, 77, 77, 0.5); color: var(--danger); }
.sbtn-danger:hover:not(:disabled) { background: rgba(255, 77, 77, 0.12); }
.sbtn-sm { padding: var(--sp-1) var(--sp-2); font-size: 0.75rem; }

/* Currently-selected action. Carries the state without an icon, and without
   relying on colour alone, since it also sets aria-pressed. currentColor keeps
   it legible on every variant. */
.sbtn.is-current {
  border-color: currentColor;
  box-shadow: inset 0 0 0 1px currentColor;
  font-weight: 700;
}

.sfield { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.sfield-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }

.sinput, .sselect, .stextarea {
  font: inherit;
  font-size: 0.8125rem;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: var(--sp-2) var(--sp-3);
  width: 100%;
  min-width: 0;
}

.stextarea { resize: vertical; min-height: 72px; }
.sinput::placeholder, .stextarea::placeholder { color: var(--text-muted); }

/* Visible focus everywhere. Keyboard use is a first-class path. */
.sbtn:focus-visible, .sinput:focus-visible, .sselect:focus-visible, .stextarea:focus-visible,
.staff-nav-link:focus-visible, .stable tbody tr:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* --------------------------------------------------------------------------
   Filter bar
   -------------------------------------------------------------------------- */

.sfilters {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  flex-wrap: wrap;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-4);
}

.sfilters-search { flex: 1 1 240px; }
/* Wraps because a filter bar may carry several actions — the covers pane has
   four — and a row that cannot wrap pushes the last one off a 390px screen. */
.sfilters-actions { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.sfilter-count { font-size: 0.75rem; color: var(--text-muted); align-self: center; }

/* --------------------------------------------------------------------------
   Table primitive
   -------------------------------------------------------------------------- */

.stable-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
}

.stable-scroll { overflow-x: auto; }

.stable { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }

.stable thead th {
  text-align: left;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  padding: var(--sp-3);
  background: var(--surface-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.stable th[aria-sort] { cursor: pointer; user-select: none; }
.stable th[aria-sort="ascending"]::after { content: " ▲"; color: var(--accent-primary); }
.stable th[aria-sort="descending"]::after { content: " ▼"; color: var(--accent-primary); }

.stable tbody td { padding: var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.stable tbody tr:last-child td { border-bottom: none; }
.stable tbody tr { cursor: pointer; }
.stable tbody tr:hover { background: var(--surface-3); }
.stable tbody tr[aria-selected="true"] { background: rgba(255, 96, 33, 0.1); }

.stable-thumb {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-3); display: block;
}

.stable-primary { font-weight: 600; }
.stable-muted { color: var(--text-muted); font-size: 0.75rem; }

.spager {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-top: 1px solid var(--line); background: var(--surface-3);
}
.spager-info { font-size: 0.75rem; color: var(--text-muted); margin-right: auto; }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.sbadge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: var(--radius-full);
  background: var(--surface-raised); color: var(--text-secondary);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.sbadge-ok { color: var(--ok); border-color: rgba(61, 220, 132, 0.35); background: rgba(61, 220, 132, 0.1); }
.sbadge-warn { color: var(--warn); border-color: rgba(255, 176, 32, 0.35); background: rgba(255, 176, 32, 0.1); }
.sbadge-danger { color: var(--danger); border-color: rgba(255, 77, 77, 0.35); background: rgba(255, 77, 77, 0.1); }
.sbadge-info { color: var(--info); border-color: rgba(77, 159, 255, 0.35); background: rgba(77, 159, 255, 0.1); }

/* --------------------------------------------------------------------------
   State blocks: loading / empty / no-match / error
   -------------------------------------------------------------------------- */

.sstate { padding: var(--sp-6) var(--sp-5); text-align: center; }
.sstate-icon { font-size: 1.5rem; margin-bottom: var(--sp-3); color: var(--text-muted); display: block; }
.sstate-title { font-size: 0.9375rem; font-weight: 700; margin: 0 0 var(--sp-2); }
.sstate-body { font-size: 0.8125rem; color: var(--text-secondary); margin: 0 auto var(--sp-4); max-width: 46ch; }
.sstate-error .sstate-icon { color: var(--danger); }
.sstate-error .sstate-title { color: var(--danger); }
.sstate-detail {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem; color: var(--text-muted);
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3);
  display: inline-block; max-width: 100%; overflow-wrap: anywhere; text-align: left;
}

.sskeleton {
  height: 14px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-raised) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: sshimmer 1.2s infinite linear;
}
@keyframes sshimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sskeleton { animation: none; } }

/* --------------------------------------------------------------------------
   Drawer
   -------------------------------------------------------------------------- */

.sdrawer-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  z-index: 60; display: flex; justify-content: flex-end;
}
.sdrawer-backdrop[hidden] { display: none; }

.sdrawer {
  width: min(480px, 100%); background: var(--surface-2);
  border-left: 1px solid var(--line); height: 100%;
  display: flex; flex-direction: column;
}

.sdrawer-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); border-bottom: 1px solid var(--line);
}
.sdrawer-title { font-size: 0.9375rem; font-weight: 700; margin: 0; }
.sdrawer-close { margin-left: auto; }
.sdrawer-body { padding: var(--sp-4); overflow-y: auto; flex: 1; }
.sdrawer-foot { padding: var(--sp-4); border-top: 1px solid var(--line); display: flex; gap: var(--sp-2); }

.sdl { display: grid; grid-template-columns: 96px 1fr; gap: var(--sp-2) var(--sp-3); margin: 0; }
.sdl dt { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.sdl dd { margin: 0; font-size: 0.8125rem; overflow-wrap: anywhere; }

/* --------------------------------------------------------------------------
   Confirmation dialog
   -------------------------------------------------------------------------- */

.sdialog-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  z-index: 70; display: grid; place-items: center; padding: var(--sp-4);
}
.sdialog-backdrop[hidden] { display: none; }

.sdialog {
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); width: min(440px, 100%); padding: var(--sp-5);
}
.sdialog-title { font-size: 1rem; font-weight: 700; margin: 0 0 var(--sp-2); }
.sdialog-body { font-size: 0.8125rem; color: var(--text-secondary); margin: 0 0 var(--sp-5); }
.sdialog-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.stoasts {
  position: fixed; right: var(--sp-4); bottom: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
  z-index: 80; max-width: min(380px, calc(100vw - 2rem));
}

.stoast {
  background: var(--surface-raised); border: 1px solid var(--line-strong);
  border-left-width: 3px; border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4); font-size: 0.8125rem;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  box-shadow: 0 8px 24px var(--shadow-color);
}
.stoast-success { border-left-color: var(--ok); }
.stoast-error { border-left-color: var(--danger); }
.stoast-warn { border-left-color: var(--warn); }
.stoast-info { border-left-color: var(--info); }
.stoast-close { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.875rem; }

/* --------------------------------------------------------------------------
   Responsive — down to 390px
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .staff-shell { grid-template-columns: 1fr; }

  .staff-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--staff-sidebar-w);
    z-index: 90; transform: translateX(-100%); transition: transform var(--transition-fast);
  }
  .staff-body[data-nav="open"] .staff-sidebar { transform: translateX(0); }
  .staff-body[data-nav="open"]::after {
    content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 85;
  }

  .staff-header .staff-menu-toggle { display: inline-flex; }
  .staff-content { padding: var(--sp-4) var(--sp-3); }
  .staff-header { padding: 0 var(--sp-3); gap: var(--sp-3); }
  .staff-header-sub { display: none; }

  .sfilters { padding: var(--sp-3); gap: var(--sp-2); }
  .sfilters-search { flex-basis: 100%; }
  .sfilters-actions { margin-left: 0; width: 100%; }
  /* `flex: 1` alone keeps every action on one line, and a flex item will not
     shrink below its own text, so four actions overflowed. A basis lets them
     share a row where they fit and wrap where they do not. */
  .sfilters-actions .sbtn { flex: 1 1 8rem; min-width: 0; justify-content: center; }

  .stoasts { left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3); max-width: none; }
  .sdrawer { width: 100%; }
  .sdl { grid-template-columns: 1fr; gap: var(--sp-1); }
  .sdl dd { margin-bottom: var(--sp-2); }
}

@media (max-width: 480px) {
  .stable thead { display: none; }
  .stable tbody tr { display: grid; grid-template-columns: 44px 1fr; gap: 0 var(--sp-3); padding: var(--sp-3); }
  .stable tbody td { border: none; padding: 0; }
  .stable tbody td[data-col="thumb"] { grid-row: span 3; }
  .stable tbody tr { border-bottom: 1px solid var(--line); }
  .stable tbody td[data-label]::before {
    content: attr(data-label) " ";
    font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-right: var(--sp-2);
  }
  /* The two-track card above reserves 44px for a thumbnail. A table without a
     thumbnail column has nothing to put there, so its cells alternate between a
     44px track and a wide one and the labels collide with their values. People
     is the clearest case: seven cells pair up as Account|Role, Status|Patreon,
     Provider|Last login, Joined.

     :has() is the test for "this row actually has a thumbnail". Where it is
     unsupported the rule is skipped and the previous layout stands, so this can
     only improve things. */
  .stable tbody tr:not(:has(td[data-col="thumb"])) {
    grid-template-columns: 1fr;
    gap: var(--sp-1) 0;
  }

  .stable tbody tr:not(:has(td[data-col="thumb"])) td[data-label] {
    display: flex;
    align-items: baseline;
    gap: var(--sp-2);
  }

  .stable tbody tr:not(:has(td[data-col="thumb"])) td[data-label]::before {
    flex: 0 0 5.5rem;
    margin-right: 0;
  }

  .spager { flex-wrap: wrap; }
  .spager-info { width: 100%; margin-bottom: var(--sp-2); }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------------
   Request fulfilment: fields whose upload metadata differs from the request.
   Colour alone would not carry this, so the marker is a border plus a written
   note naming the value the request actually asked for.
   --------------------------------------------------------------------------- */
.sinput-diff {
  border-color: rgba(255, 176, 32, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 176, 32, 0.35);
}

.up-diff {
  margin-top: 0.3rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--warn);
}

.up-diff strong { font-weight: 600; }

/* ===========================================================================
   THUMBNAIL PREVIEW
   ===========================================================================
   One floating panel for the whole panel, appended to <body> and positioned in
   viewport coordinates. Fixed and out of flow, so showing it can never move a
   row, resize a column or shift the page — and pointer-events: none means it
   cannot swallow a click or pull focus out of a metadata input being typed in.
   ========================================================================= */

#alr-thumb-preview {
  position: fixed;
  z-index: 1200;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  /* Neutral dark ground: these are transparent PNG/WebP/AVIF cut-outs, and a
     light panel would hide every dark edge of the render. */
  background: #0d0d10;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

#alr-thumb-preview[hidden] { display: none; }

#alr-thumb-preview img {
  display: block;
  width: 100%;
  height: 100%;
  /* The whole render, never cropped. */
  object-fit: contain;
}

/* Touch: no hover, so a tap opens a real overlay with a visible Close. */
.alr-thumb-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(6, 6, 8, 0.86);
}

.alr-thumb-overlay-inner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  max-width: min(92vw, 520px);
  max-height: 88vh;
}

.alr-thumb-overlay-inner img {
  max-width: 100%;
  max-height: 74vh;
  object-fit: contain;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #0d0d10;
}

.alr-thumb-overlay-close {
  min-height: 44px;
  padding: 0 1.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.stable-thumb[data-preview] { cursor: zoom-in; }

.stable-thumb[data-preview]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ===========================================================================
   SUMMARY TILES
   ===========================================================================
   Compact server-counted figures above a table. Exact head counts, never
   derived from the rows currently on screen — a summary that only describes
   page one is worse than no summary.
   ========================================================================= */

.ssummary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.ssummary:empty { display: none; }

.ssummary-tile {
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.ssummary-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.ssummary-label {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, rgba(255,255,255,0.6));
}

.ssummary-hint {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted, rgba(255,255,255,0.5));
}

/* Visible to assistive technology only. Used where a tile shows a short visual
   state ("Could not load") and the underlying reason still needs announcing. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Library cover maintenance ------------------------------------------- */
.covers-list { display: grid; gap: var(--sp-2); }

.cover-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  overflow: hidden;
}
.cover-group[data-missing="true"] { border-color: rgba(255, 176, 32, 0.45); }

.cover-head {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%; padding: var(--sp-2) var(--sp-3);
  background: none; border: 0; color: inherit; text-align: left; cursor: pointer;
  font: inherit;
}
.cover-head:hover { background: var(--surface-3, rgba(255, 255, 255, 0.03)); }
.cover-head:focus-visible { outline: 2px solid var(--accent, #6ea8fe); outline-offset: -2px; }

.cover-thumb {
  display: inline-flex; flex: 0 0 auto; width: 44px; height: 44px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-1); border: 1px solid var(--line);
}
.cover-thumb--none {
  display: grid; place-items: center;
  font-size: 0.625rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--warn); border-style: dashed;
}

.cover-meta { flex: 1 1 auto; min-width: 0; }
.cover-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-sub { font-size: 0.75rem; color: var(--text-muted, #9aa0a6); }

.cover-body { padding: 0 var(--sp-3) var(--sp-3); }
.cover-candidates {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-2);
}
.cover-candidate {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: var(--sp-2); background: var(--surface-1);
}
.cover-candidate[data-current="true"] { border-color: var(--ok, #4ade80); }
.cover-candidate-thumb {
  display: block; width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--surface-2);
}

@media (max-width: 480px) {
  .cover-candidates { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* --- Count chips that are also filters ------------------------------------
   Used by the Requests queue navigation and the Applications summary. They are
   real buttons, so they take focus and announce their own pressed state. */
.sfilter-chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.sfilter-chip:hover { background: var(--surface-3, rgba(255, 255, 255, 0.05)); }
.sfilter-chip:focus-visible { outline: 2px solid var(--accent, #6ea8fe); outline-offset: 2px; }
.sfilter-chip[aria-pressed="true"] {
  border-color: var(--accent, #6ea8fe);
  background: var(--surface-3, rgba(255, 255, 255, 0.07));
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) { .sfilter-chip { transition: none; } }

/* --- Dashboard: header refresh and "needs attention" ----------------------- */
.dash-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.dash-attention {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-5);
}
.dash-attention-clear {
  margin: 0 0 var(--sp-5);
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.dash-attention-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
  font-size: 0.8125rem;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
a.dash-attention-chip:hover, a.dash-attention-chip:focus-visible {
  background: var(--surface-3); border-color: var(--line-strong);
}
a.dash-attention-chip:focus-visible { outline: 2px solid var(--accent, #6ea8fe); outline-offset: 2px; }
.dash-attention-chip.is-warn { border-color: rgba(255, 176, 32, 0.4); color: var(--warn); }
.dash-attention-chip.is-danger { border-color: rgba(255, 77, 77, 0.4); color: var(--danger); }
.dash-attention-value { font-weight: 700; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .dash-attention-chip { transition: none; } }

/* --- Dashboard: sections, tiles and panels --------------------------------- */
.dash-section { margin: 0 0 var(--sp-6); }
.dash-section:last-child { margin-bottom: 0; }
.dash-section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  margin: 0 0 var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--line);
  color: var(--text-secondary);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--sp-2);
}

.dash-tile {
  display: block;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
a.dash-tile:hover { background: var(--surface-3); border-color: var(--line-strong); }
a.dash-tile:focus-visible { outline: 2px solid var(--accent, #6ea8fe); outline-offset: 2px; }

/* A linked tile and a plain one otherwise look identical, so there is no way
   to tell which numbers lead somewhere without hovering to check. */
a.dash-tile { position: relative; padding-right: calc(var(--sp-3) + 14px); }
a.dash-tile::after {
  content: "\2192";
  position: absolute; top: var(--sp-3); right: var(--sp-3);
  font-size: 0.8125rem; color: var(--text-muted);
  opacity: 0; transform: translateX(-3px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
a.dash-tile:hover::after, a.dash-tile:focus-visible::after { opacity: 1; transform: translateX(0); }
@media (prefers-reduced-motion: reduce) { a.dash-tile::after { transition: none; } }

.dash-tile.is-warn { border-color: rgba(255, 176, 32, 0.4); }
.dash-tile.is-danger { border-color: rgba(255, 77, 77, 0.4); }

.dash-tile-value {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.1;
  display: block;
  margin: var(--sp-1) 0 2px;
  font-variant-numeric: tabular-nums;
}
.dash-tile.is-warn .dash-tile-value { color: var(--warn); }
.dash-tile.is-danger .dash-tile-value { color: var(--danger); }
.dash-tile-value.is-zero { opacity: 0.5; }

@media (prefers-reduced-motion: reduce) { .dash-tile { transition: none; } }

/* --- Dashboard panels ------------------------------------------------------ */
.dash-panels {
  display: grid; gap: var(--sp-2); margin-top: var(--sp-3);
  /* A capped max, not 1fr: a section with only one panel (Creator Tools'
     version breakdown) would otherwise stretch it across the full row
     instead of matching the width a panel gets when there are several. */
  grid-template-columns: repeat(auto-fit, minmax(280px, 420px));
}
.dash-panel {
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.dash-panel-title { font-size: 0.8125rem; margin: 0 0 var(--sp-2); }

.dash-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.dash-recent li { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.dash-recent img, .dash-recent-noimg {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-1); border: 1px solid var(--line);
}
.dash-recent-copy { flex: 1 1 auto; min-width: 0; display: grid; font-size: 0.8125rem; }
.dash-recent-copy strong, .dash-recent-copy span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-recent-date { flex: 0 0 auto; font-size: 0.75rem; }

.dash-legends { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.dash-legend-copy { display: flex; justify-content: space-between; font-size: 0.8125rem; gap: var(--sp-2); }
.dash-legend-bar {
  display: block; height: 4px; margin-top: 3px; border-radius: 2px;
  background: var(--surface-1); overflow: hidden;
}
.dash-legend-bar > span { display: block; height: 100%; background: var(--accent, #6ea8fe); }

/* Thumbnail placeholders.
 *
 * A render whose thumbnail is missing or failed shows this instead of the
 * original. It is deliberately visible rather than an empty cell: a silent gap
 * would look like a rendering bug, and the whole point of the status column is
 * that a failed thumbnail is something a person can see and retry. */
.stable-thumb-missing {
  display: block;
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(
    45deg,
    var(--surface-3),
    var(--surface-3) 4px,
    var(--surface-2, var(--surface-3)) 4px,
    var(--surface-2, var(--surface-3)) 8px
  );
  border: 1px dashed var(--line);
}
.stable-thumb-missing[data-thumb-status="failed"] { border-color: rgba(255, 96, 33, 0.55); }

/* The dashboard's recent-uploads list and the library detail pane both render
 * the shared placeholder span rather than a table cell. */
.dash-recent [data-thumb-status]:not(img),
.lib-detail-thumb:not(img) {
  display: block;
  background: var(--surface-3);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.dash-recent [data-thumb-status]:not(img) { width: 44px; height: 44px; }
.lib-detail-thumb:not(img) { width: 100%; aspect-ratio: 3 / 4; }
img.lib-detail-thumb { width: 100%; border-radius: 8px; border: 1px solid var(--line); }

/* ===========================================================================
   FREE ROUNDS, CREDITS AND QUOTATIONS
   ---------------------------------------------------------------------------
   Uses the existing staff-panel primitives (sbtn, sfield, sdl, sbadge) rather
   than a new set, so these controls read as part of the same tool.
   =========================================================================== */

.squeue-panel {
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.squeue-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.squeue-panel-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.squeue-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.5rem 1rem;
  margin: 0 0 0.75rem;
}

.squeue-round-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
}

.squeue-ledger {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.squeue-ledger li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8125rem;
}

.squeue-ledger li:last-child {
  border-bottom: 0;
}

@media (max-width: 700px) {
  .squeue-round-controls {
    flex-direction: column;
    align-items: stretch;
  }
}
