.portal-body {
  margin: 0;
  background: var(--mt-color-background-canvas);
  color: var(--mt-color-text-primary);
}
.portal-body .site-header,
.portal-body .site-footer,
.portal-body > .site-backdrop { display: none; }
.portal-body .app-shell,
.portal-body .page { width: 100%; max-width: none; margin: 0; padding: 0; }
.portal-body .page { min-height: 100vh; min-height: 100dvh; }
.portal svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.portal h1,
.portal h2,
.portal h3,
.portal p { margin-top: 0; }
.portal h1 { font-size: clamp(2rem, 4vw, 3.8rem); line-height: 1.02; letter-spacing: -.05em; }
.portal h2 { font-size: clamp(1.55rem, 2.3vw, 2.15rem); line-height: 1.1; letter-spacing: -.035em; }
.portal h3 { margin-bottom: 14px; font-size: 1.08rem; }
.portal p { color: var(--mt-color-text-secondary); line-height: 1.6; }
.portal-kicker { margin-bottom: 8px !important; color: var(--mt-color-action-primary) !important; font-size: .72rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.portal-brand { display: inline-flex; align-items: center; gap: 11px; color: var(--mt-color-text-primary); font-size: .92rem; font-weight: 800; letter-spacing: .1em; text-decoration: none; }
.portal-brand__mark { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--mt-color-border-strong); border-radius: var(--mt-radius-compact); color: var(--mt-color-action-primary); background: var(--mt-color-action-primary-soft); }

.portal-auth { display: grid; min-height: 100vh; min-height: 100dvh; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); grid-template-rows: auto 1fr; gap: 30px 7vw; padding: clamp(24px, 5vw, 72px); background: var(--mt-color-background-canvas); }
.portal-auth > .portal-brand { grid-column: 1 / -1; align-self: start; }
.portal-auth__intro { max-width: 720px; align-self: center; }
.portal-auth__intro h1 { max-width: 13ch; margin-bottom: 24px; }
.portal-auth__intro > p { max-width: 62ch; }
.portal-auth__intro ul { display: grid; gap: 12px; margin: 30px 0 0; padding: 0; list-style: none; }
.portal-auth__intro li { position: relative; padding-left: 26px; color: var(--mt-color-text-secondary-strong); }
.portal-auth__intro li::before { position: absolute; left: 0; top: .3em; width: 15px; height: 15px; border: 1px solid var(--mt-color-status-success); border-radius: 50%; content: ""; }
.portal-auth__card { width: min(100%, 480px); align-self: center; justify-self: end; padding: clamp(26px, 4vw, 42px); border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-radius-panel); background: var(--mt-color-background-surface); box-shadow: var(--mt-shadow-surface); }
.portal-form { display: grid; gap: 18px; }
.portal-form > div:first-child { margin-bottom: 4px; }
.portal-form h2 { margin-bottom: 0; }
.portal-form label { display: grid; gap: 8px; }
.portal-form label > span { color: var(--mt-color-text-secondary-strong); font-size: .8rem; font-weight: 600; }
.portal-form input { width: 100%; min-height: var(--mt-field-height); padding: 0 15px; border: 1px solid var(--mt-color-border-strong); border-radius: var(--mt-field-radius); color: var(--mt-color-text-primary); background: var(--mt-color-background-subtle); font: inherit; }
.portal-form input:focus { outline: 3px solid var(--mt-color-focus-soft); border-color: var(--mt-color-focus); }
.portal-form .button { width: 100%; min-height: var(--mt-button-height); }
.portal-form .button--primary { color: var(--mt-component-portal-on-action); background: var(--mt-component-portal-action-background); }
.portal-link-button { min-height: 42px; padding: 0; border: 0; color: var(--mt-color-action-primary); background: transparent; font: inherit; font-size: .85rem; font-weight: 650; cursor: pointer; }
.portal-feedback { min-height: 1.4em; margin: 14px 0 0; color: var(--mt-color-text-secondary); font-size: .82rem; }
.portal-feedback:not(:empty) { padding: 10px 12px; border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-radius-compact); background: var(--mt-color-background-subtle); }

.portal-shell { min-height: 100vh; min-height: 100dvh; }
.portal-sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; display: flex; width: var(--mt-nav-width); flex-direction: column; padding: 28px 16px 20px; border-right: 1px solid var(--mt-color-border-subtle); background: var(--mt-color-background-subtle); }
.portal-sidebar > .portal-brand { padding-inline: 12px; }
.portal-nav { display: grid; gap: 6px; margin-top: 46px; }
.portal-nav a { display: flex; min-height: var(--mt-nav-item-height); align-items: center; gap: 13px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--mt-nav-item-radius); color: var(--mt-color-text-secondary); font-size: .9rem; font-weight: 600; text-decoration: none; }
.portal-nav a:hover,
.portal-nav a.is-active { border-color: var(--mt-component-portal-active-border); color: var(--mt-color-text-primary); background: var(--mt-color-action-primary-soft); }
.portal-nav a.is-active { color: var(--mt-color-action-primary); }
.portal-sidebar__footer { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 18px 6px 0; border-top: 1px solid var(--mt-color-border-subtle); }
.portal-avatar { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: var(--mt-radius-compact); color: var(--mt-component-portal-on-action); background: var(--mt-component-portal-action-background); font-weight: 800; }
.portal-sidebar__footer div { display: grid; min-width: 0; flex: 1; }
.portal-sidebar__footer strong,
.portal-sidebar__footer small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-sidebar__footer small { color: var(--mt-color-text-muted); font-size: .72rem; }
.portal-sidebar__footer button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-radius-compact); color: var(--mt-color-text-secondary); background: transparent; cursor: pointer; }

