:root {
  color-scheme: light;
  --portal-primary: #0066cc;
  --portal-primary-90: rgba(0, 102, 204, 0.9);
  --portal-primary-25: rgba(0, 102, 204, 0.25);
  --portal-primary-18: rgba(0, 102, 204, 0.18);
  --portal-primary-12: rgba(0, 102, 204, 0.12);
  --portal-primary-08: rgba(0, 102, 204, 0.08);
  --portal-background-light: #f8fafc;
  --portal-background-dark: #0f172a;
  --portal-ink: #0f172a;
  --portal-muted: #64748b;
  --portal-line: rgba(148, 163, 184, 0.28);
  --portal-panel: rgba(255, 255, 255, 0.78);
  --portal-panel-dark: rgba(15, 23, 42, 0.72);
  --portal-success: #0f9f6e;
  --portal-warning: #d97706;
  --portal-danger: #dc2626;
  --portal-shadow-lg: 0 30px 70px rgba(15, 23, 42, 0.12);
  --portal-shadow-md: 0 20px 45px rgba(15, 23, 42, 0.1);
}

html.dark {
  color-scheme: dark;
}

body[data-page] {
  min-width: 320px;
  background-color: var(--portal-background-light);
  color: var(--portal-ink);
}

html.dark body[data-page] {
  background-color: var(--portal-background-dark);
  color: rgb(241 245 249);
}

.hidden {
  display: none !important;
}

.portal-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.portal-toast-region {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 2600;
  display: grid;
  gap: 0.9rem;
  width: min(24rem, calc(100vw - 2rem));
}

.portal-toast {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: start;
  padding: 1rem 1.1rem;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: portal-toast-in 180ms ease-out;
}

html.dark .portal-toast {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(71, 85, 105, 0.85);
}

.portal-toast--success {
  border-color: rgba(16, 185, 129, 0.35);
}

.portal-toast--error {
  border-color: rgba(239, 68, 68, 0.35);
}

.portal-toast--info {
  border-color: rgba(59, 130, 246, 0.3);
}

.portal-toast--leaving {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.portal-toast__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: rgb(15 23 42);
  font-weight: 700;
}

html.dark .portal-toast__icon {
  background: rgba(148, 163, 184, 0.18);
  color: rgb(241 245 249);
}

.portal-toast--success .portal-toast__icon {
  background: rgba(16, 185, 129, 0.14);
  color: rgb(5 150 105);
}

.portal-toast--error .portal-toast__icon {
  background: rgba(239, 68, 68, 0.14);
  color: rgb(220 38 38);
}

.portal-toast__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.portal-toast__message {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--portal-muted);
}

html.dark .portal-toast__message {
  color: rgb(148 163 184);
}

.portal-empty-state {
  display: grid;
  gap: 0.45rem;
  padding: 1.75rem;
  border-radius: 1.5rem;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(241, 245, 249, 0.78));
}

html.dark .portal-empty-state {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.82), rgba(15, 23, 42, 0.72));
  border-color: rgba(71, 85, 105, 0.85);
}

.portal-empty-state__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.portal-empty-state__message {
  margin: 0;
  color: var(--portal-muted);
  line-height: 1.65;
}

html.dark .portal-empty-state__message {
  color: rgb(148 163 184);
}

.portal-modal,
.portal-auth-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  overflow-y: auto;
}

.portal-modal__backdrop,
.portal-auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.portal-modal__dialog,
.portal-auth-modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2.5rem);
  padding: 1.9rem;
  border-radius: 1.8rem;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
}

html.dark .portal-modal__backdrop,
html.dark .portal-auth-modal__backdrop {
  background: rgba(15, 23, 42, 0.32);
}

html.dark .portal-modal__dialog,
html.dark .portal-auth-modal__dialog {
  border-color: rgba(71, 85, 105, 0.85);
  background: rgba(15, 23, 42, 0.9);
}

.portal-modal__close,
.portal-auth-modal__close {
  position: sticky;
  top: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  margin: 0 0 0.75rem;
  padding: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: rgb(15 23 42);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, color 180ms ease;
}

.portal-modal__close:hover,
.portal-auth-modal__close:hover {
  transform: translateY(-1px) scale(1.03);
  background: rgba(15, 23, 42, 0.1);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
}

