/* SIPRE Design System — shared Admin + future M7C portal
   License: project-owned. Icons: original SIPRE line icons (no CDN). */

:root {
  /* Brand */
  --sipre-navy-950: #0b1f3a;
  --sipre-navy-900: #123056;
  --sipre-navy-800: #1a3f6f;
  --sipre-navy-700: #245189;
  --sipre-cyan-600: #0e8fad;
  --sipre-cyan-500: #14a8cb;
  --sipre-cyan-100: #e6f7fb;

  /* Neutrals */
  --sipre-bg: #f4f6f9;
  --sipre-surface: #ffffff;
  --sipre-surface-muted: #f8fafc;
  --sipre-border: #e2e8f0;
  --sipre-border-strong: #cbd5e1;
  --sipre-text: #0f172a;
  --sipre-text-secondary: #475569;
  --sipre-text-muted: #64748b;
  --sipre-text-inverse: #ffffff;

  /* Semantic */
  --sipre-success: #15803d;
  --sipre-success-bg: #ecfdf5;
  --sipre-warning: #b45309;
  --sipre-warning-bg: #fffbeb;
  --sipre-danger: #b91c1c;
  --sipre-danger-bg: #fef2f2;
  --sipre-info: #1d4ed8;
  --sipre-info-bg: #eff6ff;

  /* Layout */
  --sipre-radius-sm: 6px;
  --sipre-radius: 10px;
  --sipre-radius-lg: 14px;
  --sipre-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --sipre-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --sipre-sidebar-width: 260px;
  --sipre-topbar-height: 64px;
  --sipre-touch: 44px;
  --sipre-focus: 0 0 0 3px rgba(20, 168, 203, 0.35);
  --sipre-visual-viewport-top: 0px;
  --sipre-visual-viewport-height: 100dvh;

  /* Typography */
  --sipre-font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --sipre-font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  --sipre-text-xs: 0.75rem;
  --sipre-text-sm: 0.875rem;
  --sipre-text-md: 1rem;
  --sipre-text-lg: 1.125rem;
  --sipre-text-xl: 1.35rem;
  --sipre-text-2xl: 1.75rem;

  /* Breakpoints (documented; used via media queries) */
  /* sm 640 / md 768 / tablet drawer ≤1024 / desktop ≥1025 */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--sipre-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--sipre-text);
  background: var(--sipre-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--sipre-navy-800);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--sipre-cyan-600);
}

img {
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: none;
  box-shadow: var(--sipre-focus);
}

.sipre-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;
}

/* ——— Buttons ——— */
.sipre-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--sipre-touch);
  padding: 0.55rem 1rem;
  border-radius: var(--sipre-radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: var(--sipre-text-sm);
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  user-select: none;
}

.sipre-btn:disabled,
.sipre-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.sipre-btn--primary {
  background: var(--sipre-navy-900);
  color: var(--sipre-text-inverse);
}

.sipre-btn--primary:hover {
  background: var(--sipre-navy-800);
  color: var(--sipre-text-inverse);
}

.sipre-btn--secondary {
  background: var(--sipre-surface);
  color: var(--sipre-navy-900);
  border-color: var(--sipre-border-strong);
}

.sipre-btn--secondary:hover {
  background: var(--sipre-surface-muted);
}

.sipre-btn--danger {
  background: var(--sipre-danger);
  color: var(--sipre-text-inverse);
}

.sipre-btn--danger:hover {
  background: #991b1b;
  color: var(--sipre-text-inverse);
}

.sipre-btn--ghost {
  background: transparent;
  color: var(--sipre-navy-800);
  border-color: transparent;
}

.sipre-btn--ghost:hover {
  background: rgba(18, 48, 86, 0.06);
}

.sipre-btn--block {
  width: 100%;
}

.sipre-btn--icon {
  width: var(--sipre-touch);
  padding: 0;
}

/* ——— Forms ——— */
.sipre-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.sipre-field__label {
  font-size: var(--sipre-text-sm);
  font-weight: 600;
  color: var(--sipre-text-secondary);
}

.sipre-field__hint {
  font-size: var(--sipre-text-xs);
  color: var(--sipre-text-muted);
}

.sipre-field__error {
  font-size: var(--sipre-text-xs);
  color: var(--sipre-danger);
}

