/* Shared components. Every class here has exactly one builder in public/src/ui/,
 * and nothing outside that folder is allowed to use these class names -- that
 * is what stops the same markup being written twice with different padding. */

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: var(--space-4); }

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  /* Wraps rather than overflowing. A header holding a title and a segmented
   * control cannot fit both on one line at 375px, and a grid track sized by
   * min-content would otherwise be pushed wider than the viewport. */
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.card__head-text { min-width: 0; }
.card__head-text p { margin-top: var(--space-1); }

.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }

.card__foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

.section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* -------------------------------------------------------------- buttons -- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

.button:hover:not(:disabled, [aria-disabled="true"]) { background: var(--accent-hover); }
.button:disabled,
.button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.button--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.button--ghost:hover:not(:disabled, [aria-disabled="true"]) {
  background: var(--surface-2);
  border-color: var(--text-faint);
  color: var(--text);
}

.button--danger { background: var(--danger); color: var(--danger-text); }
.button--danger:hover:not(:disabled) { background: var(--danger-hover); }

.button--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.button--quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.button--small {
  min-height: 28px;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
}

.button--block { width: 100%; }
.button.is-copied { color: var(--ok); border-color: var(--ok); }

/* A button that has to read as body text -- "Clear filters and start again"
 * inside a paragraph. Still a button, because it performs an action. */
.linklike {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linklike:hover { color: var(--accent-hover); }

.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-md);
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.icon-button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-button--bordered { border-color: var(--border-strong); background: var(--surface); }

.icon-button svg { width: 17px; height: 17px; }

/* Icons are decorative next to a text label and load-bearing without one; the
 * builder sets aria-hidden accordingly. Sized in em so they track the text. */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------- fields -- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.field__optional {
  font-weight: var(--weight-normal);
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.input,
.field select,
.field textarea {
  width: 100%;
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.input:disabled,
.field select:disabled {
  background: var(--surface-2);
  color: var(--text-faint);
  cursor: not-allowed;
}

.input--mono { font-family: var(--mono); font-size: var(--text-sm); }

.field__hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

.field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--danger);
  font-weight: var(--weight-medium);
}

.field--invalid .input,
.field--invalid select,
.field--invalid textarea { border-color: var(--danger); }

.field--invalid .input:focus {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger) 20%, transparent);
}

/* `display: flex` above is an author rule and beats the user agent's
 * `[hidden] { display: none }`, so a hidden field would otherwise still show. */
.field[hidden],
.field__error[hidden],
.form-error[hidden],
.checkbox[hidden],
.row[hidden],
.banner[hidden] { display: none; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
}
.checkbox input {
  width: auto;
  margin-top: 0.15em;
  accent-color: var(--accent);
  flex: none;
}
.checkbox__text { display: block; }
.checkbox__hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid color-mix(in oklab, var(--danger) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-sm);
}

.password-meter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.password-meter__track {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--chart-track);
  overflow: hidden;
}
.password-meter__fill {
  height: 100%;
  width: 0;
  background: var(--danger);
  transition: width var(--duration) var(--ease), background var(--duration) var(--ease);
}
.password-meter--ok .password-meter__fill { background: var(--ok); }
.password-meter--warn .password-meter__fill { background: var(--warn); }

/* ---------------------------------------------------- segmented control -- */