html.dark .portal-modal__close,
html.dark .portal-auth-modal__close {
  background: rgba(148, 163, 184, 0.16);
  color: rgb(241 245 249);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.28);
}

html.dark .portal-modal__close:hover,
html.dark .portal-auth-modal__close:hover {
  background: rgba(148, 163, 184, 0.22);
  box-shadow: 0 16px 30px rgba(2, 6, 23, 0.34);
}

.portal-modal__eyebrow,
.portal-auth-modal__eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--portal-primary);
}

.portal-modal__title,
.portal-auth-modal__title {
  margin: 0.65rem 0 0;
  font-size: 1.8rem;
  font-weight: 800;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-modal__copy,
.portal-auth-modal__copy {
  margin: 0.8rem 0 0;
  color: var(--portal-muted);
  line-height: 1.65;
}

html.dark .portal-modal__copy,
html.dark .portal-auth-modal__copy {
  color: rgb(148 163 184);
}

.portal-modal__form,
.portal-auth-modal__form {
  display: grid;
  flex: 1 1 auto;
  gap: 1rem;
  margin-top: 1.5rem;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.portal-modal__field,
.portal-auth-modal__field {
  display: grid;
  gap: 0.45rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.portal-modal__field input,
.portal-modal__field select,
.portal-auth-modal__field input,
.portal-auth-modal__field select {
  width: 100%;
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.92);
  padding: 0.9rem 1rem;
  color: inherit;
  outline: none;
}

html.dark .portal-modal__field input,
html.dark .portal-modal__field select,
html.dark .portal-auth-modal__field input,
html.dark .portal-auth-modal__field select {
  border-color: rgba(71, 85, 105, 0.9);
  background: rgba(30, 41, 59, 0.92);
}

.portal-modal__field input:focus,
.portal-modal__field select:focus,
.portal-auth-modal__field input:focus,
.portal-auth-modal__field select:focus {
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.14);
}

.portal-modal__field.is-error input,
.portal-modal__field.is-error select,
.portal-auth-modal__field.is-error input,
.portal-auth-modal__field.is-error select {
  border-color: var(--portal-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
  background: rgba(254, 242, 242, 0.96);
}
.portal-modal__message,
.portal-auth-modal__message {
  min-height: 1.35rem;
  margin: 0;
  z-index: 7000;
  color: var(--portal-muted);
}

.portal-modal__message.is-error,
.portal-auth-modal__message.is-error {
  color: var(--portal-danger);
}

.portal-modal__actions,
.portal-auth-modal__actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.92) 28%);
}

.portal-modal__primary,
.portal-modal__secondary,
.portal-auth-modal__primary,
.portal-auth-modal__secondary {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.portal-modal__primary,
.portal-auth-modal__primary {
  background: var(--portal-primary);
  color: rgb(255 255 255);
}

.portal-modal__secondary,
.portal-auth-modal__secondary {
  background: rgba(241, 245, 249, 0.96);
  color: rgb(15 23 42);
}

html.dark .portal-modal__secondary,
html.dark .portal-auth-modal__secondary {
  background: rgba(30, 41, 59, 0.96);
  color: rgb(241 245 249);
}

html.dark .portal-modal__actions,
html.dark .portal-auth-modal__actions {
  border-top-color: rgba(71, 85, 105, 0.85);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.9) 28%);
}

.portal-modal__primary:disabled,
.portal-modal__secondary:disabled,
.portal-modal__close:disabled,
.portal-auth-modal__primary:disabled,
.portal-auth-modal__secondary:disabled,
.portal-auth-modal__close:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@keyframes portal-toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .portal-toast-region {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    width: auto;
  }

  .portal-modal,
  .portal-auth-modal {
    padding: 0.5rem;
  }

  .portal-modal__dialog,
  .portal-auth-modal__dialog {
    width: min(100vw - 1rem, 30rem);
    max-height: calc(100vh - 1rem);
    padding: 1.25rem;
    border-radius: 1.4rem;
  }

  .portal-modal__actions,
  .portal-auth-modal__actions {
    justify-content: stretch;
  }

  .portal-modal__primary,
  .portal-modal__secondary,
  .portal-auth-modal__primary,
  .portal-auth-modal__secondary {
    width: 100%;
  }
}
