/* The hub's dark operational look: warm near-black, grayscale chrome, colour only for state. */
:root {
  color-scheme: dark;
  --bg: oklch(0.155 0.005 70);
  --raised: oklch(0.19 0.005 70);
  --surface: oklch(0.225 0.006 70);
  --line: oklch(0.235 0.005 70);
  --line-strong: oklch(0.31 0.005 70);
  --text: oklch(0.93 0.008 70);
  --muted: oklch(0.7 0.005 70);
  --faint: oklch(0.6 0.005 70);
  --focus: oklch(0.72 0.01 70);
  --ok: oklch(0.8 0.13 150);
  --warn: oklch(0.83 0.12 80);
  --danger: oklch(0.73 0.15 28);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.45 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1,
h2,
p {
  margin: 0;
}
[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Page */
.bar,
main {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding-inline: 32px;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}
.bar h1 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.bar h1 a {
  color: inherit;
  text-decoration: none;
}
.bar-end {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  color: var(--muted);
}
#who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-end .ghost {
  margin-inline: -12px;
}
main {
  padding-block: 12px 96px;
}
#dashboard {
  display: flex;
  flex-direction: column;
  gap: 48px;
}
#accounts {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-bottom: 8px;
}

/* Text */
.note {
  color: var(--muted);
}
.ok {
  color: var(--ok);
}
.error {
  color: var(--danger);
}
.empty {
  color: var(--muted);
  padding: 10px 0;
}
code,
pre {
  font: 13px/1.5 var(--mono);
}

/* Section headings */
.section-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 10px;
  min-height: 40px;
  margin-bottom: 4px;
}
.section-head h2 {
  font-size: 15px;
  font-weight: 600;
}
.actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: -12px;
}

/* Lists and tables bleed 8px past the text column, so a hovered row has room around its text. */
.group-head,
.rows,
.table-wrap {
  margin-inline: -8px;
}

/* Accounts: one group per provider */
.group-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 12px;
  min-height: 44px;
  padding-inline: 8px;
  border-bottom: 1px solid var(--line-strong);
}
.group-head h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.summary {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.summary strong {
  color: var(--text);
  font-weight: 500;
}
.summary.none strong {
  color: var(--danger);
}
.group-head .ghost {
  margin-left: auto;
  margin-right: -12px;
}

/* Rows with quiet actions: accounts, services, and table rows with .has-actions */
.rows {
  list-style: none;
  margin-block: 0;
  padding: 0;
}
.row {
  display: grid;
  /* Fixed state and action columns keep every row on the same axes, actions shown or not. */
  grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1.2fr) 200px;
  align-items: center;
  column-gap: 16px;
  min-height: 40px;
  padding-left: 8px;
  border-bottom: 1px solid var(--line);
}
.cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.state {
  font-weight: 500;
}
.state.available {
  color: var(--ok);
}
.state.limited {
  color: var(--warn);
}
.state.signin,
.state.error {
  color: var(--danger);
}
.state.disabled,
.is-disabled .email {
  color: var(--faint);
}
.detail {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.row-actions {
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
}
.has-actions:focus-within,
.has-actions.open {
  background: var(--raised);
}
.has-actions:focus-within .row-actions,
.has-actions.open .row-actions {
  opacity: 1;
  pointer-events: auto;
}
@media (hover: hover) {
  .has-actions:hover {
    background: var(--raised);
  }
  .has-actions:hover .row-actions {
    opacity: 1;
    pointer-events: auto;
  }
}
.row-actions button {
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 13px;
}
.row-actions button:last-child {
  padding-right: 8px;
}
.row-actions button:hover {
  color: var(--text);
}
.row-actions .danger:hover {
  color: var(--danger);
}
.row-actions button:focus-visible {
  outline-offset: -4px;
}

/* Services */
.service {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  column-gap: 16px;
  padding: 10px 0 10px 8px;
  border-bottom: 1px solid var(--line);
}
.service-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.service-info {
  min-width: 0;
}
.service .row-actions {
  align-self: center;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}
.table-wrap:focus {
  outline: none;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th {
  padding: 0 16px 8px 0;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 9px 16px 9px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
th:first-child,
td:first-child {
  padding-left: 8px;
}
th:last-child,
td:last-child {
  padding-right: 8px;
}
td.actions-cell {
  padding-block: 0;
  padding-right: 0;
  vertical-align: middle;
}
.num {
  text-align: right;
}
.wrap {
  white-space: normal;
  overflow-wrap: break-word;
}
.is-revoked td {
  color: var(--faint);
}
.more {
  margin-top: 4px;
  margin-left: -4px;
}
.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-bottom: 16px;
  color: var(--muted);
}
.figures strong {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.figures .error strong {
  color: var(--danger);
}
.load-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 10px 0;
}

/* Disclosures */
details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  min-height: 40px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}
details > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
}
details[open] > summary::before {
  transform: translateY(-2px) rotate(45deg);
}
details > summary:hover {
  color: var(--text);
}
details[open] > summary {
  margin-bottom: 8px;
}
pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
  white-space: pre;
}

