/* Eclipse Technology - Espace Client & Administration unifies.
   Charte sombre Eclipse (#0a0e1a / #0f1526 / #121829), Satoshi + JetBrains Mono (codes uniquement).
   Zero AI slop : pas de bordure gauche epaisse, pas de point statut circulaire, pas de select natif,
   hauteurs controles alignees 44px (delta <= 1px), contrastes >= 4.5:1. */

:root {
  color-scheme: dark;
  --portal-surface: #0f1526;
  --portal-surface-alt: #131b30;
  --portal-line: #1e2945;
  --portal-line-strong: #2d3c63;
  --portal-ink: #f1f5f9;
  --portal-ink-muted: #a6b4cc;
  --portal-ok-bg: rgba(16, 185, 129, 0.12);
  --portal-ok-border: rgba(52, 211, 153, 0.36);
  --portal-ok-text: #86efac;
  --portal-warn-bg: rgba(245, 158, 11, 0.12);
  --portal-warn-border: rgba(251, 191, 36, 0.36);
  --portal-warn-text: #fde68a;
  --portal-err-bg: #1d1422;
  --portal-err-border: rgba(248, 113, 113, 0.44);
  --portal-err-text: #fecaca;
  --portal-info-bg: #0f1d33;
  --portal-info-border: rgba(56, 189, 248, 0.42);
  --portal-info-text: #bae6fd;
  --portal-control-h: 44px;
}

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

.portal-shell [hidden],
.portal-modal-backdrop[hidden],
.portal-toast[hidden] {
  display: none !important;
}

.portal-shell {
  max-width: var(--max, 1240px);
  min-height: calc(100dvh - 140px);
  margin: 0 auto;
  padding: 96px clamp(16px, 4vw, 56px) 84px;
  min-width: 0;
}

/* ---------- En-tete de travail sobre (1-2 niveaux) ---------- */

.portal-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--portal-line);
}

.portal-head-main {
  min-width: 0;
}

.portal-head h1 {
  margin: 0;
  max-width: none;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.08;
  font-weight: 660;
  letter-spacing: -0.025em;
  color: var(--portal-ink);
  text-shadow: none;
}

.portal-subtitle {
  margin-top: 8px;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--portal-ink-muted);
}

.portal-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.portal-session-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

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

.portal-identity {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: var(--portal-control-h);
  min-height: var(--portal-control-h);
  padding: 0 14px;
  border: 1px solid var(--portal-line);
  border-radius: var(--radius-btn, 8px);
  background: var(--portal-surface);
  font-size: 13.5px;
}

.portal-user-email {
  color: var(--portal-ink);
  font-weight: 540;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-role-tag {
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--portal-line-strong);
  background: rgba(79, 109, 245, 0.14);
  color: #c7d2fe;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Bandeau apercu lecture seule (sans bordure gauche epaisse) ---------- */

.portal-impersonation {
  margin-top: 20px;
  padding: 14px 18px;
  border: 1px solid var(--portal-info-border);
  border-radius: var(--radius, 12px);
  background: var(--portal-info-bg);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
}

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

.portal-impersonation-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.portal-impersonation-copy strong {
  font-size: 14.5px;
  font-weight: 640;
  color: #e0f2fe;
}

.portal-impersonation-copy span {
  font-size: 13.5px;
  color: var(--portal-info-text);
}

/* ---------- Chargement initial ---------- */

.portal-loading {
  margin-top: 48px;
  padding: 40px 24px;
  border: 1px solid var(--portal-line);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--portal-ink-muted);
  font-size: 15px;
}

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

.portal-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--portal-line-strong);
  border-top-color: var(--indigo, #4f6df5);
  animation: portal-spin 800ms linear infinite;
}

@keyframes portal-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Boutons & controles tactiles (exactement 44px) ---------- */

.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--portal-control-h);
  min-height: var(--portal-control-h);
  padding: 0 16px;
  border-radius: var(--radius-btn, 8px);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 580;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 120ms ease;
}

.portal-btn:active:not(:disabled) {
  transform: translateY(2px);
}

