.profile-order-milestones { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0; width: 100%; max-width: 560px; }
.profile-order-milestones li { flex: 1 1 0; min-width: 0; text-align: center; font-size: 11px; line-height: 1.4; }
.profile-order-milestones li > i { display: block; height: 4px; border-radius: 2px; margin-bottom: 7px; background: var(--profile-line, #65717c); }
.profile-order-milestones li.is-complete > i { background: var(--profile-accent, #12a9ef); }
.profile-order-milestones li > span { color: var(--profile-muted, #687583); overflow-wrap: anywhere; }
.profile-order-milestones li[aria-current] > span { color: inherit; font-weight: 700; }
body.profile-page {
  --profile-surface: #141820;
  --profile-surface-soft: #1b2230;
  --profile-line: rgba(148, 163, 184, .2);
  --profile-muted: #97a6ba;
  --profile-accent: #12a9ef;
  height: auto !important;
  min-height: 100dvh !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

html:has(body.profile-page) {
  height: auto !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

@media (min-width: 1181px) {
  html body.profile-page {
    padding: 14px !important;
  }

  html body.profile-page > .topbar {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    margin: 0 0 18px !important;
    transform: none !important;
  }
}

.profile-shell {
  width: min(1480px, 100%);
  margin: 0 auto 32px;
  border: 1px solid var(--profile-line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--profile-surface);
  box-shadow: 0 22px 56px rgba(0, 0, 0, .25);
}

.profile-workspace-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.profile-workspace-links .btn {
  min-width: 0;
  white-space: normal;
}

.profile-hero { border-bottom: 1px solid var(--profile-line); }

.profile-cover {
  position: relative;
  height: clamp(190px, 21vw, 310px);
  overflow: hidden;
  background: #0c111a;
}

.profile-cover__image { width: 100%; height: 100%; object-fit: cover; }
.profile-cover__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: #fff;
  text-align: center;
  background:
    linear-gradient(112deg, rgba(4, 25, 45, .96), rgba(8, 74, 106, .84)),
    url("../img/community-banner-placeholder.svg") center / cover no-repeat;
}
.profile-cover__fallback img { width: 92px; height: 92px; margin: 0 auto; display: block; border-radius: 22px; box-shadow: 0 18px 42px rgba(0,0,0,.3); }
.profile-cover__fallback strong { font-size: 15px; }
body.doctor-context.profile-page .profile-cover { height: 160px; }
body.doctor-context.profile-page .profile-cover__fallback img { width: 52px; height: 52px; }
.profile-cover__actions { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 8px; }
.profile-icon-action,
.profile-avatar-edit {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 6px;
  background: rgba(7, 12, 20, .78);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.profile-identity {
  position: relative;
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) auto;
  align-items: end;
  gap: 22px;
  min-height: 132px;
  padding: 22px 30px 24px;
}
.profile-avatar {
  position: relative;
  z-index: 2;
  align-self: start;
  width: 138px;
  height: 138px;
  margin-top: -78px;
  overflow: hidden;
  border: 5px solid var(--profile-surface);
  border-radius: 50%;
  background: #087fc0;
  color: #fff;
  box-shadow: 0 12px 32px rgba(0,0,0,.3);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar span { display: grid; width: 100%; height: 100%; place-items: center; font-size: 48px; font-weight: 950; }
.profile-avatar-edit { position: absolute; z-index: 3; left: 133px; top: 13px; width: 34px; height: 34px; font-size: 16px; }
.profile-identity__main { min-width: 0; }
.profile-identity__title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.profile-identity__title > div { min-width: 0; }
.profile-identity h1 { margin: 0; overflow-wrap: anywhere; font-size: clamp(24px, 3vw, 35px); line-height: 1.08; }
.profile-identity__title span:not(.profile-role) { color: var(--profile-muted); font-size: 13px; }
.profile-role { flex: 0 0 auto; padding: 6px 9px; border: 1px solid rgba(18,169,239,.32); border-radius: 6px; color: #8edcff; background: rgba(18,169,239,.1); font-size: 11px; font-weight: 800; }
.profile-identity__main > p { margin: 8px 0 0; color: var(--profile-muted); }
.profile-identity__meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 9px; color: var(--profile-muted); font-size: 12px; }
.profile-identity__meta a { color: #71cfff; text-decoration: underline; text-underline-offset: 3px; }
.profile-identity__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.profile-tabs {
  display: flex;
  gap: 2px;
  min-height: 54px;
  padding: 0 26px;
  overflow-x: auto;
  border-bottom: 1px solid var(--profile-line);
  scrollbar-width: thin;
}
.profile-tabs button {
  position: relative;
  flex: 0 0 auto;
  min-height: 54px;
  padding: 0 15px;
  border: 0;
  background: transparent;
  color: var(--profile-muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.profile-tabs button::after { content: ""; position: absolute; right: 12px; bottom: 0; left: 12px; height: 3px; background: transparent; }
.profile-tabs button.is-active { color: var(--text); }
.profile-tabs button.is-active::after { background: var(--profile-accent); }
.profile-tabs button span { margin-left: 4px; color: #6f8198; }

.profile-layout { display: grid; grid-template-columns: 285px minmax(0, 1fr); min-height: 520px; }
.profile-sidebar { border-right: 1px solid var(--profile-line); background: rgba(8, 13, 22, .28); }
.profile-sidebar > section { padding: 22px; border-bottom: 1px solid var(--profile-line); }
.profile-section-title h2,
.profile-panel__head h2 { margin: 0; font-size: 20px; }
.profile-about > p { margin: 13px 0 0; color: #c5d0df; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-about__details { display: grid; gap: 10px; margin: 17px 0 0; }
.profile-about__details > div { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; align-items: start; }
.profile-about__details dt { color: #64cafa; }
.profile-about__details dd { margin: 0; min-width: 0; color: var(--profile-muted); font-size: 12px; overflow-wrap: anywhere; }
.profile-about__details a { color: #79d2fa; }
.profile-statistics { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profile-statistics div { display: grid; gap: 2px; }
.profile-statistics strong { font-size: 20px; }
.profile-statistics span { color: var(--profile-muted); font-size: 11px; }
.profile-shortcuts { display: grid; padding: 8px 0 !important; }
.profile-shortcuts a { display: flex; justify-content: space-between; gap: 10px; padding: 12px 22px; color: #c7d3e2; font-size: 13px; font-weight: 700; }
.profile-shortcuts a:hover { background: rgba(18,169,239,.08); color: #fff; }

.profile-content { position: relative; min-width: 0; padding: 26px; }
.profile-panel { display: none; }
.profile-panel.is-active { display: block; animation: profile-panel-in .18s ease; }
@keyframes profile-panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.profile-panel__head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.profile-panel__head > div > span { display: block; margin-bottom: 4px; color: var(--profile-accent); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.profile-text-action { padding: 7px 0; border: 0; background: transparent; color: #70cef8; font-weight: 800; cursor: pointer; }

.profile-model-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.profile-model-card { position: relative; display: flex; min-width: 0; flex-direction: column; overflow: hidden; border: 1px solid var(--profile-line); border-radius: 8px; background: var(--profile-surface-soft); }
.profile-model-card__media { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; background: #0b111b; }
.profile-model-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .22s ease; }
.profile-model-card:hover .profile-model-card__media img { transform: scale(1.025); }
.profile-model-card__placeholder { display: grid; width: 100%; height: 100%; place-items: center; color: #6c7c91; font-size: 32px; font-weight: 950; }
.profile-model-card__badge { position: absolute; left: 8px; top: 8px; max-width: calc(100% - 16px); padding: 5px 8px; overflow: hidden; border-radius: 5px; background: rgba(5,10,18,.78); color: #fff; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.profile-model-card__body { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 10px; padding: 12px; }
.profile-model-card__title { display: -webkit-box; min-height: 38px; overflow: hidden; color: var(--text); font-weight: 850; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.profile-model-card__stats { display: flex; flex-wrap: wrap; gap: 9px; color: var(--profile-muted); font-size: 10px; }
.profile-model-card__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.profile-model-card__actions .btn { min-width: 0; flex: 1 1 auto; padding-inline: 8px; }

.profile-list { display: grid; gap: 10px; }
.profile-list-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 15px; border: 1px solid var(--profile-line); border-radius: 8px; background: var(--profile-surface-soft); }
.profile-list-item__main { display: grid; min-width: 0; gap: 5px; }
.profile-list-item__main strong { overflow-wrap: anywhere; }
.profile-list-item__main span,
.profile-list-item__main small { color: var(--profile-muted); font-size: 11px; line-height: 1.45; }
.profile-list-item__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.profile-status { width: max-content; max-width: 100%; padding: 5px 8px; border-radius: 5px; background: rgba(18,169,239,.1); color: #83d8ff; font-size: 10px; font-style: normal; font-weight: 850; }
.profile-status--success { background: rgba(34,197,94,.11); color: #86efac; }
.profile-status--warning { background: rgba(245,158,11,.12); color: #fde68a; }
.profile-status--danger { background: rgba(244,63,94,.12); color: #fda4af; }

.profile-favorites-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.profile-favorite { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; min-width: 0; padding: 10px; border: 1px solid var(--profile-line); border-radius: 8px; background: var(--profile-surface-soft); }
.profile-favorite__image { display: grid; width: 96px; aspect-ratio: 1; overflow: hidden; place-items: center; border-radius: 6px; background: #0b111b; color: #607086; font-weight: 900; }
.profile-favorite__image img { width: 100%; height: 100%; object-fit: cover; }
.profile-favorite__body { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.profile-favorite__body > span { color: var(--profile-muted); font-size: 10px; }
.profile-favorite__body > a { display: -webkit-box; overflow: hidden; font-weight: 800; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.profile-favorite__body strong { margin-top: auto; color: #61cef9; }
.profile-favorite__body button { align-self: start; padding: 0; border: 0; background: transparent; color: #fbbf24; font-weight: 900; cursor: pointer; }

.profile-order-list .profile-list-item { align-items: start; }
.profile-order-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; width: min(420px, 100%); margin-top: 5px; }
.profile-order-progress i { height: 4px; border-radius: 2px; background: #30394a; }
.profile-order-progress i.is-complete { background: var(--profile-accent); }
.profile-order-details { margin-top: 5px; }
.profile-order-details summary { color: #76d2fb; font-size: 11px; cursor: pointer; }
.profile-order-details pre { max-height: 190px; overflow: auto; padding: 10px; border-radius: 6px; background: #0d131d; color: #aebcd0; font: 11px/1.45 ui-monospace, monospace; white-space: pre-wrap; }

.profile-settings-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--profile-line); }
.profile-settings-summary > div { display: grid; gap: 5px; min-width: 0; padding: 18px 0; border-bottom: 1px solid var(--profile-line); }
.profile-settings-summary > div:nth-child(odd) { padding-right: 20px; }
.profile-settings-summary > div:nth-child(even) { padding-left: 20px; border-left: 1px solid var(--profile-line); }
.profile-settings-summary span { color: var(--profile-muted); font-size: 11px; }
.profile-settings-summary strong { overflow-wrap: anywhere; }
.profile-settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.profile-empty { grid-column: 1 / -1; display: grid; min-height: 180px; place-content: center; gap: 6px; padding: 24px; border: 1px dashed var(--profile-line); border-radius: 8px; color: var(--profile-muted); text-align: center; }
.profile-empty b { color: var(--text); }
.profile-loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; background: var(--profile-surface); color: var(--profile-muted); }
.profile-loading span { width: 34px; height: 34px; margin: 0 auto; border: 3px solid rgba(18,169,239,.2); border-top-color: var(--profile-accent); border-radius: 50%; animation: profile-spin .75s linear infinite; }
@keyframes profile-spin { to { transform: rotate(360deg); } }

.profile-dialog { position: fixed; z-index: 2147483500; inset: 0; display: grid; place-items: center; padding: 18px; }
.profile-dialog__backdrop { position: absolute; inset: 0; background: rgba(2,6,12,.76); backdrop-filter: blur(5px); }
.profile-dialog__window { position: relative; width: min(820px, 100%); max-height: calc(100dvh - 36px); overflow: auto; border: 1px solid var(--profile-line); border-radius: 8px; background: #151a23; box-shadow: 0 28px 70px rgba(0,0,0,.48); }
.profile-dialog__window > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--profile-line); }
.profile-dialog__window > header span { color: var(--profile-accent); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.profile-dialog__window h2 { margin: 3px 0 0; font-size: 21px; }
.profile-dialog__window > header button { width: 36px; height: 36px; border: 1px solid var(--profile-line); border-radius: 6px; background: var(--profile-surface-soft); color: var(--text); font-size: 22px; cursor: pointer; }
.profile-dialog form { padding: 20px; }
.profile-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profile-form-grid label { display: grid; min-width: 0; gap: 6px; color: var(--profile-muted); font-size: 11px; font-weight: 700; }
.profile-form-grid__wide { grid-column: 1 / -1; }
.profile-handle-input { position: relative; }
.profile-handle-input i { position: absolute; z-index: 1; left: 12px; top: 50%; transform: translateY(-50%); color: var(--profile-muted); font-style: normal; }
.profile-handle-input input { padding-left: 30px; }
.profile-dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.profile-toast { position: fixed; z-index: 2147483600; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid rgba(18,169,239,.35); border-radius: 7px; background: #101824; color: #e8f6ff; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease; }
.profile-toast.is-visible { opacity: 1; transform: none; }

body[data-theme="light"].profile-page,
html[data-theme="light"] body.profile-page {
  --profile-surface: #fff;
  --profile-surface-soft: #f5f7fa;
  --profile-line: #dbe2eb;
  --profile-muted: #667386;
}
body[data-theme="light"] .profile-cover__fallback { background: #0c668f url("../img/community-banner-placeholder.svg") center / cover no-repeat; }
body[data-theme="light"] .profile-sidebar { background: #f8fafc; }
body[data-theme="light"] .profile-about > p { color: #344155; }
body[data-theme="light"] .profile-dialog__window { background: #fff; }
body[data-theme="light"] .profile-order-details pre { background: #edf1f6; color: #344155; }
body[data-theme="light"] .profile-toast { background: #fff; color: #162033; }

@media (max-width: 1180px) {
  html body.profile-page > .topbar {
    z-index: 2147482000 !important;
    isolation: isolate;
  }

  html body.user-mode.profile-page > .topbar.is-menu-open,
  html body.user-mode.profile-page > .topbar[data-mobile-menu-open="true"],
  html body.admin-mode.profile-page > .topbar.is-menu-open,
  html body.admin-mode.profile-page > .topbar[data-mobile-menu-open="true"] {
    height: auto !important;
    min-height: 64px !important;
    max-height: calc(100dvh - 16px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  html body.user-mode.profile-page > .topbar.is-menu-open #site-main-nav,
  html body.user-mode.profile-page > .topbar[data-mobile-menu-open="true"] #site-main-nav,
  html body.admin-mode.profile-page > .topbar.is-menu-open #site-main-nav,
  html body.admin-mode.profile-page > .topbar[data-mobile-menu-open="true"] #site-main-nav {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  html body.user-mode.profile-page > .topbar.is-menu-open #topbar-actions,
  html body.user-mode.profile-page > .topbar[data-mobile-menu-open="true"] #topbar-actions,
  html body.admin-mode.profile-page > .topbar.is-menu-open #topbar-actions,
  html body.admin-mode.profile-page > .topbar[data-mobile-menu-open="true"] #topbar-actions {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body.profile-page.is-mobile-menu-open {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  .profile-model-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .profile-favorites-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .profile-identity { grid-template-columns: 112px minmax(0, 1fr); align-items: start; padding-inline: 20px; }
  .profile-avatar { width: 108px; height: 108px; margin-top: -58px; }
  .profile-avatar-edit { left: 92px; top: 15px; }
  .profile-identity__actions { grid-column: 1 / -1; justify-content: flex-start; }
  .profile-layout { grid-template-columns: 225px minmax(0, 1fr); }
  .profile-sidebar > section { padding: 18px; }
  .profile-content { padding: 20px; }
  .profile-model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  body.profile-page { padding-inline: 8px; }
  .profile-shell { border-right: 0; border-left: 0; }
  .profile-cover { height: 175px; }
  .profile-cover__actions { right: 10px; bottom: 10px; }
  .profile-identity { grid-template-columns: 84px minmax(0, 1fr); gap: 13px; padding: 15px 14px 18px; }
  .profile-avatar { width: 82px; height: 82px; margin-top: -44px; border-width: 4px; }
  .profile-avatar span { font-size: 29px; }
  .profile-avatar-edit { left: 71px; top: 4px; width: 30px; height: 30px; }
  .profile-identity__title { align-items: flex-start; }
  .profile-identity__title { flex-direction: column; gap: 6px; }
  .profile-identity h1 { font-size: 23px; }
  .profile-identity__meta { display: grid; gap: 5px; }
  .profile-identity__actions .btn { flex: 1 1 150px; }
  .profile-tabs { min-height: 48px; padding: 0 8px; }
  .profile-tabs button { min-height: 48px; padding-inline: 12px; }
  .profile-layout { display: block; }
  .profile-sidebar { border-right: 0; border-bottom: 1px solid var(--profile-line); }
  .profile-sidebar > section { padding: 16px; }
  .profile-sidebar .profile-statistics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .profile-shortcuts { display: none; }
  .profile-content { padding: 17px 12px 24px; }
  .profile-panel__head { align-items: center; }
  .profile-model-grid,
  .profile-favorites-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .profile-model-card__body { padding: 10px; }
  .profile-model-card__actions { display: grid; }
  .profile-list-item { grid-template-columns: 1fr; }
  .profile-list-item__actions { justify-content: flex-start; }
  .profile-list-item__actions .btn { flex: 1 1 130px; }
  .profile-favorite { grid-template-columns: 74px minmax(0, 1fr); padding: 8px; }
  .profile-favorite__image { width: 74px; }
  .profile-settings-summary { grid-template-columns: 1fr; }
  .profile-settings-summary > div,
  .profile-settings-summary > div:nth-child(odd),
  .profile-settings-summary > div:nth-child(even) { padding: 14px 0; border-left: 0; }
  .profile-form-grid { grid-template-columns: 1fr; }
  .profile-form-grid__wide { grid-column: auto; }
  .profile-dialog { padding: 0; }
  .profile-dialog__window { width: 100%; height: 100dvh; max-height: none; border-radius: 0; }
}

@media (max-width: 460px) {
  .profile-cover { height: 148px; }
  .profile-cover__fallback img { width: 72px; height: 72px; border-radius: 18px; }
  .profile-sidebar .profile-statistics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-model-grid,
  .profile-favorites-grid { grid-template-columns: 1fr; }
  .profile-model-grid--latest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-model-grid--latest .profile-model-card:nth-child(n+3) { display: none; }
  .profile-model-card__actions .btn { min-height: 34px; }
  .profile-favorite { grid-template-columns: 88px minmax(0, 1fr); }
  .profile-favorite__image { width: 88px; }
}