.portal-main { width: calc(100% - var(--mt-nav-width)); max-width: 1540px; margin-left: var(--mt-nav-width); padding: 32px clamp(24px, 4vw, 64px) 80px; }
.portal-topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.portal-topbar h1 { margin-bottom: 0; font-size: clamp(1.8rem, 3vw, 2.65rem); }
.portal-system-state { display: inline-flex; min-height: 38px; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-radius-round); color: var(--mt-color-text-secondary-strong); background: var(--mt-color-background-surface); font-size: .76rem; font-weight: 600; }
.portal-system-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--mt-color-status-success); box-shadow: 0 0 0 5px var(--mt-component-portal-success-glow); }
.portal-section { display: grid; gap: 18px; padding: 16px 0 36px; scroll-margin-top: 18px; }
.portal-section + .portal-section { padding-top: 36px; border-top: 1px solid var(--mt-color-border-subtle); }
.portal-section__head { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.portal-section__head h2 { margin-bottom: 8px; }
.portal-section__head p:last-child { max-width: 72ch; margin-bottom: 0; }
.portal-card { min-width: 0; padding: clamp(22px, 2.5vw, 32px); border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-card-radius); background: var(--mt-color-background-surface); box-shadow: var(--mt-shadow-surface); }
.portal-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.portal-card__head a { color: var(--mt-color-action-primary); font-size: .78rem; font-weight: 650; text-decoration: none; }
.portal-badge { display: inline-flex; min-height: 30px; align-items: center; padding: 0 11px; border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-radius-round); color: var(--mt-color-text-secondary); font-size: .72rem; font-weight: 700; }
.portal-badge.is-active { color: var(--mt-color-status-success); background: var(--mt-component-portal-success-soft); }
.portal-connect-card { position: relative; display: grid; min-height: 330px; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); align-items: center; gap: 30px; overflow: hidden; padding: clamp(30px, 5vw, 66px); border: 1px solid var(--mt-component-portal-hero-border); border-radius: var(--mt-radius-panel); background: var(--mt-color-background-surface); }
.portal-connect-card__copy { position: relative; z-index: 2; }
.portal-connect-card__copy h2 { margin-bottom: 10px; font-size: clamp(3.2rem, 8vw, 6.6rem); letter-spacing: -.07em; }
.portal-connect-card__copy > p:not(.portal-kicker) { max-width: 54ch; }
.portal-connect-button { display: inline-flex; min-height: 54px; align-items: center; gap: 12px; margin-top: 14px; padding: 0 22px; border-radius: var(--mt-radius-control); color: var(--mt-component-portal-on-action); background: var(--mt-component-portal-action-background); font-weight: 750; text-decoration: none; }
.portal-connect-button span { display: grid; }
.portal-orbit { position: relative; width: min(26vw, 320px); aspect-ratio: 1; justify-self: center; border: 1px solid var(--mt-component-portal-orbit-border); border-radius: 50%; }
.portal-orbit::before,
.portal-orbit::after { position: absolute; inset: 15%; border: 1px solid var(--mt-component-portal-orbit-inner-border); border-radius: 50%; content: ""; }
.portal-orbit::after { inset: 31%; }
.portal-orbit__core { position: absolute; inset: 50% auto auto 50%; display: grid; width: 70px; height: 70px; place-items: center; transform: translate(-50%, -50%); border-radius: 50%; color: var(--mt-component-portal-on-action); background: var(--mt-component-portal-action-background); font-size: 1.4rem; font-weight: 800; box-shadow: 0 0 0 16px var(--mt-component-portal-action-glow); }
.portal-orbit i { position: absolute; width: 11px; height: 11px; border: 2px solid var(--mt-color-background-surface); border-radius: 50%; background: var(--mt-color-status-success); }
.portal-orbit i:nth-of-type(1) { left: 13%; top: 32%; }
.portal-orbit i:nth-of-type(2) { right: 8%; top: 47%; }
.portal-orbit i:nth-of-type(3) { left: 42%; bottom: 5%; }
.portal-home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.portal-summary { display: grid; gap: 11px; margin: 20px 0; }
.portal-summary__row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 11px; border-top: 1px solid var(--mt-color-border-subtle); }
.portal-summary__row:first-child { padding-top: 0; border-top: 0; }
.portal-summary__row span { color: var(--mt-color-text-secondary); font-size: .8rem; }
.portal-summary__row strong { font-size: .86rem; text-align: right; }
.portal-location-preview { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.portal-location-pill { display: inline-flex; min-height: 38px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-radius-round); color: var(--mt-color-text-secondary-strong); background: var(--mt-color-background-subtle); font-size: .78rem; font-weight: 650; }
.portal-location-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--mt-color-status-success); }
.portal-location-pill.is-offline { opacity: .65; }
.portal-location-pill.is-offline i { background: var(--mt-color-status-error); }
.portal-location-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.portal-location { display: grid; min-height: 148px; gap: 16px; padding: 22px; border: 1px solid var(--mt-color-border-subtle); border-radius: var(--mt-radius-card); background: var(--mt-color-background-surface); text-decoration: none; }
.portal-location__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.portal-location__flag { display: grid; width: 42px; height: 42px; place-items: center; border-radius: var(--mt-radius-compact); color: var(--mt-color-text-primary); background: var(--mt-color-background-subtle); font-size: .78rem; font-weight: 800; }
.portal-location__state { color: var(--mt-color-status-success); font-size: .74rem; font-weight: 700; }
.portal-location.is-offline .portal-location__state { color: var(--mt-color-status-error); }
.portal-location strong { display: block; color: var(--mt-color-text-primary); }
.portal-location small { color: var(--mt-color-text-muted); }
.portal-profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.portal-list { display: grid; }
.portal-list__row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-top: 1px solid var(--mt-color-border-subtle); }
.portal-list__row:first-child { border-top: 0; }
.portal-list__row div { display: grid; gap: 3px; }
.portal-list__row strong { font-size: .84rem; }
.portal-list__row small,
.portal-list__row > span { color: var(--mt-color-text-muted); font-size: .74rem; }
.portal-action-stack { display: flex; flex-wrap: wrap; gap: 10px; }
.portal-support { display: flex; flex-direction: column; }
.portal-support .button { margin-top: auto; }
.portal-admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.portal-admin-stats article { padding: 14px; border-radius: var(--mt-radius-compact); background: var(--mt-color-background-subtle); }
.portal-admin-stats span { display: block; color: var(--mt-color-text-muted); font-size: .7rem; overflow-wrap: anywhere; }
.portal-admin-stats strong { display: block; margin-top: 7px; }
.portal-feedback--global { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); }

