.portal-page { min-height: 100vh; background: linear-gradient(180deg, var(--hero-from) 0, var(--surface-soft) 50%, var(--hero-end) 100%); }
.portal-header { position: relative; }
.portal-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.portal-nav a { padding: 9px 11px; color: var(--ink-soft); border-radius: 8px; font-size: .88rem; font-weight: 680; text-decoration: none; }
.portal-nav a:hover, .portal-nav a[aria-current="page"] { color: var(--ink-deep); background: var(--tint); }
.auth-layout { min-height: calc(100vh - 150px); display: grid; grid-template-columns: minmax(0, .92fr) minmax(430px, .78fr); align-items: center; gap: clamp(55px, 10vw, 130px); padding-block: clamp(56px, 8vw, 100px); }
.auth-layout > *, .auth-card { min-width: 0; }
.register-layout { align-items: start; }
.auth-intro h1 { max-width: 680px; margin-bottom: 24px; font-size: clamp(3rem, 5.5vw, 5.25rem); letter-spacing: -.06em; }
.auth-intro > p { max-width: 650px; font-size: 1.08rem; }
.auth-benefits { display: grid; gap: 1px; margin-top: 36px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 15px; }
.auth-benefits > div { display: grid; grid-template-columns: 43px 1fr; gap: 15px; padding: 18px; background: var(--glass-surface); }
.auth-benefits > div > span { width: 35px; height: 35px; display: grid; place-items: center; color: var(--teal-dark); background: var(--teal-soft); border-radius: 9px; font-size: .72rem; font-weight: 800; }
.auth-benefits p { margin: 0; font-size: .82rem; line-height: 1.55; }
.auth-benefits strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: .86rem; }
.auth-safety { display: grid; grid-template-columns: auto 1fr; gap: 12px; margin-top: 20px; padding: 15px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.auth-safety .icon { color: var(--teal); }
.auth-safety p { margin: 0; font-size: .78rem; }
.auth-safety strong { color: var(--ink); }
.auth-card { padding: clamp(27px, 4vw, 42px); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 22px; box-shadow: var(--shadow-lg); }
.card-heading { margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.card-heading .eyebrow { margin-bottom: 8px; }
.card-heading h2 { margin-bottom: 7px; font-size: 2rem; }
.card-heading p { margin: 0; font-size: .84rem; }
.notice { margin-bottom: 20px; padding: 13px 15px; border: 1px solid; border-radius: 10px; font-size: .82rem; }
.notice ul { margin: 0; padding-left: 20px; }
.notice-error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.notice-success { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.notice-warning { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.auth-card form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--ink); font-size: .8rem; font-weight: 750; }
.field input { width: 100%; min-height: 50px; padding: 11px 13px; color: var(--ink-deep); background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: 10px; outline: none; }
.field input:focus { background: var(--paper); border-color: var(--teal); box-shadow: 0 0 0 4px rgba(8,127,122,.1); }
.field input::placeholder { color: var(--muted); }
.field small, .password-note { color: var(--muted); font-size: .72rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.password-note { display: block; margin-top: -7px; }
.honeypot { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important; }
.honeypot label, .honeypot input { width: 1px !important; min-width: 0 !important; height: 1px !important; padding: 0 !important; border: 0 !important; }
.auth-submit { min-height: 52px; margin-top: 3px; }
.terms-line { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: start; color: var(--muted); font-size: .77rem; }
.terms-line input { width: 17px; height: 17px; margin: 3px 0 0; accent-color: var(--teal); }
.terms-line a, .card-footer a { color: var(--teal-dark); font-weight: 700; }
.create-account-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 25px; padding-top: 22px; border-top: 1px solid var(--line); }
.create-account-panel strong { display: block; color: var(--ink); font-size: .86rem; }
.create-account-panel p { margin: 2px 0 0; font-size: .74rem; }
.create-account-panel > a { display: inline-flex; align-items: center; gap: 7px; color: var(--teal-dark); font-size: .8rem; font-weight: 780; text-decoration: none; white-space: nowrap; }
.card-footer { margin-top: 22px; padding-top: 19px; border-top: 1px solid var(--line); text-align: center; }
.card-footer p { margin: 0; font-size: .8rem; }
.portal-footer { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding-block: 22px; color: var(--muted); border-top: 1px solid var(--line); font-size: .72rem; }
.portal-footer div { display: flex; gap: 17px; }
.portal-footer a { text-decoration: none; }
.portal-footer a:hover { color: var(--teal-dark); }

/* Account profile */
.profile-layout { padding-block: 45px 80px; }
.profile-top { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.profile-identity { display: flex; align-items: center; gap: 18px; }
.profile-identity img { width: 78px; height: 78px; object-fit: cover; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-sm); }
.profile-identity .eyebrow { margin-bottom: 5px; }
.profile-identity h1 { margin: 0 0 3px; font-size: clamp(2.2rem, 4vw, 3.8rem); }
.profile-identity p { margin: 0; font-size: .84rem; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-download-actions { margin-top: 18px; }
.profile-grid { display: grid; grid-template-columns: 1.25fr .75fr; align-items: start; gap: 18px; }
.profile-stack { display: grid; gap: 18px; }
.profile-grid > *, .profile-stack, .profile-card, .order-table-wrap { min-width: 0; }
.profile-card { padding: 26px; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow-sm); }
.profile-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.profile-card-head h2 { margin: 0 0 5px; font-size: 1.3rem; }
.profile-card-head p { margin: 0; font-size: .78rem; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid; border-radius: 99px; font-size: .68rem; font-weight: 800; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.status-active, .status-paid, .status-completed { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.status-pending, .status-invoice-open, .status-partial { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.status-neutral, .status-failed, .status-expired { color: var(--muted); background: var(--surface-subtle); border-color: var(--line-strong); }
.subscription-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.subscription-summary > div { padding: 16px; background: var(--canvas); border: 1px solid var(--line); border-radius: 11px; }
.subscription-summary dt { color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.subscription-summary dd { margin: 6px 0 0; color: var(--ink); font-size: .87rem; font-weight: 730; overflow-wrap: anywhere; }
.profile-empty { padding: 23px; color: var(--ink-soft); background: var(--canvas); border: 1px dashed var(--line-strong); border-radius: 11px; text-align: center; }
.profile-empty strong { display: block; margin-bottom: 5px; color: var(--ink); }
.profile-empty p { margin: 0 0 14px; font-size: .8rem; }
.order-table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.order-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: .76rem; }
.order-table th, .order-table td { padding: 12px 10px; color: var(--ink-soft); border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.order-table thead th { color: var(--muted); font-size: .64rem; letter-spacing: .05em; text-transform: uppercase; }
.order-table tbody th { max-width: 170px; overflow: hidden; color: var(--ink); font-family: ui-monospace, monospace; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.order-table tr:last-child > * { border-bottom: 0; }
.quick-links { display: grid; gap: 8px; }
.quick-link { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 15px; padding: 14px; color: var(--ink); background: var(--canvas); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.quick-link strong { font-size: .82rem; }
.quick-link span { display: block; margin-top: 2px; color: var(--muted); font-size: .69rem; }
.quick-link > span:last-child { margin: 0; color: var(--teal); font-size: 1rem; }
.avatar-settings { display: grid; gap: 13px; }
.avatar-settings summary { color: var(--teal-dark); font-size: .78rem; font-weight: 750; cursor: pointer; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding-top: 12px; }
.avatar-option { position: relative; cursor: pointer; }
.avatar-option input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-option > span { display: grid; place-items: center; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; }
.avatar-option img { width: 58px; height: 58px; border-radius: 9px; }
.avatar-option strong { overflow: hidden; max-width: 100%; color: var(--muted); font-size: .56rem; text-overflow: ellipsis; white-space: nowrap; }
.avatar-option input:checked + span { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,122,.1); }
.avatar-submit { width: 100%; min-height: 42px; }
.account-facts { display: grid; gap: 9px; margin: 0; }
.account-facts > div { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.account-facts > div:last-child { border-bottom: 0; }
.account-facts dt { color: var(--muted); font-size: .7rem; }
.account-facts dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: .76rem; font-weight: 680; }

@media (max-width: 920px) {
  .portal-nav { display: none; }
  .portal-header .theme-slot { margin-left: auto; }
  .auth-layout, .profile-grid { grid-template-columns: 1fr; }
  .auth-layout { max-width: 760px; }
  .auth-intro h1 { font-size: clamp(2.8rem, 9vw, 4.5rem); }
  .profile-top { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 620px) {
  .auth-layout { padding-block: 38px 60px; }
  .auth-intro h1 { font-size: clamp(2.35rem, 11vw, 3.4rem); overflow-wrap: anywhere; }
  .auth-card { padding: 23px; border-radius: 17px; }
  .field-row, .subscription-summary { grid-template-columns: 1fr; }
  .create-account-panel { align-items: flex-start; flex-direction: column; }
  .portal-footer { align-items: flex-start; flex-direction: column; }
  .profile-identity { align-items: flex-start; }
  .profile-identity img { width: 62px; height: 62px; }
  .profile-actions, .profile-actions .button { width: 100%; }
  .avatar-grid { grid-template-columns: repeat(2, 1fr); }
}

/* v5.3 dark account surfaces */
:root[data-theme="dark"] .portal-page {
  background-image:
    radial-gradient(circle at 88% 5%, rgba(124, 92, 252, .09), transparent 31rem),
    radial-gradient(circle at 8% 18%, rgba(49, 214, 232, .06), transparent 27rem),
    linear-gradient(180deg, var(--hero-from), var(--surface-soft) 52%, var(--hero-end));
}
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .profile-card {
  background-color: var(--paper);
  background-image: linear-gradient(145deg, rgba(255, 255, 255, .025), transparent 46%);
  border-color: var(--line);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .24);
}
:root[data-theme="dark"] .auth-safety,
:root[data-theme="dark"] .quick-link,
:root[data-theme="dark"] .subscription-summary > div,
:root[data-theme="dark"] .profile-empty { background-color: #080f1d; }
:root[data-theme="dark"] .quick-link:hover {
  background-color: #101c2f;
  border-color: #4b658e;
}
:root[data-theme="dark"] .field input:focus {
  background: #0b1423;
  border-color: #31b7ca;
  box-shadow: 0 0 0 4px rgba(49, 214, 232, .11), 0 10px 28px rgba(0, 0, 0, .15);
}
:root[data-theme="dark"] .profile-identity img {
  border-color: #49658e;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}

@media (max-width: 420px) {
  .profile-identity { width: 100%; }
  .profile-identity > div { min-width: 0; }
  .profile-identity h1, .profile-identity p { overflow-wrap: anywhere; }
  .profile-card { padding: 21px; }
}
