:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f5f7fb;
  --card: #ffffff;
  --blue: #2563eb;
  --green: #11845b;
  --red: #c03245;
  --amber: #a15c07;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-panel,
.dashboard {
  width: min(1180px, calc(100% - 32px));
}
.auth-card {
  width: min(420px, 100%);
  margin: auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(17,24,39,.08);
}
.mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}
h1 { margin: 18px 0 8px; font-size: clamp(30px, 5vw, 48px); letter-spacing: -.04em; line-height: 1; }
p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 750; }
input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  outline: none;
}
select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37,99,235,.12); outline: none; }
.form { display: grid; gap: 12px; }
.primary,
.secondary,
.text-button {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 800;
}
.primary { border: 0; background: var(--ink); color: #fff; }
.secondary { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.text-button { border: 0; background: transparent; color: var(--blue); padding: 0; }
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
}
.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 13px;
}
.alert.error { color: var(--red); border-color: #efbdc5; background: #fff0f2; }
.alert.success { color: var(--green); border-color: #b8dfd0; background: #e9f7f1; }

.dashboard {
  margin: 0 auto;
  padding: 28px 0 56px;
}
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.topbar h1 { margin-top: 6px; }
.account {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.summary-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}
.summary-card span { display: block; color: var(--muted); font-size: 13px; }
.summary-card strong { display: block; margin-top: 8px; font-size: 30px; letter-spacing: -.04em; }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.toolbar input { max-width: 360px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
tbody tr:last-child td { border-bottom: 0; }
.email { font-weight: 800; }
.user-link {
  color: var(--ink);
  text-decoration: none;
}
.user-link:hover { color: var(--blue); text-decoration: underline; }
.user-id { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}
.pill.free { background: #f2f4f7; color: var(--muted); }
.pill.active,
.pill.trialing { background: #e9f7f1; color: var(--green); }
.pill.canceled,
.pill.incomplete,
.pill.past_due { background: #fff5e7; color: var(--amber); }
.sub-detail { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.permission-editor {
  display: grid;
  grid-template-columns: 86px 132px auto;
  align-items: end;
  gap: 7px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.permission-editor label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.permission-editor input {
  height: 36px;
  margin-top: 4px;
  border-radius: 10px;
  font-size: 13px;
}
.permission-editor select {
  margin-top: 4px;
  font-size: 13px;
}
.save-button {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
}
.detail-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 16px 48px rgba(17,24,39,.06);
}
.detail-user,
.permission-block,
.detail-actions {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}
.detail-user {
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.detail-user h2 {
  margin: 6px 0 6px;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -.03em;
}
.detail-user p {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.permission-block {
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcff;
}
.permission-block h3 {
  margin: 0 0 10px;
  font-size: 20px;
}
.permission-fields {
  display: grid;
  grid-template-columns: 120px 170px;
  gap: 10px;
  width: min(100%, 310px);
}
.detail-actions {
  align-items: center;
  justify-content: flex-end;
  padding-top: 6px;
}
.empty { padding: 34px; color: var(--muted); text-align: center; }

@media (max-width: 720px) {
  .topbar,
  .toolbar { align-items: stretch; flex-direction: column; }
  .summary { grid-template-columns: 1fr; }
  .account { justify-content: space-between; }
  .toolbar input { max-width: none; }
  .detail-user,
  .permission-block,
  .detail-actions {
    flex-direction: column;
  }
  .permission-fields {
    width: 100%;
    grid-template-columns: 1fr;
  }
}
