/* Account Registry directory. Mobile-first: phone cards
   (<720px), Fold/compact-tablet two-line grid (720-1099px), dense desktop
   table (>=1100px). Loaded after account-registry.css; the toolbar, collapsed tables,
   detail sheet and modal touch fixes live in account-registry-sheet.css. */

body[data-page="account-registry"] {
  min-height: 100vh;
  min-height: 100dvh;
}

body[data-page="account-registry"] .go-main {
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
}

.registry-directory {
  background: linear-gradient(135deg, rgba(23, 31, 42, 0.96), rgba(11, 14, 20, 0.98));
  border: 1px solid rgba(97, 175, 239, 0.22);
  border-radius: 8px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06), 0 12px 34px rgba(0, 0, 0, 0.28);
  padding: 12px;
  min-width: 0;
}

.registry-directory-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.registry-directory-header span,
.registry-sheet-kicker,
.registry-sheet-section-title span {
  display: block;
  color: var(--amber, #f59e0b);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.registry-directory-header h3 {
  margin: 2px 0 0;
  color: #fff;
  font-size: 18px;
}

.registry-directory-header em {
  color: var(--muted, #a8a29a);
  font-size: 13px;
  font-style: normal;
  white-space: nowrap;
}

.registry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.registry-list-head {
  display: none;
}

/* ---- Row (phone card) ---- */
.registry-row {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 108px;
  grid-template-areas:
    "avatar name    name    state"
    "avatar email   email   email"
    ".      region  ring    ring"
    ".      role    created created";
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(8, 10, 14, 0.72);
  color: var(--text, #f4f1ec);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.registry-row:hover,
.registry-row:active {
  background: rgba(97, 175, 239, 0.08);
  border-color: rgba(97, 175, 239, 0.36);
}

.registry-row:focus-visible,
.registry-sheet-close:focus-visible,
.registry-sheet-card button:focus-visible {
  outline: 2px solid #61afef;
  outline-offset: 2px;
}

.registry-row[data-protected="true"] {
  border-color: rgba(97, 175, 239, 0.34);
}

.rl-avatar {
  grid-area: avatar;
  align-self: start;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2d6aa0, #61afef);
  color: #04121f;
  font-size: 13px;
  font-weight: 800;
}

.rl-avatar[data-kind="org"],
.rl-avatar[data-kind="mesh"] {
  border-radius: 10px;
}

.rl-avatar[data-image="true"] {
  overflow: hidden;
  background: #1e2a38;
}

.rl-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.rl-avatar[data-kind="org"] img {
  object-fit: contain;
  padding: 3px;
  box-sizing: border-box;
}

.registry-row[data-tone="full"] .rl-avatar {
  background: linear-gradient(135deg, #6f9b52, #98c379);
}
.registry-row[data-tone="partial"] .rl-avatar {
  background: linear-gradient(135deg, #b8913f, #e5c07b);
}
.registry-row[data-tone="error"] .rl-avatar {
  background: linear-gradient(135deg, #a8454e, #e06c75);
}

.rl-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rl-name {
  grid-area: name;
}
.rl-email {
  grid-area: email;
  color: var(--muted, #a8a29a);
  font-size: 13px;
}
.rl-region {
  grid-area: region;
}
.rl-ring {
  grid-area: ring;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
}
.rl-role {
  grid-area: role;
}
.rl-state {
  grid-area: state;
  justify-self: end;
  overflow: visible;
}
.rl-created {
  grid-area: created;
}

.rl-name strong {
  display: inline;
  color: #fff;
  font-size: 15px;
  font-weight: 650;
}

.rl-lock {
  margin-left: 6px;
  color: #61afef;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rl-email[data-empty="true"],
.rl-muted {
  color: var(--muted, #a8a29a);
  font-style: italic;
}

.rl-region,
.rl-ring,
.rl-role,
.rl-created {
  margin-top: 8px;
  font-size: 13px;
}

.rl-region::before,
.rl-ring::before,
.rl-role::before,
.rl-created::before {
  content: attr(data-label);
  display: block;
  color: var(--muted, #a8a29a);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rl-state-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--muted, #a8a29a);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.rl-state-pill[data-tone="full"] {
  color: #98c379;
  border-color: rgba(152, 195, 121, 0.5);
  background: rgba(152, 195, 121, 0.1);
}
.rl-state-pill[data-tone="partial"] {
  color: #e5c07b;
  border-color: rgba(229, 192, 123, 0.5);
  background: rgba(229, 192, 123, 0.1);
}
.rl-state-pill[data-tone="error"] {
  color: #e06c75;
  border-color: rgba(224, 108, 117, 0.5);
  background: rgba(224, 108, 117, 0.1);
}

/* ---- Phones ---- */
@media (max-width: 719px) {
  .account-registry-header p {
    display: none;
  }
  /* Six state tiles as a compact 3x2 strip so the directory stays near the top. */
  .account-registry-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .account-registry-metrics article {
    padding: 8px 10px;
  }
  .account-registry-metrics strong {
    font-size: 22px;
    margin-top: 2px;
  }
  .account-registry-toolbar input,
  .account-registry-toolbar select {
    font-size: 16px;
  }
  .registry-directory {
    padding: 10px;
  }
  .account-registry-advanced > summary small {
    display: none;
  }
}

/* ---- Fold main / compact tablet ---- */
@media (min-width: 720px) {
  /* Six state tiles in one row (legacy 4-up left two orphans). */
  .account-registry-metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .registry-directory {
    padding: 16px;
  }
  .registry-list {
    gap: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
  }
  .registry-list-item + .registry-list-item .registry-row {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .registry-list-head,
  .registry-row {
    grid-template-columns: 36px minmax(0, 1.6fr) minmax(0, 1fr) 112px 104px;
    grid-template-areas:
      "avatar name  region role  created"
      "avatar email ring   state created";
    column-gap: 12px;
  }
  .registry-list-head {
    display: grid;
    grid-template-areas: ". name region role created";
    padding: 0 12px 8px;
    color: var(--muted, #a8a29a);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .rl-head-name {
    grid-area: name;
  }
  .rl-head-name::after {
    content: " / Email";
  }
  .rl-head-region {
    grid-area: region;
  }
  .rl-head-region::after {
    content: " / Ring";
  }
  .rl-head-role {
    grid-area: role;
  }
  .rl-head-role::after {
    content: " / State";
  }
  .rl-head-created {
    grid-area: created;
  }
  .rl-head-email,
  .rl-head-ring,
  .rl-head-state {
    display: none;
  }
  .registry-row {
    min-height: 60px;
    padding: 10px 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .rl-avatar {
    width: 36px;
    height: 36px;
    align-self: center;
    font-size: 12px;
  }
  .rl-state {
    justify-self: start;
  }
  .rl-region,
  .rl-ring,
  .rl-role,
  .rl-created {
    margin-top: 0;
  }
  .rl-region::before,
  .rl-ring::before,
  .rl-role::before,
  .rl-created::before {
    content: none;
  }
  .rl-ring {
    color: var(--muted, #a8a29a);
  }
}

/* ---- Desktop: one line per person, every field its own column ---- */
@media (min-width: 1100px) {
  .registry-list-head,
  .registry-row {
    grid-template-columns:
      32px minmax(0, 1.2fr) minmax(0, 1.5fr) 64px minmax(96px, 0.8fr) 96px 112px 104px;
    grid-template-areas: "avatar name email region ring role state created";
  }
  .registry-list-head {
    grid-template-areas: ". name email region ring role state created";
  }
  .rl-head-email {
    grid-area: email;
  }
  .rl-head-ring {
    grid-area: ring;
  }
  .rl-head-state {
    grid-area: state;
  }
  .rl-head-email,
  .rl-head-ring,
  .rl-head-state {
    display: block;
  }
  .rl-head-name::after,
  .rl-head-region::after,
  .rl-head-role::after {
    content: none;
  }
  .registry-row {
    min-height: 52px;
    padding: 8px 12px;
  }
  .rl-avatar {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }
  .rl-name strong {
    font-size: 14px;
  }
  .rl-ring {
    color: var(--text, #f4f1ec);
  }
}

@media (prefers-reduced-motion: reduce) {
  .registry-row,
  .account-registry-advanced > summary::before {
    transition: none;
  }
}

.registry-row .rl-avatar[data-image="true"] {
  background: #1e2a38;
}
