/* Shares apps/admin-web's tokens and layout so Corleone's surfaces read as one
   product, with one deliberate difference: --accent is a calm blue rather than
   the admin app's brown, so nobody mistakes the account site for the operator
   console (or the other way round). No inline styles anywhere -- the CSP
   forbids them. */
:root {
  color-scheme: light;
  --background: #f4f5f2;
  --foreground: #202421;
  --muted: #667067;
  --panel: #ffffff;
  --line: #d8ded7;
  --accent: #2f5d8a;
  --accent-strong: #1f4166;
  --danger: #a33a2b;
  --warn: #936c12;
  --shadow: 0 18px 45px rgba(28, 37, 31, 0.12);
}

* {
  box-sizing: border-box;
}

/* Views toggle with the hidden attribute; a class that sets display (flex,
   grid) would otherwise silently override it and show the element anyway. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--foreground);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

/* Irreversible or session-destroying actions. */
button.danger {
  border-color: rgba(163, 58, 43, 0.4);
  color: var(--danger);
}

button.danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: rgba(163, 58, 43, 0.08);
}

.shell {
  width: min(1100px, calc(100vw - 32px));
  margin: 32px auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.masthead.compact {
  align-items: center;
  padding: 18px 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

h3 {
  padding: 20px 28px 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lede {
  margin: 0;
  padding: 18px 28px;
  color: var(--muted);
  font-size: 0.95rem;
}

.masthead .lede,
.masthead.compact .lede {
  padding: 0;
}

.footnote {
  margin: 0;
  padding: 12px 28px 24px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--warn);
  font-size: 0.85rem;
  font-weight: 750;
  text-align: center;
}

.status-pill[data-tone="good"] {
  border-color: rgba(31, 122, 92, 0.35);
  color: #145940;
  background: rgba(31, 122, 92, 0.08);
}

.status-pill[data-tone="bad"] {
  border-color: rgba(163, 58, 43, 0.35);
  color: var(--danger);
  background: rgba(163, 58, 43, 0.08);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
}

.detail .toolbar {
  border-bottom: none;
}

/* Matches the status pill's "bad" tone so failures read consistently. */
.auth-error {
  margin: 0;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(163, 58, 43, 0.35);
  color: var(--danger);
  background: rgba(163, 58, 43, 0.08);
  font-size: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
}

.filters input,
.filters select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--foreground);
  font: inherit;
}

.filters input {
  flex: 1 1 220px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

th:first-child,
td:first-child {
  padding-left: 28px;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(47, 93, 138, 0.05);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.74rem;
  font-weight: 700;
}

.badge[data-tone="danger"] {
  color: var(--danger);
  background: rgba(163, 58, 43, 0.12);
}

.badge[data-tone="off"] {
  color: var(--warn);
  background: rgba(147, 108, 18, 0.12);
}

.badge[data-tone="ok"] {
  color: #145940;
  background: rgba(31, 122, 92, 0.1);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 8px;
  border: 1px solid var(--line);
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

td.actions {
  white-space: nowrap;
}

td.actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.85rem;
}

td.actions button + button {
  margin-left: 8px;
}

/* --- Overlay dialogs ------------------------------------------------------ */
/* Native <dialog> + showModal(): the browser supplies the focus trap, Escape
   handling, and top-layer stacking; only the look is styled here. No inline
   styles anywhere -- the CSP forbids them. */

dialog {
  width: min(560px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--foreground);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(28, 37, 31, 0.45);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 28px 28px;
}

.dialog-form h2 {
  margin: 0 0 8px;
}

.dialog-form label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
}

.dialog-form input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--foreground);
  font: inherit;
}

.dialog-form .toolbar {
  margin-top: 12px;
  padding: 0;
  border: none;
}

.field-error {
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: rgba(163, 58, 43, 0.08);
  color: var(--danger);
  font-size: 0.85rem;
}

/* --- Account header ------------------------------------------------------- */

.identity {
  display: flex;
  align-items: center;
  min-width: 0;
}

.breadcrumb {
  display: flex;
  gap: 8px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.section-title {
  padding: 22px 28px 0;
  font-size: 1.15rem;
}

/* --- Dashboard tiles ------------------------------------------------------ */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 28px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  color: var(--foreground);
  text-decoration: none;
}

a.tile:hover,
a.tile:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(47, 93, 138, 0.12);
}

.tile[aria-disabled="true"] {
  background: var(--background);
  color: var(--muted);
}

.tile-title {
  font-size: 1.05rem;
  font-weight: 750;
}

.tile-detail {
  color: var(--muted);
  font-size: 0.88rem;
}

a.tile-danger:hover,
a.tile-danger:focus-visible {
  border-color: var(--danger);
  box-shadow: 0 6px 18px rgba(163, 58, 43, 0.12);
}

a.tile-danger .tile-title {
  color: var(--danger);
}

/* --- Cards and forms ------------------------------------------------------ */

.card {
  margin: 18px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
}

.card p {
  margin: 0 0 10px;
}

.card .toolbar,
.inline-form .toolbar {
  padding: 8px 0 0;
  border: none;
}

.card.warning {
  border-color: rgba(163, 58, 43, 0.35);
  background: rgba(163, 58, 43, 0.05);
}

.card.reveal {
  border-color: rgba(31, 122, 92, 0.45);
  background: rgba(31, 122, 92, 0.06);
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
}

/* A sentence-style label, e.g. "Type <email> to confirm". */
.inline-form label.plain {
  display: block;
}

.inline-form .card {
  margin: 8px 0 0;
}

.inline-form input,
.inline-form select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--foreground);
  font: inherit;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.row > label {
  flex: 1 1 200px;
}

.inline-form label.check,
.card label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--foreground);
  font-size: 0.9rem;
}

.check input {
  min-height: 0;
}

.secret {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--background);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.row .secret {
  flex: 1 1 280px;
}

/* --- Two-factor setup ----------------------------------------------------- */

.steps {
  margin: 0;
  padding-left: 20px;
}

.steps > li + li {
  margin-top: 22px;
}

.qr-frame {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.qr {
  display: block;
  width: 196px;
  height: 196px;
}

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px 14px;
  margin: 10px 0;
  padding: 0;
  list-style: none;
}

.footnote {
  padding: 0;
}

/* --- Tables --------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .shell {
    width: calc(100vw - 16px);
    margin: 8px auto;
  }

  .masthead,
  .masthead.compact {
    flex-wrap: wrap;
    padding: 18px;
  }

  .card {
    margin: 14px 16px;
  }

  .tiles {
    padding: 16px;
  }

  th:first-child,
  td:first-child {
    padding-left: 16px;
  }
}
