/* Auth + admin forms — matches Optronix portal button/input feel */
.portal-auth-wrap {
  max-width: 440px;
  margin-inline: auto;
  padding: 0 20px 48px;
}

.portal-auth-panel {
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid var(--border);
  border-radius: clamp(12px, 1.5vw, 18px);
  padding: clamp(24px, 3vw, 36px);
}

.portal-auth-panel h1 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2vw, 1.6rem);
  font-weight: 700;
  color: var(--text);
}

.portal-auth-panel .sub {
  margin: 0 0 24px;
  color: rgba(238, 240, 255, 0.7);
  font-size: 0.95rem;
  line-height: 1.5;
}

.portal-field {
  margin-bottom: 18px;
}

.portal-field label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: rgba(238, 240, 255, 0.85);
}

.portal-field input[type="text"],
.portal-field input[type="email"],
.portal-field input[type="tel"],
.portal-field input[type="password"],
.portal-field input[type="number"],
.portal-field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(1, 1, 1, 0.35);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}

.portal-field input:focus,
.portal-field select:focus {
  outline: 2px solid rgba(123, 126, 242, 0.45);
  outline-offset: 1px;
}

.portal-sub-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(238, 240, 255, 0.88);
}

.portal-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: rgba(238, 240, 255, 0.8);
}

/* main.css sets appearance:none + border:none on all inputs — restores visible checkboxes */
body.page-portal input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  -moz-appearance: checkbox;
  width: 1.125rem;
  height: 1.125rem;
  min-width: 1.125rem;
  min-height: 1.125rem;
  flex-shrink: 0;
  vertical-align: middle;
  cursor: pointer;
  accent-color: var(--primary);
}

