:root {
  color-scheme: light;
  --portal-paper: #f6f5f2;
  --portal-white: #ffffff;
  --portal-night: #050505;
  --portal-ink: #111111;
  --portal-copy: #505050;
  --portal-muted: #737373;
  --portal-line: rgba(17, 17, 17, 0.14);
  --portal-line-dark: rgba(255, 255, 255, 0.16);
  --portal-accent: #ffc563;
  --portal-error: #9d2d25;
  --portal-success: #315f3b;
  --portal-font: Geist, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --portal-mono: "Fragment Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--portal-paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--portal-ink);
  background: var(--portal-paper);
  font-family: var(--portal-font);
  -webkit-font-smoothing: antialiased;
}

body::selection,
body *::selection { color: var(--portal-ink); background: var(--portal-accent); }

a { color: inherit; text-underline-offset: 0.2em; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--portal-accent);
  outline-offset: 3px;
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 1.06rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.portal-brand img { width: 38px; height: auto; display: block; }

.portal-login {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(430px, 0.95fr);
  min-height: 100vh;
}

.portal-login-stage {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(28px, 4vw, 64px);
  color: var(--portal-white);
  background: var(--portal-night);
}

.portal-login-stage::before,
.portal-login-stage::after {
  position: absolute;
  z-index: -1;
  content: "";
  border: 1px solid var(--portal-line-dark);
  border-radius: 50%;
}

.portal-login-stage::before {
  right: -16vw;
  bottom: -26vw;
  width: min(70vw, 820px);
  aspect-ratio: 1;
}

.portal-login-stage::after {
  right: 8vw;
  bottom: 7vw;
  width: min(24vw, 300px);
  aspect-ratio: 1;
  background: var(--portal-accent);
  border-color: var(--portal-accent);
  box-shadow: 0 28px 90px rgba(255, 197, 99, 0.22);
}

.portal-stage-copy { max-width: 720px; padding: 12vh 0 8vh; }

.portal-stage-copy h1 {
  max-width: 10ch;
  margin: 0;
  font-size: clamp(3.9rem, 8.4vw, 8.6rem);
  font-weight: 500;
  line-height: 0.88;
  letter-spacing: -0.06em;
  text-wrap: balance;
}

.portal-stage-copy p {
  max-width: 35rem;
  margin: clamp(28px, 5vw, 48px) 0 0;
  color: rgba(255,255,255,.68);
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  line-height: 1.65;
}

.portal-stage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  color: rgba(255,255,255,.56);
  font-family: var(--portal-mono);
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.portal-login-panel {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(28px, 6vw, 88px);
  background: var(--portal-paper);
}

.portal-form-shell { width: min(100%, 520px); }

.portal-mobile-brand { display: none; margin-bottom: 48px; }

.portal-lock {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 32px;
  place-items: center;
  color: var(--portal-white);
  background: var(--portal-ink);
}

.portal-lock svg { width: 22px; height: 22px; }

.portal-form-shell h2 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.35rem, 4.4vw, 4.4rem);
  font-weight: 500;
  line-height: .96;
  letter-spacing: -.045em;
  text-wrap: balance;
}

.portal-form-intro {
  max-width: 42ch;
  margin: 20px 0 36px;
  color: var(--portal-copy);
  line-height: 1.65;
}

.portal-form { display: grid; gap: 20px; }
.portal-field { display: grid; gap: 9px; }

