/* Team Platform — gateway UI */

:root {
  color-scheme: dark;

  --bg: #08070c;
  --bg-soft: #0c0a12;
  --surface: #110e18;
  --surface-2: #161320;
  --surface-3: #1e1a2b;
  --border: #241f33;
  --border-strong: #342c48;

  --text: #f4f2fa;
  --text-2: #c9c2da;
  --muted: #8e86a6;
  --faint: #5d5672;

  --accent: #9333ea;
  --accent-2: #7c3aed;
  --accent-hi: #a855f7;
  --accent-text: #c4a0ff;
  --accent-soft: rgba(147, 51, 234, 0.14);

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;

  --mod-running: #5dcaa5;
  --mod-posts: #b07cff;
  --mod-batch: #6f9bff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --ring: 0 0 0 3px rgba(168, 85, 247, 0.35);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.02);

  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(147, 51, 234, 0.16), transparent 70%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
ul { list-style: none; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--ring); }

h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted); }

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 24px;
}

/* ---------- Brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }

.logo-mark {
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, #b47cff 0%, #7c3aed 55%, #5b21b6 100%);
  box-shadow: 0 6px 18px -6px rgba(147, 51, 234, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 40px;
  padding: 0 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:disabled {
  opacity: 1;
  color: var(--faint);
  background: var(--surface-2);
  border-color: var(--border);
  box-shadow: none;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #a04ff0, #8130e0);
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 16px -8px rgba(147, 51, 234, 0.8);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #ad62f5, #8d3ae9); }
.btn-primary:active:not(:disabled) { background: #7c2fd6; }

.btn-secondary {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: #262036; }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-sm { height: 32px; padding: 0 0.7rem; font-size: 0.8125rem; border-radius: 8px; gap: 0.35rem; }
.btn-lg { height: 46px; font-size: 0.9375rem; }
.btn-block { width: 100%; }

.btn.is-loading { pointer-events: none; opacity: 0.85; }
.btn.is-loading::before {
  content: '';
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.btn-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.btn-close:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Forms ---------- */

.field { margin-bottom: 1.1rem; border: 0; min-width: 0; }
.field label,
.field legend {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: #43395c; }
.input:focus { outline: none; border-color: var(--accent-hi); box-shadow: var(--ring); }
.input[readonly] { color: var(--muted); background: var(--surface); cursor: default; }
.input[readonly]:focus { border-color: var(--border-strong); box-shadow: none; }
.input-sm { height: 36px; font-size: 0.875rem; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 2.75rem; }
.input-wrap:has(.input-actions > :nth-child(2)) .input { padding-right: 5rem; }
.input-wrap:has(.input-actions > :nth-child(3)) .input { padding-right: 7rem; }
.input-actions {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
}
.input-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.input-sm ~ .input-actions .input-btn { width: 28px; height: 28px; }
button.input-btn:hover { background: var(--surface-3); color: var(--text); }
.input-btn.is-done { color: var(--success); }

[data-toggle-password] .when-shown { display: none; }
[data-toggle-password].is-shown .when-shown { display: block; }
[data-toggle-password].is-shown .when-hidden { display: none; }

.hint {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.hint .icon { display: inline; vertical-align: -2px; }
.hint-warn { color: var(--warning); }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1.1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  border: 1px solid;
}
.alert .icon { margin-top: 1px; }
.alert-error { color: #fda4a4; background: var(--danger-soft); border-color: rgba(248, 113, 113, 0.28); }

.checklist { display: grid; gap: 0.35rem; margin: -0.2rem 0 1.25rem; }
.checklist li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8125rem;
  color: var(--faint);
  transition: color 0.15s;
}
.checklist li .icon { opacity: 0.4; }
.checklist li.is-ok { color: var(--success); }
.checklist li.is-ok .icon { opacity: 1; }

.eyebrow {
  display: inline-block;
  margin-bottom: 0.6rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-text);
  background: var(--accent-soft);
}

/* ---------- Auth (login / setup) ---------- */

.auth { min-height: 100vh; display: grid; }

.auth-aside { display: none; }