.portal-btn:disabled,
.portal-btn[aria-disabled="true"] {
  opacity: 0.48;
  cursor: not-allowed;
}

.portal-btn-primary {
  background: var(--indigo-fill, #3b57db);
  border-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.portal-btn-primary:hover:not(:disabled),
.portal-btn-primary:focus-visible:not(:disabled) {
  background: var(--indigo-fill-hover, #4360ec);
  color: #ffffff;
}

.portal-btn-secondary {
  background: var(--portal-surface-alt);
  border-color: var(--portal-line-strong);
  color: var(--portal-ink);
}

.portal-btn-secondary:hover:not(:disabled),
.portal-btn-secondary:focus-visible:not(:disabled) {
  border-color: var(--indigo, #4f6df5);
  background: #192440;
  color: #ffffff;
}

.portal-btn-ghost {
  background: transparent;
  border-color: var(--portal-line-strong);
  color: #cbd5e1;
}

.portal-btn-ghost:hover:not(:disabled),
.portal-btn-ghost:focus-visible:not(:disabled) {
  border-color: rgba(240, 240, 245, 0.45);
  background: rgba(240, 240, 245, 0.06);
  color: #ffffff;
}

.portal-btn-danger {
  background: #991b1b;
  border-color: rgba(248, 113, 113, 0.5);
  color: #ffffff;
}

.portal-btn-danger:hover:not(:disabled),
.portal-btn-danger:focus-visible:not(:disabled) {
  background: #b91c1c;
  color: #ffffff;
}

.portal-btn-sm {
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.portal-btn.is-copied {
  border-color: rgba(6, 182, 218, 0.65);
  background: rgba(6, 182, 218, 0.14);
  color: #67e8f9;
}

/* ---------- Ecran de connexion Magic Link ---------- */

.portal-login {
  margin-top: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  border: 1px solid var(--portal-line);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
  overflow: hidden;
}

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

.portal-login-pane {
  padding: clamp(24px, 3.6vw, 44px);
  border-right: 1px solid var(--portal-line);
}

.portal-scope-pane {
  padding: clamp(24px, 3.6vw, 44px);
  background: #0d1322;
}

.portal-login h2 {
  font-size: clamp(21px, 2vw, 26px);
  line-height: 1.18;
  font-weight: 630;
  letter-spacing: -0.015em;
  color: var(--portal-ink);
}

.portal-login-lead {
  margin-top: 10px;
  color: var(--portal-ink-muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 52ch;
}

.portal-form {
  margin-top: 24px;
  display: grid;
  gap: 18px;
}

.portal-field {
  display: grid;
  gap: 7px;
}

.portal-field label,
.portal-fieldset legend {
  font-size: 13.5px;
  font-weight: 580;
  color: #dce4f2;
  padding: 0;
}

.portal-field input[type="email"],
.portal-field input[type="text"],
.portal-field input[type="number"],
.portal-search-wrap input[type="search"] {
  width: 100%;
  height: var(--portal-control-h);
  min-height: var(--portal-control-h);
  padding: 0 14px;
  border-radius: var(--radius-btn, 8px);
  border: 1px solid var(--portal-line-strong);
  background: #0a0e1a;
  color: var(--portal-ink);
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.portal-field input::placeholder,
.portal-search-wrap input::placeholder {
  color: #7c8ca8;
}

.portal-field input:focus-visible,
.portal-search-wrap input:focus-visible {
  outline: 2px solid var(--indigo, #4f6df5);
  outline-offset: 2px;
  border-color: var(--indigo, #4f6df5);
}

.portal-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.portal-notice {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-btn, 8px);
  border: 1px solid var(--portal-line-strong);
  font-size: 14px;
  line-height: 1.55;
}

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

.portal-notice-ok {
  background: var(--portal-ok-bg);
  border-color: var(--portal-ok-border);
  color: var(--portal-ok-text);
}

.portal-notice-err {
  background: var(--portal-err-bg);
  border-color: var(--portal-err-border);
  color: var(--portal-err-text);
}

.portal-login-footnote {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--portal-line);
  font-size: 13px;
  color: var(--portal-ink-muted);
}

.portal-scope-list {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
}

.portal-scope-list li {
  padding: 16px 0;
  border-top: 1px solid var(--portal-line);
  display: grid;
  gap: 5px;
}

.portal-scope-list li:last-child {
  padding-bottom: 0;
}

.portal-scope-list strong {
  font-size: 15px;
  font-weight: 620;
  color: var(--portal-ink);
}

.portal-scope-list span {
  font-size: 14px;
  line-height: 1.55;
  color: var(--portal-ink-muted);
}

/* ---------- Workspace (Client & Admin) ---------- */

.portal-workspace {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  min-width: 0;
  max-width: 100%;
}

.portal-workspace > *,
.portal-tabpanel > * {
  min-width: 0;
  max-width: 100%;
}

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

/* Bandeau KPI continu divise par filets 1px (zero containeritis) */

.portal-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--portal-line);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
  overflow: hidden;
}

.portal-kpi-cell {
  padding: 18px 20px;
  border-right: 1px solid var(--portal-line);
  display: grid;
  gap: 6px;
  min-width: 0;
}

.portal-kpi-cell:last-child {
  border-right: 0;
}

.portal-kpi-cell dt {
  font-size: 13px;
  font-weight: 520;
  color: var(--portal-ink-muted);
}

.portal-kpi-cell dd {
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 660;
  letter-spacing: -0.02em;
  color: var(--portal-ink);
  font-variant-numeric: tabular-nums;
}

.portal-kpi-cell dd.is-accent {
  color: #7dd3fc;
}

.portal-kpi-sub {
  font-size: 12.5px;
  color: var(--portal-ink-muted);
}

/* ---------- Barres d'outils & onglets segmentes (hauteur 44px exacte) ---------- */

.portal-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.portal-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.portal-segmented {
  display: inline-flex;
  align-items: center;
  height: var(--portal-control-h);
  min-height: var(--portal-control-h);
  padding: 3px;
  border: 1px solid var(--portal-line-strong);
  border-radius: var(--radius-btn, 8px);
  background: #0d1322;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
}

.portal-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--portal-ink-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.portal-seg-btn:hover,
.portal-seg-btn:focus-visible {
  color: #ffffff;
  background: rgba(240, 240, 245, 0.06);
}

.portal-seg-btn.is-active,
.portal-seg-btn[aria-selected="true"] {
  background: var(--indigo-fill, #3b57db);
  color: #ffffff;
}

.portal-tab-count {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.45);
  color: inherit;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Barre de filtres Admin (controles voisins 44px identiques) ---------- */

.portal-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

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

.portal-search-wrap {
  position: relative;
  flex: 1 1 260px;
  min-width: 220px;
}

.portal-search-wrap input[type="search"] {
  padding-right: 42px;
}

.portal-kbd {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--portal-line-strong);
  background: var(--portal-surface);
  color: var(--portal-ink-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11.5px;
  pointer-events: none;
}

/* Custom accessible dropdown (listbox aria, sans menu natif navigateur) */

.portal-dropdown {
  position: relative;
  flex: 0 0 auto;
}

.portal-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 176px;
  height: var(--portal-control-h);
  min-height: var(--portal-control-h);
  padding: 0 14px;
  border: 1px solid var(--portal-line-strong);
  border-radius: var(--radius-btn, 8px);
  background: #0d1322;
  color: var(--portal-ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 560;
  cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.portal-dropdown-trigger:hover,
.portal-dropdown-trigger:focus-visible,
.portal-dropdown-trigger[aria-expanded="true"] {
  border-color: var(--indigo, #4f6df5);
  background: var(--portal-surface-alt);
}

.portal-caret {
  font-size: 11px;
  color: var(--portal-ink-muted);
  transition: transform 150ms var(--ease);
}

.portal-dropdown-trigger[aria-expanded="true"] .portal-caret {
  transform: rotate(180deg);
}

.portal-dropdown-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 100%;
  margin: 0;
  padding: 5px;
  list-style: none;
  border: 1px solid var(--portal-line-strong);
  border-radius: var(--radius-btn, 8px);
  background: var(--portal-surface-alt);
  box-shadow: 0 18px 40px rgba(2, 6, 20, 0.72);
  display: grid;
  gap: 2px;
}

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

.portal-dropdown-list li {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: #cbd5e1;
  cursor: pointer;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.portal-dropdown-list li:hover,
.portal-dropdown-list li.is-focused {
  background: rgba(79, 109, 245, 0.18);
  color: #ffffff;
}

.portal-dropdown-list li.is-selected {
  background: var(--indigo-fill, #3b57db);
  color: #ffffff;
  font-weight: 600;
}

/* ---------- Panneaux, tableaux & lignes ---------- */

.portal-tabpanel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  min-width: 0;
  max-width: 100%;
}

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

.portal-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
}

.portal-section-head h2 {
  font-size: 19px;
  font-weight: 630;
  letter-spacing: -0.015em;
  color: var(--portal-ink);
}

.portal-section-meta {
  font-size: 13.5px;
  color: var(--portal-ink-muted);
}

.portal-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--portal-line);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.portal-table thead th {
  padding: 13px 16px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 620;
  color: var(--portal-ink-muted);
  background: #0d1322;
  border-bottom: 1px solid var(--portal-line);
  white-space: nowrap;
}

.portal-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--portal-line);
  color: var(--portal-ink);
  vertical-align: middle;
}

.portal-table tbody tr:last-child td {
  border-bottom: 0;
}

.portal-table tbody tr:hover td {
  background: rgba(79, 109, 245, 0.04);
}

.portal-cell-main {
  display: grid;
  gap: 3px;
}

.portal-cell-title {
  font-weight: 600;
  color: var(--portal-ink);
}

.portal-cell-sub {
  font-size: 13px;
  color: var(--portal-ink-muted);
}

.portal-mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12.5px;
  color: #cbd5e1;
}

.portal-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.portal-row-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

@media (max-width: 960px) {
  .portal-row-actions {
    flex-wrap: wrap;
  }
}

/* Etiquettes statut typographiques nettes (ZERO point circulaire) */

.portal-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--portal-line-strong);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.portal-status-ok {
  background: var(--portal-ok-bg);
  border-color: var(--portal-ok-border);
  color: var(--portal-ok-text);
}

.portal-status-warn {
  background: var(--portal-warn-bg);
  border-color: var(--portal-warn-border);
  color: var(--portal-warn-text);
}

.portal-status-err {
  background: var(--portal-err-bg);
  border-color: var(--portal-err-border);
  color: var(--portal-err-text);
}

.portal-status-neutral {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.28);
  color: #cbd5e1;
}

/* ---------- Zone cle Ed25519 reemise ---------- */

.portal-key-row td {
  padding: 0 16px 18px;
  background: #0c1221;
}

.portal-key-row:hover td {
  background: #0c1221;
}

.portal-key-row .portal-key-reveal {
  margin-top: 0;
}

.portal-key-reveal {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid rgba(79, 109, 245, 0.45);
  border-radius: var(--radius-btn, 8px);
  background: #0a0e1a;
  display: grid;
  gap: 10px;
}

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

.portal-key-label {
  font-size: 13px;
  font-weight: 600;
  color: #c7d2fe;
}

.portal-key-code {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--portal-line);
  border-radius: 6px;
  background: #0f1526;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  word-break: break-all;
  white-space: pre-wrap;
}

