/* Admin console.
 *
 * Every colour, size, radius and face here is a token. There is no hex in this
 * file and there must never be one: the point of the token layer is that the
 * client's palette arrives in data/brand.json and reaches every surface, and a
 * single literal here is a colour that silently survives the next rebrand.
 *
 * The page renders inside .on-dark (set on <html>), so it is the client's own
 * navy palette rather than a second dark theme invented for this screen. Their
 * green and red pass contrast on that ground unmodified - which is the finding
 * from the brand work, put to use. */

.admin-body {
  min-height: 100vh;
  background: var(--ground);
}

.admin {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-9);
}

/* head --------------------------------------------------------------------- */

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-6);
  flex-wrap: wrap;
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--line);
}

.admin-eyebrow {
  margin: 0 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-muted);
}

.admin-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}

.admin-lede {
  margin: var(--space-4) 0 0;
  max-width: 62ch;
  font-size: var(--text-body);
  color: var(--ink-soft);
}

.admin-lede em {
  font-style: normal;
  color: var(--ink);
  font-weight: var(--weight-medium);
}



.admin-notices {
  margin-top: var(--space-6);
  display: grid;
  gap: var(--space-3);
}

/* layout ------------------------------------------------------------------- */

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--space-8);
  align-items: start;
  margin-top: var(--space-7);
}

.admin-sticky {
  position: sticky;
  /* Clears the phone notch when this column stops being a sidebar. */
  top: calc(var(--space-6) + env(safe-area-inset-top, 0px));
  display: grid;
  gap: var(--space-4);
}

.admin-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.admin-bar h2,
.admin-side-head {
  margin: 0;
  font-size: var(--text-title);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}

.admin-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.admin-bar-actions .btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-caption);
}

.admin-count {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.admin-hint {
  margin: var(--space-3) 0 var(--space-6);
  max-width: 68ch;
  font-size: var(--text-small);
  color: var(--ink-muted);
}

/* groups ------------------------------------------------------------------- */

.admin-groups {
  display: grid;
  gap: var(--space-7);
}

.type-group h3 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line-soft);
}

.type-list {
  display: grid;
  gap: var(--space-2);
}

.type-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--surface-sunken);
}

.type-row:hover {
  border-color: var(--line);
}

/* Focus lands on the hidden input, so the ring is drawn on the row. */
.type-row:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* An off row is the one that changes the score, so it is marked in the ink
 * rather than only by an empty box - a scan down the list has to show what is
 * excluded without the reader checking twenty checkboxes. */
.type-row[data-on="false"] {
  background: transparent;
  border-color: var(--line-soft);
}

.type-row[data-on="false"] .type-label,
.type-row[data-on="false"] .type-key {
  color: var(--ink-muted);
  text-decoration: line-through;
  text-decoration-color: var(--control-line);
}

.type-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border-radius: var(--radius-sm);
}

.type-name {
  min-width: 0;
}

.type-label {
  display: block;
  font-size: var(--text-body);
  color: var(--ink);
  line-height: var(--leading-snug);
}

.type-key {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--ink-muted);
  letter-spacing: var(--tracking-slight);
}

.type-stats {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  text-align: right;
}

.type-stat {
  display: grid;
  gap: 1px;
  min-width: 52px;
}

.type-stat span:first-child {
  color: var(--ink);
}

.type-stat span:last-child {
  font-size: var(--text-micro);
  color: var(--ink-muted);
  letter-spacing: var(--tracking-slight);
}

/* Never observed here: stated rather than shown as 0%, because "0%" and "we
 * have no shoes carrying this" are different facts and only one of them is an
 * argument for switching it off. */
.type-stat--none span:first-child {
  color: var(--ink-muted);
}

.type-cleanable {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-slight);
  color: var(--good);
  border: 1px solid var(--good-edge);
  background: var(--good-wash);
  border-radius: var(--radius-pill);
  padding: 1px var(--space-3);
  white-space: nowrap;
}

/* effect panel ------------------------------------------------------------- */

.effect-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: grid;
  gap: var(--space-5);
}

.effect-idle {
  margin: 0;
  font-size: var(--text-small);
  color: var(--ink-muted);
}

.effect-scores {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  font-variant-numeric: tabular-nums;
}

.effect-from,
.effect-to {
  font-family: var(--font-mono);
  line-height: var(--leading-tight);
}

.effect-from {
  font-size: var(--text-title);
  color: var(--ink-muted);
}

.effect-arrow {
  color: var(--ink-muted);
  font-size: var(--text-small);
}

.effect-to {
  font-size: var(--text-reliability);
  color: var(--ink);
}

