/* ============================================================
   Vei-Rise Operator Portal — Material Design 3 component adapters
   Consumes the shared token contract from md3-tokens.css. Every
   rule is rooted at .portal-page so the existing .portal-* hooks
   keep their names and the page layouts/grids stay untouched.
   ============================================================ */

/* ---- Page ---- */
body.portal-page,
.portal-page {
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-body-size);
  line-height: var(--md-sys-typescale-body-line);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
}

.portal-page code {
  font-family: "SFMono-Regular", ui-monospace, monospace;
}

/* ---- Focus: visible 2px outline, not removed by outline-none utilities ---- */
.portal-page :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--md-sys-focus-outline-width) solid var(--md-sys-color-primary);
  outline-offset: var(--md-sys-focus-outline-offset);
}

.portal-page main:focus {
  outline: none;
}

/* ---- Skip link ---- */
.portal-page .portal-skip-link {
  position: absolute;
  left: var(--md-sys-space-4);
  top: -100px;
  z-index: 50;
  padding: var(--md-sys-space-3) var(--md-sys-space-4);
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-secondary);
  color: var(--md-sys-color-on-secondary);
  font-weight: 600;
  transition: top var(--md-sys-motion-duration-short) var(--md-sys-motion-easing);
}
.portal-page .portal-skip-link:focus {
  top: var(--md-sys-space-4);
}

/* ---- Top app bar ---- */
.portal-page .portal-header {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  border-top: 4px solid var(--md-sys-color-brand-fill);
  box-shadow: var(--md-sys-elevation-1);
}

.portal-page .portal-brand-marks {
  display: flex;
  align-items: center;
  gap: var(--md-sys-space-3);
}

.portal-page .portal-brand-logo {
  display: block;
  width: auto;
  height: 2.75rem;
  max-width: min(9.25rem, 40vw);
}

@media (min-width: 768px) {
  .portal-page .portal-brand-logo { height: 3.25rem; max-width: 10.5rem; }
}

.portal-page .portal-app-title {
  font-size: var(--md-sys-typescale-title-size);
  line-height: var(--md-sys-typescale-title-line);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--md-sys-color-on-surface);
}

.portal-page .portal-app-description {
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-size);
  line-height: var(--md-sys-typescale-label-line);
}

/* ---- Text utilities ---- */
.portal-page .portal-kicker       { color: var(--md-sys-color-primary); }
.portal-page .portal-primary-text { color: var(--md-sys-color-primary); }
.portal-page .portal-warning-text { color: var(--md-sys-color-warning); }

.portal-page .portal-inline-link {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
.portal-page .portal-inline-link:hover {
  color: var(--md-sys-color-on-primary-container);
}

/* ---- Buttons and navigation (≥44px targets) ---- */
.portal-page .portal-nav-link,
.portal-page .portal-primary-button,
.portal-page .portal-secondary-button,
.portal-page .portal-text-button,
.portal-page .portal-hero-primary-link,
.portal-page .portal-hero-secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--md-sys-target-min);
  gap: var(--md-sys-space-2);
  border-radius: var(--md-sys-shape-corner-full);
  font-weight: 600;
  line-height: var(--md-sys-typescale-label-line);
  text-align: center;
  transition:
    background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing),
    color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing),
    border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing),
    box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing);
}

.portal-page .portal-nav-link,
.portal-page .portal-text-button {
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
}
.portal-page .portal-nav-link:hover,
.portal-page .portal-text-button:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--md-sys-state-hover-opacity), transparent);
  color: var(--md-sys-color-on-surface);
}
.portal-page .portal-nav-link[aria-current="page"] {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.portal-page .portal-primary-button {
  background: var(--md-sys-color-brand-fill);
  color: var(--md-sys-color-on-brand-fill);
  border: 1px solid transparent;
  box-shadow: none;
}
.portal-page .portal-primary-button:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-brand-fill) var(--md-sys-state-hover-opacity), var(--md-sys-color-brand-fill));
  box-shadow: var(--md-sys-elevation-1);
}
.portal-page .portal-primary-button:active {
  background: color-mix(in srgb, var(--md-sys-color-on-brand-fill) var(--md-sys-state-pressed-opacity), var(--md-sys-color-brand-fill));
}