/* A radiogroup that looks like a toolbar: the range and interval pickers. */
.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.segmented__option {
  padding: var(--space-1) var(--space-3);
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.segmented__option:hover:not(:disabled, [aria-checked="true"]) { color: var(--text); }
.segmented__option[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(16 16 26 / 10%);
}
.segmented__option:disabled { opacity: 0.45; cursor: not-allowed; }

/* --------------------------------------------------------------- tables -- */

.table-wrap {
  overflow-x: auto;
  /* A horizontally scrollable region must be reachable by keyboard, which
   * needs a tabindex; that in turn needs a focus style that is not the
   * generic 2px ring drawn outside a card's rounded corner. */
  scrollbar-gutter: stable;
}
.table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

thead th {
  padding: var(--space-2) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody td {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.is-selected { background: var(--accent-soft); }
tbody tr.is-selected:hover { background: color-mix(in oklab, var(--accent-soft) 80%, var(--accent)); }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.col-select { width: 1%; padding-right: 0; }

/* A column heading that is also a sort control. Inherits the th's type rather
 * than looking like a control dropped into a header. */
.sortable {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.sortable:hover { color: var(--accent); }
.sortable--active { color: var(--text); }
.sortable__arrow { font-size: 0.85em; color: var(--accent); }
.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.code-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* Bounded so five columns fit a desktop card without a scrollbar. Narrower
 * viewports scroll inside .table-wrap, which is intended. */
.dest-link {
  display: inline-block;
  max-width: 34ch;
  vertical-align: bottom;
}

.compact-table { font-size: var(--text-sm); }
.compact-table td { padding: var(--space-2) var(--space-2) var(--space-2) 0; border-bottom: none; }
.compact-table tr:hover { background: none; }
.compact-table td:first-child { max-width: 0; width: 100%; }

/* A count with a proportional bar behind it -- the referrer breakdown. */
.share {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
}
.share__label { min-width: 0; }
.share__track {
  height: 4px;
  margin-top: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--chart-track);
  overflow: hidden;
}
.share__fill { height: 100%; background: var(--chart-bar); border-radius: inherit; }
.share__value { font-variant-numeric: tabular-nums; font-size: var(--text-sm); }

/* --------------------------------------------------------------- badges -- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 1px var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.01em;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge--active {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in oklab, var(--ok) 30%, transparent);
}
.badge--expired {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 30%, transparent);
}
.badge--disabled,
.badge--revoked {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 30%, transparent);
}
.badge--neutral {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-align: center;
  line-height: 1.4;
}

/* ---------------------------------------------------------------- stats -- */

.stat-row {
  display: grid;
  /* min(150px, 100%) rather than a bare 150px: a bare minimum larger than the
   * container makes the track overflow instead of collapsing to one column. */
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: var(--space-3);
}

.stat {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.stat__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
}
.stat__label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.stat__note {
  display: block;
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--text-faint);
}

/* ------------------------------------------------------- definition list -- */

.definition {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: var(--space-3) var(--space-4);
  font-size: var(--text-base);
}
.definition dt {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-muted);
}
.definition dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.definition--compact { grid-template-columns: 100px minmax(0, 1fr); gap: var(--space-2) var(--space-4); }

@media (max-width: 640px) {
  .definition,
  .definition--compact {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
  .definition dt { margin-top: var(--space-3); font-size: var(--text-sm); }
  .definition dt:first-child { margin-top: 0; }
}

/* -------------------------------------------------------------- notices -- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.notice--warn {
  border-color: color-mix(in oklab, var(--warn) 40%, transparent);
  background: var(--warn-soft);
  color: var(--warn);
}
.notice--danger {
  border-color: color-mix(in oklab, var(--danger) 40%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}
.notice--info {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}
.notice strong { font-weight: var(--weight-bold); }
.notice__icon { flex: none; margin-top: 0.15em; }

/* A page-wide banner: offline, or a degraded state. Pinned under the top bar. */
.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--warn-soft);
  color: var(--warn);
  border-bottom: 1px solid color-mix(in oklab, var(--warn) 35%, transparent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: center;
}

/* --------------------------------------------------- empty/error/loading -- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-9) var(--space-5);
  text-align: center;
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: var(--text-lg);
}
.empty__body { max-width: 46ch; color: var(--text-muted); }
.empty__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-9);
  color: var(--text-muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* Skeletons mirror the shape of what is loading, so the page does not jump
 * when the data lands. The shimmer is a background sweep rather than an
 * opacity pulse: it survives being disabled under reduced motion as a plain
 * grey block, which still reads as "not here yet". */
.skeleton {
  display: block;
  height: 1em;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}
@keyframes skeleton-sweep {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--surface-2); }
}
.skeleton--text { height: 0.8em; }
.skeleton--block { height: 100%; }

/* ----------------------------------------------------------- pagination -- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.pager__label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.pager__controls { display: flex; align-items: center; gap: var(--space-1); }
.pager__page {
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pager__size { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); }
.pager__size select {
  min-height: 28px;
  padding: 2px var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
}

/* --------------------------------------------------------------- modals -- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: rgb(10 10 14 / 55%);
  backdrop-filter: blur(3px);
  animation: fade var(--duration) var(--ease);
  overflow-y: auto;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - var(--space-9));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal--wide { max-width: 580px; }
.modal--narrow { max-width: 400px; }

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.modal__title { min-width: 0; }
.modal__subtitle { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--text-muted); }
.modal__body { padding: var(--space-5); overflow-y: auto; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.modal__foot--spread { justify-content: space-between; }

@media (max-width: 520px) {
  .backdrop { padding: var(--space-3); place-items: end center; }
  .modal { max-height: calc(100vh - var(--space-6)); }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .button { width: 100%; }
}

.secret {
  display: block;
  padding: var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--text-sm);
  word-break: break-all;
  user-select: all;
}

.review {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-base);
}
.review dt { color: var(--text-muted); }
.review dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.progress-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.progress-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.progress-list__item:last-child { border-bottom: 0; }
.progress-list__ok { color: var(--ok); }
.progress-list__fail { color: var(--danger); }

.progress-bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--chart-track);
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  transition: width var(--duration) var(--ease);
}

/* ---------------------------------------------------------------- menus -- */