.portal-msg {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.portal-msg--err {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: #fecaca;
}

.portal-msg--ok {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #bbf7d0;
}

.portal-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

.portal-dash-toolbar {
  max-width: var(--portal-content-max);
  width: 100%;
  margin: 0 auto 24px;
  padding: 0 clamp(14px, 3vw, 28px);
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-dash-toolbar .meta {
  color: rgba(238, 240, 255, 0.75);
  font-size: 0.95rem;
}

.portal-dash-toolbar a {
  color: rgba(161, 163, 255, 0.95);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.portal-dash-toolbar a:hover {
  color: #c5c6ff;
}

.portal-card-link {
  cursor: pointer;
}

.portal-card-link[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

/* Admin */
.admin-layout {
  max-width: var(--portal-content-max);
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 28px) 64px;
  box-sizing: border-box;
}

.admin-section {
  margin-bottom: 40px;
}

.admin-section h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: var(--text);
}

.admin-table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(18, 18, 18, 0.75);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  -webkit-overflow-scrolling: touch;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

.admin-table-wrap::-webkit-scrollbar {
  height: 5px;
}

.admin-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.admin-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

.admin-table-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: auto;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  vertical-align: top;
}

.admin-table th {
  color: rgba(238, 240, 255, 0.65);
  font-weight: 600;
  vertical-align: bottom;
}

.admin-table td.admin-user-actions {
  white-space: nowrap;
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: normal;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-inline {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.admin-inline .btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.88rem;
  border-radius: 10px;
}

/*
 * Admin page: main.css gives all main>section:first-of-type 240px top padding and
 * all section siblings 100px margin-top (marketing layout). Portal admin uses a
 * toolbar div for header clearance, so those rules read as a huge empty strip.
 */
body.page-portal main .admin-layout > section.admin-section {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* --------------------------------------------------------------------------
   Portal-only header & footer (compact; distinct from main marketing site)
   -------------------------------------------------------------------------- */

body.page-portal {
  --portal-header-h: calc(24px + env(safe-area-inset-top, 0px) + clamp(28px, 2.4vw + 16px, 47px));
  --portal-sidebar-w: 312px;
  --portal-sidebar-w-collapsed: 72px;
  /* Thin centred column: larger side gutters on wide screens */
  --portal-content-max: min(960px, calc(100vw - clamp(28px, 6vw, 80px)));
}

/* No top-of-page vignette from marketing bg overlay */
body.page-portal .bg-overlay {
  background: none;
  opacity: 0;
  pointer-events: none;
}

body.page-portal #site-header.portal-app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10040;
  padding: calc(10px + env(safe-area-inset-top, 0px)) clamp(16px, 3vw, 40px) 14px;
  padding-right: max(clamp(16px, 3vw, 40px), env(safe-area-inset-right, 0px));
  padding-left: max(clamp(16px, 3vw, 40px), env(safe-area-inset-left, 0px));
  /* Nearly black bar + subtle site palette (purple / green / teal) */
  background:
    radial-gradient(ellipse 80% 120% at 0% 0%, rgba(20, 184, 166, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 70% 100% at 100% 100%, rgba(126, 217, 87, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse 55% 90% at 50% -20%, rgba(123, 126, 242, 0.14) 0%, transparent 45%),
    linear-gradient(180deg, #111116 0%, #0b0b0e 45%, #08080a 100%) !important;
  background-color: #08080a;
  border-bottom: 1px solid rgba(123, 126, 242, 0.12);
  box-shadow:
    0 1px 0 rgba(126, 217, 87, 0.08),
    inset 0 1px 0 rgba(123, 126, 242, 0.06);
}

body.page-portal #site-header.portal-app-header.scrolled {
  padding: calc(10px + env(safe-area-inset-top, 0px)) clamp(16px, 3vw, 40px) 14px !important;
  padding-right: max(clamp(16px, 3vw, 40px), env(safe-area-inset-right, 0px)) !important;
  padding-left: max(clamp(16px, 3vw, 40px), env(safe-area-inset-left, 0px)) !important;
  background:
    radial-gradient(ellipse 80% 120% at 0% 0%, rgba(20, 184, 166, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 70% 100% at 100% 100%, rgba(126, 217, 87, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 55% 90% at 50% -20%, rgba(123, 126, 242, 0.12) 0%, transparent 45%),
    linear-gradient(180deg, #0e0e12 0%, #09090c 45%, #060608 100%) !important;
  border-bottom-color: rgba(123, 126, 242, 0.14) !important;
  box-shadow:
    0 1px 0 rgba(126, 217, 87, 0.09),
    inset 0 1px 0 rgba(123, 126, 242, 0.07) !important;
}

/* Bottom hairline: purple centre, teal left, green right — same tokens as main site */
body.page-portal #site-header.portal-app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(20, 184, 166, 0.35) 0%,
    rgba(20, 184, 166, 0.08) 12%,
    transparent 22%,
    rgba(123, 126, 242, 0.15) 38%,
    rgba(161, 163, 255, 0.45) 50%,
    rgba(123, 126, 242, 0.15) 62%,
    transparent 78%,
    rgba(126, 217, 87, 0.12) 88%,
    rgba(126, 217, 87, 0.38) 100%
  );
  background-size: 100% 100%;
  opacity: 0.75;
  animation: none;
}

@media (prefers-reduced-motion: no-preference) {
  body.page-portal #site-header.portal-app-header::after {
    animation: portalHeaderAccentShift 18s ease-in-out infinite;
  }
}

@keyframes portalHeaderAccentShift {
  0%,
  100% {
    filter: hue-rotate(0deg);
    opacity: 0.72;
  }
  50% {
    filter: hue-rotate(4deg);
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.page-portal #site-header.portal-app-header::after {
    animation: none !important;
  }
}

body.page-portal #site-header.portal-app-header .portal-app-header__container {
  width: 100%;
}

body.page-portal #site-header.portal-app-header .portal-app-header__main-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  min-height: clamp(40px, 5vw, 52px);
  width: 100%;
}

body.page-portal #site-header.portal-app-header .portal-app-header__start {
  justify-self: start;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(8px, 1.5vw, 12px);
}

body.page-portal #site-header.portal-app-header .portal-app-header__end {
  justify-self: end;
  min-width: 0;
}