.sipre-input,
.sipre-select,
.sipre-textarea {
  width: 100%;
  min-height: var(--sipre-touch);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--sipre-border-strong);
  border-radius: var(--sipre-radius-sm);
  background: var(--sipre-surface);
  color: var(--sipre-text);
  font: inherit;
  /* 16px min: iOS Safari zooms focused inputs below this. */
  font-size: 16px;
  font-size: max(16px, var(--sipre-text-md));
}

.sipre-input:focus,
.sipre-select:focus,
.sipre-textarea:focus {
  border-color: var(--sipre-cyan-500);
}

.sipre-input--invalid,
.sipre-select--invalid {
  border-color: var(--sipre-danger);
}

.sipre-input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.sipre-input-group .sipre-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.sipre-input-group .sipre-btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 0;
}

.sipre-search {
  position: relative;
}

.sipre-search .sipre-input {
  padding-left: 2.5rem;
}

.sipre-search__icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sipre-text-muted);
  pointer-events: none;
}

/* ——— Surfaces ——— */
.sipre-card {
  background: var(--sipre-surface);
  border: 1px solid var(--sipre-border);
  border-radius: var(--sipre-radius);
  box-shadow: var(--sipre-shadow-sm);
  padding: 1.25rem;
}

.sipre-card__title {
  margin: 0 0 0.35rem;
  font-size: var(--sipre-text-lg);
  font-weight: 700;
  color: var(--sipre-navy-900);
}

.sipre-card__subtitle {
  margin: 0 0 1rem;
  color: var(--sipre-text-muted);
  font-size: var(--sipre-text-sm);
}

.sipre-stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 6.5rem;
}

.sipre-stat__label {
  font-size: var(--sipre-text-sm);
  color: var(--sipre-text-muted);
  font-weight: 600;
}

.sipre-stat__value {
  font-size: var(--sipre-text-2xl);
  font-weight: 700;
  color: var(--sipre-navy-900);
  letter-spacing: -0.02em;
}

.sipre-stat__meta {
  font-size: var(--sipre-text-xs);
  color: var(--sipre-text-secondary);
}

.sipre-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

/* ——— Badge / Alert ——— */
.sipre-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: var(--sipre-text-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.sipre-badge--success {
  background: var(--sipre-success-bg);
  color: var(--sipre-success);
  border-color: #bbf7d0;
}

.sipre-badge--warning {
  background: var(--sipre-warning-bg);
  color: var(--sipre-warning);
  border-color: #fde68a;
}

.sipre-badge--danger {
  background: var(--sipre-danger-bg);
  color: var(--sipre-danger);
  border-color: #fecaca;
}

.sipre-badge--info {
  background: var(--sipre-info-bg);
  color: var(--sipre-info);
  border-color: #bfdbfe;
}

.sipre-badge--neutral {
  background: var(--sipre-surface-muted);
  color: var(--sipre-text-secondary);
  border-color: var(--sipre-border);
}

.sipre-badge--soon {
  background: var(--sipre-cyan-100);
  color: var(--sipre-navy-800);
  border-color: #b6e8f3;
  font-weight: 600;
}

.sipre-alert {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border-radius: var(--sipre-radius);
  border: 1px solid var(--sipre-border);
  background: var(--sipre-surface);
}

.sipre-alert--danger {
  background: var(--sipre-danger-bg);
  border-color: #fecaca;
  color: #7f1d1d;
}

.sipre-alert--warning {
  background: var(--sipre-warning-bg);
  border-color: #fde68a;
  color: #78350f;
}

.sipre-alert--info {
  background: var(--sipre-info-bg);
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.sipre-alert--success {
  background: var(--sipre-success-bg);
  border-color: #bbf7d0;
  color: #14532d;
}

.sipre-alert__title {
  font-weight: 700;
  margin: 0 0 0.15rem;
}

.sipre-alert__body {
  margin: 0;
  font-size: var(--sipre-text-sm);
}

/* ——— Table ——— */
.sipre-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--sipre-border);
  border-radius: var(--sipre-radius);
  background: var(--sipre-surface);
}

.sipre-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.sipre-table th,
.sipre-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--sipre-border);
  vertical-align: middle;
  font-size: var(--sipre-text-sm);
}

.sipre-table th {
  background: var(--sipre-surface-muted);
  color: var(--sipre-text-secondary);
  font-weight: 700;
  white-space: nowrap;
}

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

.sipre-table tbody tr:hover {
  background: rgba(20, 168, 203, 0.04);
}

.sipre-table tr.sipre-table__row--clickable {
  cursor: pointer;
}

