/* The account menu and the admin screens: people and access, devices, activity, backups,
   archived records, plans, sample data, the lead import, and the parts they lend to other
   pages (a record's history; the spreadsheet links on Sales and Expenses).
   Only what the shared parts in app.css do not give. Every selector carries a class that
   starts with adm-, so this file cannot restyle a page or the shell.
   The look is the one of SPEC-STEP7.md: white, thin grey lines, plain lines between rows,
   one blue for what can be done, no colour on a row. */

/* ---------- Shared parts ---------- */

/* An admin sheet with a table in it gets more room on a laptop. */
@media (min-width: 900px) {
  .sheet:has(> .sheet__body > .adm-wide) {
    width: min(880px, calc(100vw - 48px));
    max-width: 880px;
  }
}

.adm-wait,
.adm-empty,
.adm-quiet {
  color: var(--ink-3);
}

.adm-wait,
.adm-empty {
  padding: 8px 0;
}

.adm-gap {
  margin-top: 12px;
}

/* A box for something that belongs together: a form opened in place, a password shown
   once, a list of skipped rows. */
.adm-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--panel);
}

/* A password or a key shown once: large enough to read out, selected whole with a tap. */
.adm-secret {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0, "dlig" 0;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  user-select: all;
}

/* What a screen says in the preview build, where there is no server behind it. */
.adm-preview {
  display: grid;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--panel);
  color: var(--ink-2);
}

.adm-preview__title {
  font-weight: 600;
  color: var(--ink);
}

/* A part of a sheet: its name in 13px 600, then rows. Parts are kept apart by a thin line. */
.adm-blk {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.adm-blk__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-height: 32px;
}