.auth-main {
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.auth-card { width: 100%; max-width: 400px; }

.auth-brand-mobile { margin-bottom: 2rem; }

.auth-title { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 0.35rem; }
.auth-sub { color: var(--muted); margin-bottom: 1.75rem; font-size: 0.9375rem; }
.auth-help { margin-top: 1.5rem; font-size: 0.8125rem; color: var(--muted); text-align: center; }

@media (min-width: 960px) {
  .auth { grid-template-columns: minmax(440px, 1fr) minmax(480px, 1fr); }

  .auth-aside {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 3rem;
    padding: 40px 56px;
    border-right: 1px solid var(--border);
    background:
      radial-gradient(ellipse 90% 60% at 0% 0%, rgba(147, 51, 234, 0.22), transparent 60%),
      radial-gradient(ellipse 70% 50% at 100% 100%, rgba(93, 202, 165, 0.07), transparent 60%),
      var(--bg-soft);
  }

  .auth-brand-mobile { display: none; }
  .auth-main { padding: 40px 56px; }
}

.auth-pitch { max-width: 460px; }
.auth-pitch h1 { font-size: 2.1rem; line-height: 1.15; letter-spacing: -0.03em; margin-bottom: 0.9rem; }
.auth-pitch > p { color: var(--text-2); margin-bottom: 2rem; }

.auth-modules { display: grid; gap: 0.75rem; }
.auth-modules li {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}
.auth-modules strong { display: block; font-size: 0.9rem; font-weight: 600; }
.auth-modules div > span { display: block; font-size: 0.8125rem; color: var(--muted); }
.auth-modules .module-icon { width: 36px; height: 36px; border-radius: 10px; }

.auth-foot { display: flex; align-items: center; gap: 0.45rem; font-size: 0.8125rem; color: var(--muted); }

/* ---------- App shell ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  border-bottom: 1px solid var(--border);
  background: rgba(8, 7, 12, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.nav-inner { height: 100%; display: flex; align-items: center; gap: 1.5rem; }

.nav-links { display: flex; align-items: center; gap: 0.25rem; flex: 1; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 34px;
  padding: 0 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s, background-color 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-link.is-active { color: var(--text); background: var(--surface-3); }

.user-menu { position: relative; }
.user-menu summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  height: 38px;
  padding: 0 0.6rem 0 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  list-style: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover,
.user-menu[open] summary { background: var(--surface-2); border-color: var(--border-strong); }
.user-email {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
  color: var(--text-2);
}
.user-menu .chev { color: var(--muted); transition: transform 0.15s; }
.user-menu[open] .chev { transform: rotate(180deg); }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 270px;
  padding: 0.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  animation: pop 0.14s ease-out;
}
.menu-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.6rem 0.8rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.menu-who { min-width: 0; }
.menu-who strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-who span { font-size: 0.78rem; color: var(--muted); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  height: 36px;
  padding: 0 0.6rem;
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-2);
  text-align: left;
}
.menu-item:hover { background: var(--surface-3); color: var(--text); }

.avatar {
  --h: 270;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: hsl(var(--h) 85% 82%);
  background: hsl(var(--h) 40% 20%);
  box-shadow: inset 0 0 0 1px hsl(var(--h) 50% 32% / 0.7);
}
.avatar-sm { width: 30px; height: 30px; font-size: 0.7rem; }

.page { padding-top: 40px; padding-bottom: 64px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1.75rem;
}
.lead { margin-top: 0.35rem; color: var(--muted); font-size: 0.975rem; }

/* ---------- Hub ---------- */

.notice {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.07);
  color: var(--warning);
}
.notice strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 0.15rem; }
.notice p { color: var(--text-2); font-size: 0.875rem; }

.module-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.module-icon {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: var(--mod, var(--accent-text));
  background: color-mix(in srgb, var(--mod, var(--accent-hi)) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mod, var(--accent-hi)) 28%, transparent);
}

