:root {
  --bg: #f3f0e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #211c16;
  --muted: #6f665c;
  --line: #ded5c8;
  --accent: #00684f;
  --accent-strong: #004c3a;
  --gold: #d88a19;
  --danger: #b52b4c;
  --shadow: 0 18px 52px rgba(45, 38, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfaf6 0%, var(--bg) 100%);
  font-family: "Quicksand", "Segoe UI", sans-serif;
}

.source-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
}

.source-tabs > span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.source-tabs button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.source-tabs button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.badge.source-animateit { background: #c8ff32; color: #11120f; }

button,
input,
select {
  font: inherit;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.users-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
}

h2 {
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.15;
}

h3 {
  font-size: 14px;
}

.hero__copy {
  max-width: 780px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.admin-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-nav a,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  cursor: pointer;
}

.admin-nav a[aria-current="page"],
button[data-invite-new],
button[data-save-role] {
  color: #fff;
  border-color: transparent;
  background: var(--accent);
}

.toolbar,
.panel,
.notice {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.toolbar {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 8px;
}

.toolbar label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  border-color: rgba(0, 104, 79, 0.72);
  box-shadow: 0 0 0 3px rgba(0, 104, 79, 0.14);
}

.notice {
  display: none;
  margin: 16px 0;
  padding: 12px 14px;
  color: var(--accent-strong);
  font-weight: 800;
  border-radius: 8px;
}

.notice.show {
  display: block;
}

.notice.is-error {
  color: var(--danger);
  border-color: rgba(181, 43, 76, 0.32);
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  gap: 16px;
  align-items: start;
}

.merchant-access-panel {
  margin: 16px 0;
}

.panel-heading {
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(320px, 1.2fr);
  gap: 20px;
  align-items: end;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.store-identity {
  display: grid;
  gap: 4px;
}

.store-identity code {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.store-identity small,
.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.store-tags,
.store-link-list {
  display: grid;
  gap: 7px;
}

.store-tags code {
  display: block;
  max-width: 190px;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-link-card {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.store-link-card code,
.store-link-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.use-case-cell {
  max-width: 360px;
  white-space: normal;
  line-height: 1.45;
}

.panel {
  overflow: hidden;
  border-radius: 8px;
}

.user-detail-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 18px;
  padding: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(79, 68, 55, 0.12);
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sort-button {
  min-height: 0;
  padding: 0;
  color: inherit;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.sort-button.is-active {
  color: var(--accent);
}

td {
  color: #373029;
  font-size: 14px;
  font-weight: 700;
}

tr.is-selected td {
  background: rgba(0, 104, 79, 0.08);
}

.user-email {
  display: inline;
  min-height: auto;
  padding: 0;
  color: var(--accent-strong);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  border: 0;
  background: transparent;
}

.role-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  border-radius: 8px;
  background: var(--accent);
}

.badge.pending {
  color: var(--ink);
  background: #f0bd55;
}

.badge.basic {
  color: var(--ink);
  background: #e9e1d6;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions a.dashboard-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

button[data-invite-user] {
  color: var(--accent-strong);
}

.detail-header {
  display: grid;
  gap: 10px;
}

.detail-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h3 {
  color: var(--accent-strong);
}

.detail-section dl {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(0, 1.2fr);
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
}

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

.detail-row dt,
.detail-row dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.detail-row dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-row dd {
  color: var(--ink);
  font-weight: 900;
}

button.dashboard-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  border-color: var(--line);
  background: #eee7dc;
  opacity: 1;
}

button.danger-button {
  color: #fff;
  border-color: transparent;
  background: var(--danger);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.auth-panel {
  width: min(680px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.pilot-review-dialog {
  width: min(540px, calc(100vw - 40px));
  box-sizing: border-box;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.pilot-review-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.pilot-review-dialog form, .pilot-review-dialog label { display: grid; gap: 10px; }
.pilot-review-dialog form { gap: 16px; }
.pilot-review-dialog p, .pilot-review-dialog h2 { margin: 0; overflow-wrap: anywhere; }
.pilot-review-dialog textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 10px; }
.pilot-review-dialog .pilot-authorization { display: flex; align-items: start; }
.pilot-review-dialog input[type="checkbox"] { width: auto; flex: none; }

.auth-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
  margin-top: 24px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .hero,
  .toolbar,
  .users-layout,
  .auth-form,
  .panel-heading {
    grid-template-columns: 1fr;
  }

  .user-detail-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .users-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .role-cell,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