.adm-blk__title {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

.adm-blk__n {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.adm-blk__note {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
}

.adm-blk__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* Plain lines: a list in a sheet, rows apart by the soft line. */
.adm-lines {
  border-top: 1px solid var(--line-soft);
}

.adm-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 16px;
  min-height: 56px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.adm-line--stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

.adm-line--form {
  grid-template-columns: minmax(0, 1fr);
}

.adm-line__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.adm-line__main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.adm-line__title {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.adm-line__title .tag {
  margin-left: 4px;
}

.adm-line__sub {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.adm-line__fig,
.adm-fig {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.adm-line__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

/* An address or a folder: numbers that line up, text that can be selected in one go. */
.adm-ip,
.adm-path {
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.adm-path {
  font-weight: 500;
  color: var(--ink);
  user-select: all;
}

/* A word a cell needs only on a phone, where the cell has no column heading above it. */
.adm-phone {
  display: none;
}

@media (max-width: 899.98px) {
  .adm-phone {
    display: inline;
  }
}

/* ---------- The account menu ---------- */

.adm-menu__me {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
}

.adm-menu__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.adm-menu__list {
  border-top: 1px solid var(--line-soft);
}

.adm-menu__item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 56px;
  padding: 9px 8px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.adm-menu__label {
  font-weight: 500;
}

.adm-menu__desc {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
}

.adm-menu__group {
  padding: 24px 8px 8px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: var(--ink-3);
}

.adm-menu__list--last {
  margin-top: 24px;
}

/* ---------- My name and color ---------- */

.adm-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.adm-swatch {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--control);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
}

.adm-swatch__dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--marker);
}

.adm-swatch[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---------- People ---------- */

.adm-people {
  border-top: 1px solid var(--line-soft);
}

.adm-person {
  min-width: 0;
  border-bottom: 1px solid var(--line-soft);
}

.adm-person__open {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 65px;
  padding: 10px 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

button.adm-person__open {
  cursor: pointer;
}

.adm-person__main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.adm-person__name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.adm-person__name .tag {
  margin-left: 4px;
}

.adm-person__sub {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

/* One person's sheet */

.adm-who {
  display: flex;
  align-items: center;
  gap: 12px;
}

.adm-who__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* Last sign-in and last active: label left, value right of it. */
.adm-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 16px;
  margin: 16px 0;
  font-size: 13px;
  line-height: 18px;
}

.adm-facts dt {
  color: var(--ink-3);
}

/* The access picker: four pages, three small switches each. Label over the levels on a
   narrow phone, beside them where there is room. */
.adm-access {
  display: grid;
  gap: 8px;
}

.adm-access__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: center;
}

.adm-access__page {
  font-weight: 500;
}

.adm-access__seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 360px;
}

.adm-access__seg .seg__btn {
  padding: 0 6px;
  white-space: nowrap;
}

@media (min-width: 480px) {
  .adm-access__row {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
  }
}

/* An admin's levels are shown, not offered. */
.adm-access--locked .seg__btn {
  color: var(--ink-3);
  cursor: default;
}

.adm-access--locked .seg__btn[aria-pressed="true"] {
  color: var(--ink-2);
}

/* Where someone is signed in */

.adm-sessions {
  border-top: 1px solid var(--line-soft);
}

.adm-session {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.adm-session__device {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.adm-session__device .tag {
  margin-left: 4px;
}

.adm-session__meta {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
}

/* ---------- Activity ---------- */

/* The numbers line sits flush with the sheet's text, with what the counts take in under it. */
.adm-totals {
  display: grid;
  gap: 8px;
}

.adm-totals .figures {
  margin: 0;
  padding: 0;
  border-bottom: 0;
}

.adm-totals__note {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
}

/* The shared table inside a sheet: no page padding around it. */
.adm-table .dt {
  margin: 0;
}

.adm-person-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.adm-person-cell__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 899.98px) {
  /* A sheet already has its own side padding. */
  .adm-table .dt__row {
    padding-left: 0;
    padding-right: 0;
  }

  .adm-table .adm-person-cell .mark {
    display: none;
  }

  /* "In 7 days: ..." is a quiet third line, like the line above it. */
  .adm-table .dt__c-work {
    font-size: 13px;
    line-height: 18px;
    color: var(--ink-3);
  }
}

.adm-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.adm-events {
  border-top: 1px solid var(--line-soft);
}

.adm-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.adm-event__main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.adm-event__text {
  overflow-wrap: anywhere;
}

.adm-event__text strong {
  font-weight: 600;
}

.adm-event__note {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.adm-event__meta {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
}

.adm-more {
  display: flex;
  justify-content: center;
}

/* ---------- Backups ---------- */

.adm-backups {
  border-top: 1px solid var(--line-soft);
}

.adm-backup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 16px;
  min-height: 56px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.adm-backup__main,
.adm-archived__main {
  min-width: 0;
}

.adm-backup__when {
  font-weight: 500;
}

.adm-backup__when .tag {
  margin-left: 4px;
}

.adm-backup__meta {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* A plain warning: a grey box. No colour: nothing is late. */
.adm-notice {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--panel);
}

.adm-notice__title {
  font-weight: 600;
}

.adm-notice__step {
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
  color: var(--ink-2);
}

/* A command to copy: the tool's own type (no monospace), in a white box with a thin line,
   so it reads as something to take away rather than something to tap. */
.adm-cmd {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--bg);
}

/* Ligatures off: the typeface joins "--" into a dash, and a command has to read as typed.
   .adm-literal does the same for a piece of a command quoted inside a sentence. */
.adm-cmd__text,
.adm-literal {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0, "dlig" 0;
}

.adm-cmd__text {
  font: inherit;
  font-size: 13px;
  line-height: 18px;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0, "dlig" 0;
  user-select: all;
  overflow-wrap: anywhere;
}

.adm-literal {
  white-space: nowrap;
}

/* The restore steps (and the two-step set-up) are a real sequence, so they are numbered. */
.adm-steps {
  display: grid;
  gap: 16px;
  padding-left: 24px;
  list-style: decimal;
}

.adm-steps li {
  padding-left: 4px;
}

.adm-steps li::marker {
  font-weight: 600;
  color: var(--ink-3);
}

.adm-steps .adm-cmd {
  margin-top: 6px;
}

/* ---------- Archived ---------- */

.adm-archived {
  border-top: 1px solid var(--line-soft);
}

.adm-archived__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 16px;
  min-height: 56px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.adm-archived__title {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.adm-archived__title .tag {
  margin-left: 4px;
}

.adm-archived__sub {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

/* ---------- The lead import ---------- */

/* "Step 2 of 3  Match the columns": where the import is. Focus lands here on each step. */
.adm-steps-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.adm-steps-line:focus {
  outline: none;
}

.adm-steps-line__n {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
}

.adm-steps-line__title {
  font-weight: 600;
}

.adm-drop {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--panel);
}

.adm-drop--over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.adm-drop__input {
  background: var(--bg);
}

.adm-fieldset {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 16px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.adm-fieldset__legend {
  padding: 0 0 8px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

.adm-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.adm-counts dt {
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-3);
}

.adm-counts dd {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.adm-errlist {
  display: grid;
  gap: 4px;
  padding-left: 20px;
  list-style: disc;
  font-size: 13px;
  line-height: 18px;
  overflow-wrap: anywhere;
}

.adm-done {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

/* ---------- Lent to other pages ---------- */

/* A record's history: who changed it, when, and which fields. */
.adm-historylist__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.adm-historylist__row:first-child {
  border-top: 0;
  padding-top: 0;
}

.adm-historylist__main {
  min-width: 0;
  overflow-wrap: anywhere;
}

.adm-historylist__when {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-3);
}

/* Quiet buttons have side padding; pull one back so its text lines up with what is above
   it (Show all under a history, Remove under a person's own Library comment). */
.adm-pull {
  margin-left: -12px;
}

/* Spreadsheet actions in a page's toolbar: import, download. */
.adm-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (min-width: 700px) {
  .adm-tools {
    margin-left: auto;
  }
}

/* Hover only where a pointer can hover, so taps on phones do not leave it stuck. */
@media (hover: hover) {
  .adm-menu__item:hover,
  button.adm-person__open:hover {
    background: var(--panel);
  }
}

/* ---------- A person's own colour ----------
   Marks are grey everywhere (app.css). Two places show the person's colour, because that is
   where it is chosen and explained: the marks in People and the mark in the account menu.
   White initials on the colour in light; the dark page colour on the lighter dark-theme
   colours, so the initials keep 4.5:1 in both. */
.mark.adm-mark--owner {
  background: var(--marker);
  color: var(--on-accent);
}

@media (prefers-color-scheme: dark) {
  .mark.adm-mark--owner {
    color: var(--bg);
  }
}

/* The six person colours. app.css no longer has them (marks are grey everywhere), so they
   live here, only for the two places that show them: the owner mark and the colour picker.
   Same values the shared stylesheet had; the dark ones are lighter so dark initials read on
   them (4.5:1 or more on every colour, light and dark). */
.adm-mark--owner,
.adm-swatch {
  --adm-m-blue: #1f5fd0;
  --adm-m-green: #0b7a5e;
  --adm-m-violet: #7446c9;
  --adm-m-orange: #b85c00;
  --adm-m-magenta: #b0237a;
  --adm-m-slate: #48607a;
}

@media (prefers-color-scheme: dark) {
  .adm-mark--owner,
  .adm-swatch {
    --adm-m-blue: #6fa1ff;
    --adm-m-green: #46c7a3;
    --adm-m-violet: #b095f5;
    --adm-m-orange: #f0a24a;
    --adm-m-magenta: #f07cc0;
    --adm-m-slate: #9db2c8;
  }
}

.adm-mark--owner.mk-blue, .adm-swatch.mk-blue { --marker: var(--adm-m-blue); }
.adm-mark--owner.mk-green, .adm-swatch.mk-green { --marker: var(--adm-m-green); }
.adm-mark--owner.mk-violet, .adm-swatch.mk-violet { --marker: var(--adm-m-violet); }
.adm-mark--owner.mk-orange, .adm-swatch.mk-orange { --marker: var(--adm-m-orange); }
.adm-mark--owner.mk-magenta, .adm-swatch.mk-magenta { --marker: var(--adm-m-magenta); }
.adm-mark--owner.mk-slate, .adm-swatch.mk-slate { --marker: var(--adm-m-slate); }
.adm-mark--owner.mk-none { --marker: var(--chip); color: var(--ink-2); }