/* Mobile list cards for tables */
.sipre-mobile-list {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

.sipre-mobile-card {
  background: var(--sipre-surface);
  border: 1px solid var(--sipre-border);
  border-radius: var(--sipre-radius);
  padding: 1rem;
  box-shadow: var(--sipre-shadow-sm);
}

.sipre-mobile-card__title {
  font-weight: 700;
  color: var(--sipre-navy-900);
  margin: 0 0 0.35rem;
}

.sipre-mobile-card__meta {
  display: grid;
  gap: 0.25rem;
  font-size: var(--sipre-text-sm);
  color: var(--sipre-text-secondary);
}

@media (max-width: 767px) {
  .sipre-table-wrap--responsive {
    display: none;
  }

  .sipre-mobile-list--responsive {
    display: flex;
  }
}

/* ——— Empty / Loading / Skeleton ——— */
.sipre-empty,
.sipre-error-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--sipre-text-secondary);
}

.sipre-empty__title,
.sipre-error-state__title {
  margin: 0.75rem 0 0.35rem;
  color: var(--sipre-navy-900);
  font-size: var(--sipre-text-lg);
}

.sipre-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--sipre-text-secondary);
  font-size: var(--sipre-text-sm);
}

.sipre-spinner {
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid var(--sipre-border-strong);
  border-top-color: var(--sipre-cyan-500);
  border-radius: 50%;
  animation: sipre-spin 0.7s linear infinite;
}

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

.sipre-skeleton {
  display: block;
  height: 1rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: sipre-shimmer 1.2s ease-in-out infinite;
}

@keyframes sipre-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* ——— Page chrome ——— */
.sipre-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.sipre-page-header__title {
  margin: 0;
  font-size: var(--sipre-text-xl);
  font-weight: 700;
  color: var(--sipre-navy-950);
}

.sipre-page-header__subtitle {
  margin: 0.25rem 0 0;
  color: var(--sipre-text-muted);
  font-size: var(--sipre-text-sm);
}

.sipre-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sipre-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  font-size: var(--sipre-text-sm);
  color: var(--sipre-text-muted);
}

.sipre-breadcrumb a {
  color: var(--sipre-text-secondary);
  text-decoration: none;
}

.sipre-breadcrumb a:hover {
  color: var(--sipre-cyan-600);
}

.sipre-breadcrumb__sep {
  color: var(--sipre-border-strong);
}

.sipre-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ——— Dialog / Toast ——— */
.sipre-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.sipre-dialog {
  width: min(480px, 100%);
  background: var(--sipre-surface);
  border-radius: var(--sipre-radius-lg);
  border: 1px solid var(--sipre-border);
  box-shadow: var(--sipre-shadow);
  padding: 1.25rem;
}

.sipre-dialog__title {
  margin: 0 0 0.5rem;
  font-size: var(--sipre-text-lg);
  color: var(--sipre-navy-900);
}

.sipre-dialog__body {
  margin: 0 0 1.25rem;
  color: var(--sipre-text-secondary);
  font-size: var(--sipre-text-sm);
}

.sipre-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sipre-toast-host {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}

.sipre-toast {
  background: var(--sipre-navy-900);
  color: var(--sipre-text-inverse);
  border-radius: var(--sipre-radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--sipre-shadow);
  font-size: var(--sipre-text-sm);
}

.sipre-toast--success {
  background: #14532d;
}

.sipre-toast--error {
  background: #7f1d1d;
}

/* ——— Wizard ——— */
.sipre-wizard-steps {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.sipre-wizard-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--sipre-border);
  background: var(--sipre-surface);
  font-size: var(--sipre-text-sm);
  color: var(--sipre-text-muted);
}

.sipre-wizard-step--active {
  border-color: var(--sipre-cyan-500);
  color: var(--sipre-navy-900);
  background: var(--sipre-cyan-100);
  font-weight: 700;
}

.sipre-wizard-step--done {
  border-color: #bbf7d0;
  color: var(--sipre-success);
}

.sipre-wizard-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--sipre-surface-muted);
  font-weight: 700;
  font-size: var(--sipre-text-xs);
}

.sipre-wizard-step--active .sipre-wizard-step__num {
  background: var(--sipre-navy-900);
  color: white;
}

.sipre-dropzone {
  border: 1.5px dashed var(--sipre-border-strong);
  border-radius: var(--sipre-radius);
  padding: 1.5rem;
  text-align: center;
  background: var(--sipre-surface-muted);
  color: var(--sipre-text-secondary);
}

