/* ══════════════════════════════════════════
   FIRE SITE KIT: THE CONSOLE LAYER
   The parts a Fire console is built from, shared so fire-admin and Fire
   Studio feel like one product (docs/plans/fire-studio/console.md, 15.5):
   the data table and its phone cards, the pager, the filter sheet, the icon
   button with its tooltip, the modal, the record grid and its rail, the
   readiness line, the state mark and the banner. One type scale, one row
   height, one content width, taken from fire-admin's admin.css. Linked
   after header.css and before theme.css; console.js beside it.

   State has three tokens of its own, --ok, --warn and --down, each reading
   at least 4.5:1 as text on --bg and --surface in both themes (the kit's
   --green and --amber do not on white). A state colour means state and
   nothing else: never a person's colour, never a chart's. Running, stopped
   and test use --text-2. Every mark is a glyph and a word, never colour
   alone.
   ══════════════════════════════════════════ */

:root,
[data-theme="dark"] {
  --ok: #22c55e;
  --warn: #f59e0b;
  --down: #ef4444;
  --ok-dim: rgba(34, 197, 94, 0.1);
  --warn-dim: rgba(245, 158, 11, 0.12);
  --down-dim: rgba(239, 68, 68, 0.1);
  --console-max: 1440px;
  --console-row: 44px;
  --console-control: 30px;
  --console-panel: 560px;
}

[data-theme="light"] {
  --ok: #15803d;
  --warn: #b45309;
  --down: #b91c1c;
  --ok-dim: rgba(21, 128, 61, 0.08);
  --warn-dim: rgba(180, 83, 9, 0.1);
  --down-dim: rgba(185, 28, 28, 0.08);
}

/* --- A state's chip (story.css's .story-chip) in its state's colour: the
   word on a tint of it, with no edge. The word says the state, so colour is
   never the only sign. story.css comes later and sets the chip's own grey,
   so each tone names both classes. --- */
.story-chip.story-chip-ok {
  color: var(--ok);
  background: var(--ok-dim);
}

.story-chip.story-chip-warn {
  color: var(--warn);
  background: var(--warn-dim);
}

.story-chip.story-chip-down {
  color: var(--down);
  background: var(--down-dim);
}

