:root {
  --bg-base: #191430;
  --bg-gradient:
    radial-gradient(1200px 800px at -10% -10%, rgba(197, 181, 255, 0.22), transparent 60%),
    radial-gradient(900px 600px at 110% -20%, rgba(146, 120, 228, 0.2), transparent 55%),
    repeating-linear-gradient(45deg, rgba(69, 55, 111, 0.35) 0 14px, rgba(48, 38, 76, 0.35) 14px 28px),
    #191430;
  --surface-0: rgba(34, 25, 60, 0.78);
  --surface-1: rgba(34, 25, 60, 0.9);
  --surface-2: rgba(34, 25, 60, 0.6);
  --surface-light: rgba(246, 242, 255, 0.9);
  --text: #f7f4ff;
  --text-soft: #cdc4ea;
  --text-strong: #ffffff;
  --accent: #bda8ff;
  --accent-strong: #8f72e7;
  --border: rgba(206, 196, 238, 0.28);
  --shadow-lg: 0 32px 65px rgba(17, 10, 35, 0.55);
  --shadow-card: 0 24px 45px rgba(28, 18, 52, 0.55);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --max-shell: 1220px;
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Manrope", "Inter", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text);
  min-height: 100%;
}

body.theme-light {
  --bg-base: #f5f2ff;
  --bg-gradient:
    radial-gradient(1200px 800px at -10% -10%, rgba(189, 168, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at 110% -20%, rgba(158, 134, 230, 0.14), transparent 55%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 14px, rgba(225, 212, 250, 0.08) 14px 28px),
    #f5f2ff;
  --surface-0: rgba(255, 255, 255, 0.92);
  --surface-1: rgba(255, 255, 255, 0.97);
  --surface-2: rgba(255, 255, 255, 0.7);
  --surface-light: #ffffff;
  --text: #241b3f;
  --text-soft: #6b6190;
  --text-strong: #1c1533;
  --accent: #bda8ff;
  --accent-strong: #8f72e7;
  --border: rgba(86, 70, 125, 0.16);
  --shadow-lg: 0 30px 60px rgba(112, 94, 150, 0.16);
  --shadow-card: 0 20px 40px rgba(112, 94, 150, 0.14);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-strong);
}

.portal-app {
  min-height: 100vh;
  background: var(--bg-gradient);
  padding-bottom: 80px;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  background: var(--bg-gradient);
}

.auth-card {
  width: min(420px, 100%);
  padding: 36px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 18px;
  text-align: left;
}

.auth-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
}

.auth-field {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-0);
  color: var(--text);
}

.auth-field:focus-visible {
  outline: none;
  border-color: rgba(189, 168, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(189, 168, 255, 0.18);
}

.auth-card label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 6px;
  display: inline-block;
}

.auth-message {
  font-size: 13px;
  color: #f87171;
}

.btn-primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--accent-strong);
  color: var(--text-strong);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(143, 114, 231, 0.32);
}

.btn-primary:focus-visible {
  outline: 3px solid rgba(189, 168, 255, 0.38);
  outline-offset: 2px;
}

.shell {
  width: min(var(--max-shell), 100% - 48px);
  margin: 0 auto;
}

.portal-header {
  position: sticky;
  top: 18px;
  z-index: 100;
  margin: 24px auto 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-0);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(26px);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.portal-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-display);
}

.portal-brand span {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}

.portal-brand strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-strong);
}

.portal-nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.portal-nav-link {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.portal-nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.portal-nav-link.logout-btn {
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}

.portal-nav-link.logout-btn:hover {
  background: rgba(189, 168, 255, 0.24);
  color: #8f72e7;
  border-color: rgba(189, 168, 255, 0.4);
}

.portal-nav-link.is-active {
  background: rgba(189, 168, 255, 0.22);
  color: var(--text-strong);
  border-color: rgba(189, 168, 255, 0.4);
}

.portal-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text-soft);
}

.portal-user-badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(189, 168, 255, 0.24);
  color: var(--text-strong);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.portal-filters {
  padding: 0 0 12px;
}

