:root {
  color-scheme: light;
  --portal-bg: #dceffa;
  --portal-ink: #102038;
  --portal-muted: #60758f;
  --portal-panel: rgba(255, 255, 255, 0.42);
  --portal-border: rgba(255, 255, 255, 0.56);
  --portal-accent: #0d88ff;
  --portal-accent-soft: rgba(13, 136, 255, 0.14);
  --portal-shadow: 0 24px 70px rgba(78, 122, 165, 0.12);
  --portal-shadow-strong: 0 34px 90px rgba(67, 108, 153, 0.16);
  --portal-danger: #dc2626;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: 'Manrope', sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.9), transparent 20%),
    radial-gradient(circle at 82% 12%, rgba(196, 236, 255, 0.74), transparent 25%),
    radial-gradient(circle at 78% 88%, rgba(34, 145, 255, 0.12), transparent 22%),
    linear-gradient(138deg, #ebf7ff 0%, #d7edf9 38%, #c7e3f4 68%, #d5ebf7 100%);
  color: var(--portal-ink);
}

.portal-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 96px 96px;
  opacity: 0.24;
  mask-image: radial-gradient(circle at center, black 42%, transparent 90%);
}

.portal-ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(28px);
  pointer-events: none;
  z-index: 0;
}

.portal-ambient--one {
  top: 6%;
  right: 7%;
  width: 22rem;
  height: 22rem;
  background: rgba(133, 218, 255, 0.26);
}

.portal-ambient--two {
  left: 4%;
  bottom: 12%;
  width: 18rem;
  height: 18rem;
  background: rgba(255, 255, 255, 0.34);
}

.portal-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  min-height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  padding: 22px;
}

.sidebar-panel,
.topbar-panel,
.glass-panel,
.metric-card,
.table-panel,
.form-panel,
.modal-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--portal-border);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.56), rgba(220, 238, 249, 0.32));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.56),
    var(--portal-shadow);
  backdrop-filter: blur(26px) saturate(145%);
  -webkit-backdrop-filter: blur(26px) saturate(145%);
}

.sidebar-panel::before,
.topbar-panel::before,
.glass-panel::before,
.metric-card::before,
.table-panel::before,
.form-panel::before,
.modal-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 36%);
  pointer-events: none;
}

.sidebar-panel > *,
.topbar-panel > *,
.glass-panel > *,
.metric-card > *,
.table-panel > *,
.form-panel > *,
.modal-card > * {
  position: relative;
  z-index: 1;
}

.sidebar-panel {
  position: sticky;
  top: 22px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100vh - 44px);
  overflow: auto;
  border-radius: 32px;
  padding: 24px 20px 20px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    var(--portal-shadow-strong);
}

.sidebar-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sidebar-panel::after {
  content: '';
  position: absolute;
  inset: auto -8% -18% auto;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(13, 136, 255, 0.18), transparent 68%);
  filter: blur(12px);
  pointer-events: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: #0f172a;
  text-decoration: none;
}

.brand-mark__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.9);
}

.portal-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.portal-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border: 1px solid transparent;
  border-radius: 20px;
  color: #35506d;
  text-decoration: none;
  font-size: 0.96rem;
  font-weight: 700;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.12));
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.portal-nav__link:hover,
.portal-nav__link.is-active {
  transform: translateX(4px);
  border-color: rgba(255, 255, 255, 0.58);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(213, 238, 255, 0.38) 65%, rgba(170, 225, 255, 0.18));
  color: #0d4f8f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.54), 0 16px 36px rgba(86, 133, 176, 0.12);
}

.portal-nav__link.is-active {
  position: relative;
}

.portal-nav__link.is-active::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 50%;
  width: 4px;
  height: 44%;
  border-radius: 999px;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #63c8ff, #1588ff);
  box-shadow: 0 0 18px rgba(21, 136, 255, 0.36);
}

.portal-nav__meta {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(53, 80, 109, 0.52);
}

.sidebar-cta {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 28px;
  padding: 18px;
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.4), transparent 30%),
    linear-gradient(145deg, rgba(8, 120, 255, 0.16), rgba(255, 255, 255, 0.42));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.portal-main {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.topbar-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 30px;
  padding: 22px 24px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    var(--portal-shadow-strong);
}

