* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--color-surface-page);
  color: var(--color-text);
  font: var(--font-size-body) / var(--line-height-body) var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

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

a,
button {
  -webkit-tap-highlight-color: var(--color-transparent);
}

a {
  color: var(--color-forest-800);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-leaf-alpha-40);
  outline-offset: var(--space-1);
}

.team-shell {
  width: min(var(--size-content-max), 100%);
  margin: auto;
  padding: var(--space-6) var(--space-5) var(--space-12);
}

.team-navigation {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.team-navigation a {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-touch);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-forest-800);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-label);
  text-decoration: none;
}

.team-navigation a:hover {
  background: var(--color-surface-subtle);
}

.team-navigation a[aria-current="page"] {
  background: var(--color-forest-900);
  color: var(--color-surface-card);
}

.card {
  /* Legacy-Alias auf .ui-card für Konsistenz (DESIGN.md 1.2.0: 12px Radius) */
  margin: var(--space-4) 0;
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-card);
  box-shadow: var(--shadow-sm);
}

h1,
h2,
h3 {
  color: var(--color-forest-950);
  line-height: var(--line-height-tight);
}

h1 {
  margin: var(--space-1) 0;
  font-size: clamp(2rem, 7vw, 3.375rem);
  font-weight: var(--font-weight-strong);
  letter-spacing: -0.035em;
}

label {
  display: block;
  margin: var(--space-4) 0 var(--space-2);
  color: var(--color-text);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-label);
}

input,
select,
textarea,
button,
.button {
  width: 100%;
  min-height: var(--size-control);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}

input,
select,
textarea {
  background: var(--color-surface-card);
  color: var(--color-text);
}

button,
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--size-button);
  margin-top: var(--space-4);
  border-color: var(--color-forest-900);
  background: var(--color-forest-900);
  color: var(--color-surface-card);
  font-weight: var(--font-weight-bold);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.secondary {
  border-color: var(--color-forest-900);
  background: var(--color-surface-card);
  color: var(--color-forest-900);
}

.error,
.message {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
}

.error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.message {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.list {
  display: grid;
  gap: var(--space-3);
}

.person {
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.roles {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.roles label {
  display: flex;
  align-items: center;
  min-height: var(--size-touch);
  gap: var(--space-2);
}

.roles input {
  width: var(--space-6);
  min-height: var(--space-6);
}

.muted {
  color: var(--color-text-muted);
}

.loading {
  display: none;
}

button:active .loading {
  display: inline;
}

.page-header,
.section-heading,
.user-row,
.sheet-header,
.sheet-footer {
  display: flex;
  align-items: center;
}

.page-header {
  justify-content: space-between;
  gap: var(--space-6);
  margin: var(--space-8) 0 var(--space-10);
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--color-forest-700);
  font-size: .75rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.page-intro,
.sheet-header p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.page-action,
.empty-state .button {
  width: auto;
  margin: 0;
}

.user-overview {
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-card);
  box-shadow: var(--shadow-sm);
}

.section-heading {
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.section-heading h2,
.section-heading p,
.form-section h3 {
  margin: 0;
}

.user-list { display: grid; }

.user-row {
  display: grid;
  grid-template-columns: 48px minmax(180px, 1fr) minmax(180px, auto) auto auto;
  gap: var(--space-4);
  width: 100%;
  min-height: 76px;
  margin: 0;
  padding: var(--space-3) var(--space-6);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-surface-card);
  color: var(--color-text);
  text-align: left;
}

.user-row:last-child { border-bottom: 0; }
.user-row:hover { background: var(--color-surface-page); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-surface-subtle);
  color: var(--color-forest-800);
  font-weight: var(--font-weight-bold);
}

.avatar-large { width: 56px; height: 56px; flex: 0 0 auto; }
.user-identity { display: grid; align-self: center; }
.user-identity span { color: var(--color-text-muted); font-size: var(--font-size-label); }
.role-summary { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.role-label,
.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: .8125rem;
  font-weight: var(--font-weight-label);
}

.role-label { background: var(--color-surface-subtle); color: var(--color-forest-800); }
.status-active { background: var(--color-success-soft); color: var(--color-success); }
.status-invited { background: var(--color-info-soft); color: var(--color-info); }
.status-disabled { background: var(--color-neutral-soft); color: var(--color-neutral); }
.row-action { color: var(--color-forest-800); font-size: var(--font-size-label); font-weight: var(--font-weight-label); }
.row-action span { font-size: 1.25rem; }
.empty-state { padding: var(--space-12) var(--space-6); text-align: center; }
.empty-state p { color: var(--color-text-muted); }
.empty-state .button { display: inline-flex; }

.sheet-layer[hidden] { display: none; }
.sheet-layer { position: fixed; inset: 0; z-index: var(--z-sheet-backdrop); }
.sheet-backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--color-forest-950) 42%, transparent); }
.sheet {
  position: absolute;
  inset: 0 0 0 auto;
  display: flex;
  flex-direction: column;
  width: min(var(--size-sheet), 100%);
  background: var(--color-surface-card);
  box-shadow: var(--shadow-drawer);
  animation: sheet-in var(--motion-drawer) var(--ease-standard);
}