/* Controls */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.primary {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
}
.primary:hover {
  background: oklch(0.85 0.008 70);
}
.ghost {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}
.ghost:hover {
  background: var(--raised);
  color: var(--text);
}
.icon {
  width: 36px;
  height: 36px;
  margin-right: -8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}
.icon:hover {
  background: var(--surface);
  color: var(--text);
}
button:disabled {
  opacity: 0.55;
  cursor: progress;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
summary:focus-visible {
  border-radius: 6px;
}

/* Forms */
label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 13px;
}
input:not([type="checkbox"]),
select,
textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea {
  padding: 10px 12px;
  font: 13px/1.5 var(--mono);
  resize: vertical;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--focus);
}
input:disabled {
  border-color: var(--line);
  color: var(--muted);
}
::placeholder {
  color: var(--faint);
}
label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin: 8px 0 0;
  color: var(--text);
  font-size: 14px;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--text);
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.inline-field {
  display: flex;
  gap: 8px;
}
.inline-field input {
  flex: 1;
}

/* Sign-in */
#login {
  max-width: 400px;
  margin: 18vh auto 0;
}
#signin-hq {
  width: 100%;
}
#signin-hq + details {
  margin-top: 16px;
}
#key-signin.solo > summary {
  display: none;
}
#key-signin label {
  margin-top: 0;
}

/* Dialogs */
dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 16px 24px 24px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--raised);
  color: var(--text);
}
dialog::backdrop {
  background: oklch(0.1 0 0 / 0.6);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.dialog-head h2 {
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
dialog form:not(.dialog-head) > .primary,
dialog details > .primary,
#key-result > .primary {
  margin-top: 20px;
}
dialog .note {
  margin-top: 12px;
}
dialog details {
  margin-top: 8px;
}
dialog input:not([type="checkbox"]),
dialog select,
dialog textarea {
  background: var(--bg);
}
.wide {
  width: 100%;
}
.secret {
  margin-top: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dialog-message {
  margin-top: 16px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* The status line for actions outside dialogs */
#message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 10;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 32px oklch(0 0 0 / 0.45);
  overflow-wrap: anywhere;
  transform: translateX(-50%);
}
#message.error,
.dialog-message.error {
  color: var(--danger);
}

@media (pointer: coarse) {
  .ghost,
  .primary,
  .row-actions button {
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  .bar,
  main {
    padding-inline: 20px;
  }
  #who {
    display: none;
  }
  #dashboard {
    gap: 40px;
  }
  .group-head {
    padding-bottom: 6px;
  }
  .group-head .summary {
    order: 1;
    flex-basis: 100%;
  }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "email state"
      "detail detail"
      "actions actions";
    padding-block: 10px;
    padding-right: 8px;
  }
  .row .email {
    grid-area: email;
  }
  .row .state {
    grid-area: state;
  }
  .row .detail {
    grid-area: detail;
  }
  .row .detail:empty {
    display: none;
  }
  .row .row-actions,
  .service .row-actions {
    display: none;
    grid-area: actions;
    justify-content: flex-start;
    margin-left: -10px;
  }
  .has-actions.open .row-actions,
  .has-actions:focus-within .row-actions {
    display: flex;
  }
  .row.open .cell {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .service {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "name" "info" "actions";
    row-gap: 2px;
  }
  .service-name {
    grid-area: name;
  }
  .service-info {
    grid-area: info;
  }
  .pair {
    grid-template-columns: 1fr;
    gap: 0;
  }
  input:not([type="checkbox"]),
  select,
  textarea {
    font-size: 16px;
  }
  dialog {
    padding-inline: 20px;
  }
}

/* Your accounts: the same groups as the admin list, one per provider */
#routing {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 16px;
}
.group-head h3 {
  font-size: 15px;
  font-weight: 600;
}
.routing-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 8px;
  margin-top: 8px;
}
.routing-note .ghost {
  margin-left: -12px;
}
.routing-note span + .ghost {
  margin-left: 0;
}
.owner-row,
.proxy-row {
  grid-template-columns: minmax(0, 1fr) auto;
  padding-right: 8px;
}
.proxy-row input {
  width: 9rem;
}
#routing details {
  margin-top: 8px;
}

/* The out-of-usage prompt */
.out-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}
#out-people {
  margin-top: 16px;
}
.out-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}
.routing-consent {
  margin-block: 12px 16px;
}
