.settings-page {
  min-height: calc(100vh - var(--header-height));
  padding: clamp(2.15rem, 3.6vw, 3.4rem) clamp(1.15rem, 4.5vw, 4rem) 6rem;
  background:
    radial-gradient(circle at 78% 4%, rgba(217, 54, 75, 0.055), transparent 22rem),
    linear-gradient(180deg, #fbfafb, #f8f6f7);
}

.settings-shell {
  width: min(100%, 78rem);
  margin: 0 auto;
}

.settings-tabs {
  display: inline-flex;
  gap: 0.4rem;
  padding: 0.4rem;
  background: rgba(239, 235, 237, 0.76);
  border: 1px solid rgba(80, 45, 54, 0.07);
  border-radius: 0.95rem;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.8);
}

.settings-tabs button {
  display: flex;
  min-height: 3rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.62rem 1.15rem;
  color: #7c6f73;
  background: transparent;
  border: 0;
  border-radius: 0.7rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
  transition: 160ms ease;
}

.settings-tabs button:hover { color: #3c3034; }
.settings-tabs button.is-active {
  color: #302327;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 3px rgba(56, 31, 38, 0.08), 0 0.4rem 1rem rgba(82, 43, 54, 0.04);
}
.settings-tabs .icon { width: 1rem; height: 1rem; }

.settings-body { margin-top: 2.8rem; }
.settings-view { animation: settings-arrive 260ms ease both; }

.settings-section-heading {
  display: flex;
  min-height: 2.8rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.45rem;
  padding: 0 0.2rem;
}
.settings-section-heading h2 { margin: 0; font-size: 1.58rem; font-weight: 700; letter-spacing: -0.045em; }
.member-count { display: grid; min-width: 2rem; height: 2rem; place-items: center; color: #8c7e82; background: #f0ecee; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }

.settings-card,
.invite-strip,
.member-list,
.module-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(77, 48, 56, 0.1);
  box-shadow: 0 1px 2px rgba(52, 35, 40, 0.025), 0 1rem 2.8rem rgba(87, 47, 58, 0.045);
}

.settings-card { padding: clamp(1.65rem, 2.6vw, 2.15rem); border-radius: 1.2rem; }
.settings-card + .settings-card { margin-top: 1.65rem; }

.profile-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2rem; }

