:root {
  --profile-bg: #f3f7fa;
  --profile-ink: #17213a;
  --profile-muted: #64748b;
  --profile-border: #dbe4ec;
  --profile-primary: #172d6b;
  --profile-accent: #0f8f7b;
  --profile-danger: #b42318;
  --profile-surface: #fff;
  --profile-shadow: 0 14px 38px rgba(23, 45, 107, 0.08);
}

* { box-sizing: border-box; }
body.profile-page { margin: 0; min-width: 320px; background: linear-gradient(180deg, #edf6f7 0, var(--profile-bg) 320px); color: var(--profile-ink); font-family: var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.profile-header { min-height: 76px; padding: 10px max(24px, calc((100% - 1180px) / 2)); background: rgba(255, 255, 255, 0.94); border-bottom: 1px solid var(--profile-border); display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px); }
.profile-brand { display: flex; align-items: center; gap: 11px; color: var(--profile-primary); text-decoration: none; }
.profile-brand img { width: 48px; height: 48px; object-fit: contain; }
.profile-brand span { display: grid; line-height: 1.2; }
.profile-brand strong { font-size: 1rem; }
.profile-brand small { margin-top: 3px; color: var(--profile-muted); font-size: 0.72rem; font-weight: 600; }
.profile-header__actions { display: flex; align-items: center; gap: 8px; }
.profile-icon-link { min-height: 44px; padding: 9px 13px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--profile-primary); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font: inherit; font-size: 0.84rem; font-weight: 700; text-decoration: none; transition: background-color .2s ease, border-color .2s ease; }
.profile-icon-link:hover { background: #f3f6fb; border-color: var(--profile-border); }
.profile-container { width: min(1180px, calc(100% - 32px)); margin: 36px auto 56px; }
.profile-hero { min-height: 142px; padding: 28px 32px; border: 1px solid rgba(23, 45, 107, .08); border-radius: 22px; background: linear-gradient(135deg, var(--profile-primary), #205c73); color: #fff; display: flex; align-items: center; gap: 20px; box-shadow: var(--profile-shadow); }
.profile-avatar-panel { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.profile-avatar { position: relative; width: 88px; height: 88px; flex: 0 0 88px; overflow: hidden; border: 3px solid rgba(255,255,255,.82); border-radius: 50%; background: linear-gradient(145deg, #fff, #c7f1ea); color: var(--profile-primary); display: grid; place-items: center; font-size: 1.8rem; font-weight: 800; box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.profile-avatar__image { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-controls { display: grid; gap: 6px; min-width: 110px; }
.profile-avatar-button { min-height: 32px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.45); border-radius: 8px; background: rgba(255,255,255,.15); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font: inherit; font-size: .76rem; font-weight: 750; transition: background-color .2s ease, border-color .2s ease, transform .2s ease; }
.profile-avatar-button:hover { border-color: rgba(255,255,255,.8); background: rgba(255,255,255,.28); transform: translateY(-1px); }
.profile-avatar-button--remove { border-color: rgba(255,196,190,.65); color: #ffe4e0; }
.profile-avatar-controls small { max-width: 132px; color: rgba(255,255,255,.7); font-size: .66rem; line-height: 1.35; }
.profile-identity { min-width: 0; flex: 1; }
.profile-identity h1 { margin: 3px 0 8px; color: #fff; font-size: clamp(1.55rem, 3vw, 2.15rem); }
.profile-identity p { margin: 0; color: rgba(255,255,255,.82); }
.profile-identity strong { color: #fff; }
.eyebrow { margin: 0; color: #b8f1e7 !important; text-transform: uppercase; font-size: .72rem; font-weight: 800; letter-spacing: .11em; }
.role-badge { padding: 7px 13px; border: 1px solid rgba(255,255,255,.36); border-radius: 999px; background: rgba(255,255,255,.13); color: #fff; font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.profile-layout { margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .8fr); gap: 24px; align-items: start; }
.profile-sidebar { display: grid; gap: 24px; }
.profile-card { padding: 26px; border: 1px solid var(--profile-border); border-radius: 18px; background: var(--profile-surface); box-shadow: 0 8px 26px rgba(23,45,107,.055); }
.card-heading { margin-bottom: 24px; display: flex; align-items: flex-start; gap: 13px; }
.card-heading--compact { margin-bottom: 20px; }
.card-heading__icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; background: #eaf2ff; color: var(--profile-primary); display: grid; place-items: center; }
.card-heading__icon--danger { background: #fff0ee; color: var(--profile-danger); }
.card-heading h2 { margin: 0 0 5px; color: var(--profile-ink); font-size: 1.08rem; }
.card-heading p { margin: 0; color: var(--profile-muted); font-size: .84rem; line-height: 1.5; }
.profile-form { display: grid; gap: 18px; }
.profile-form label { display: grid; gap: 7px; color: #293550; font-size: .87rem; font-weight: 600; }
.profile-form input, .profile-form select { width: 100%; min-height: 46px; border: 1px solid #b8c5d8; border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--profile-ink); font: inherit; font-weight: 400 !important; line-height: 1.45; transition: border-color .2s ease, box-shadow .2s ease; }
.profile-form input:focus, .profile-form select:focus, button:focus { outline: none !important; border-color: #3b82f6 !important; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18) !important; }
.required-star { color: #ef4444; margin-left: 2px; font-weight: bold; }
.profile-form input[readonly] { background: #f4f6f8; color: var(--profile-muted); cursor: not-allowed; }
.profile-form small, .fieldset-note { margin: 0; color: var(--profile-muted); font-size: .76rem; font-weight: 500; line-height: 1.5; }
.profile-form fieldset { min-width: 0; padding: 20px; border: 1px solid var(--profile-border); border-radius: 14px; background: #fbfcfe; display: grid; gap: 16px; }
.profile-form legend { padding: 0 7px; color: var(--profile-primary); font-size: .9rem; font-weight: 800; }
.profile-form a { color: var(--profile-primary); }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.form-actions { display: flex; justify-content: flex-end; }
.btn { min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; cursor: pointer; font: inherit; font-size: .86rem; font-weight: 750; }
.btn-primary { background: var(--profile-primary); color: #fff; }
.btn-secondary { background: #eaf2ff; color: var(--profile-primary); border-color: #cad8ed; }
.btn-danger-outline { width: 100%; background: #fff; color: var(--profile-danger); border-color: #efb4ae; }
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .55; cursor: wait; }
.danger-zone { border-color: #f0cbc7; }
.form-status { min-height: 24px; margin: 16px 0 -8px; color: var(--profile-muted); font-size: .86rem; }
.form-status:empty { min-height: 0; margin: 0; }
.form-status.error, .field-status { color: var(--profile-danger); }
.field-status { margin: 0; font-size: .8rem; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: grid; gap: 10px; }
.toast { max-width: min(360px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 10px; background: #166534; color: #fff; box-shadow: 0 12px 30px rgba(15,23,42,.24); }
.toast.error { background: var(--profile-danger); }
.skip-link { position: fixed; left: 12px; top: -90px; z-index: 1000; padding: 10px 14px; border-radius: 8px; background: #fff; color: var(--profile-primary); }
.skip-link:focus { top: 12px; }
.profile-page :focus-visible { outline: 3px solid rgba(15,143,123,.4); outline-offset: 3px; }

.membership-application { margin-top: 24px; }
.membership-current-status { margin: -6px 0 20px; padding: 13px 15px; border: 1px solid #bfdbfe; border-radius: 10px; background: #eff6ff; color: #1e3a8a; font-size: .9rem; font-weight: 650; }
.membership-current-status.error { border-color: #fecaca; background: #fef2f2; color: var(--profile-danger); }
.membership-form textarea { width: 100%; min-height: 96px; resize: vertical; border: 1px solid #b8c5d8; border-radius: 10px; padding: 10px 12px; color: var(--profile-ink); font: inherit; font-weight: 400; }
.membership-form input[type="file"] { min-height: 46px; padding: 7px; background: #fff; cursor: pointer; }
.membership-form input[type="file"]::file-selector-button { margin-right: 10px; padding: 8px 12px; border: 0; border-radius: 7px; background: #eaf2ff; color: var(--profile-primary); cursor: pointer; font: inherit; font-size: .78rem; font-weight: 750; }
.membership-form input[type="file"]::file-selector-button:hover { background: #dbe8ff; }
.membership-type-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.membership-type-options > label { min-height: 76px; padding: 14px; border: 1px solid var(--profile-border); border-radius: 12px; display: flex; grid-template-columns: auto 1fr; align-items: flex-start; gap: 10px; cursor: pointer; }
.membership-type-options > label:has(input:checked) { border-color: var(--profile-primary); background: #f1f5ff; box-shadow: 0 0 0 2px rgba(23,45,107,.1); }
.membership-type-options input, .membership-consent input { width: 20px; min-height: 20px; margin: 1px 0 0; accent-color: var(--profile-primary); }
.membership-type-options span { display: grid; gap: 4px; }
.membership-type-options small { display: block; }
.membership-consent { padding: 14px; border-radius: 10px; background: #f8fafc; display: flex !important; grid-template-columns: auto 1fr; align-items: flex-start; gap: 10px !important; line-height: 1.5; }
.membership-history { margin-top: 24px; }
.membership-history h3 { margin: 0 0 12px; font-size: 1rem; }
.membership-history-list { display: grid; gap: 12px; }
.membership-history-list article { padding: 16px; border: 1px solid var(--profile-border); border-radius: 12px; background: #fbfcfe; }
.membership-history-list article > div { display: flex; justify-content: space-between; gap: 12px; }
.membership-history-list time { color: var(--profile-muted); font-size: .78rem; }
.membership-history-list p { margin: 10px 0 0; line-height: 1.5; }
.membership-history-list .btn { width: fit-content; margin-top: 12px; text-decoration: none; }
.membership-reject-reason { color: var(--profile-danger); }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; }
  .profile-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .profile-header { padding: 9px 14px; }
  .profile-brand small, .profile-icon-link span { display: none; }
  .profile-icon-link { width: 44px; padding: 9px; justify-content: center; }
  .profile-container { width: min(100% - 24px, 1180px); margin-top: 20px; }
  .profile-hero { padding: 22px 20px; border-radius: 18px; align-items: flex-start; flex-wrap: wrap; }
  .profile-avatar-panel { width: 100%; align-items: flex-start; }
  .profile-avatar { width: 72px; height: 72px; flex-basis: 72px; font-size: 1.4rem; }
  .profile-avatar-controls { min-width: 130px; }
  .role-badge { margin-left: 0; margin-top: 0; }
  .profile-card { padding: 20px; }
  .profile-grid, .profile-sidebar { grid-template-columns: 1fr; }
  .profile-form fieldset { padding: 16px; }
  .form-actions .btn { width: 100%; }
  .membership-type-options { grid-template-columns: 1fr; }
  .membership-history-list article > div { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  .profile-icon-link, .profile-form input, .profile-form select { transition: none; }
}