.module {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 1.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--text);
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.2s ease, border-color 0.2s, box-shadow 0.2s;
}
.module::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--mod) 16%, transparent), transparent 55%);
  opacity: 0.7;
  transition: opacity 0.2s;
}
a.module:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--mod) 45%, var(--border));
  box-shadow: 0 22px 44px -24px color-mix(in srgb, var(--mod) 60%, transparent);
}
a.module:hover::before { opacity: 1; }
a.module:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mod) 45%, transparent); }

.module-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.module-name { font-size: 1.2rem; font-weight: 650; margin-bottom: 0.3rem; }
.module-desc { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1.25rem; }
.tags li {
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.module-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--mod);
}
.module-foot .go { transition: transform 0.2s; }
a.module:hover .module-foot .go { transform: translateX(4px); }

.module.is-locked { cursor: not-allowed; background: var(--surface); }
.module.is-locked::before { display: none; }
.module.is-locked .module-icon { color: var(--faint); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border); }
.module.is-locked .module-name { color: var(--text-2); }
.module.is-locked .tags li { opacity: 0.6; }
.module.is-locked .module-foot { color: var(--faint); font-weight: 500; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 24px;
  padding: 0 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status[data-state="checking"] .dot { animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="online"] { color: var(--success); border-color: rgba(52, 211, 153, 0.25); background: var(--success-soft); }
.status[data-state="online"] .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.status[data-state="offline"] { color: var(--danger); border-color: rgba(248, 113, 113, 0.28); background: var(--danger-soft); }
.status[data-state="offline"] .dot { background: var(--danger); }

.team-strip {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, background-color 0.15s;
}
.team-strip:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
.team-strip-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--accent-text);
  background: var(--accent-soft);
}
.team-strip-text { flex: 1; min-width: 0; }
.team-strip-text strong { display: block; font-weight: 600; font-size: 0.95rem; }
.team-strip-text span { display: block; font-size: 0.8125rem; color: var(--muted); }
.team-strip-go { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; font-weight: 600; color: var(--accent-text); }

/* ---------- Team admin ---------- */