.topbar-panel--hero::after {
  content: '';
  position: absolute;
  inset: auto 8% -24% auto;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(36, 154, 255, 0.16), transparent 70%);
  filter: blur(8px);
  pointer-events: none;
}

.topbar-panel .button-primary,
.topbar-panel .button-secondary,
.topbar-panel .button-ghost,
.topbar-panel .button-danger {
  padding: 10px 14px;
  font-size: 0.84rem;
  font-weight: 700;
}

.topbar-panel .status-pill {
  padding: 8px 11px;
  font-size: 0.74rem;
}

.portal-content {
  display: grid;
  gap: 22px;
}

.content-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.content-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.metric-card,
.glass-panel,
.table-panel,
.form-panel {
  border-radius: 32px;
  padding: 24px;
}

.metric-card {
  min-height: 220px;
  background:
    radial-gradient(circle at top right, rgba(187, 232, 255, 0.38), transparent 24%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.66), rgba(222, 240, 250, 0.36));
}

.glass-panel,
.table-panel,
.form-panel,
.modal-card {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    var(--portal-shadow-strong);
}

.glass-panel a,
.table-panel a,
.form-panel a {
  color: inherit;
}

.section-title {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(53, 80, 109, 0.58);
}

.topbar-panel h1,
.glass-panel h2,
.table-panel h2,
.form-panel h2,
.modal-card h2 {
  letter-spacing: -0.06em;
}

.metric-value {
  font-size: clamp(2rem, 2.8vw, 3rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
}

.muted-copy {
  color: var(--portal-muted);
  line-height: 1.7;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.54);
  color: #2c4d70;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill--success {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.status-pill--warning {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

.status-pill--danger {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
}

.portal-table tbody tr {
  transition: background 180ms ease;
}

.portal-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.36);
}

.portal-table th,
.portal-table td {
  padding: 16px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  text-align: left;
  vertical-align: top;
}

.portal-table th {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(53, 80, 109, 0.56);
}

.portal-table td {
  color: #24364d;
}

.portal-table--api-keys {
  min-width: 920px;
}

.portal-table--api-keys th,
.portal-table--api-keys td {
  white-space: nowrap;
  vertical-align: middle;
}

.portal-table--api-keys th:nth-child(1),
.portal-table--api-keys td:nth-child(1) {
  width: 26%;
}

.portal-table--api-keys th:nth-child(2),
.portal-table--api-keys td:nth-child(2) {
  width: 29%;
}

.portal-table--api-keys th:nth-child(3),
.portal-table--api-keys td:nth-child(3) {
  width: 13%;
}

.portal-table--api-keys th:nth-child(4),
.portal-table--api-keys td:nth-child(4) {
  width: 14%;
}

.portal-table--api-keys th:nth-child(5),
.portal-table--api-keys td:nth-child(5) {
  width: 18%;
}

.api-key-cell--name,
.api-key-cell--preview,
.api-key-cell--expires {
  font-size: 0.98rem;
}

.api-key-cell--preview {
  letter-spacing: 0.06em;
}

.portal-table--api-keys .inline-actions--compact {
  flex-wrap: nowrap;
  gap: 12px;
}

.portal-table--api-keys .button-ghost,
.portal-table--api-keys .button-danger {
  min-width: 104px;
  padding: 10px 18px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #36506d;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  border: 1px solid rgba(191, 219, 254, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  padding: 14px 16px;
  font: inherit;
  color: var(--portal-ink);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: rgba(13, 136, 255, 0.9);
  box-shadow: 0 0 0 4px rgba(13, 136, 255, 0.12);
}

.button-primary,
.button-secondary,
.button-ghost,
.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 999px;
  padding: 13px 18px;
  border: 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.button-primary:disabled,
.button-secondary:disabled,
.button-ghost:disabled,
.button-danger:disabled,
.button-primary.is-loading,
.button-secondary.is-loading,
.button-ghost.is-loading,
.button-danger.is-loading {
  cursor: wait;
  opacity: 0.88;
  transform: none;
  pointer-events: none;
}

.button-primary.is-loading::before,
.button-secondary.is-loading::before,
.button-ghost.is-loading::before,
.button-danger.is-loading::before {
  content: '';
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: portal-button-spin 0.8s linear infinite;
}