.portal-field label {
  font-family: var(--portal-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.portal-field input {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  color: var(--portal-ink);
  background: var(--portal-white);
  border: 1px solid var(--portal-line);
  border-radius: 0;
  caret-color: var(--portal-ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.portal-field input::placeholder { color: #777; opacity: 1; }
.portal-field input:focus { outline: 0; border-color: var(--portal-ink); box-shadow: inset 0 0 0 1px var(--portal-ink); }
.portal-field input:disabled { cursor: not-allowed; color: var(--portal-muted); background: #ecebe7; }
.portal-field input:invalid:not(:placeholder-shown) { border-color: rgba(157, 45, 37, .62); }
.portal-field small { color: var(--portal-muted); font-size: .76rem; line-height: 1.45; }

.portal-password-wrap { position: relative; }
.portal-password-wrap input { padding-right: 70px; }

.portal-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  min-height: 40px;
  padding: 0 10px;
  transform: translateY(-50%);
  color: var(--portal-copy);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
}

.portal-submit {
  display: inline-flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 8px;
  padding: 14px 18px;
  color: var(--portal-white);
  background: var(--portal-ink);
  border: 1px solid var(--portal-ink);
  border-radius: 0;
  cursor: pointer;
  font-weight: 600;
  transition: transform 180ms cubic-bezier(.16,1,.3,1), background 180ms ease;
}

.portal-submit::after { content: "→"; font-size: 1.25rem; line-height: 1; }
.portal-submit:hover { transform: translateY(-2px); background: #2b2b2b; }
.portal-submit:disabled { cursor: wait; transform: none; color: #aaa; background: #363636; }

.portal-status {
  min-height: 24px;
  margin: 4px 0 0;
  color: var(--portal-copy);
  font-size: .9rem;
  line-height: 1.5;
}

.portal-status[data-tone="error"] { color: var(--portal-error); }
.portal-status[data-tone="success"] { color: var(--portal-success); }

.portal-help {
  margin-top: 32px;
  padding-top: 24px;
  color: var(--portal-muted);
  border-top: 1px solid var(--portal-line);
  font-size: .88rem;
  line-height: 1.6;
}

.portal-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 28px;
  color: var(--portal-muted);
  font-size: .78rem;
}

.portal-legal a:hover { color: var(--portal-ink); }
.portal-step[hidden] { display: none; }

/* Dashboard */
.portal-dashboard { min-height: 100vh; background: var(--portal-paper); }

.portal-dashboard-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.portal-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 28px;
  color: var(--portal-white);
  background: var(--portal-night);
}

.portal-sidebar-nav { display: grid; gap: 6px; margin: 68px 0 32px; }

.portal-nav-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  color: rgba(255,255,255,.62);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.portal-nav-button:hover { color: var(--portal-white); border-color: var(--portal-line-dark); }
.portal-nav-button[aria-current="page"] { color: var(--portal-ink); background: var(--portal-accent); }

.portal-sidebar-footer { margin-top: auto; }

.portal-logout {
  width: 100%;
  min-height: 46px;
  color: var(--portal-white);
  background: transparent;
  border: 1px solid var(--portal-line-dark);
  cursor: pointer;
}

.portal-main { min-width: 0; padding: clamp(28px, 5vw, 72px); }

.portal-dashboard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: clamp(48px, 7vw, 88px);
}

.portal-dashboard-head h1 {
  margin: 0;
  font-size: clamp(3rem, 7vw, 7.25rem);
  font-weight: 500;
  line-height: .88;
  letter-spacing: -.06em;
}

.portal-user-chip { max-width: 260px; color: var(--portal-copy); font-size: .88rem; line-height: 1.55; text-align: right; overflow-wrap: anywhere; }

.portal-view[hidden] { display: none; }

.portal-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: clamp(32px, 5vw, 72px);
}

.portal-overview h2,
.portal-section h2 {
  margin: 0 0 22px;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.035em;
}

.portal-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--portal-line);
  border-bottom: 1px solid var(--portal-line);
}

.portal-metric { padding: 28px 18px 30px 0; }
.portal-metric + .portal-metric { padding-left: 18px; border-left: 1px solid var(--portal-line); }
.portal-metric strong { display: block; font-size: clamp(2.4rem, 5vw, 4.4rem); font-weight: 500; line-height: 1; letter-spacing: -.055em; }
.portal-metric span { display: block; margin-top: 12px; color: var(--portal-muted); font-size: .82rem; }

.portal-callout {
  padding: 28px;
  color: var(--portal-white);
  background: var(--portal-night);
  box-shadow: 0 22px 80px rgba(15,15,16,.18);
}

.portal-callout p { margin: 0 0 28px; color: rgba(255,255,255,.7); line-height: 1.65; }
.portal-callout a { display: inline-block; padding-bottom: 5px; border-bottom: 1px solid currentColor; text-decoration: none; }

.portal-section { max-width: 980px; }
.portal-data-list { border-top: 1px solid var(--portal-line); }

.portal-data-row {
  display: grid;
  grid-template-columns: minmax(150px, .7fr) minmax(220px, 1.4fr) minmax(120px, .55fr);
  gap: 24px;
  align-items: center;
  padding: 22px 0;
  border-bottom: 1px solid var(--portal-line);
}

.portal-data-row strong { font-weight: 600; }
.portal-data-row span { color: var(--portal-copy); line-height: 1.5; }
.portal-data-row a { justify-self: end; }
.portal-contract-price { display: block; margin-top: 6px; color: var(--portal-ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.portal-empty { padding: 34px 0; color: var(--portal-muted); border-bottom: 1px solid var(--portal-line); }

.portal-settings { max-width: 1080px; }

.portal-settings-head {
  display: grid;
  grid-template-columns: minmax(220px, .55fr) minmax(300px, .8fr);
  gap: clamp(28px, 6vw, 90px);
  align-items: end;
  padding-bottom: clamp(34px, 5vw, 58px);
}

.portal-settings-head h2 {
  margin: 0;
  font-size: clamp(3.1rem, 6vw, 6.3rem);
  font-weight: 500;
  line-height: .9;
  letter-spacing: -.055em;
}

.portal-settings-head > p {
  max-width: 48ch;
  margin: 0;
  color: var(--portal-copy);
  line-height: 1.7;
}

.portal-settings-section {
  display: grid;
  grid-template-columns: minmax(190px, .42fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 92px);
  padding: clamp(36px, 5vw, 58px) 0;
  border-top: 1px solid var(--portal-line);
}

.portal-settings-label h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -.025em;
}

.portal-settings-label p {
  max-width: 31ch;
  margin: 12px 0 0;
  color: var(--portal-muted);
  font-size: .88rem;
  line-height: 1.65;
}

.portal-settings-form { min-width: 0; }

.portal-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 18px;
}

.portal-field-wide { grid-column: 1 / -1; }

.portal-settings-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 26px;
}

