:root {
  --ink: #0f1722;
  --ink-soft: #4d5d73;
  --surface: #f4f8fc;
  --card: #ffffff;
  --line: #dbe5f0;
  --brand-a: #0ab8ff;
  --brand-b: #8b5cf6;
  --brand-c: #00d4a0;
  --cta: #0c4ef5;
  --cta-hover: #0a3fc5;
  --radius: 20px;
  --shadow: 0 18px 48px rgba(11, 38, 81, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 10%, rgba(10, 184, 255, 0.18), transparent 24%),
    radial-gradient(circle at 8% 22%, rgba(139, 92, 246, 0.12), transparent 30%),
    linear-gradient(180deg, #f9fbff 0%, var(--surface) 45%, #eef4fb 100%);
  line-height: 1.5;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Header ── */
.container {
  width: min(680px, 92vw);
  margin: 0 auto;
}

header {
  padding: 22px 0;
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  background: rgba(236, 243, 251, 0.94);
  border-bottom: 1px solid rgba(189, 205, 222, 0.9);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  z-index: 20;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand img.brand-wordmark {
  width: auto;
  height: 15px;
  max-width: min(154px, 39vw);
  object-fit: contain;
  transform: translate(-11px, 2px);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
}

.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #d2deec;
  border-radius: 999px;
  background: linear-gradient(180deg, #f8fbff, #edf3fb);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.language-switch {
  color: #5f7088;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.language-select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  background-color: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  padding: 6px 24px 6px 2px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%235f7088' d='M1.2.7 5 4.3 8.8.7 10 1.8 5 6 0 1.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

/* ── Main ── */
main {
  padding: 48px 0 80px;
}

/* ── Panel card ── */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
}

.panel.hidden {
  display: none;
}

.panel h1 {
  margin: 0 0 6px;
  font-family: "Space Grotesk", Manrope, sans-serif;
  font-size: 1.8rem;
}

.lead {
  margin: 0 0 28px;
  color: var(--ink-soft);
}

/* ── Message ── */
.message {
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
  margin-bottom: 20px;
  font-size: 0.93rem;
}

.message.hidden {
  display: none;
}

.message.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.message.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.message.info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 14px;
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

/* ── Form ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.field label {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.field input {
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}

.field input:focus {
  border-color: var(--cta);
}

.terms-check {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 600;
  color: var(--ink-soft);
}

.terms-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cta);
}

.terms-check.is-readonly {
  opacity: 0.65;
}

.terms-check.is-readonly input[type="checkbox"] {
  cursor: not-allowed;
}

.terms-check a {
  color: var(--cta);
  text-decoration: underline;
}

.choice-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.choice-option input[type="radio"] {
  accent-color: var(--cta);
}

.small-hint {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.password-wrap {
  position: relative;
}

.phone-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-country-select {
  width: 108px;
  padding: 11px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}

.phone-country-select:focus {
  border-color: var(--cta);
}

.phone-input-wrap input {
  flex: 1;
}

.password-wrap input {
  width: 100%;
  padding-right: 44px;
}

.toggle-pw {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 4px;
  line-height: 1;
}

.toggle-pw:hover {
  color: var(--ink);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--cta);
  color: #fff;
  width: 100%;
  margin-top: 4px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--cta-hover);
}

.btn-outline {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.subscription-plan-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.subscription-plan-label {
  font-size: 12px;
  color: #666;
  margin-right: 4px;
}

.plan-buy-btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-family: "Space Grotesk", Manrope, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(18, 69, 216, 0.3);
  overflow: hidden;
}

.plan-buy-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(112deg, #0b66ff, #5d44ff 58%, #11c0ff);
  z-index: -2;
}

.plan-buy-btn::after {
  content: "";
  position: absolute;
  top: -10%;
  left: -40%;
  width: 32%;
  height: 120%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: planShine 3.2s ease-in-out infinite;
  z-index: -1;
  pointer-events: none;
}

.plan-buy-btn:hover,
.plan-buy-btn:focus-visible {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 14px 28px rgba(18, 69, 216, 0.36);
  filter: saturate(1.06);
  outline: none;
}

.plan-buy-btn.plan-buy-premium::before {
  background: linear-gradient(112deg, #0f4fff, #6938ff 48%, #00c59a);
}

.plan-buy-btn.is-disabled,
.plan-buy-btn.is-disabled:hover,
.plan-buy-btn.is-disabled:focus-visible {
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.12);
  box-shadow: none;
  opacity: 0.7;
  color: #111;
  outline: none;
}

.plan-buy-btn.is-disabled::before {
  background: linear-gradient(135deg, #e8ebf3, #d7deea);
}

.plan-buy-btn.is-disabled::after {
  animation: none;
  opacity: 0;
}

@keyframes planShine {
  0% { left: -40%; opacity: 0; }
  18% { opacity: 1; }
  48% { left: 130%; opacity: 0.9; }
  100% { left: 130%; opacity: 0; }
}

.link-btn {
  background: none;
  border: none;
  color: var(--cta);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Auth switch ── */
.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 0.93rem;
  color: var(--ink-soft);
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.auth-recovery {
  margin: 2px 0 6px;
}

.forgot-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.forgot-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.forgot-panel .btn {
  width: 100%;
}

.danger-zone {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff5f5;
}

.danger-zone h2 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.danger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

.danger-btn {
  border-color: #ef4444;
  color: #b91c1c;
}

.danger-btn:hover:not(:disabled) {
  background: #fee2e2;
}

/* ── Profile header ── */
.profile-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  font-family: "Space Grotesk", Manrope, sans-serif;
  letter-spacing: -0.01em;
  user-select: none;
}

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

.avatar-upload-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cta);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid #fff;
  transition: background 0.15s;
}