/* ---------- Vue d'ensemble & connecteurs ---------- */

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

.portal-panel {
  border: 1px solid var(--portal-line);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
  padding: 20px 22px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.portal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.portal-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 0;
  border-top: 1px solid var(--portal-line);
}

.portal-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.portal-list li:last-child {
  padding-bottom: 0;
}

.portal-connectors-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.portal-connector-card {
  padding: 18px 20px;
  border: 1px solid var(--portal-line);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
  display: grid;
  gap: 10px;
  align-content: start;
}

.portal-connector-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.portal-connector-head h3 {
  font-size: 16px;
  font-weight: 630;
  color: var(--portal-ink);
}

.portal-connector-detail {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--portal-ink-muted);
}

.portal-connector-time {
  font-size: 12.5px;
  color: #8b9bb8;
}

.portal-empty {
  padding: 32px 24px;
  border: 1px solid var(--portal-line);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
  display: grid;
  gap: 8px;
}

.portal-empty strong {
  font-size: 16px;
  color: var(--portal-ink);
}

.portal-empty p {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--portal-ink-muted);
  max-width: 60ch;
}

.portal-empty a {
  color: #93c5fd;
}

/* ---------- Modales accessibles ---------- */

.portal-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(4, 7, 16, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

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

.portal-modal {
  width: min(560px, 100%);
  border: 1px solid var(--portal-line-strong);
  border-radius: var(--radius, 12px);
  background: var(--portal-surface);
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.portal-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--portal-line);
}

