:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #151b24;
  --muted: #667085;
  --line: #d9e2ec;
  --teal: #0f766e;
  --teal-soft: #d7f3ef;
  --red: #b42318;
  --red-soft: #fee4e2;
  --amber: #b45309;
  --amber-soft: #ffedd5;
  --shadow: 0 16px 40px rgba(16, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
}

.secondaryButton,
.dangerButton {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  font-weight: 780;
}

.compact {
  min-height: 38px;
}

.secondaryButton {
  background: var(--surface);
  color: var(--ink);
}

.dangerButton {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.searchWrap,
.usersToolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0 0 14px;
  background: var(--bg);
}

.usersToolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f7;
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 820;
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.1);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input {
  height: 48px;
  padding: 0 14px;
}

textarea {
  margin-top: 7px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.peopleGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.personTile,
.emptyState,
.profileCard,
.groupsPanel,
.notice,
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.personTile {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-rows: auto auto auto auto;
  gap: 2px 12px;
  min-height: 132px;
  padding: 14px;
  color: inherit;
  text-align: left;
}

.personTile .avatar {
  grid-row: 1 / 5;
}

.personName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 830;
}

.personTag,
.personId,
.personGroups,
.meta,
.panelHeader p,
#profileMeta {
  color: var(--muted);
  font-size: 13px;
}

.personId,
.personGroups {
  overflow-wrap: anywhere;
}

.avatar,
.avatarLarge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 900;
  overflow: hidden;
}

.avatar {
  width: 56px;
  height: 56px;
}

.avatarSmall {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.avatarLarge {
  width: 78px;
  height: 78px;
  font-size: 24px;
}

.avatar img,
.avatarLarge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile {
  display: grid;
  gap: 12px;
}

.profileCard {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.profileMain {
  min-width: 0;
}

.profileMain h2,
.title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.groupsPanel {
  overflow: hidden;
}

.panelHeader {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.list {
  display: grid;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.groupRow {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
}

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

.title {
  font-weight: 780;
}

.meta {
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.badge {
  align-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 850;
}

.badgeOk {
  background: var(--teal-soft);
  color: var(--teal);
}

.badgeWarn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badgeBad {
  background: var(--red-soft);
  color: var(--red);
}

.emptyState {
  grid-column: 1 / -1;
  padding: 22px;
}

.emptyState p {
  margin-top: 5px;
  color: var(--muted);
}

.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  color: var(--red);
  border-color: #f3c4bd;
  background: #fff8f7;
  box-shadow: none;
}

.notice[data-tone="info"] {
  color: var(--teal);
  border-color: #b9e6df;
  background: #f2fffc;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(21, 27, 36, 0.52);
}

.modal {
  width: min(560px, 100%);
  padding: 18px;
}

.modal p {
  margin: 10px 0 14px;
  color: var(--muted);
  white-space: pre-wrap;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.modalActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.modalForm {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 27px;
  }

  .peopleGrid {
    grid-template-columns: 1fr;
  }

  .profileCard {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .profileCard .dangerButton {
    grid-column: 1 / -1;
    width: 100%;
  }

  .avatarLarge {
    width: 64px;
    height: 64px;
    font-size: 21px;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .usersToolbar {
    grid-template-columns: 1fr;
  }

  .groupRow {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .groupRow .badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .modalActions {
    grid-template-columns: 1fr;
  }
}