.portal-page .portal-secondary-button {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border: 1px solid transparent;
  box-shadow: none;
}
.portal-page .portal-secondary-button:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-secondary-container) var(--md-sys-state-hover-opacity), var(--md-sys-color-secondary-container));
}

.portal-page :is(.portal-primary-button, .portal-secondary-button, .portal-text-button):disabled,
.portal-page :is(.portal-primary-button, .portal-secondary-button, .portal-text-button)[aria-disabled="true"] {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  border-color: var(--md-sys-color-outline-variant);
  box-shadow: none;
  cursor: not-allowed;
}

/* ---- Chips ---- */
.portal-page .portal-status-chip,
.portal-page .portal-accent-chip,
.portal-page .portal-soft-chip,
.portal-page .portal-warning-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-space-1);
  border-radius: var(--md-sys-shape-corner-full);
  font-weight: 600;
  line-height: var(--md-sys-typescale-label-line);
}

.portal-page .portal-status-chip {
  background: var(--md-sys-color-secondary-container);
  border: 1px solid transparent;
  color: var(--md-sys-color-on-secondary-container);
}

.portal-page .portal-accent-chip {
  background: var(--md-sys-color-primary-container);
  border: 1px solid transparent;
  color: var(--md-sys-color-on-primary-container);
}

.portal-page .portal-soft-chip {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface-variant);
}

.portal-page .portal-warning-chip {
  background: var(--md-sys-color-warning-container);
  border: 1px solid transparent;
  color: var(--md-sys-color-on-warning-container);
}

/* ---- Icon shell ---- */
.portal-page .portal-icon-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
  width: 2.75rem;
  flex: none;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-primary-container);
  border: 1px solid transparent;
  color: var(--md-sys-color-on-primary-container);
  box-shadow: none;
}

/* ---- Cards and panels ---- */
.portal-page .portal-accent-card {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-1);
}

.portal-page .portal-plain-panel {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: none;
}

.portal-page .portal-fieldset {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: none;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing),
    border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing);
}
.portal-page .portal-fieldset:hover {
  background: var(--md-sys-color-surface-container-low);
  border-color: var(--md-sys-color-outline);
}
.portal-page .portal-fieldset:has(input:checked) {
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}
.portal-page .portal-fieldset:focus-within {
  outline: var(--md-sys-focus-outline-width) solid var(--md-sys-color-primary);
  outline-offset: var(--md-sys-focus-outline-offset);
}

.portal-page .portal-info-panel {
  background: var(--md-sys-color-secondary-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  color: var(--md-sys-color-on-secondary-container);
}

/* ---- Selectable rows (page/number selection) ---- */
.portal-page .portal-choice {
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-large);
  transition: border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing),
    background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing);
}
.portal-page .portal-choice:hover {
  border-color: var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-low);
}
.portal-page .portal-choice:has(input:checked) {
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}
.portal-page .portal-choice:focus-within {
  outline: var(--md-sys-focus-outline-width) solid var(--md-sys-color-primary);
  outline-offset: var(--md-sys-focus-outline-offset);
}

/* ---- Hero card: solid tonal surface, no gradients or specular layers ---- */
.portal-page .portal-hero-card {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--md-sys-color-brand-fill) 9%, var(--md-sys-color-surface-container-lowest));
  color: var(--md-sys-color-on-surface);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-brand-fill) 35%, transparent);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: none;
}
.portal-page .portal-hero-card::before { content: none; }

.portal-page .portal-hero-icon {
  background: var(--md-sys-color-secondary-container);
  border-color: transparent;
  color: var(--md-sys-color-on-secondary-container);
}

.portal-page .portal-hero-kicker    { color: var(--md-sys-color-primary); }
.portal-page .portal-hero-subkicker { color: var(--md-sys-color-on-surface-variant); }
.portal-page .portal-hero-copy      { color: var(--md-sys-color-on-surface-variant); }