.portal-modal-head h2 {
  font-size: 20px;
  font-weight: 640;
  color: var(--portal-ink);
}

.portal-icon-close {
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--portal-line-strong);
  background: transparent;
  color: var(--portal-ink-muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.portal-icon-close:hover,
.portal-icon-close:focus-visible {
  color: #ffffff;
  border-color: rgba(240, 240, 245, 0.45);
}

.portal-modal-desc {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--portal-ink-muted);
}

.portal-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.portal-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.portal-radio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--portal-control-h);
  min-height: var(--portal-control-h);
  padding: 0 14px;
  border-radius: var(--radius-btn, 8px);
  border: 1px solid var(--portal-line-strong);
  background: #0a0e1a;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 560;
  cursor: pointer;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease), color 140ms var(--ease);
}

.portal-radio-btn.is-selected,
.portal-radio-btn[aria-checked="true"] {
  border-color: var(--indigo, #4f6df5);
  background: rgba(79, 109, 245, 0.22);
  color: #ffffff;
}

.portal-field-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
}

.portal-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  font-size: 14px;
  color: #dbe3f0;
  cursor: pointer;
}

.portal-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--indigo, #4f6df5);
  flex-shrink: 0;
}

.portal-modal-foot {
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--portal-line);
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Toast ---------- */