/* --- The page --- */
.console {
  max-width: var(--console-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.console-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.console-head h1 {
  font-size: var(--text-2xl);
}

.console-head .lede {
  margin-bottom: 0;
}

/* A console's sections are rows of a page, not a marketing site's bands:
   no padding of their own, and headings at the console's scale. */
.console section {
  padding: 0;
}

.console h2 {
  font-size: var(--text-xl);
}

.console h3 {
  font-size: var(--text-lg);
}

/* Two columns on a desk (1100px and wider): the record in the main column,
   what serves it in the rail at the right (console.md, 15.4). */
.console-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.console-rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (min-width: 1100px) {
  .console-record {
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  }

  .console-rail {
    position: sticky;
    top: calc(var(--nav-height) + var(--space-4));
  }
}

/* --- The data table ---
   Positioned, so what a cell holds out of sight (a column's .visually-hidden
   name) is clipped by the table's own scroll and never widens the page. */
.console-table {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.console-table__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.console-table__title {
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}

.console-table__count {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.console-table__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.console-table__foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}

table.console-data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

table.console-data thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.console-data tbody td,
table.console-data tbody th {
  height: var(--console-row);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

table.console-data tbody tr:last-child > * {
  border-bottom: 0;
}

table.console-data tbody th {
  font-weight: 500;
  text-align: left;
}

table.console-data .num {
  text-align: right;
}

/* A column a reader may sort by (console.js): its name is a button, and an
   arrow says the order once it is chosen; aria-sort says it to a screen
   reader. */
.console-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.console-sort:hover {
  color: var(--text);
}

.console-sort:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.num .console-sort {
  flex-direction: row-reverse;
}

[aria-sort="ascending"] > .console-sort::after {
  content: "\2191";
}

[aria-sort="descending"] > .console-sort::after {
  content: "\2193";
}

table.console-data .wrap {
  white-space: normal;
}

table.console-data .row-empty td {
  color: var(--text-2);
  white-space: normal;
}

table.console-data tbody tr.row-open {
  cursor: pointer;
}

table.console-data tbody tr.row-open:hover {
  background: var(--surface-2);
}

/* A table of facts: the name down the first column, the value beside it. */
table.console-data.facts tbody th {
  width: 14rem;
  color: var(--text-2);
  font-weight: 400;
}

/* A fact's value wraps (an address is long), as a list's cells do not. */
table.console-data.facts tbody td {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* --- The pager: the foot of every paged table (20, 50 or 100 rows) --- */
.console-pager {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.console-pager__pages {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.console-pager__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--console-control);
  height: var(--console-control);
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.console-pager__num:hover {
  color: var(--text);
  border-color: var(--border-hover);
  opacity: 1;
}

.console-pager__num[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.console-pager__step-spent {
  opacity: 0.45;
  pointer-events: none;
}

.console-pager__count {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.console-pager__size {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-3);
}

.console-pager__size select {
  width: auto;
  padding: var(--space-1) var(--space-8) var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  background-position: right var(--space-2) center;
}

/* --- Filters: a row in the table's head on a desk; on a phone, a sheet
   behind one button at the foot of the screen (console.js) --- */
.console-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin-left: auto;
}

.console-filters select,
.console-filters input[type="search"],
.console-filters input[type="text"],
.console-filters input[type="date"] {
  width: auto;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

/* A day: the browser's own picker drawn for a dark ground, the field on the
   surface with a hairline edge and its day in the quieter text (owner,
   2026-11-17). */
.console-filters input[type="date"] {
  color-scheme: dark;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}

[data-theme="light"] .console-filters input[type="date"] {
  color-scheme: light;
}

/* A filter: its name over its control, small, as every field has a visible
   label. */
.console-filter {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--text-xs);
  color: var(--text-3);
}

/* Between a range's two days: a hyphen. */
.console-filters__to {
  align-self: center;
  color: var(--text-3);
}

.console-filters__clear {
  align-self: flex-end;
  padding-bottom: var(--space-1);
  font-size: var(--text-sm);
}

/* A filter's choice: the arrow nearer its edge, as its box is smaller. */
.console-filters select {
  padding-right: calc(var(--space-3) * 2 + var(--select-arrow-width));
  background-position: right var(--space-3) center;
}

@supports (appearance: base-select) {
  .console-filters select {
    padding-right: var(--space-3);
  }
}

.console-filter-fab {
  display: none;
}

@media (max-width: 768px) {
  .console-filters[popover] {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    max-height: 70vh;
    margin: 0;
    padding: var(--space-6) var(--space-4) var(--space-8);
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    overflow-y: auto;
    background: var(--bg);
    color: var(--text);
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .console-filters[popover]:popover-open {
    display: flex;
  }

  .console-filters[popover]::backdrop {
    background: var(--overlay-bg);
  }

  .console-filters[popover] select,
  .console-filters[popover] input {
    width: 100%;
    min-height: var(--target);
  }

  .console-filter-fab {
    display: inline-flex;
    position: fixed;
    right: var(--space-4);
    bottom: var(--space-4);
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-dropdown);
  }
}

/* --- The icon button and its tooltip --- */
.console-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: var(--console-control);
  height: var(--console-control);
  padding: 0;
  font-size: 20px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.console-icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
  opacity: 1;
}

.console-icon-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.console-icon-btn-ok,
.console-icon-btn-ok:hover { color: var(--ok); }
.console-icon-btn-accent,
.console-icon-btn-accent:hover { color: var(--accent); }
.console-icon-btn-down,
.console-icon-btn-down:hover { color: var(--down); }

.console-icon-btn svg {
  display: block;
  width: 1em;
  height: 1em;
}

/* A finger gets 44px where the pointer is coarse; the button keeps its 30. */
@media (pointer: coarse) {
  .console-icon-btn::after {
    content: "";
    position: absolute;
    inset: calc((var(--console-control) - var(--target)) / 2);
  }
}

.console-tooltip {
  inset: auto;
  margin: 0 0 var(--space-1);
  position-area: top;
  position-try-fallbacks: flip-block;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-xs);
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}

@supports not (position-area: top) {
  .console-tooltip {
    display: none;
  }
}

/* --- Buttons in rows: the kit's button, a little shorter --- */
.btn-compact {
  min-height: 36px;
  padding: var(--space-2) var(--space-4);
  line-height: 20px;
}

/* --- The modal: the platform's dialog on the surface, with no edge and
   no line under its title (owner, 2026-11-17), buttons at the right --- */
.console-modal {
  width: min(480px, calc(100vw - var(--space-8)));
  max-height: calc(100vh - var(--space-8));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  overflow: auto;
}

.console-modal-wide {
  width: min(960px, calc(100vw - var(--space-8)));
}

.console-modal::backdrop {
  background: var(--overlay-bg);
}

.console-modal__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}

.console-modal__title {
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}

.console-modal__x {
  margin-left: auto;
  width: var(--console-control);
  height: var(--console-control);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.console-modal__x:hover {
  background: var(--surface-2);
  color: var(--text);
}

.console-modal__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}

.console-modal__lede {
  color: var(--text-2);
  font-size: var(--text-sm);
}

.console-modal__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* --- The panel: the platform's dialog at the window's right, its full
   height, sliding in over the page dimmed behind (console.js fills it from
   a link's data-panel). In at the normal pace, out at the exit pace, as the
   shell's menu. The head and body fill it, so a click inside never lands on
   the dialog itself, which is the backdrop's click. --- */
.console-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(var(--console-panel), 100vw);
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transform: translateX(100%);
  transition: transform var(--duration-exit) var(--ease-in),
              overlay var(--duration-exit) var(--ease-in) allow-discrete,
              display var(--duration-exit) var(--ease-in) allow-discrete;
}

.console-panel[open] {
  display: flex;
  flex-direction: column;
  transform: none;
  transition-duration: var(--duration-normal);
  transition-timing-function: var(--ease-out);
}

.console-panel::backdrop {
  background: transparent;
  transition: background var(--duration-exit) var(--ease-in),
              overlay var(--duration-exit) var(--ease-in) allow-discrete,
              display var(--duration-exit) var(--ease-in) allow-discrete;
}

.console-panel[open]::backdrop {
  background: var(--overlay-bg);
  transition-duration: var(--duration-normal);
  transition-timing-function: var(--ease-out);
}

@starting-style {
  .console-panel[open] {
    transform: translateX(100%);
  }

  .console-panel[open]::backdrop {
    background: transparent;
  }
}

.console-panel__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.console-panel__title {
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}

.console-panel__head .console-modal__x {
  flex: none;
}

.console-panel__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Each part keeps its height and the body scrolls, rather than squeezing them. */
.console-panel__body > * {
  flex: none;
}

/* A panel written in the page (a form, say: the site's script opens it):
   its form fills it, the body scrolling between the head and a foot that
   holds its buttons, at the right, as a modal's. */
.console-panel > form {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.console-panel__foot {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}

/* While it loads, and when it could not: one line in the quieter text. */
.console-panel__status {
  margin: 0;
  color: var(--text-2);
  font-size: var(--text-sm);
}

@media (prefers-reduced-motion: reduce) {
  .console-panel,
  .console-panel::backdrop {
    transition: none;
  }
}

/* --- The readiness line: a mark, the words, and the one action --- */
.console-readiness {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.console-readiness__words {
  flex: 1 1 auto;
  min-width: 0;
}

.console-readiness__action {
  margin-left: auto;
}

/* --- The state mark: one glyph and one word, in the state's colour --- */
.console-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.console-mark::before {
  content: "";
  flex: none;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.console-mark-ok { color: var(--ok); }
.console-mark-ok::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.55 18L3.85 12.3l1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z'/%3E%3C/svg%3E"); }

.console-mark-warn { color: var(--warn); }
.console-mark-warn::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 15V3h2v12zm0 6v-2h2v2z'/%3E%3C/svg%3E"); }

.console-mark-down { color: var(--down); }
.console-mark-down::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.4 19L5 17.6l5.6-5.6L5 6.4L6.4 5l5.6 5.6L17.6 5L19 6.4L13.4 12l5.6 5.6l-1.4 1.4l-5.6-5.6z'/%3E%3C/svg%3E"); }

.console-mark-running { color: var(--text-2); }
.console-mark-running::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4a8 8 0 1 0 8 8h-2a6 6 0 1 1-6-6z'/%3E%3C/svg%3E");
  animation: console-spin 1.2s linear infinite;
}

.console-mark-neutral { color: var(--text-2); }
.console-mark-neutral::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 13v-2h14v2z'/%3E%3C/svg%3E"); }

@keyframes console-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .console-mark-running::before {
    animation: none;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4a8 8 0 1 0 0 16a8 8 0 0 0 0-16m0 2a6 6 0 1 1 0 12a6 6 0 0 1 0-12'/%3E%3C/svg%3E");
  }
}

/* State as text, where a mark would be too much. */
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-down { color: var(--down); }

/* --- The banner: under the header on every page while something is on --- */
.console-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--warn);
  background: var(--warn-dim);
  color: var(--text);
  font-size: var(--text-sm);
}

.console-banner-down {
  border-bottom-color: var(--down);
  background: var(--down-dim);
}

.console-banner__since {
  color: var(--text-2);
}

.console-banner__action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.console-banner__words {
  margin: 0;
  color: var(--text);
}

/* In the shell a banner stands at the top of the page, a box in its column,
   rather than a band under a header: its ground alone, no edge (owner,
   2026-11-17). */
.console-shell .console-banner {
  border: 0;
  border-radius: var(--radius);
}

/* The banners sit between the fixed header and the page, in the flow: the
   wrapper clears the header and the page follows the banners. */
.console-banners {
  padding-top: var(--nav-height);
}

.console-banners + .page {
  padding-top: var(--space-8);
}

/* --- A count in the menu: "Inbox 3" --- */
.console-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  height: 1.5em;
  margin-left: var(--space-2);
  padding: 0 0.4em;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--white);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* --- A setting or a fact, as a row: its name, its value, a short note --- */
.console-rows {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.console-row {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr) auto;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  min-height: var(--console-row);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.console-row:last-child {
  border-bottom: 0;
}

.console-row__label {
  color: var(--text-2);
  font-size: var(--text-sm);
}

.console-row__value {
  font-variant-numeric: tabular-nums;
}

.console-row__note {
  grid-column: 2 / -1;
  color: var(--text-3);
  font-size: var(--text-xs);
}

.console-row__action {
  justify-self: end;
}

/* --- The shell: the console's side, and the page beside it ---
   A control panel's frame. The body is a grid of two columns, at least the
   window's height: the side (an <aside>: its <header> with Fire's mark and
   the product's name, its <nav> of pages, and its <footer>: who is signed
   in, where, and Sign out) at one width, and the page (<main>) in the rest.
   The side stays in view as the page scrolls. The side carries the brand, so
   a console has no Fire Header across the top, and no footer.

   Below 1024px it is one column: the side is a bar across the top, the
   brand and a menu button, and the rest of the side is a panel that slides
   in from the right. The panel is a popover, so the browser opens and closes
   it; console.js closes it if the window grows past 1024px. body.console-shell
   turns it on. */
.console-shell {
  --console-side: 232px;
  display: grid;
  grid-template-columns: var(--console-side) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.console-side {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  height: 100vh;
  height: 100dvh;
  padding: var(--space-6) var(--space-3);
  overflow-y: auto;
  background: var(--surface);
}

.console-side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-3);
}

/* Fire's mark and the product's name (the Fire Header's wordmark), at a
   control panel's size. */
.console-side__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.console-side__brand .fire-mark {
  width: 1.25rem;
  height: 1.25rem;
}

/* A product name too long for the side at the wordmark's own size (FIRE
   BLACKBOX): the wordmark smaller and tracked a little closer, on one line,
   its weight, case, and colour as ever. */
.console-side__brand-long .site-nav__wordmark {
  font-size: var(--text-sm);
  letter-spacing: 0.25em;
  white-space: nowrap;
}

/* Everything under the brand: the pages, the seats to switch to, and the
   foot. On a desk it is the side's own column; the popover's own look is
   undone. */
.console-side__menu {
  position: static;
  inset: auto;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-8);
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: visible;
  background: none;
  color: inherit;
}