.profile-avatar {
  --profile-avatar-color: #89384e;
  --profile-avatar-a: #f8e8ec;
  --profile-avatar-b: #f1dfe4;
  display: grid;
  width: 5.2rem;
  height: 5.2rem;
  flex: 0 0 auto;
  place-items: center;
  color: var(--profile-avatar-color);
  background: linear-gradient(145deg, var(--profile-avatar-a), var(--profile-avatar-b));
  border: 1px solid rgba(193, 65, 96, 0.12);
  border-radius: 1.48rem;
  box-shadow: 0 0.8rem 1.7rem rgba(133, 60, 80, 0.09), inset 0 1px rgba(255, 255, 255, 0.9);
  font-size: 1.12rem;
  font-weight: 750;
}
.profile-avatar--ocean { --profile-avatar-color: #315a73; --profile-avatar-a: #eaf3f7; --profile-avatar-b: #dcebf2; }
.profile-avatar--violet { --profile-avatar-color: #5d4d78; --profile-avatar-a: #f0edf5; --profile-avatar-b: #e6e1ef; }
.profile-avatar--amber { --profile-avatar-color: #755526; --profile-avatar-a: #f8f1e4; --profile-avatar-b: #f0e5d1; }
.profile-avatar--mint { --profile-avatar-color: #315f54; --profile-avatar-a: #eaf4f0; --profile-avatar-b: #dcece6; }

.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: end; gap: 1.2rem; }
.settings-form label { display: grid; gap: 0.58rem; }
.settings-form label > span { color: #75676b; font-size: 0.72rem; font-weight: 650; }
.settings-form input,
.invite-strip input,
.settings-form select,
.invite-strip select,
.role-select select {
  width: 100%;
  min-height: 3.3rem;
  padding: 0 0.92rem;
  color: #34282c;
  background: #fbf9fa;
  border: 1px solid #e7e0e2;
  border-radius: 0.78rem;
  outline: 0;
  font-size: 0.84rem;
  transition: 160ms ease;
}
.settings-form input:focus,
.invite-strip input:focus,
.settings-form select:focus,
.invite-strip select:focus,
.role-select select:focus { background: #fff; border-color: rgba(215, 47, 72, 0.32); box-shadow: 0 0 0 0.2rem rgba(215, 47, 72, 0.055); }

.settings-button {
  min-height: 3.25rem;
  align-self: end;
  padding: 0.68rem 1.05rem;
  color: #55474c;
  background: #fff;
  border: 1px solid #e5dde0;
  border-radius: 0.78rem;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: 0 0.35rem 0.9rem rgba(67, 39, 47, 0.045);
  transition: 160ms ease;
}
.settings-button:hover { border-color: rgba(215, 47, 72, 0.2); transform: translateY(-1px); }
.settings-button--primary { color: #fff; background: var(--gradient-accent); border-color: transparent; box-shadow: 0 0.6rem 1.2rem rgba(170, 27, 53, 0.16), inset 0 1px rgba(255,255,255,.23); }
.settings-form > .settings-button { grid-column: auto; justify-self: end; }
.settings-form__actions { display: flex; align-items: stretch; gap: .55rem; }
.settings-form__actions .settings-button { white-space: nowrap; }

.settings-card__title { display: flex; align-items: center; gap: 1rem; }
.settings-card__title h3 { margin: 0; font-size: 0.9rem; font-weight: 700; }
.settings-card__icon { display: grid; width: 2.9rem; height: 2.9rem; place-items: center; color: #715f78; background: #eee9f1; border-radius: 0.88rem; }
.settings-card__icon--rose { color: #a6405a; background: #f5e7eb; }
.settings-card__icon .icon { width: 1rem; height: 1rem; }
.settings-form--password { grid-template-columns: 1fr 1fr auto; align-items: end; margin-top: 1.65rem; }
.settings-form--password > .settings-button { grid-column: auto; }

.invite-strip { display: grid; grid-template-columns: auto minmax(13rem, 1fr) 9rem auto; align-items: center; gap: 1rem; padding: 1.2rem; border-radius: 1.12rem; }
.invite-strip__icon { display: grid; width: 2.8rem; height: 2.8rem; place-items: center; color: #a44159; background: #f6e9ec; border-radius: 0.84rem; }
.invite-strip__icon .icon { width: 1rem; height: 1rem; }
.invite-strip input, .invite-strip select { background: transparent; }
.invite-strip select, .role-select select { padding-right: 2rem; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8d7d82 50%), linear-gradient(135deg, #8d7d82 50%, transparent 50%); background-position: calc(100% - 0.9rem) 50%, calc(100% - 0.64rem) 50%; background-size: 0.28rem 0.28rem, 0.28rem 0.28rem; background-repeat: no-repeat; }

.member-list { overflow: hidden; margin-top: 1.25rem; border-radius: 1.12rem; }
.member-row { display: grid; grid-template-columns: auto minmax(12rem, 1fr) 8.5rem; min-height: 5.15rem; align-items: center; gap: 1.15rem; padding: 0.86rem 1.3rem; transition: 150ms ease; }
.member-row + .member-row { border-top: 1px solid rgba(77, 48, 56, 0.075); }
.member-row:hover { background: rgba(250, 247, 248, 0.8); }
.member-avatar { display: grid; width: 2.45rem; height: 2.45rem; place-items: center; color: #8c3b50; background: #f4e5e9; border-radius: 0.78rem; font-size: 0.65rem; font-weight: 750; }
.member-avatar--ocean { color: #315a73; background: #e3eef4; }
.member-avatar--violet { color: #5d4d78; background: #eae6f1; }
.member-avatar--amber { color: #755526; background: #f3ead8; }
.member-avatar--mint { color: #315f54; background: #e2eee9; }
.member-details { display: grid; min-width: 0; gap: 0.24rem; }
.member-details strong { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; font-weight: 680; }
.member-details strong small { padding: 0.2rem 0.42rem; color: #9a7d86; background: #f5ecef; border-radius: 999px; font-size: 0.55rem; text-transform: uppercase; letter-spacing: 0.04em; }
.member-details > span { overflow: hidden; color: #94868a; font-size: 0.7rem; text-overflow: ellipsis; }
.role-select select { min-height: 2.3rem; background-color: transparent; border-color: transparent; font-size: 0.72rem; font-weight: 650; }
.role-select select:hover { background-color: #f8f5f6; border-color: #ebe4e6; }
.module-section { position: relative; padding: clamp(1.15rem, 2.1vw, 1.65rem); background: linear-gradient(145deg,rgba(255,255,255,.72),rgba(249,246,249,.58)); border: 1px solid rgba(77,48,56,.075); border-radius: 1.35rem; box-shadow: 0 1.5rem 3.8rem rgba(74,40,51,.045),inset 0 1px rgba(255,255,255,.9); }
.module-grid { display: grid; grid-template-columns: repeat(12,minmax(0,1fr)); gap: 1rem; }
.module-card { display: grid; grid-column: span 3; grid-template-columns: auto minmax(0, 1fr) auto; min-width: 0; min-height: 6.15rem; align-items: center; gap: 1rem; padding: 1.15rem 1.2rem; border-radius: 1.08rem; opacity: 0.62; transition: 180ms ease; }
.module-card:nth-last-child(-n+3) { grid-column: span 4; }
.module-card.is-enabled { opacity: 1; }
.module-card:hover { border-color: rgba(215, 47, 72, 0.15); transform: translateY(-1px); }
.module-card__icon { display: grid; width: 2.7rem; height: 2.7rem; place-items: center; color: #88787d; background: #f2eef0; border-radius: 0.82rem; transition: 180ms ease; }
.module-card.is-enabled .module-card__icon { color: #af3b58; background: #f6e8ec; }
.module-card__icon .icon { width: 1rem; height: 1rem; }
.module-card > strong { overflow: hidden; font-size: 0.76rem; font-weight: 690; text-overflow: ellipsis; white-space: nowrap; }

.switch { display: inline-flex; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch__track { display: block; width: 2.55rem; height: 1.48rem; padding: 0.2rem; background: #e6e0e2; border-radius: 999px; transition: 180ms ease; }
.switch__track span { display: block; width: 1.08rem; height: 1.08rem; background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(60, 37, 44, 0.18); transition: 180ms cubic-bezier(.2,.8,.2,1); }
.switch input:checked + .switch__track { background: linear-gradient(135deg, #df4058, #b91e3b); box-shadow: 0 0 0 0.2rem rgba(215,47,72,.05), 0 0 0.8rem rgba(215,47,72,.13); }
.switch input:checked + .switch__track span { transform: translateX(1.07rem); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.settings-toast { position: fixed; z-index: 80; right: 1.5rem; bottom: 1.5rem; padding: 0.72rem 0.95rem; color: #fff; background: rgba(49, 37, 41, 0.94); border: 1px solid rgba(255,255,255,.12); border-radius: 0.75rem; box-shadow: 0 1rem 2.5rem rgba(45, 25, 31, 0.22); opacity: 0; transform: translateY(0.5rem); transition: 180ms ease; font-size: 0.74rem; font-weight: 650; }
.settings-toast.is-visible { opacity: 1; transform: none; }

@keyframes settings-arrive { from { opacity: 0; transform: translateY(0.35rem); } to { opacity: 1; transform: none; } }

@media (max-width: 62rem) {
  .module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .module-card, .module-card:nth-last-child(-n+3) { grid-column: span 1; }
  .module-card:last-child:nth-child(odd) { width: calc(50% - .5rem); grid-column: 1 / -1; justify-self: center; }
}

@media (max-width: 44rem) {
  .settings-page { padding: 1.3rem 0.9rem 3rem; }
  .settings-tabs { display: flex; width: 100%; }
  .settings-tabs button { flex: 1; justify-content: center; padding-inline: 0.55rem; }
  .settings-body { margin-top: 1.7rem; }
  .settings-form, .settings-form--password { grid-template-columns: 1fr; }
  .settings-form > .settings-button, .settings-form--password > .settings-button { grid-column: 1; justify-self: stretch; }
  .settings-form__actions { grid-column: 1; }
  .settings-form__actions .settings-button { flex: 1; }
  .invite-strip { grid-template-columns: auto 1fr; }
  .invite-role { grid-column: 2; }
  .invite-strip .settings-button { grid-column: 2; width: 100%; }
  .member-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .role-select { grid-column: 2; }
  .profile-card { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: 1fr; }
  .module-card:last-child:nth-child(odd) { width: 100%; grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .settings-view { animation: none; }
}
