@layer components {

  /* The plain pages' links (shared/_page_nav): houses, users, account, sign out. One line that never wraps:
     short of room it drops words, then folds under ☰ (data-fit, page_nav_controller.js). */
  .page-nav {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    font-size: 13px;
  }

  /* Clipped sideways only, so the page never scrolls before the menu has measured itself; the team's list still
     drops below. */
  .page-nav__items {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 14px;
    min-width: 0;
    overflow-x: clip;

    &>*,
    & .page-nav__end>* {
      flex: none;
    }
  }

  /* Words gone, still read out: the far end's first ("start"), then every entry's ("icons"). */
  .page-nav[data-fit="start"] .page-nav__end .page-nav__label,
  .page-nav[data-fit="icons"] .page-nav__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .page-nav__menu {
    display: none;
    padding: 0;
    color: var(--color-ink-muted);
    background: none;
    border: 0;
    cursor: pointer;

    &:hover,
    &:focus-visible,
    &[aria-expanded="true"] {
      color: var(--color-ink);
    }

    .button__icon {
      width: 20px;
      height: 20px;
      margin: 0;
    }
  }

  /* Folded: ☰ before the logo opens the entries as a list under it, words back. */
  .page-nav[data-fit="menu"] {
    .page-nav__menu {
      display: flex;
    }

    .page-nav__items {
      position: absolute;
      top: calc(100% + 6px);
      left: 0;
      z-index: 20;
      display: none;
      flex-direction: column;
      align-items: stretch;
      gap: 0;
      min-width: 220px;
      padding: 4px;
      overflow-x: visible;
      background: var(--color-surface);
      border: 1px solid var(--color-edge);
      border-radius: 6px;
      box-shadow: 0 8px 24px color-mix(in oklch, var(--black) 40%, transparent);
    }

    &.is-open .page-nav__items {
      display: flex;
    }

    .page-nav__end {
      flex-direction: column;
      align-items: stretch;
      gap: 0;
      margin: 4px 0 0;
      padding-top: 4px;
      border-top: 1px solid var(--color-line);
    }

    .page-nav__link {
      width: 100%;
      padding: 6px 8px;
      border-radius: 4px;

      &:hover {
        background: color-mix(in oklch, var(--color-surface), var(--color-ink) 10%);
        /* as the team's list */
      }
    }
  }

  .page-nav__link,
  button.page-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    font-size: 13px;
    color: var(--color-ink-muted);
    background: none;
    border: 0;
    text-decoration: none;
    cursor: pointer;

    &:hover,
    &.is-current {
      color: var(--color-ink);
    }

    /* No ring (base.css): focused from the keyboard, an entry lights up like one pointed at, its words
       underlined. */
    &:focus-visible {
      color: var(--color-ink);

      .page-nav__label {
        text-decoration: underline;
        text-underline-offset: 3px;
      }
    }
  }

  /* The logo (ApplicationHelper#logo) leading the links, home to the houses. */
  /* button_to's form holds its button as a block, not on a line of text whose strut
     makes the box taller than the links beside it. */
  .page-nav form {
    display: flex;
  }

  /* Each link's icon before its words, a touch smaller than the text's line. */
  .page-nav__link .button__icon {
    width: 15px;
    height: 15px;
    margin: 0;
  }

  .page-nav__logo {
    --logo-ink: var(--color-ink);
    --logo-wall: var(--color-ink);
    display: flex;
    margin-right: 6px;

    svg {
      height: 22px;
      width: auto;
    }
  }

  /* The language and sign out, at the far end. */
  .page-nav__end {
    display: flex;
    align-items: center;
    /* links, button_to's forms and the team's details are boxes of different heights */
    gap: 14px;
    margin-left: auto;
  }

  /* Beside the button at the head's end, the title alone at its start. */
  .page__aside {
    margin-left: auto;
    color: var(--color-ink-muted);
  }

  /* A name and its email (UsersHelper#name_and_email): a small dot between, the email quieter. */
  .identity__dot {
    margin-inline: 0.45em;
    font-size: 0.8em;
    color: var(--color-ink-muted);
  }

  .identity__email {
    color: var(--color-ink-muted);
  }

  /* A card on the account and users pages: a title row, then a table. */
  .account-section {
    margin-bottom: 14px;
  }

  .account-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  /* The account's tables (teams, passkeys, devices, apps): the first column names the thing and takes whatever
     wraps — an app's note, say —, the short columns after it (dates, counts, "~1 година тому") stay on one line. */
  .account-section .card-table :is(th, td):not(:first-child) {
    white-space: nowrap;
  }

  /* A note under a row's name (an app's outdated tools): wrapped, though the first column keeps to one line
     (tables.css), rather than running under the columns beside it. */
  .account-section__note {
    white-space: normal;
  }

  /* The MCP connector's address, to copy into Claude. */
  .account-section__address {
    display: block;
    margin: 8px 0 10px;
    padding: 6px 8px;
    font-size: 13px;
    overflow-wrap: anywhere;
    user-select: all;
    background: var(--color-canvas);
    border: 1px solid var(--color-line);
    border-radius: 6px;
  }

  /* A table in a card: rules run edge to edge (its scroll box bleeds over the card's padding, tables.css), text
     keeps the card's padding (its end cells). */
  .card-table {
    width: 100%;
    font-size: 13px;
    border-collapse: separate;
    /* each cell owns its rule, so the first column's stays with it (tables.css) */
    border-spacing: 0;

    & th,
    & td {
      padding: 6px 8px;
      text-align: left;
      border-bottom: var(--hairline) solid var(--color-line);
    }

    & :is(th, td):first-child {
      padding-left: 14px;
    }

    & :is(th, td):last-child {
      padding-right: 14px;
    }

    & thead th {
      font-size: 11px;
      font-weight: 600;
      color: var(--color-ink-muted);
    }

    /* The last row showing: a filter (list-filter) may have hidden those after it. */
    & tbody tr:not(:has(~ tr:not([hidden]))) td {
      border-bottom: 0;
    }

    & .table__num {
      text-align: right;
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
    }

    & .table__qty {
      white-space: nowrap;
    }

    /* Nested so it outweighs the cells' left alignment above. */
    & .card-table__actions {
      text-align: right;
      white-space: nowrap;
    }
  }

  .badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 11px;
    color: var(--color-ink);
    background: var(--color-primary-surface);
    border-radius: 999px;
  }

  .badge--warning {
    background: var(--color-warning-surface);
  }

  .modal__hint {
    font-size: 12px;
    color: var(--color-ink-muted);
  }
}