.filters-shell {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-0);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-card);
  padding: 20px 26px;
  display: grid;
  gap: 18px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
}

.filter-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-inline .filter-label {
  margin-right: 4px;
}

.portal-main {
  margin-top: 32px;
}

.dashboard-section {
  margin-bottom: 36px;
}

.dashboard-grid {
  display: grid;
  gap: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
}

.portal-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.stat-card {
  padding: 18px;
  display: grid;
  gap: 10px;
}

.stat-card-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-strong);
}

.stat-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-soft);
}

.stat-card-delta {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(189, 168, 255, 0.22);
  color: #8f72e7;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.stat-card-delta.is-negative {
  background: rgba(248, 113, 113, 0.18);
  color: #f87171;
}

.chart-card {
  padding: 24px;
  display: grid;
  gap: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow-card);
}

.chart-card h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
}

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-soft);
  font-size: 13px;
}

.insight-feed {
  display: grid;
  gap: 14px;
}

.insight-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.insight-tag {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(189, 168, 255, 0.22);
  color: var(--text-strong);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}

.insight-copy {
  font-size: 13px;
  color: var(--text);
}

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

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

.section-title {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.section-title span {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
}

.section-title h2 {
  margin: 0;
  font-size: 24px;
  font-family: var(--font-display);
  color: var(--text-strong);
}

.section-title p {
  margin: 0;
  font-size: 14px;
  color: var(--text-soft);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.dash-graph,
.dash-graph > div,
.dash-graph .js-plotly-plot {
  width: 100% !important;
}

.dash-graph .main-svg {
  border-radius: var(--radius-md);
}

.text-muted {
  color: var(--text-soft);
  font-size: 13px;
}

.list-unstyled {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.list-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  list-style: none;
}

.list-inline li {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-soft);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.9);
  display: inline-block;
}

.status-dot.warning {
  background: rgba(234, 179, 8, 0.9);
}

.status-dot.alert {
  background: rgba(239, 68, 68, 0.9);
}

.filter-radio,
.filter-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-radio label,
.filter-checklist label {
  background: var(--surface-2);
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.filter-radio input:checked + span,
.filter-checklist input:checked + span {
  color: var(--text-strong);
  border-color: rgba(129, 140, 248, 0.45);
  background: rgba(129, 140, 248, 0.2);
}

.filter-radio input,
.filter-checklist input {
  display: none;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-card th {
  text-align: left;
  padding: 12px 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}

.table-card td {
  padding: 10px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--text);
}

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

.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(189, 168, 255, 0.22);
  color: #8f72e7;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.badge-soft.warning {
  background: rgba(250, 204, 21, 0.18);
  color: #facc15;
}

.badge-soft.alert {
  background: rgba(248, 113, 113, 0.18);
  color: #f87171;
}

.callout {
  border-radius: var(--radius-md);
  border: 1px dashed rgba(189, 168, 255, 0.32);
  background: rgba(189, 168, 255, 0.12);
  padding: 18px 20px;
  color: var(--text);
  font-size: 13px;
  display: grid;
  gap: 6px;
}

.callout strong {
  font-size: 14px;
  font-family: var(--font-display);
}

@media (max-width: 1100px) {
  .portal-header {
    flex-wrap: wrap;
    gap: 18px;
  }
  .portal-nav-links {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
  .portal-user {
    margin-left: 0;
  }
  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .portal-header {
    padding: 16px 20px;
  }
  .portal-nav-links {
    gap: 8px;
  }
  .portal-nav-link {
    padding: 8px 12px;
  }
  .filters-grid {
    grid-template-columns: 1fr;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .portal-card {
    padding: 18px;
  }
  .chart-card {
    padding: 20px;
  }
}
.auth-demo-hint {
    margin-bottom: 1.5rem;
    color: #1f2937;
}

.auth-demo-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.auth-demo-item {
    margin-bottom: 0.65rem;
}

.auth-demo-label {
    display: block;
    font-weight: 600;
}

.auth-demo-credentials {
    display: inline-block;
    margin-top: 0.25rem;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
}

.auth-demo-tier {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}