.menu-anchor { position: relative; display: inline-flex; }

.menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: var(--z-menu);
  min-width: 200px;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.menu--left { right: auto; left: 0; }

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.menu__item:hover,
.menu__item:focus-visible { background: var(--surface-2); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-soft); }
.menu__item:disabled { opacity: 0.5; cursor: not-allowed; }

.menu__label {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu__sep { height: 1px; margin: var(--space-1) 0; background: var(--border); }

/* ------------------------------------------------------------- info dot -- */

/* An inline "why does this say that?" affordance. A real <button> with
 * aria-expanded rather than a title attribute, because a title is unreachable
 * by touch and by keyboard, and half of what this API does needs explaining. */
.infodot {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: var(--weight-bold);
  line-height: 1;
  cursor: help;
  vertical-align: 1px;
  flex: none;
}
.infodot:hover,
.infodot[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

.infodot-wrap { position: relative; display: inline-flex; }

.infodot__panel {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  z-index: var(--z-menu);
  width: max-content;
  max-width: min(280px, 70vw);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  transform: translateX(-50%);
  white-space: normal;
}
.infodot__panel--below { bottom: auto; top: calc(100% + var(--space-2)); }

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

.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(400px, calc(100vw - var(--space-7)));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: slide-in var(--duration) var(--ease);
}
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } }
.toast--danger { border-left-color: var(--danger); }
.toast--success { border-left-color: var(--ok); }
.toast--warn { border-left-color: var(--warn); }
.toast__body { flex: 1; min-width: 0; }
.toast__message { font-size: var(--text-sm); }
.toast__detail {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.toast__action { margin-top: var(--space-2); }

/* ---------------------------------------------------------------- charts -- */

.chart-wrap {
  position: relative;
  height: 170px;
  margin-top: var(--space-2);
}
.chart-wrap--tall { height: 220px; }

.chart {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart__bar {
  fill: var(--chart-bar);
  transition: fill var(--duration-fast) var(--ease);
}
.chart__bar:hover { fill: var(--chart-bar-hover); }
/* A bar for a bucket with no clicks still gets a baseline, so the axis reads
 * as a continuous range rather than as gaps where nothing was recorded. */
.chart__bar--zero { fill: var(--chart-bar-zero); }
.chart__grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart__gridlabel { fill: var(--text-faint); font-size: 10px; font-family: var(--sans); }

.chart-axis {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: var(--space-4);
}

.sparkline { display: block; width: 72px; height: 20px; overflow: visible; }
.sparkline__line { fill: none; stroke: var(--chart-bar); stroke-width: 1.5; stroke-linejoin: round; }

/* ------------------------------------------------------------------- qr -- */

/* A QR has to survive being photographed off a screen, which is a far lower
 * effective resolution than it looks. At 168px a version-3 code is under four
 * device pixels per module and phones simply fail to lock on. Always pure
 * black on white -- a themed QR inherits whatever contrast the page happens
 * to have, and scanners need the full range. */
.qr {
  display: block;
  width: 232px;
  max-width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: #000;
}
.qr svg { display: block; width: 100%; height: auto; }

button.qr { cursor: zoom-in; appearance: none; font: inherit; }
button.qr:hover { border-color: var(--accent); }

.qr--lg { width: min(78vw, 400px); margin: 0 auto; padding: 18px; }

.qr-caption {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-align: center;
}

/* Centred under the code rather than beside it: the block is sized by the QR,
 * which is 232px, and both places that render one give it a shrink-to-fit
 * column. */
.qr-actions {
  display: flex;
  justify-content: center;
  margin-top: var(--space-2);
}

/* ------------------------------------------------------- section spacing -- */

/* Sibling spacing between the top-level blocks of a screen, so no screen file
 * has to set a margin at the call site. `.card + .card` is declared with the
 * cards above; these cover the mixed cases. */
.card + .split,
.split + .card,
.split + .split { margin-top: var(--space-4); }

/* A short line of explanation under a card heading, before its content. */
.section-intro { margin-bottom: var(--space-4); }

/* A footnote inside a flush card, under a table, sharing the table's gutters. */
.table-note {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}

/* A note that follows a card rather than sitting inside one. */
.list-note { margin-top: var(--space-3); }

/* Vertical rhythm inside a skeleton stat tile. */
.skeleton-gap { margin-top: var(--space-2); }

.text-center { text-align: center; }