/* The menu's open and close buttons: under 1024px only. */
.console-side__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--target);
  height: var(--target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.console-side__toggle svg {
  width: 24px;
  height: 24px;
}

.console-main {
  min-width: 0;
  max-width: var(--console-max);
  padding: var(--space-8) var(--space-10) var(--space-16);
}

.console-shell .console-head {
  gap: var(--space-1);
  margin-bottom: var(--space-6);
}

.console-shell .console-head h1 {
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}

/* A title and the page's own buttons, on one line where they fit. */
.console-head__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
}

.console-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Where a record sits, over its title: "Wallets / Picker 7". */
.console-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-2);
}

.console-crumbs a {
  color: var(--text-2);
}

.console-crumbs a:hover {
  color: var(--text);
}

/* Tabs, two ways alike: a record's parts each its own page (a nav of
   links under its title, the current one aria-current="page"), or parts of
   one place shown one at a time (a role="tablist" of buttons, the shown
   one aria-selected="true", each naming its role="tabpanel" in
   aria-controls; console.js switches them). The current one is underlined
   in the accent. A row that will not fit scrolls sideways in its own box. */
.console-tabs {
  display: flex;
  gap: var(--space-6);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.console-head .console-tabs {
  margin-top: var(--space-4);
}

.console-tabs__tab {
  margin-bottom: -1px;
  padding: var(--space-3) 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.console-tabs__tab:hover {
  color: var(--text);
}

.console-tabs__tab[aria-current="page"],
.console-tabs__tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.console-side__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.console-side__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-2);
  font: 500 var(--text-sm)/1.2 var(--sans);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-fast, 150ms) ease-out, color var(--duration-fast, 150ms) ease-out;
}

