:root {
  --green: #07c160;
  --green-dark: #059b4d;
  --ink: #17202a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7fb;
  --card: #ffffff;
  --danger: #ef4444;
  --warn: #f59e0b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 76px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: env(safe-area-inset-top) 18px 0;
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  font-size: 22px;
}

.topbar-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.admin-topbar {
  justify-content: space-between;
}

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

.admin-topbar .btn {
  min-height: 34px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  text-decoration: none;
}

.page {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.wide-page {
  width: min(1180px, 100%);
}

.hero {
  text-align: center;
  padding: 26px 12px 18px;
}

.logo {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  object-fit: cover;
  box-shadow: 0 12px 30px rgba(7, 193, 96, .22);
}

.title {
  margin: 14px 0 4px;
  font-size: 24px;
  font-weight: 900;
}

.subtitle,
.hint,
.muted {
  color: var(--muted);
}

.actions,
.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions {
  margin: 18px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
  font-weight: 800;
}

.btn.primary {
  background: var(--green);
  color: #fff;
}

.btn.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.btn.ghost {
  background: #fff;
  border: 1px solid var(--line);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.card,
.activity-card,
.group-card,
.user-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .04);
}

.card {
  padding: 18px;
  margin-bottom: 14px;
}

.auth-card {
  margin-top: 28px;
}

.auth-switch {
  margin: 16px 0 0;
  color: var(--muted);
  text-align: center;
}

.auth-switch button {
  padding: 4px 6px;
  background: transparent;
  color: var(--green-dark);
  font-weight: 900;
}

.activity-card,
.group-card,
.user-card {
  padding: 14px;
  margin-bottom: 12px;
}

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

.admin-title {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 900;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric strong {
  display: block;
  font-size: 24px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.admin-panel {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.admin-search {
  width: min(320px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.admin-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.admin-toolbar .btn {
  min-height: 38px;
  padding: 0 12px;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.admin-actions .btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 900;
}

.activity-head,
.user-card,
.member,
.participant,
.selected-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.activity-head {
  justify-content: space-between;
}

.activity-name {
  font-weight: 900;
  font-size: 17px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8fff1;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.badge.gray {
  background: #eef2f7;
  color: #475569;
}

.badge.warn {
  background: #fff7ed;
  color: #c2410c;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  font-weight: 800;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  outline: none;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #f1f5f9;
}

.avatar.large {
  width: 84px;
  height: 84px;
}

.avatar-picker {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.avatar-picker.compact {
  margin-top: -6px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.avatar-crop-modal {
  max-width: 380px;
}

.crop-stage {
  display: grid;
  place-items: center;
  margin: 8px 0 18px;
}

.crop-canvas {
  width: 280px;
  height: 280px;
  max-width: 100%;
  border-radius: 50%;
  background: #f1f5f9;
  box-shadow: 0 0 0 1px var(--line), 0 0 0 999px rgba(15, 23, 42, .02);
  cursor: move;
  touch-action: none;
}

.crop-hint {
  margin: -4px 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.participants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}

.participant {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.participant.selected {
  border-color: var(--green);
  background: #effdf5;
}

.participant.disabled {
  opacity: .5;
}

.participant-name,
.user-name,
.member-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--line);
}

.tab {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  color: var(--green);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(15, 23, 42, .42);
}

.modal {
  width: min(520px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 18px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
}

.option.active {
  border-color: var(--green);
  background: #effdf5;
}

.option-icon {
  font-size: 24px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 80;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-weight: 700;
}

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

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.selected-list {
  display: grid;
  gap: 8px;
}

.selected-item {
  justify-content: space-between;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
}

.priority {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.group-members {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.reason {
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

@media (max-width: 520px) {
  .page {
    padding: 14px;
  }

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

  .actions .btn,
  .row-actions .btn {
    flex: 1 1 150px;
  }
}

@media (max-width: 840px) {
  .admin-hero,
  .admin-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-toolbar {
    justify-content: stretch;
  }

  .admin-toolbar .btn,
  .admin-search {
    flex: 1 1 160px;
  }

  .admin-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