.sipre-dropzone--active {
  border-color: var(--sipre-cyan-500);
  background: var(--sipre-cyan-100);
}

.sipre-file-picker {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.sipre-file-picker label:focus-within {
  outline: 2px solid var(--sipre-cyan-500);
  outline-offset: 2px;
}

/* ——— App shell ——— */
.sipre-shell {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sipre-sidebar-width) 1fr;
  grid-template-rows: calc(var(--sipre-topbar-height) + env(safe-area-inset-top, 0px)) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.sipre-shell__sidebar {
  grid-area: sidebar;
  background: var(--sipre-navy-950);
  color: var(--sipre-text-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: -webkit-fill-available;
  height: 100dvh;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sipre-shell__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  min-height: var(--sipre-topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sipre-shell__brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.sipre-shell__brand-text {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: var(--sipre-text-sm);
}

.sipre-shell__nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.65rem 1rem;
}

.sipre-nav-link,
.sipre-nav-soon {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--sipre-touch);
  padding: 0.45rem 0.75rem;
  border-radius: var(--sipre-radius-sm);
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: var(--sipre-text-sm);
  font-weight: 550;
  margin-bottom: 0.2rem;
}

.sipre-nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.sipre-nav-link.active {
  background: rgba(20, 168, 203, 0.22);
  color: white;
  box-shadow: inset 3px 0 0 var(--sipre-cyan-500);
}

.sipre-nav-soon {
  opacity: 0.55;
  cursor: not-allowed;
  justify-content: space-between;
}

.sipre-nav-soon .sipre-badge--soon {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}

.sipre-shell__topbar {
  grid-area: topbar;
  background: var(--sipre-surface);
  border-bottom: 1px solid var(--sipre-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: env(safe-area-inset-top, 0px) 1.25rem 0 1.25rem;
  min-height: calc(var(--sipre-topbar-height) + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  z-index: 30;
  min-width: 0;
  overflow: hidden;
}

.sipre-shell__topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.sipre-shell__title {
  margin: 0;
  font-size: var(--sipre-text-lg);
  font-weight: 700;
  color: var(--sipre-navy-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sipre-shell__topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  max-width: 55%;
  min-width: 0;
}

.sipre-shell__user {
  text-align: right;
  font-size: var(--sipre-text-sm);
}

.sipre-shell__user-name {
  font-weight: 700;
  color: var(--sipre-navy-900);
}

.sipre-shell__user-role {
  color: var(--sipre-text-muted);
  font-size: var(--sipre-text-xs);
}

.sipre-shell__org {
  display: none;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--sipre-border);
  border-radius: var(--sipre-radius-sm);
  background: var(--sipre-surface-muted);
  font-size: var(--sipre-text-xs);
  color: var(--sipre-text-secondary);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .sipre-shell__org {
    display: inline-block;
  }
}

.sipre-shell__content {
  grid-area: content;
  padding: 1.25rem;
  min-width: 0;
}

.sipre-nav-checkbox {
  position: absolute;
}

.sipre-menu-toggle {
  display: none;
}

.sipre-drawer-backdrop {
  display: none;
}

/* Tablet / phone: CSS checkbox drawer (includes QA viewport 1024×768) */
@media (max-width: 1024px) {
  .sipre-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "content";
  }

  .sipre-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .sipre-shell__sidebar {
    position: fixed;
    inset: var(--sipre-visual-viewport-top, 0px) auto auto 0;
    width: min(var(--sipre-sidebar-width), 86vw);
    /* JS synchronizes these variables with Safari's visualViewport.
       100vh/100dvh remain no-JS fallbacks. */
    height: 100vh;
    height: 100dvh;
    height: var(--sipre-visual-viewport-height, 100dvh);
    min-height: var(--sipre-visual-viewport-height, 100dvh);
    max-height: var(--sipre-visual-viewport-height, 100dvh);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--sipre-shadow);
  }

  .sipre-drawer-backdrop {
    display: block;
    position: fixed;
    inset: var(--sipre-visual-viewport-top, 0px) 0 auto 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    height: var(--sipre-visual-viewport-height, 100dvh);
    min-height: var(--sipre-visual-viewport-height, 100dvh);
    background: rgba(15, 23, 42, 0.4);
    z-index: 35;
    border: 0;
    padding: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    cursor: pointer;
  }

  .sipre-nav-checkbox:checked ~ .sipre-shell__sidebar,
  .sipre-shell:has(.sipre-nav-checkbox:checked) .sipre-shell__sidebar {
    transform: translateX(0);
  }

  .sipre-nav-checkbox:checked ~ .sipre-drawer-backdrop,
  .sipre-shell:has(.sipre-nav-checkbox:checked) .sipre-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 639px) {
  .sipre-shell__content {
    padding: 1rem 0.75rem 1.5rem;
  }

  .sipre-shell__topbar {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .sipre-shell__title {
    font-size: var(--sipre-text-md);
  }

  .sipre-shell__user,
  .sipre-shell__org {
    display: none;
  }

  .sipre-shell__topbar-right {
    max-width: none;
  }

  .sipre-shell__topbar-right .sipre-btn span:not(.sipre-icon),
  .sipre-shell__topbar-right .sipre-btn:not(.sipre-btn--icon) {
    /* keep icon + short label; avoid collision with page title */
    white-space: nowrap;
  }

  .sipre-stat-grid {
    grid-template-columns: 1fr;
  }

  /* Prevent full-page horizontal scroll from wide tables/cards */
  .sipre-shell,
  .sipre-shell__content {
    overflow-x: hidden;
  }
}

/* ——— Auth layout ——— */
.sipre-auth {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.5rem, env(safe-area-inset-top, 0px))
    max(1.5rem, env(safe-area-inset-right, 0px))
    max(1.5rem, env(safe-area-inset-bottom, 0px))
    max(1.5rem, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(ellipse at top left, rgba(20, 168, 203, 0.12), transparent 45%),
    radial-gradient(ellipse at bottom right, rgba(18, 48, 86, 0.12), transparent 40%),
    var(--sipre-bg);
}

.sipre-auth__card {
  width: min(420px, 100%);
  background: var(--sipre-surface);
  border: 1px solid var(--sipre-border);
  border-radius: var(--sipre-radius-lg);
  box-shadow: var(--sipre-shadow);
  padding: 2rem 1.75rem 1.75rem;
}

.sipre-auth__logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.sipre-auth__logo img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.sipre-auth__title {
  margin: 0;
  text-align: center;
  font-size: var(--sipre-text-xl);
  color: var(--sipre-navy-950);
}

.sipre-auth__subtitle {
  margin: 0.35rem 0 1.5rem;
  text-align: center;
  color: var(--sipre-text-muted);
  font-size: var(--sipre-text-sm);
}

/* ——— Reconnect ———
   Dialog = transparent shell (centered via margin:auto). Dimming = ::backdrop only.
   White card = .components-reconnect-container only. State visibility lives in scoped CSS. */
#components-reconnect-modal {
  background: transparent;
  border: none;
  padding: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  max-width: min(20rem, calc(100vw - 2rem));
  max-height: none;
}

#components-reconnect-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

#components-reconnect-modal[open],
#components-reconnect-modal:modal {
  /* Compact shell only — never 100vw/100vh full-bleed surface */
  width: fit-content;
  height: fit-content;
  max-width: min(20rem, calc(100vw - 2rem));
  margin: auto;
  padding: 0;
  display: block;
}

.components-reconnect-container {
  background: var(--sipre-surface);
  border: 1px solid var(--sipre-border);
  border-radius: var(--sipre-radius-lg);
  box-shadow: var(--sipre-shadow);
  padding: 1.5rem;
  width: min(20rem, 100%);
  box-sizing: border-box;
  text-align: center;
  color: var(--sipre-text);
  font-family: var(--sipre-font);
}

.components-reconnect-container p {
  margin: 0;
  color: var(--sipre-text-secondary);
}

#components-reconnect-button,
#components-resume-button {
  margin: 0.25rem auto 0;
  min-height: var(--sipre-touch);
  min-width: 120px;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: var(--sipre-radius-sm);
  background: var(--sipre-navy-900);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#components-reconnect-button:hover,
#components-resume-button:hover {
  background: var(--sipre-navy-800);
}

#components-reconnect-button:active,
#components-resume-button:active {
  background: var(--sipre-navy-900);
}

#blazor-error-ui {
  background: var(--sipre-danger-bg);
  color: var(--sipre-danger);
  border-top: 1px solid #fecaca;
  bottom: 0;
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  position: fixed;
  width: 100%;
  z-index: 1000;
  font-family: var(--sipre-font);
}

#blazor-error-ui .reload {
  color: var(--sipre-navy-800);
  margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.55rem;
}