.console-side__link:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.console-side__link[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
}

.console-side__link:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

/* A named group in the menu: the level you are at, the others you hold. */
.console-side__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.console-side__label {
  padding: 0 var(--space-3) var(--space-1);
  font: 500 var(--text-xs)/1.4 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.console-side__note {
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-2);
}

/* The side's foot, at its bottom: who is signed in, where, and Sign out. */
/* A page's icon in the menu (Material Symbols, inline SVG), before its name. */
.console-side__icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* The side's foot, at its bottom, across its width over a line: who is
   signed in and where, and the menu of what is theirs (.console-more). */
.console-side__foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: auto calc(-1 * var(--space-3)) 0;
  padding: var(--space-4) var(--space-3) 0;
  border-top: 1px solid var(--border);
}

.console-side__person {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.console-side__who {
  flex: 1;
  min-width: 0;
}

/* The level a person is at, under their name: small, in capitals. */
.console-side__level {
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--text-3);
}

/* --- The foot's menu: three dots open what is the person's own (Settings,
   Sign out) above it, a popover placed by anchor positioning; where the
   browser cannot place it, at the side's foot. --- */
.console-more__toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  anchor-name: --console-more;
}

.console-more__toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}

.console-more {
  position: fixed;
  inset: auto auto var(--space-16) var(--space-3);
  min-width: 192px;
  margin: 0;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dropdown);
}