.stats {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 1.25rem;
}
.stat {
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.stat-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.stat-label .stat-icon { color: var(--mod); }
.stat-value { display: flex; align-items: baseline; gap: 0.4rem; font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 0.8125rem; font-weight: 500; color: var(--faint); letter-spacing: 0; }

.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search > .icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search .input { height: 38px; padding-left: 2.3rem; font-size: 0.875rem; }
.search .input::-webkit-search-cancel-button { filter: invert(0.6); }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 30px;
  padding: 0 0.75rem;
  border-radius: 7px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s;
}
.segmented button span { font-size: 0.72rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.segmented button:hover { color: var(--text); }
.segmented button.is-active { color: var(--text); background: var(--surface-3); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.segmented button.is-active span { color: var(--text-2); }

.member { border-bottom: 1px solid var(--border); transition: background-color 0.2s; }
.member:last-child { border-bottom: 0; }
.member:hover { background: rgba(255, 255, 255, 0.012); }

.member-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 0.9rem 1.5rem;
  padding: 1rem 1.15rem;
}

.member.is-dirty { background: rgba(147, 51, 234, 0.06); box-shadow: inset 3px 0 0 var(--accent-hi); }
.member.is-highlight { animation: flash 2.4s ease-out; }
.member.is-inactive .member-id { opacity: 0.55; }

.member-id { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.member-text { min-width: 0; }
.member-email {
  display: block;
  font-weight: 550;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem; min-height: 20px; margin-top: 0.2rem; }
.member-since { font-size: 0.78rem; color: var(--faint); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 20px;
  padding: 0 0.45rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
}
.badge-accent { color: var(--accent-text); background: var(--accent-soft); border-color: rgba(168, 85, 247, 0.3); }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(248, 113, 113, 0.3); }

.member-access, .chip-group { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip { position: relative; display: inline-flex; }
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.chip-body {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 32px;
  padding: 0 0.75rem 0 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
  user-select: none;
}
.chip-mark {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid var(--faint);
  color: transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover .chip-body { border-color: #4a4063; color: var(--text-2); }
.chip input:checked + .chip-body,
.chip.is-static .chip-body {
  color: var(--text);
  border-color: color-mix(in srgb, var(--mod) 50%, transparent);
  background: color-mix(in srgb, var(--mod) 13%, transparent);
}
.chip input:checked + .chip-body .chip-mark,
.chip.is-static .chip-mark {
  border-color: var(--mod);
  background: var(--mod);
  color: #0b0a10;
}
.chip input:focus-visible + .chip-body { box-shadow: var(--ring); }
.chip.is-static { opacity: 0.75; }
.chip.is-static input { display: none; }

.member-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.4rem; }
/* Kept in the layout while hidden so the row doesn't jump when it appears. */
.member-actions [data-discard]:disabled { visibility: hidden; }

.protected { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8125rem; color: var(--muted); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; margin-right: 0.35rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: background-color 0.18s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s, background-color 0.18s;
}
.switch input:checked + .switch-track { background: rgba(52, 211, 153, 0.25); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.45); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--success); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch-label { font-size: 0.8125rem; color: var(--text-2); }

.member-password {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 380px) 1fr;
  align-items: center;
  gap: 0.4rem 1rem;
  padding-top: 0.25rem;
}
.member-password .hint { margin-top: 0; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

@media (max-width: 920px) {
  .member-row { grid-template-columns: 1fr; gap: 0.85rem; }
  .member-actions { justify-content: flex-start; flex-wrap: wrap; }
  .member-password { grid-template-columns: 1fr; }
}

/* ---------- Dialog ---------- */

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.modal::backdrop { background: rgba(4, 3, 8, 0.72); backdrop-filter: blur(3px); }
.modal[open] .modal-card { animation: pop 0.18s ease-out; }

.modal-card {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
.modal-head h2 { font-size: 1.2rem; margin-bottom: 0.2rem; }
.modal-head p { font-size: 0.875rem; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}
.modal-foot-end { display: flex; gap: 0.5rem; margin-left: auto; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  top: calc(var(--nav-h) + 14px);
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.6rem 0.8rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  pointer-events: auto;
  animation: slide-in 0.25s ease-out;
}
.toast > span { flex: 1; padding-top: 1px; }
.toast-success > .icon { color: var(--success); }
.toast-error { border-color: rgba(248, 113, 113, 0.35); }
.toast-error > .icon { color: var(--danger); }
.toast-close { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--muted); }
.toast-close:hover { background: var(--surface-3); color: var(--text); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }

/* ---------- Error page ---------- */

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; }
.error-card { width: 100%; max-width: 460px; text-align: center; }
.error-brand { margin-bottom: 3rem; }
.error-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 1.25rem;
  border-radius: 16px;
  color: var(--accent-text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.3);
}
.error-code { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.error-card h1 { margin-bottom: 0.6rem; }
.error-msg { color: var(--text-2); margin-bottom: 1.75rem; }
.error-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem; }
.error-retry { margin-top: 1.25rem; font-size: 0.8125rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- Motion ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(0.98); } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes flash { 0%, 35% { background: rgba(52, 211, 153, 0.1); } 100% { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .container { padding-inline: 16px; }
  .page { padding-top: 28px; }
  h1 { font-size: 1.5rem; }
  .nav-inner { gap: 0.75rem; }
  .nav .brand-name, .user-email { display: none; }
  .nav .brand .logo-mark { margin-right: 0.25rem; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head .btn { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .stat { padding: 0.8rem 0.9rem; }
  .stat-value { font-size: 1.35rem; }
  .search { max-width: none; flex-basis: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; justify-content: center; }
  .modal-card { padding: 1.25rem; }
  .modal-foot-end { width: 100%; }
  .modal-foot-end .btn { flex: 1; }
  .team-strip-go { display: none; }
  .module { min-height: 0; }
  .member-actions { flex-wrap: nowrap; }
  .member-actions [data-save] { margin-left: auto; }
  .member-actions [data-discard]:disabled { display: none; }
  .member-actions .btn-label { display: none; }
  .toasts { top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; }
}

@media (max-width: 330px) {
  .stats { grid-template-columns: 1fr; }
}