@keyframes sheet-in { from { transform: translateX(100%); } }
.sheet-open { overflow: hidden; }
.sheet-header { align-items: flex-start; gap: var(--space-4); padding: var(--space-6); border-bottom: 1px solid var(--color-border); }
.sheet-header > div:nth-child(1):not(.avatar), .user-sheet-header > div:nth-child(2) { flex: 1; min-width: 0; }
.sheet-header h2 { margin: 0; font-size: 1.625rem; }
.icon-button { width: var(--size-touch); min-height: var(--size-touch); margin: 0 0 0 auto; padding: 0; border-color: var(--color-border); background: var(--color-surface-card); color: var(--color-text); font-size: 1.75rem; font-weight: 400; }
.sheet-form { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.sheet-body { flex: 1; overflow-y: auto; padding: var(--space-6); }
.sheet-footer { justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); padding-bottom: max(var(--space-4), env(safe-area-inset-bottom)); }
.sheet-footer .button { width: auto; margin: 0; }
.form-section + .form-section { margin-top: var(--space-8); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
.field-help { margin: var(--space-2) 0 var(--space-4); color: var(--color-text-muted); font-size: var(--font-size-label); }
.choice-list { display: grid; gap: var(--space-2); }
.choice-row { display: flex; align-items: center; gap: var(--space-3); min-height: var(--size-touch); margin: 0; padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); cursor: pointer; }
.choice-row:has(input:checked) { border-color: var(--color-leaf-600); background: var(--color-leaf-100); }
.choice-row input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--color-forest-800); }
.choice-row span { display: grid; }
.choice-row small { color: var(--color-text-muted); font-weight: 400; }
.account-facts { display: grid; gap: var(--space-3); margin: 0 0 var(--space-8); }
.account-facts div { display: flex; justify-content: space-between; gap: var(--space-4); padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
.account-facts dt { color: var(--color-text-muted); }
.account-facts dd { margin: 0; text-align: right; font-weight: var(--font-weight-label); }
.form-section > .button { margin-top: var(--space-4); }
.account-access form + form { margin-top: var(--space-3); }
.account-access .button { margin-top: 0; }
.button.danger { border-color: var(--color-danger-soft); background: var(--color-danger-soft); color: var(--color-danger); }

@media (max-width: 679px) {
  .team-shell {
    padding: var(--space-4) var(--space-3) var(--space-10);
  }

  .card {
    padding: var(--space-5);
  }

  .page-header { align-items: stretch; flex-direction: column; margin-top: var(--space-6); }
  .page-action { width: 100%; }
  .user-row { grid-template-columns: 48px minmax(0, 1fr) auto; padding: var(--space-4); }
  .role-summary { grid-column: 2 / 4; }
  .status-badge { grid-column: 3; grid-row: 1; }
  .row-action { display: none; }
  .sheet { width: 100%; }
  .sheet-footer .button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