.button-primary:hover,
.button-secondary:hover,
.button-ghost:hover,
.button-danger:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, #1588ff, #0066ff);
  box-shadow: 0 18px 40px rgba(13, 136, 255, 0.24);
}

.button-secondary {
  color: #17324f;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.86);
}

.button-ghost {
  color: #1f4870;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.44);
}

.button-danger {
  color: white;
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

@keyframes portal-button-spin {
  to {
    transform: rotate(360deg);
  }
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.message-box {
  display: none;
  margin-top: 16px;
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 0.92rem;
  font-weight: 600;
}

.message-box.is-visible {
  display: block;
}

.message-box.is-success {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.message-box.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.message-box.is-info {
  background: rgba(13, 136, 255, 0.12);
  color: #0d4f8f;
}

.key-preview {
  font-family: 'Courier New', monospace;
  letter-spacing: 0.08em;
  word-break: break-all;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(14px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 620px);
  border-radius: 34px;
  padding: 28px;
}

.empty-state {
  padding: 32px;
  border-radius: 28px;
  border: 1px dashed rgba(148, 163, 184, 0.42);
  background: rgba(255, 255, 255, 0.34);
  text-align: center;
  color: var(--portal-muted);
}

.glass-panel .rounded-2xl,
.table-panel .rounded-2xl,
.form-panel .rounded-2xl,
.modal-card .rounded-2xl,
.sidebar-cta .rounded-2xl,
.metric-card .rounded-2xl {
  border: 1px solid rgba(255, 255, 255, 0.46);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.68), rgba(240, 248, 255, 0.42) 72%, rgba(223, 240, 251, 0.26));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

a.glass-panel {
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

a.glass-panel:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    0 28px 70px rgba(72, 114, 156, 0.16);
}

.sidebar-cta .inline-actions,
.topbar-panel .inline-actions,
.form-panel .inline-actions {
  row-gap: 12px;
}

.sidebar-cta .button-primary,
.sidebar-cta .button-secondary {
  flex: 1 1 auto;
}

.profile-shell .glass-panel,
.profile-shell .form-panel,
.security-shell .glass-panel,
.security-shell .form-panel {
  min-height: 100%;
}

.api-keys-shell {
  grid-template-columns: 1fr;
}

.api-keys-shell .form-panel,
.api-keys-shell .table-panel {
  width: 100%;
}

.profile-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

.profile-hero__orb {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 168px;
  min-height: 168px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 32px;
  background:
    radial-gradient(circle at 40% 35%, rgba(116, 214, 255, 0.8), rgba(15, 136, 255, 0.42) 42%, rgba(255, 255, 255, 0.3) 72%, transparent 74%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.52), rgba(221, 240, 250, 0.18));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    0 24px 50px rgba(83, 126, 171, 0.14);
}

.profile-hero__orb .status-pill {
  background: rgba(255, 255, 255, 0.72);
}

.profile-stat-card,
.profile-link-tile {
  min-height: 124px;
}

.profile-preference-panel {
  display: flex;
  flex-direction: column;
}

.profile-preference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.profile-link-tile {
  display: block;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.profile-link-tile:hover {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    0 22px 46px rgba(73, 116, 160, 0.14);
}

.security-status-card .rounded-2xl,
.security-password-card .field-input,
.security-email-card .field-input,
.security-email-card .field-select,
.security-email-card .button-secondary,
.security-password-card .button-secondary {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media (max-width: 1180px) {
  .portal-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    position: relative;
    top: auto;
    max-height: none;
    overflow: hidden;
  }

  .content-grid-3,
  .content-grid-2 {
    grid-template-columns: 1fr;
  }

  .profile-hero,
  .profile-preference-grid {
    grid-template-columns: 1fr;
  }

  .profile-hero__orb {
    min-width: 100%;
    min-height: 132px;
  }
}

@media (max-width: 768px) {
  .portal-layout {
    padding: 14px;
    gap: 16px;
  }

  .portal-ambient {
    display: none;
  }

  .topbar-panel {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
  }

  .metric-card,
  .glass-panel,
  .table-panel,
  .form-panel,
  .modal-card {
    border-radius: 28px;
    padding: 20px;
  }

  .profile-link-tile,
  .profile-stat-card {
    min-height: 0;
  }

  .portal-table {
    display: block;
    overflow-x: auto;
  }
}