@supports (position-area: top) {
  .console-more {
    position-anchor: --console-more;
    position-area: top span-left;
    inset: auto;
    margin-bottom: var(--space-2);
  }
}

.console-more__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-2);
  font: 500 var(--text-sm)/1.2 var(--sans);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.console-more__item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.console-more form {
  margin: 0;
}

@media (max-width: 1023px) {
  .console-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .console-side {
    z-index: var(--z-sticky);
    height: auto;
    padding: var(--space-2) var(--space-4);
    overflow: visible;
  }

  .console-side__head {
    padding: 0;
  }

  .console-side__toggle {
    display: inline-flex;
  }

  /* The panel: the window's full height at its right, the page dimmed
     behind; in at the normal pace, out at the exit pace (header.css's). */
  .console-side__menu {
    position: fixed;
    inset: 0 0 0 auto;
    width: var(--menu-width);
    height: 100vh;
    height: 100dvh;
    padding: var(--space-16) var(--space-3) var(--space-6);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform var(--duration-exit) var(--ease-in),
                overlay var(--duration-exit) var(--ease-in) allow-discrete,
                display var(--duration-exit) var(--ease-in) allow-discrete;
  }

  .console-side__menu:not(:popover-open) {
    display: none;
  }

  .console-side__menu:popover-open {
    transform: none;
    transition-duration: var(--duration-normal);
    transition-timing-function: var(--ease-out);
  }

  .console-side__menu::backdrop {
    background: transparent;
    transition: background var(--duration-exit) var(--ease-in),
                overlay var(--duration-exit) var(--ease-in) allow-discrete,
                display var(--duration-exit) var(--ease-in) allow-discrete;
  }

  .console-side__menu:popover-open::backdrop {
    background: var(--overlay-bg);
    transition-duration: var(--duration-normal);
    transition-timing-function: var(--ease-out);
  }

  @starting-style {
    .console-side__menu:popover-open {
      transform: translateX(100%);
    }

    .console-side__menu:popover-open::backdrop {
      background: transparent;
    }
  }

  .console-side__menu > .console-side__toggle {
    position: absolute;
    top: var(--space-2);
    right: var(--space-4);
  }

  .console-main {
    padding: var(--space-6) var(--space-6) var(--space-12);
  }
}