.portal-settings-actions .portal-submit { width: min(100%, 260px); margin: 0; flex: 0 0 auto; }
.portal-settings-actions .portal-status { margin: 0; }

.portal-settings-hint {
  margin: 14px 0 0;
  color: var(--portal-muted);
  font-size: .8rem;
  line-height: 1.55;
}

.portal-stripe-panel {
  min-width: 0;
  padding: clamp(24px, 4vw, 38px);
  color: var(--portal-white);
  background: var(--portal-night);
  box-shadow: 0 22px 80px rgba(15,15,16,.16);
}

.portal-stripe-wordmark {
  display: block;
  margin-bottom: 30px;
  color: #b7a1ff;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -.06em;
}

.portal-stripe-panel strong { display: block; font-size: clamp(1.35rem, 2vw, 1.8rem); font-weight: 500; letter-spacing: -.025em; }
.portal-stripe-panel p { margin: 12px 0 0; color: rgba(255,255,255,.64); font-size: .88rem; line-height: 1.65; }

.portal-stripe-button {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  margin-top: 28px;
  padding: 13px 18px;
  color: var(--portal-ink);
  background: var(--portal-white);
  border: 1px solid var(--portal-white);
  cursor: pointer;
  font-weight: 600;
  transition: transform 180ms cubic-bezier(.16,1,.3,1), background 180ms ease;
}

.portal-stripe-button:hover { transform: translateY(-2px); background: var(--portal-accent); border-color: var(--portal-accent); }
.portal-stripe-button:disabled { cursor: not-allowed; transform: none; color: rgba(255,255,255,.45); background: rgba(255,255,255,.08); border-color: var(--portal-line-dark); }
.portal-stripe-panel > .portal-status { min-height: 0; color: rgba(255,255,255,.62); }
.portal-stripe-panel > .portal-status[data-tone="error"] { color: #ffaaa4; }

.portal-loading { min-height: 40vh; display: grid; place-items: center; color: var(--portal-muted); }

/* Nicht überspringbare Ersteinrichtung */
body[data-onboarding-locked="true"] { overflow: hidden; }
body[data-onboarding-locked="true"] .portal-dashboard-shell { pointer-events: none; user-select: none; }

.portal-onboarding {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.portal-onboarding-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, .78);
  backdrop-filter: blur(9px);
}

.portal-onboarding-dialog {
  position: relative;
  width: min(100%, 660px);
  padding: clamp(28px, 5vw, 54px);
  background: var(--portal-paper);
  box-shadow: 0 32px 120px rgba(0, 0, 0, .36);
}