.portal-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 16px;
  border-radius: var(--radius-btn, 8px);
  border: 1px solid var(--portal-line-strong);
  background: #141d34;
  color: var(--portal-ink);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}

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

.portal-toast.is-error {
  background: var(--portal-err-bg);
  border-color: var(--portal-err-border);
  color: var(--portal-err-text);
}

.portal-toast.is-ok {
  border-color: var(--portal-ok-border);
}

/* ---------- Responsive (375px mobile & tablettes) ---------- */

@media (max-width: 960px) {
  .portal-login {
    grid-template-columns: minmax(0, 1fr);
  }

  .portal-login-pane {
    border-right: 0;
    border-bottom: 1px solid var(--portal-line);
  }

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

  .portal-kpi-cell:nth-child(2) {
    border-right: 0;
  }

  .portal-kpi-cell:nth-child(1),
  .portal-kpi-cell:nth-child(2) {
    border-bottom: 1px solid var(--portal-line);
  }

  .portal-overview-grid,
  .portal-connectors-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .portal-shell {
    padding-top: 84px;
    padding-bottom: 64px;
  }

  .portal-head-actions,
  .portal-session-bar {
    width: 100%;
  }

  .portal-identity {
    width: 100%;
    justify-content: space-between;
  }

  .portal-user-email {
    max-width: 190px;
  }

  .portal-kpi-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .portal-kpi-cell {
    border-right: 0;
    border-bottom: 1px solid var(--portal-line);
  }

  .portal-kpi-cell:last-child {
    border-bottom: 0;
  }

  .portal-toolbar,
  .portal-toolbar-actions,
  .portal-filter-bar {
    width: 100%;
  }

  .portal-segmented {
    width: 100%;
  }

  .portal-dropdown,
  .portal-dropdown-trigger {
    width: 100%;
  }

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

  .portal-kbd {
    display: none;
  }

  .portal-modal {
    padding: 18px;
  }

  .portal-modal-foot .portal-btn {
    flex: 1 1 auto;
  }
}