.avatar-upload-btn:hover {
  background: var(--cta-hover);
}

.avatar-remove-btn {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
}

.avatar-remove-btn:hover {
  color: var(--ink);
  border-color: #c7d6e7;
}

.profile-header-text {
  flex: 1;
  min-width: 0;
}

.profile-header-text h1 {
  margin: 0;
  font-size: 1.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-role-badge {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
  font-weight: 600;
}

#logout-btn {
  white-space: nowrap;
}

/* ── Profile form ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.form-grid .field:last-child {
  grid-column: span 2;
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .field:last-child {
    grid-column: span 1;
  }
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.form-actions .btn-primary {
  width: auto;
  flex: 1;
}

#profile-form .form-actions .btn {
  width: auto;
}

.profile-static-value {
  margin: 0;
  min-height: 44px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  display: flex;
  align-items: center;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--line);
  margin: 36px 0;
}

/* ── Appointments ── */
#appointments-section > h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.appointments-subsection + .appointments-subsection {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.appointments-subsection h2 {
  margin: 0 0 4px;
  font-size: 1.02rem;
}

/* ── Memberships ── */
#memberships-section h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

#memberships-open-app-link {
  margin-bottom: 12px;
}

#activity-section h2,
#security-section h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.small-hint {
  margin: 4px 0 0;
  font-size: 0.82rem;
}

.memberships-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.membership-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.membership-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  font-size: 1rem;
}

.membership-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.upcoming-status-stamp,
.visit-status-stamp {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7f1d1d;
  background: #fef2f2;
  border: 1px solid #fecaca;
  flex-shrink: 0;
}

.membership-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.membership-info {
  flex: 1;
  min-width: 0;
}

.membership-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.membership-role {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
}

#activity-toggle-btn {
  margin-top: 12px;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.upcoming-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.upcoming-reschedule {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f8fcff;
  display: grid;
  gap: 8px;
}

.upcoming-reschedule-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.upcoming-reschedule input,
.upcoming-reschedule select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}

.upcoming-reschedule-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .upcoming-reschedule-row {
    grid-template-columns: 1fr;
  }

  .profile-header {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 14px;
  }

  #logout-btn {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
}