.effect-delta {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  padding: 1px var(--space-3);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* Raising a score is the direction that needs watching, so it is the one that
 * gets the warning colour. There is no "good" state here to paint green. */
.effect-delta[data-level="none"] {
  color: var(--ink-muted);
  border: 1px solid var(--line);
}

.effect-delta[data-level="small"] {
  color: var(--caution);
  background: var(--caution-wash);
  border: 1px solid var(--caution-edge);
}

.effect-delta[data-level="large"] {
  color: var(--critical);
  background: var(--critical-wash);
  border: 1px solid var(--critical-edge);
}

.effect-caption {
  margin: 0;
  font-size: var(--text-small);
  color: var(--ink-soft);
}

.effect-rows {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding-top: var(--space-5);
  border-top: 1px solid var(--line-soft);
}

.effect-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-small);
  color: var(--ink-soft);
}

.effect-row b {
  font-family: var(--font-mono);
  font-weight: var(--weight-regular);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.effect-worst {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line-soft);
}

.effect-worst-head {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 var(--space-2);
}

.worst-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-4);
  font-size: var(--text-caption);
  align-items: baseline;
}

.worst-name {
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.worst-move {
  font-family: var(--font-mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.admin-save {
  display: flex;
  gap: var(--space-3);
}

.admin-save .btn {
  flex: 1;
  justify-content: center;
}

.admin-save-note {
  margin: 0;
  font-size: var(--text-caption);
  color: var(--ink-muted);
  min-height: 18px;
}

.admin-save-note[data-state="dirty"] {
  color: var(--caution);
}

.admin-save-note[data-state="saved"] {
  color: var(--good);
}

.admin-save-note[data-state="error"] {
  color: var(--critical);
}




/* narrow ------------------------------------------------------------------- */

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Un-stick it: a sticky panel in a single column covers the list it is
   * describing. It moves above the types instead, because the consequence is
   * the thing that must not be scrolled past. */
  .admin-sticky {
    position: static;
  }

  .admin-side {
    order: -1;
  }

  .type-row {
    grid-template-columns: 22px minmax(0, 1fr);
    row-gap: var(--space-3);
  }

  .type-stats {
    grid-column: 2;
    justify-content: flex-start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* login -------------------------------------------------------------------- */

.login-body {
  display: grid;
  place-items: center;
}

.login {
  width: 100%;
  max-width: 380px;
  padding: var(--space-8) var(--space-5);
  display: grid;
  gap: var(--space-6);
}

.login-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6) var(--space-6);
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2);
}

/* Critical, not caution: a refused sign-in is a refusal, and painting it amber
 * invites a second look for a warning that is not there. */
.login-error {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-small);
  color: var(--critical);
  background: var(--critical-wash);
  border: 1px solid var(--critical-edge);
  border-radius: var(--radius-md);
}

.login-cmd {
  margin: var(--space-4) 0 0;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow-x: auto;
  white-space: pre;
}

.login-foot {
  margin: 0;
  font-size: var(--text-small);
  line-height: var(--leading-snug);
  color: var(--ink-muted);
}



/* accounts ------------------------------------------------------------------ */

.admin-section {
  margin-top: var(--space-9);
}

.admin-section > h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-title);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}

.people {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.person {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "identity tags"
    "meta     actions";
  gap: var(--space-3) var(--space-5);
  align-items: center;
  padding: var(--space-5) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

/* Your own row, marked by the edge rather than by a different background: the
 * list is read by scanning down it, and one row on a different ground reads as
 * a state rather than as an identity. */
.person[data-you="true"] {
  border-left: 2px solid var(--brand-ink);
}

.person-identity { grid-area: identity; min-width: 0; }
.person-tags     { grid-area: tags; display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.person-meta     { grid-area: meta; }
.person-actions  { grid-area: actions; display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: flex-end; }

.person-name {
  font-size: var(--text-lead);
  color: var(--ink);
  line-height: var(--leading-snug);
}

.person-email,
.person-meta {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-actions .btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-caption);
}

/* Destructive, and it looks it. The colour is the warning - a Remove button
 * that matches every other button gets clicked at the speed of every other
 * button. */
.btn--danger {
  background: transparent;
  color: var(--critical);
  border-color: var(--critical-edge);
}

.btn--danger:hover:not(:disabled) {
  background: var(--critical-wash);
}

.add-card {
  margin-top: var(--space-5);
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 640px;
}

.add-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5);
}

.field-optional {
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: var(--tracking-normal);
  color: var(--ink-muted);
}

.field-help {
  margin: var(--space-2) 0 0;
  font-size: var(--text-caption);
  line-height: var(--leading-snug);
  color: var(--ink-muted);
}