body.page-portal #site-header.portal-app-header .portal-app-header__brand {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  z-index: 1;
  flex-shrink: 0;
}

body.page-portal #site-header.portal-app-header .portal-app-header__logo,
body.page-portal #site-header.portal-app-header .brand-img {
  display: block;
  height: clamp(28px, 2.4vw + 16px, 47px) !important;
  width: auto;
  max-width: clamp(72px, 9vw + 44px, 156px);
  object-fit: contain;
}

body.page-portal #site-header.portal-app-header .portal-app-header__brand:hover {
  transform: scale(1.02);
}

/* Logo: full strength (avoid main.css .brand:hover opacity + any softness) */
body.page-portal #site-header.portal-app-header .portal-app-header__brand .brand-img,
body.page-portal #site-header.portal-app-header .portal-app-header__logo {
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
}

body.page-portal #site-header.portal-app-header .portal-app-header__brand:hover .brand-img {
  opacity: 1 !important;
}

body.page-portal #site-header.portal-app-header .portal-app-header__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;
}

/* Mobile / small screens: open left sidebar */
body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(123, 126, 242, 0.28);
  border-radius: 10px;
  background: rgba(4, 4, 6, 0.85);
  cursor: pointer;
  flex-shrink: 0;
  color: rgba(230, 232, 255, 0.92);
  transition: background 0.2s ease, border-color 0.2s ease;
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(161, 163, 255, 0.35);
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars,
body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars::before,
body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars {
  position: relative;
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars::before,
body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars::after {
  content: "";
  position: absolute;
  left: 0;
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars::before {
  top: -6px;
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open-bars::after {
  top: 6px;
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open[aria-expanded="true"] .portal-app-header__sidebar-open-bars {
  background: transparent;
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open[aria-expanded="true"] .portal-app-header__sidebar-open-bars::before {
  top: 0;
  transform: rotate(45deg);
}

body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open[aria-expanded="true"] .portal-app-header__sidebar-open-bars::after {
  top: 0;
  transform: rotate(-45deg);
}

@media (max-width: 1023px) {
  body.page-portal #site-header.portal-app-header .portal-app-header__sidebar-open {
    display: inline-flex;
  }
}

body.page-portal #site-header.portal-app-header .portal-app-header__guest-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Fixed left sidebar (desktop) / drawer (mobile) */
.portal-sidebar {
  position: relative;
  z-index: 10030;
}

.portal-sidebar__backdrop {
  display: none !important;
}

.portal-sidebar__panel {
  position: fixed;
  top: var(--portal-header-h);
  left: 0;
  z-index: 10030;
  display: flex;
  flex-direction: column;
  width: var(--portal-sidebar-w);
  height: calc(100dvh - var(--portal-header-h));
  max-height: calc(100vh - var(--portal-header-h));
  box-sizing: border-box;
  background: #111116;
  border-right: 1px solid rgba(123, 126, 242, 0.22);
  box-shadow: 4px 0 28px rgba(0, 0, 0, 0.25);
  transition:
    width 0.22s ease,
    transform 0.26s ease;
  overflow: hidden;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__panel {
  width: var(--portal-sidebar-w-collapsed);
}

.portal-sidebar__mobile-bar {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.portal-sidebar__mobile-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(238, 240, 255, 0.92);
}

.portal-sidebar__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(238, 240, 255, 0.9);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.portal-sidebar__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.portal-sidebar__user {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

@media (min-width: 1024px) {
  .portal-sidebar__user {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
}

.portal-sidebar__user-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal-sidebar__user .portal-sidebar__collapse {
  display: none;
}

@media (min-width: 1024px) {
  .portal-sidebar__user .portal-sidebar__collapse {
    display: inline-flex;
    flex-shrink: 0;
    align-self: center;
  }
}

.portal-sidebar__user-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(161, 163, 255, 0.9);
}

.portal-sidebar__session {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 500;
  color: rgba(210, 212, 235, 0.88);
}

.portal-sidebar__session-kicker {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(166, 168, 199, 0.75);
  margin-bottom: 3px;
}

.portal-sidebar__session-email {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.86rem;
  font-weight: 600;
  color: rgba(248, 250, 255, 0.95);
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-sidebar__session-org {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: rgba(180, 182, 210, 0.78);
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__user {
  flex-direction: column-reverse;
  align-items: center;
  padding: 12px 6px 14px;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__session {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1023px) {
  .portal-sidebar__mobile-bar {
    display: flex;
  }

  body.page-portal .portal-sidebar__panel {
    width: min(var(--portal-sidebar-w), 92vw) !important;
    transform: translateX(-100%);
    box-shadow: none;
  }

  body.page-portal.portal-sidebar--collapsed .portal-sidebar__panel {
    width: min(var(--portal-sidebar-w), 92vw) !important;
    transform: translateX(-100%);
  }

  body.page-portal.portal-sidebar--open .portal-sidebar__panel {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }
}

.portal-sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.portal-sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  flex-wrap: nowrap;
}

.portal-sidebar__list > li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0 8px;
  box-sizing: border-box;
}

.portal-sidebar__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  margin: 2px 0;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(230, 232, 255, 0.9);
  text-decoration: none;
  white-space: normal;
  opacity: 1;
  line-height: 1.35;
  transition: background 0.15s ease, color 0.15s ease;
}

/* Isolate from main.css nav a / ::after underline animations */
.portal-sidebar__link::after {
  display: none !important;
  content: none !important;
}

.portal-sidebar__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.portal-sidebar__link--admin {
  color: rgba(165, 180, 252, 0.95);
}

.portal-sidebar__link--admin:hover {
  background: rgba(123, 126, 242, 0.15);
  color: #e0e7ff;
}

.portal-sidebar__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: rgba(161, 163, 255, 0.85);
}

.portal-sidebar__label {
  min-width: 0;
  line-height: 1.3;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__link {
  justify-content: center;
  padding-inline: 8px;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__footer {
  padding-inline: 6px;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__logout {
  padding: 8px 4px;
  font-size: 0.58rem;
  line-height: 1.15;
  white-space: normal;
}

.portal-sidebar__footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.portal-sidebar__collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 6px;
  border: 1px solid rgba(123, 126, 242, 0.25);
  border-radius: 10px;
  background: rgba(4, 4, 6, 0.75);
  color: rgba(238, 240, 255, 0.92);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.portal-sidebar__collapse:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(161, 163, 255, 0.35);
  color: #fff;
}

.portal-sidebar__collapse-icons {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.portal-sidebar__collapse-svg {
  display: block;
  flex-shrink: 0;
}

/* Expanded sidebar: show “minimise” (double chevron left). Collapsed rail: show “expand” (double chevron right). */
.portal-sidebar__collapse-svg--expand {
  display: none;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__collapse-svg--minimise {
  display: none;
}

body.page-portal.portal-sidebar--collapsed:not(.portal-sidebar--open) .portal-sidebar__collapse-svg--expand {
  display: block;
}

/* Main + footer stay full-viewport width; sidebar is fixed and overlaps content */

body.page-portal #site-header.portal-app-header .portal-app-header__link {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: clamp(4px, 0.25vw + 3px, 8px) clamp(5px, 0.55vw + 4px, 16px);
  font-size: clamp(0.58rem, 0.32rem + 0.75vw, 0.898rem);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(230, 232, 255, 0.88);
  text-decoration: none;
  border: none;
  border-radius: clamp(8px, 0.4vw + 6px, 10px);
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

body.page-portal #site-header.portal-app-header .portal-app-header__link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

body.page-portal #site-header.portal-app-header .portal-app-header__link--accent {
  color: rgba(165, 180, 252, 0.95);
}

body.page-portal #site-header.portal-app-header .portal-app-header__link--accent:hover {
  background: rgba(123, 126, 242, 0.15);
  color: #e0e7ff;
}

/* Sign out: red label — header (guest none) or sidebar footer */
body.page-portal button.portal-app-header__link.portal-app-header__logout,
body.page-portal button.portal-sidebar__logout {
  flex-shrink: 0;
  padding: clamp(8px, 0.5vw + 6px, 12px) clamp(4px, 0.8vw + 2px, 16px);
  color: #f87171 !important;
  border: none !important;
  background: transparent !important;
  font-weight: 600;
  box-shadow: none !important;
}

body.page-portal button.portal-sidebar__logout {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  border-radius: 10px;
}

body.page-portal button.portal-app-header__link.portal-app-header__logout:hover,
body.page-portal button.portal-sidebar__logout:hover {
  color: #fca5a5 !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: none !important;
  box-shadow: none !important;
}

body.page-portal footer.portal-app-footer {
  margin-top: 32px;
  padding: 10px clamp(16px, 3vw, 40px) calc(12px + env(safe-area-inset-bottom, 0px));
  background: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body.page-portal footer.portal-app-footer .portal-app-footer__inner {
  margin: 0;
  max-width: var(--portal-content-max);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: rgba(166, 167, 199, 0.82);
  text-align: center;
}

body.page-portal footer.portal-app-footer .portal-app-footer__meta {
  opacity: 0.9;
}

body.page-portal footer.portal-app-footer .portal-app-footer__legal-link {
  color: rgba(189, 190, 220, 0.95);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  transition: color 0.2s ease, border-color 0.2s ease;
}

body.page-portal footer.portal-app-footer .portal-app-footer__legal-link:hover {
  color: #e5e6ff;
  border-bottom-color: rgba(255, 255, 255, 0.25);
}

/* Toolbar sits below fixed header */
.page-portal .portal-dash-toolbar {
  padding-top: calc(var(--portal-header-h) + 2.75rem);
}

@media (max-width: 1023px) {
  body.page-portal #site-header.portal-app-header .portal-app-header__logo,
  body.page-portal #site-header.portal-app-header .brand-img {
    height: clamp(22px, 3.5vw + 12px, 44px) !important;
    max-width: clamp(52px, 14vw + 28px, 140px);
  }

  body.page-portal #site-header.portal-app-header .portal-app-header__link {
    font-size: clamp(0.65rem, 0.48rem + 0.85vw, 0.88rem);
  }

  .page-portal .portal-dash-toolbar {
    padding-top: calc(var(--portal-header-h) + 2.25rem);
  }
}

body.page-portal.portal-sidebar--open {
  overflow-x: hidden;
}

/* Sign-out confirmation — in-app dialog (works on light & dark portal pages) */
body.portal-logout-confirm-open {
  overflow: hidden;
}

.portal-logout-confirm {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top, 0px) + 12px) 24px 24px;
  box-sizing: border-box;
}

.portal-logout-confirm[hidden] {
  display: none !important;
}

.portal-logout-confirm__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 14, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.portal-logout-confirm__panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: clamp(22px, 4vw, 28px);
  border-radius: 16px;
  background:
    radial-gradient(ellipse 90% 80% at 10% 0%, rgba(20, 184, 166, 0.09) 0%, transparent 55%),
    radial-gradient(ellipse 80% 70% at 100% 100%, rgba(126, 217, 87, 0.07) 0%, transparent 50%),
    linear-gradient(180deg, #14141a 0%, #0c0c10 100%);
  border: 1px solid rgba(123, 126, 242, 0.22);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(161, 163, 255, 0.08),
    0 0 36px -24px rgba(126, 217, 87, 0.2);
  color: rgba(238, 240, 255, 0.95);
}

.portal-logout-confirm__title {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.portal-logout-confirm__text {
  margin: 0 0 22px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(200, 202, 235, 0.88);
}

.portal-logout-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.portal-logout-confirm__btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.portal-logout-confirm__btn--secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(238, 240, 255, 0.92);
}

.portal-logout-confirm__btn--secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.portal-logout-confirm__btn--danger {
  background: rgba(185, 28, 28, 0.45);
  border-color: rgba(248, 113, 113, 0.65);
  color: #fecaca;
}

.portal-logout-confirm__btn--danger:hover {
  background: rgba(220, 38, 38, 0.78);
  color: #fff;
  border-color: #f87171;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  .portal-logout-confirm__btn {
    transition: none;
  }
}

/* Locked portal area — click for details */
body.portal-access-modal-open {
  overflow: hidden;
}

.portal-access-modal {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top, 0px) + 12px) 24px 24px;
  box-sizing: border-box;
}

.portal-access-modal[hidden] {
  display: none !important;
}

.portal-access-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 14, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.portal-access-modal__panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: clamp(22px, 4vw, 28px);
  border-radius: 16px;
  background:
    radial-gradient(ellipse 90% 80% at 10% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 55%),
    linear-gradient(180deg, #14141a 0%, #0c0c10 100%);
  border: 1px solid rgba(123, 126, 242, 0.2);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(161, 163, 255, 0.07);
  color: rgba(238, 240, 255, 0.95);
}

.portal-access-modal__title {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.portal-access-modal__text {
  margin: 0 0 22px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(200, 202, 235, 0.88);
}

.portal-access-modal__text strong {
  color: rgba(232, 234, 255, 0.98);
  font-weight: 600;
}

.portal-access-modal__text a {
  color: rgba(165, 180, 252, 0.95);
  text-decoration: none;
  border-bottom: 1px solid rgba(165, 180, 252, 0.35);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.portal-access-modal__text a:hover {
  color: rgba(199, 210, 254, 1);
  border-bottom-color: rgba(199, 210, 254, 0.55);
}

.portal-access-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.portal-access-modal__btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.portal-access-modal__btn--primary {
  background: rgba(79, 70, 229, 0.85);
  border-color: rgba(129, 140, 248, 0.55);
  color: #fff;
}

.portal-access-modal__btn--primary:hover {
  background: rgba(99, 102, 241, 0.95);
  border-color: rgba(165, 180, 252, 0.65);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.28);
}

@media (prefers-reduced-motion: reduce) {
  .portal-access-modal__btn {
    transition: none;
  }

  .portal-access-modal__text a {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   Portal pages — small screens (forms, admin, dialogs)
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .portal-auth-wrap {
    padding: 0 clamp(12px, 4vw, 20px) max(36px, calc(24px + env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
  }

  .portal-auth-panel {
    padding: clamp(20px, 5vw, 28px);
  }

  .portal-auth-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .portal-auth-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .portal-access-modal {
    padding: max(12px, env(safe-area-inset-top, 0px) + 8px) max(12px, env(safe-area-inset-right, 0px))
      max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    align-items: flex-end;
  }

  .portal-access-modal__panel {
    max-height: min(85dvh, calc(100dvh - 2rem));
    overflow-y: auto;
  }

  .portal-dash-toolbar {
    padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px));
  }

  .admin-layout {
    padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: max(36px, calc(24px + env(safe-area-inset-bottom, 0px)));
  }

  .admin-table th,
  .admin-table td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  body.page-portal.page-admin .admin-accordion__summary {
    padding: 12px 14px;
    padding-right: 40px;
    font-size: 0.95rem;
  }

  body.page-portal.page-admin .admin-accordion__body {
    padding: 0 14px 14px;
  }

  body.page-portal.page-admin .portal-check {
    align-items: flex-start;
  }

  body.page-portal.page-admin .portal-check label {
    line-height: 1.35;
  }
}