@media (max-width: 1080px) {
  .portal-location-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-support { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .portal-auth { grid-template-columns: 1fr; }
  .portal-auth__intro { padding-top: 40px; }
  .portal-auth__card { justify-self: stretch; }
  .portal-sidebar { position: sticky; inset: 0 0 auto; width: 100%; height: auto; flex-direction: row; align-items: center; padding: max(12px, env(safe-area-inset-top)) 14px 10px; border-right: 0; border-bottom: 1px solid var(--mt-color-border-subtle); }
  .portal-sidebar > .portal-brand { padding: 0; }
  .portal-sidebar .portal-brand > span:last-child,
  .portal-sidebar__footer { display: none; }
  .portal-nav { display: flex; flex: 1; justify-content: flex-end; gap: 2px; margin: 0; }
  .portal-nav a { min-width: 48px; padding: 0 11px; }
  .portal-nav a span { display: none; }
  .portal-main { width: 100%; margin-left: 0; padding: 26px 20px 64px; }
  .portal-connect-card { grid-template-columns: 1fr; }
  .portal-orbit { position: absolute; right: -80px; bottom: -90px; width: 310px; opacity: .55; }
}
@media (max-width: 640px) {
  .portal-auth { padding: 20px 16px 34px; }
  .portal-auth__intro { padding-top: 20px; }
  .portal-auth__intro h1 { font-size: 2.35rem; }
  .portal-auth__intro ul { margin-top: 22px; }
  .portal-auth__card { padding: 22px 18px; border-radius: var(--mt-radius-card); }
  .portal-main { padding-inline: 14px; }
  .portal-topbar { align-items: flex-start; }
  .portal-system-state { width: 38px; padding: 0; justify-content: center; }
  .portal-system-state { font-size: 0; }
  .portal-home-grid,
  .portal-location-grid,
  .portal-profile-grid { grid-template-columns: 1fr; }
  .portal-connect-card { min-height: 390px; padding: 28px 22px; align-items: start; }
  .portal-connect-card__copy h2 { font-size: 4rem; }
  .portal-connect-button { width: 100%; justify-content: center; }
  .portal-card { padding: 20px 18px; }
  .portal-support { grid-column: auto; }
  .portal-action-stack { display: grid; }
  .portal-action-stack .button { width: 100%; }
  .portal-admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .portal * { scroll-behavior: auto !important; }
}