/* The setup link. Brand-washed rather than plain, because it appears once and
 * has to be noticed before the page is navigated away from. */
.link-box {
  margin-top: var(--space-5);
  padding: var(--space-6);
  background: var(--brand-wash);
  border: 1px solid var(--brand-edge);
  border-radius: var(--radius-lg);
  max-width: 640px;
}

.link-head {
  margin: 0 0 var(--space-4);
  font-size: var(--text-body);
  color: var(--ink);
}

.link-row {
  display: flex;
  gap: var(--space-3);
}

.link-url {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
}

.link-note {
  margin: var(--space-4) 0 0;
  font-size: var(--text-caption);
  line-height: var(--leading-snug);
  color: var(--ink-soft);
}

.setup-for {
  margin: 0 0 var(--space-6);
  font-size: var(--text-small);
  color: var(--ink-soft);
}

.setup-for strong {
  font-family: var(--font-mono);
  font-weight: var(--weight-regular);
  color: var(--ink);
}

@media (max-width: 640px) {
  .person {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "identity"
      "tags"
      "meta"
      "actions";
  }

  .person-tags,
  .person-actions {
    justify-content: flex-start;
  }
}

/* console header -----------------------------------------------------------
 * Two jobs, previously done by one flat row of four things at equal weight:
 * navigation (which grows as the console does) and identity (which does not).
 * Sign out was the heaviest element on the page and the rarest action; it now
 * lives inside the user menu, where its weight matches how often it is wanted.
 */

.user-menu {
  position: relative;
  flex: none;
}

.user-button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  cursor: pointer;
}

.user-button:hover,
.user-button[aria-expanded="true"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--brand-wash);
  border: 1px solid var(--brand-edge);
  color: var(--brand-ink);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-normal);
}

.user-label {
  font-size: var(--text-small);
  white-space: nowrap;
}

.user-chevron {
  width: 10px;
  height: 6px;
  color: var(--ink-muted);
}

.user-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 20;
  min-width: 220px;
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.user-panel-head {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: var(--space-2);
}

.user-panel-name {
  font-size: var(--text-body);
  color: var(--ink);
  line-height: var(--leading-snug);
}

.user-panel-email {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--ink-muted);
  word-break: break-all;
}

.user-panel-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: var(--text-small);
  cursor: pointer;
}

.user-panel-item:hover {
  background: var(--surface-sunken);
}

/* navigation --------------------------------------------------------------- */

.console-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  margin-top: var(--space-6);
  border-bottom: 1px solid var(--line);
}

.nav-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  /* The row that grows. It scrolls rather than wraps so the leave link stays
   * where it is once there are more pages than fit. */
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-body);
  color: var(--ink-muted);
  text-decoration: none;
  white-space: nowrap;
  /* Transparent, not absent: the current tab's rule must not change the
   * height of the row and shift everything by two pixels. */
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.nav-tab:hover {
  color: var(--ink);
}

.nav-tab[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--brand-ink);
}

/* Leaving the console, not moving inside it - so it is set apart from the tabs
 * rather than being one more of them. */
.nav-leave {
  flex: none;
  padding: var(--space-3) 0;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--ink-muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav-leave:hover {
  color: var(--ink);
}

@media (max-width: 560px) {
  .user-label {
    display: none;
  }
}

/* footer -------------------------------------------------------------------
 * Centred and quiet. It replaced two paragraphs of explanation, one of which
 * had gone stale - it still named data/scope.json after the file moved to
 * var/. Neither was lost: the fingerprint point is on every result, in the
 * "Withheld by configuration" card, and the first-account command is on the
 * login page where somebody actually needs it. */


/* The heart is the one glyph here the brand faces do not carry - they are
 * subset to latin + latin-ext - so the browser substitutes from the system
 * emoji font. Nudged up because that substitute sits low against this text. */
.brand-heart {
  display: inline-block;
  vertical-align: -0.05em;
}

.brand-foot {
  margin-top: var(--space-9);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
  /* Stacked, not side by side: the line names the company and the mark sits
   * under it, rather than the mark standing in for the name. */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.brand-made {
  margin: 0;
  font-size: var(--text-small);
  color: var(--ink-muted);
}

.brand-logo {
  display: block;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

/* No `color` here on purpose. The mark carries its own - white for the name,
 * grey for the strapline, and a black slash inside the symbol. Tinting it with
 * a token washed all three into one flat, faded shape. */
.brand-logo svg {
  display: block;
  width: 156px;
  height: auto;
}

.brand-logo:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: var(--space-2);
}