.portal-page .portal-hero-primary-link {
  background: var(--md-sys-color-brand-fill);
  color: var(--md-sys-color-on-brand-fill);
  border: 1px solid transparent;
  box-shadow: none;
}
.portal-page .portal-hero-primary-link:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-brand-fill) var(--md-sys-state-hover-opacity), var(--md-sys-color-brand-fill));
  color: var(--md-sys-color-on-brand-fill);
}

.portal-page .portal-hero-secondary-link {
  background: transparent;
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface);
}
.portal-page .portal-hero-secondary-link:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--md-sys-state-hover-opacity), transparent);
}

/* ---- Dark panel (pricing summary blocks) ---- */
.portal-page .portal-dark-panel {
  background: color-mix(in srgb, var(--md-sys-color-brand-fill) 9%, var(--md-sys-color-surface-container-lowest));
  border: 1px solid color-mix(in srgb, var(--md-sys-color-brand-fill) 35%, transparent);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: none;
  color: var(--md-sys-color-on-surface);
}
.portal-page .portal-dark-panel-label { color: var(--md-sys-color-on-surface-variant); }
.portal-page .portal-dark-panel [class*="bg-white/"] {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

/* ---- Stage list ---- */
.portal-page .portal-stage-current {
  background: var(--md-sys-color-brand-fill);
  color: var(--md-sys-color-on-brand-fill);
}

/* ---- Progress ---- */
.portal-page .portal-progress {
  width: 100%;
  height: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-high);
  box-shadow: none;
}
.portal-page .portal-progress::-webkit-progress-bar {
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-full);
}
.portal-page .portal-progress::-webkit-progress-value { border-radius: var(--md-sys-shape-corner-full); }
.portal-page .portal-progress::-moz-progress-bar      { border-radius: var(--md-sys-shape-corner-full); }

.portal-page .portal-progress--teal::-webkit-progress-value  { background: var(--md-sys-color-brand-fill); }
.portal-page .portal-progress--teal::-moz-progress-bar       { background: var(--md-sys-color-brand-fill); }
.portal-page .portal-progress--amber::-webkit-progress-value { background: var(--md-sys-color-warning); }
.portal-page .portal-progress--amber::-moz-progress-bar      { background: var(--md-sys-color-warning); }
.portal-page .portal-progress--sky::-webkit-progress-value   { background: var(--md-sys-color-secondary); }
.portal-page .portal-progress--sky::-moz-progress-bar        { background: var(--md-sys-color-secondary); }

/* ---- Form fields ---- */
.portal-page .portal-field {
  display: block;
  width: 100%;
  min-height: var(--md-sys-target-comfortable);
  padding: var(--md-sys-space-3) var(--md-sys-space-4);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: var(--md-sys-typescale-label-size);
  line-height: var(--md-sys-typescale-label-line);
  box-shadow: none;
  transition: border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing),
    box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing);
}
.portal-page .portal-field::placeholder { color: var(--md-sys-color-outline); }
.portal-page .portal-field:hover { border-color: var(--md-sys-color-on-surface-variant); }
.portal-page .portal-field:focus,
.portal-page .portal-field:focus-visible {
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
  outline: var(--md-sys-focus-outline-width) solid var(--md-sys-color-primary);
  outline-offset: var(--md-sys-focus-outline-offset);
}
.portal-page .portal-field[aria-invalid="true"],
.portal-page .portal-field--error {
  border-color: var(--md-sys-color-error);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-error);
}
.portal-page .portal-field:disabled,
.portal-page .portal-field[readonly] {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  border-style: dashed;
  cursor: not-allowed;
}
.portal-page textarea.portal-field { min-height: 6rem; }
.portal-page select.portal-field { padding-right: var(--md-sys-space-8); }

.portal-page .portal-checkbox,
.portal-page .portal-radio {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  accent-color: var(--md-sys-color-primary);
  border-radius: var(--md-sys-shape-corner-extra-small);
}
.portal-page .portal-radio { border-radius: var(--md-sys-shape-corner-full); }

