:root {
  --portal-bg: #f4f6fb;
  --portal-panel: #ffffff;
  --portal-text: #15151a;
  --portal-muted: #626774;
  --portal-border: rgba(21, 21, 26, 0.1);
  --portal-border-strong: rgba(21, 21, 26, 0.16);
  --portal-blue: #413df2;
  --portal-blue-dark: #2e2bb8;
  --portal-green: #127a78;
  --portal-red: #d92d20;
  --portal-amber: #a15c07;
  --portal-shadow: 0 22px 58px rgba(18, 24, 38, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.portal-page {
  min-height: 100vh;
  margin: 0;
  background: #f6f7fa;
  color: var(--portal-text);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.portal-page button,
body.portal-page input,
body.portal-page select,
body.portal-page textarea {
  font: inherit;
}

body.portal-page a {
  color: inherit;
}

.portal-skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  transform: translateY(-140%);
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  background: var(--portal-text);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.portal-skip-link:focus {
  transform: translateY(0);
}

.portal-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.portal-auth {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 3rem);
}

.portal-auth-header,
.portal-topbar {
  display: flex;
  align-items: center;
}

.portal-auth-header {
  align-self: start;
  width: min(100%, 1040px);
  margin: 0 auto;
  justify-content: space-between;
  gap: 1rem;
}

.portal-auth-header img,
.portal-brand img {
  display: block;
  width: 172px;
  height: auto;
}

.portal-auth-site-link {
  color: #4b5565;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
}

.portal-auth-site-link:hover,
.portal-auth-site-link:focus-visible {
  color: var(--portal-blue);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.portal-auth-shell {
  align-self: center;
  display: grid;
  align-items: center;
  grid-template-columns: minmax(320px, 420px);
  justify-content: center;
  justify-items: stretch;
  gap: clamp(1.2rem, 3vw, 1.7rem);
  width: min(100%, 420px);
  margin: 0 auto;
}

.portal-auth-copy {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 1rem;
  max-width: 420px;
  text-align: center;
}

.portal-eyebrow,
.portal-card-kicker {
  display: inline-flex;
  align-items: center;
  color: var(--portal-blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.portal-command h1 {
  max-width: 720px;
  margin: 0.75rem 0 0;
  color: var(--portal-text);
  font-size: clamp(2.6rem, 6vw, 5rem);
  font-weight: 800;
  line-height: 0.98;
}

.portal-auth-copy h1 {
  margin: 0;
  color: var(--portal-text);
  font-size: clamp(1.95rem, 3.5vw, 2.85rem);
  font-weight: 800;
  line-height: 1.05;
}

.portal-tag,
.portal-status,
.portal-scan-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.38rem 0.65rem;
  border: 1px solid var(--portal-border);
  border-radius: 999px;
  background: #fff;
  color: #343842;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.portal-login-card,
.portal-panel,
.portal-dialog-card {
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--portal-shadow);
}

.portal-login-card {
  align-self: center;
  display: grid;
  gap: 1.1rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: 0 16px 36px rgba(18, 24, 38, 0.08);
}

.portal-login-card .portal-card-kicker {
  color: #555b66;
}

.portal-login-card h2,
.portal-panel h2,
.portal-dialog-card h2 {
  margin: 0.25rem 0 0;
  color: var(--portal-text);
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  font-weight: 800;
  line-height: 1.1;
}

.portal-field {
  display: grid;
  gap: 0.45rem;
}

.portal-field label {
  color: #343842;
  font-size: 0.82rem;
  font-weight: 800;
}

.portal-field input,
.portal-field select,
.portal-field textarea,
.portal-search input,
.portal-filter-row select {
  width: 100%;
  min-height: 3rem;
  border: 1px solid var(--portal-border);
  border-radius: 6px;
  background: #fff;
  color: var(--portal-text);
  padding: 0.75rem 0.85rem;
  outline: none;
}

.portal-field textarea {
  min-height: 7rem;
  resize: vertical;
}

.portal-field input:focus-visible,
.portal-field select:focus-visible,
.portal-field textarea:focus-visible,
.portal-search input:focus-visible,
.portal-filter-row select:focus-visible,
.portal-primary-button:focus-visible,
.portal-secondary-button:focus-visible,
.portal-icon-button:focus-visible,
.portal-tabs a:focus-visible,
.portal-client-card:focus-visible {
  outline: 3px solid rgba(65, 61, 242, 0.35);
  outline-offset: 3px;
}

.portal-primary-button,
.portal-secondary-button,
.portal-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.portal-primary-button {
  min-height: 3rem;
  border: 1px solid var(--portal-blue);
  background: var(--portal-blue);
  color: #fff;
  padding: 0.85rem 1rem;
}

.portal-primary-button:hover {
  border-color: var(--portal-blue-dark);
  background: var(--portal-blue-dark);
}

.portal-secondary-button {
  min-height: 2.8rem;
  border: 1px solid var(--portal-border-strong);
  background: #fff;
  color: var(--portal-text);
  padding: 0.75rem 0.9rem;
}

.portal-secondary-button:hover {
  border-color: rgba(65, 61, 242, 0.32);
  color: var(--portal-blue);
}

.portal-icon-button {
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--portal-border);
  background: #fff;
  color: var(--portal-text);
  padding: 0;
}

.portal-icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-login-hint {
  margin: 0;
  color: var(--portal-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.portal-auth-note {
  margin: 0;
  padding-top: 0.2rem;
  color: var(--portal-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.portal-error {
  min-height: 1.25rem;
  margin: 0;
  color: var(--portal-red);
  font-size: 0.82rem;
  font-weight: 700;
}

.portal-app {
  min-height: 100vh;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--portal-border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.portal-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.portal-tabs a {
  padding: 0.65rem 0.78rem;
  border-radius: 6px;
  color: #343842;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.portal-tabs a:hover {
  background: rgba(65, 61, 242, 0.08);
  color: var(--portal-blue);
}

.portal-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.portal-user div {
  display: grid;
  text-align: right;
}

.portal-user span {
  color: var(--portal-muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-user strong {
  font-size: 0.88rem;
}

.portal-main {
  display: grid;
  gap: 1rem;
  width: min(100% - 2rem, 1460px);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) 0 3rem;
}

.portal-command {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 2vw, 1.5rem) 0;
}

.portal-command h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
}

.portal-command-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.portal-metrics,
.portal-grid {
  display: grid;
  gap: 1rem;
}

.portal-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.portal-metrics article {
  min-height: 8rem;
  padding: 1rem;
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(18, 24, 38, 0.06);
}

.portal-metrics span {
  display: block;
  color: var(--portal-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-metrics strong {
  display: block;
  margin-top: 0.5rem;
  color: var(--portal-text);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 800;
  line-height: 1;
}

.portal-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  align-items: start;
}

.portal-panel {
  min-width: 0;
  padding: clamp(1rem, 2vw, 1.25rem);
}

.portal-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.portal-panel-header > span {
  color: var(--portal-muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.portal-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 220px);
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}

.portal-client-list {
  display: grid;
  gap: 0.75rem;
  max-height: 680px;
  overflow: auto;
  padding-right: 0.2rem;
}

.portal-client-card {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fff;
  color: var(--portal-text);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
}

.portal-client-card:hover,
.portal-client-card.is-active {
  border-color: rgba(65, 61, 242, 0.35);
  box-shadow: 0 14px 34px rgba(65, 61, 242, 0.08);
}

.portal-client-card-top,
.portal-client-meta,
.portal-client-score-row,
.portal-history-item,
.portal-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.portal-client-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.25;
}

.portal-client-meta {
  flex-wrap: wrap;
  justify-content: flex-start;
  color: var(--portal-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.portal-score-bar {
  overflow: hidden;
  width: 100%;
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(21, 21, 26, 0.08);
}

.portal-score-bar span {
  display: block;
  height: 100%;
  width: var(--score-width, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--portal-blue), var(--portal-green));
}

.portal-status {
  color: var(--status-color, var(--portal-blue));
  background: var(--status-bg, rgba(65, 61, 242, 0.08));
  border-color: var(--status-border, rgba(65, 61, 242, 0.18));
}

.portal-client-detail {
  position: sticky;
  top: 5.5rem;
}

.portal-detail-stack {
  display: grid;
  gap: 1rem;
}

.portal-detail-title {
  display: grid;
  gap: 0.5rem;
}

.portal-detail-title h2 {
  font-size: clamp(1.6rem, 3vw, 2.25rem);
}

.portal-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.portal-detail-grid div,
.portal-note,
.portal-empty-state {
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fbfcff;
  padding: 0.85rem;
}

.portal-detail-grid span,
.portal-note span {
  display: block;
  color: var(--portal-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-detail-grid strong,
.portal-note strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--portal-text);
  font-size: 0.92rem;
  line-height: 1.4;
}

.portal-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.portal-scan-form,
.portal-associate-form {
  display: grid;
  gap: 0.9rem;
}

.portal-scan-options,
.portal-checkbox-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.portal-scan-options label,
.portal-checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.9rem;
  border: 1px solid var(--portal-border);
  border-radius: 6px;
  background: #fff;
  padding: 0.7rem;
  color: #343842;
  font-size: 0.82rem;
  font-weight: 800;
}

.portal-scan-results,
.portal-history-list,
.portal-action-list,
.portal-associate-list {
  display: grid;
  gap: 0.75rem;
}

.portal-empty-state {
  color: var(--portal-muted);
}

.portal-empty-state strong {
  display: block;
  color: var(--portal-text);
  margin-bottom: 0.25rem;
}

.portal-empty-state p {
  margin: 0;
  line-height: 1.5;
}

.portal-scan-summary {
  display: grid;
  gap: 1rem;
}

.portal-scan-score {
  display: grid;
  place-items: center;
  width: 9rem;
  aspect-ratio: 1;
  border: 10px solid rgba(65, 61, 242, 0.16);
  border-top-color: var(--portal-blue);
  border-radius: 50%;
  color: var(--portal-text);
  font-size: 2.2rem;
  font-weight: 800;
}

.portal-finding-list {
  display: grid;
  gap: 0.65rem;
}

.portal-finding {
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fff;
  padding: 0.85rem;
}

.portal-finding strong {
  display: block;
  color: var(--portal-text);
  font-size: 0.92rem;
}

.portal-finding span {
  display: block;
  margin-top: 0.25rem;
  color: var(--portal-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.portal-history-item,
.portal-action-item {
  align-items: start;
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fff;
  padding: 0.9rem;
}

.portal-history-item h3,
.portal-action-item h3 {
  margin: 0;
  font-size: 0.95rem;
}

.portal-history-item p,
.portal-action-item p {
  margin: 0.25rem 0 0;
  color: var(--portal-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.portal-associate-card {
  display: grid;
  gap: 0.45rem;
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fff;
  padding: 0.9rem;
}

.portal-associate-card h3 {
  margin: 0;
  color: var(--portal-text);
  font-size: 0.96rem;
  line-height: 1.35;
}

.portal-associate-card p {
  margin: 0;
  color: var(--portal-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.portal-permission-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.portal-dialog {
  width: min(100% - 2rem, 760px);
  border: 0;
  background: transparent;
  padding: 0;
}

.portal-dialog::backdrop {
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(8px);
}

.portal-dialog-card {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.portal-dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.portal-dialog-full {
  grid-column: 1 / -1;
}

.portal-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media (max-width: 1080px) {
  .portal-auth-shell,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .portal-client-detail {
    position: static;
  }

  .portal-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .portal-auth {
    overflow-x: hidden;
  }

  .portal-auth-header {
    align-items: flex-start;
  }

  .portal-auth-header img,
  .portal-brand img {
    width: 142px;
  }

  .portal-auth-site-link {
    max-width: 7.5rem;
    text-align: right;
  }

  .portal-auth-shell {
    align-self: start;
    width: 100%;
    padding-top: 1rem;
  }

  .portal-auth-copy,
  .portal-login-card {
    width: 100%;
    min-width: 0;
  }

  .portal-auth-copy h1 {
    font-size: clamp(1.85rem, 8vw, 2.25rem);
  }

  .portal-topbar {
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .portal-tabs {
    grid-column: 1 / -1;
    justify-content: flex-start;
    order: 3;
  }

  .portal-user div {
    display: none;
  }

  .portal-command {
    display: grid;
    align-items: start;
  }

  .portal-command-actions,
  .portal-command-actions .portal-primary-button,
  .portal-command-actions .portal-secondary-button {
    width: 100%;
  }

  .portal-metrics,
  .portal-filter-row,
  .portal-detail-grid,
  .portal-scan-options,
  .portal-checkbox-row,
  .portal-dialog-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .portal-auth-header {
    display: grid;
    justify-content: start;
  }

  .portal-auth-site-link {
    max-width: none;
    text-align: left;
  }

  .portal-auth-copy h1 {
    font-size: 1.95rem;
  }

  .portal-main {
    width: min(100% - 1rem, 1460px);
  }

  .portal-panel,
  .portal-login-card {
    padding: 1rem;
  }

  .portal-auth {
    padding: 1rem;
  }
}