@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
  .console-side__menu,
  .console-side__menu::backdrop {
    transition: none;
  }
}

/* --- Phones: one column, tables as cards, rows as stacks --- */
@media (max-width: 768px) {
  .console {
    padding: 0 var(--space-4);
  }

  .console-main {
    padding: var(--space-5) var(--space-4) var(--space-12);
  }

  .console-banner {
    padding: var(--space-3) var(--space-4);
  }

  /* A head that held only filters is empty once they are a sheet: it takes
     no room. The sheet itself still opens, from the top layer. */
  .console-table__head:not(:has(> :not(.console-filters))) {
    padding: 0;
    border-bottom: 0;
  }

  /* A table of three columns or more is a list of cards: a row a card, its
     cells two to a line, each under its column's name (data-label on the
     cell). A cell without a name, or marked wrap, takes the whole line; a
     cell marked data-empty is left out. A table of facts keeps its shape. */
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) { display: block; }
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) > thead { display: none; }
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) > tbody { display: block; }
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) > tbody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row dense;
    gap: var(--space-2) var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
  }
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) > tbody > tr > :is(td, th) {
    display: block;
    height: auto;
    padding: 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) > tbody > tr > :is(td:not([data-label]), td.wrap, th) { grid-column: 1 / -1; }
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) > tbody > tr > td[data-empty] { display: none; }
  table.console-data:not(.facts):has(> thead > tr > :nth-child(3)) > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
  }

  .console-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .console-row__label {
    grid-column: 1 / -1;
  }

  .console-row__note {
    grid-column: 1 / -1;
  }

  .console-pager__size {
    margin-left: 0;
  }
}