.portal-page .portal-file-input {
  color: var(--md-sys-color-on-surface-variant);
}
.portal-page .portal-file-input::file-selector-button {
  margin-right: var(--md-sys-space-4);
  padding: var(--md-sys-space-2) var(--md-sys-space-4);
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font: inherit;
  font-size: var(--md-sys-typescale-label-size);
  font-weight: 600;
  cursor: pointer;
}
.portal-page .portal-file-input:hover::file-selector-button {
  background: color-mix(in srgb, var(--md-sys-color-on-secondary-container) var(--md-sys-state-hover-opacity), var(--md-sys-color-secondary-container));
}

/* ---- Messages: persistent region, never auto-dismissed ---- */
.portal-page .portal-messages {
  display: grid;
  gap: var(--md-sys-space-3);
}

.portal-page .portal-message {
  display: flex;
  gap: var(--md-sys-space-3);
  align-items: flex-start;
  padding: var(--md-sys-space-3) var(--md-sys-space-4);
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: var(--md-sys-typescale-label-size);
  line-height: var(--md-sys-typescale-label-line);
  box-shadow: var(--md-sys-elevation-1);
}
.portal-page .portal-message--success {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
}
.portal-page .portal-message--error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-color: var(--md-sys-color-error);
}
.portal-page .portal-message--warning {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
}
.portal-page .portal-message-label {
  flex: none;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  line-height: var(--md-sys-typescale-label-line);
}

/* ---- Published package cards (as on the public site) ---- */
.portal-page .portal-price-card {
  position: relative;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-1);
}
.portal-page .portal-price-card--highlight {
  border: 2px solid var(--md-sys-color-brand-fill);
  box-shadow: var(--md-sys-elevation-2);
}
.portal-page .portal-price-chip {
  align-self: flex-start;
  margin-bottom: var(--md-sys-space-3);
  padding: var(--md-sys-space-1) var(--md-sys-space-3);
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-brand-fill);
  color: var(--md-sys-color-on-brand-fill);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.portal-page .portal-price-amount { font-size: 2.25rem; line-height: 2.75rem; font-weight: 800; letter-spacing: -0.02em; }
.portal-page .portal-price-features { list-style: none; margin-left: 0; padding: 0; display: grid; gap: var(--md-sys-space-3); align-content: start; font-size: var(--md-sys-typescale-label-size); color: var(--md-sys-color-on-surface-variant); }
.portal-page .portal-price-features li { position: relative; padding-left: 1.75rem; }
.portal-page .portal-price-features li::before {
  content: "✓"; position: absolute; left: 0; top: 0; width: 1.25rem; height: 1.25rem;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 9999px;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
  font-size: 0.75rem; font-weight: 700;
}

/* ---- Demo band and powered-by mark ---- */
.portal-page .portal-demo-band {
  margin: 0;
  padding: var(--md-sys-space-2) var(--md-sys-space-4);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  border-bottom: 3px solid var(--md-sys-color-brand-fill);
}
.portal-page .portal-powered-by {
  font-weight: 700;
  color: var(--md-sys-color-brand-accent);
}

/* ---- Footer ---- */
.portal-page .portal-footer {
  border-top: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-size);
  line-height: var(--md-sys-typescale-label-line);
}

/* ---- Motion ---- */
@media (prefers-reduced-motion: reduce) {
  .portal-page *,
  .portal-page *::before,
  .portal-page *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}

/* Text inside filled brand surfaces follows the theme's on-colour, not fixed white utilities. */
.portal-page .portal-hero-card :is(h2, h3, strong) {
  color: var(--md-sys-color-on-surface);
}
.portal-page .portal-dark-panel,
.portal-page .portal-dark-panel :is(h3, p, strong, div) {
  color: var(--md-sys-color-on-surface);
}
.portal-page .portal-dark-panel p.portal-dark-panel-label {
  color: var(--md-sys-color-on-surface-variant);
}