.portal-onboarding-progress {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: clamp(34px, 6vw, 58px);
}

.portal-onboarding-progress span {
  padding: 10px 0;
  color: var(--portal-muted);
  border-top: 2px solid var(--portal-line);
  font-family: var(--portal-mono);
  font-size: .7rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.portal-onboarding-progress span[data-state="active"] { color: var(--portal-ink); border-color: var(--portal-ink); }
.portal-onboarding-progress span[data-state="complete"] { color: var(--portal-success); border-color: var(--portal-success); }
.portal-onboarding-kicker { color: var(--portal-muted); font-family: var(--portal-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.portal-onboarding-dialog h1 { margin: 12px 0 18px; font-size: clamp(2.35rem, 6vw, 4.4rem); font-weight: 500; line-height: .94; letter-spacing: -.05em; }
.portal-onboarding-dialog > div > p { margin: 0 0 30px; color: var(--portal-copy); line-height: 1.65; }
.portal-onboarding-contract { display: grid; gap: 7px; margin: 30px 0 4px; padding: 22px; color: var(--portal-white); background: var(--portal-night); }
.portal-onboarding-contract span { color: rgba(255,255,255,.58); font-family: var(--portal-mono); font-size: .7rem; text-transform: uppercase; }
.portal-onboarding-contract strong { font-size: 1.35rem; }
.portal-onboarding-contract b { color: var(--portal-accent); font-weight: 600; }
.portal-onboarding-dialog .portal-stripe-button { color: var(--portal-white); background: var(--portal-ink); border-color: var(--portal-ink); }
.portal-onboarding-dialog .portal-stripe-button:hover { color: var(--portal-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media (max-width: 940px) {
  .portal-login { grid-template-columns: 1fr; }
  .portal-login-stage { min-height: 45vh; padding-bottom: 48px; }
  .portal-stage-copy { padding: 10vh 0 4vh; }
  .portal-login-panel { min-height: auto; }
  .portal-login-stage::before { right: -30vw; bottom: -60vw; width: 105vw; }
  .portal-login-stage::after { right: 8vw; bottom: -2vw; width: 28vw; }
  .portal-dashboard-shell { grid-template-columns: 1fr; }
  .portal-sidebar { position: static; height: auto; padding: 20px 24px; overflow: hidden; }
  .portal-sidebar-nav { width: calc(100% + 48px); grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(130px, 1fr); margin: 24px -24px 0; padding: 0 24px 18px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; }
  .portal-sidebar-nav::-webkit-scrollbar { display: none; }
  .portal-sidebar-footer { position: absolute; top: 18px; right: 24px; }
  .portal-logout { width: auto; padding: 0 14px; }
  .portal-overview { grid-template-columns: 1fr; }
  .portal-settings-head { grid-template-columns: 1fr; align-items: start; }
  .portal-settings-section { grid-template-columns: minmax(160px, .36fr) minmax(0, 1fr); gap: 32px; }
}

@media (max-width: 640px) {
  .portal-login-stage { min-height: 390px; }
  .portal-stage-copy h1 { font-size: clamp(3.5rem, 17vw, 5.8rem); }
  .portal-stage-meta { display: none; }
  .portal-login-panel { padding: 44px 22px 56px; }
  .portal-main { padding: 34px 22px 56px; }
  .portal-sidebar-nav { grid-auto-columns: minmax(155px, 1fr); }
  .portal-sidebar-nav .portal-nav-button span { display: none; }
  .portal-dashboard-head { display: block; margin-bottom: 48px; }
  .portal-user-chip { margin-top: 22px; text-align: left; }
  .portal-metrics { grid-template-columns: 1fr; }
  .portal-metric + .portal-metric { padding-left: 0; border-top: 1px solid var(--portal-line); border-left: 0; }
  .portal-data-row { grid-template-columns: 1fr; gap: 8px; }
  .portal-data-row a { justify-self: start; }
  .portal-settings-section { grid-template-columns: 1fr; gap: 26px; }
  .portal-settings-grid { grid-template-columns: 1fr; }
  .portal-field-wide { grid-column: auto; }
  .portal-settings-actions { display: grid; gap: 12px; }
  .portal-settings-actions .portal-submit { width: 100%; }
}
