:root {
  --shell-gap: 16px;
  --shell-radius: 18px;
  --shell-border: rgba(255, 255, 255, 0.08);
  --shell-panel: rgba(17, 24, 39, 0.72);
  --shell-panel-strong: rgba(17, 24, 39, 0.9);
  --shell-soft: rgba(99, 102, 241, 0.14);
  --shell-text-soft: rgba(226, 232, 240, 0.78);
  --shell-shadow: 0 14px 44px rgba(0, 0, 0, 0.24);
  --success-soft: rgba(34, 197, 94, 0.15);
  --warning-soft: rgba(245, 158, 11, 0.16);
  --error-soft: rgba(239, 68, 68, 0.16);
  --info-soft: rgba(59, 130, 246, 0.16);
}

body.modal-open {
  overflow: hidden;
}

.page-shell {
  max-width: 1680px;
  margin: 0 auto;
  padding-bottom: 104px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
}

.command-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: var(--shell-gap);
  margin: 14px 0 12px;
  padding: 16px 18px;
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius);
  background: linear-gradient(180deg, rgba(31, 41, 55, 0.88), rgba(17, 24, 39, 0.82));
  box-shadow: var(--shell-shadow);
}

.utility-bar {
  position: sticky;
  top: 78px;
  z-index: 36;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--shell-border);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: var(--shell-shadow);
}

.utility-left,
.utility-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.utility-caption {
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--shell-text-soft);
}

.utility-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  font-size: 0.84rem;
}

.utility-inline span {
  color: var(--shell-text-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.utility-inline select,
.utility-inline input {
  margin: 0;
}

.command-actions,
.command-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.command-section-title {
  width: 100%;
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--shell-text-soft);
}

.command-kpis {
  justify-content: flex-end;
}

.command-chip {
  min-width: 150px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--shell-border);
  background: rgba(15, 23, 42, 0.72);
}

.command-chip span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--shell-text-soft);
  margin-bottom: 4px;
}

.command-chip strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.2;
}

.shell-shortcut {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.context-banner {
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(49, 46, 129, 0.78));
  box-shadow: var(--shell-shadow);
}

.context-banner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.context-title-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.context-primary h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.context-copy {
  margin: 0;
  color: rgba(248, 250, 252, 0.84);
  line-height: 1.5;
}

.context-secondary {
  display: grid;
  gap: 10px;
}

.context-metric {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.context-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--shell-text-soft);
}

.shell-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.22);
  border: 1px solid rgba(165, 180, 252, 0.26);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.shell-badge-soft {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 250px) minmax(0, 1fr);
  gap: var(--shell-gap);
  align-items: start;
}

.nav-rail,
.content-panel,
.summary-rail,
.command-bar,
.context-banner,
.utility-bar {
  border-radius: 20px;
}

.nav-rail {
  position: sticky;
  top: 152px;
}

.nav-rail {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(17, 24, 39, 0.84));
}

.summary-rail {
  display: none;
}

.content-panel {
  min-width: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(17, 24, 39, 0.84));
}

.nav-rail-header,
.summary-rail .panel-header,
.content-panel .panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(17, 24, 39, 0.8));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px 16px 0 0;
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-button,
#mobileTabBar .nav-button,
.shell-shortcut .nav-button {
  justify-content: flex-start;
  min-height: 44px;
  border-radius: 14px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.nav-button:hover,
#mobileTabBar .nav-button:hover,
.shell-shortcut .nav-button:hover {
  transform: translateY(-1px);
}

.nav-button.active,
#mobileTabBar .nav-button.active,
.shell-shortcut .nav-button.active {
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.22);
}

.workspace-content {
  min-height: 720px;
}

.workspace-content > *:first-child {
  margin-top: 0;
}

.workspace-content .panel,
.workspace-content .card,
.workspace-content .metric-card,
.workspace-content .table-card {
  border-radius: 18px;
}

.workspace-content table {
  width: 100%;
}

.workspace-content .table-wrap,
.workspace-content .data-table-wrap {
  overflow-x: auto;
}

.rail-section + .rail-section {
  margin-top: 14px;
}

.summary-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.summary-stack > * {
  min-width: 0;
  word-break: break-word;
}

.message {
  position: relative;
  z-index: 5;
}

.mobile-tabbar {
  display: none;
}

.workspace-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding: 10px 2px 0;
  font-size: 0.76rem;
  color: rgba(226, 232, 240, 0.58);
}

.workspace-footer-copy {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace-footer-copy-soft {
  justify-content: flex-end;
}

.action-inline-status {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}

.action-inline-status.is-pending {
  animation: pulse-inline 1.8s ease-in-out infinite;
}

.action-inline-status.is-info {
  background: var(--info-soft);
}

.action-inline-status.is-warning {
  background: var(--warning-soft);
}

.action-inline-status.is-error {
  background: var(--error-soft);
}

.action-inline-status.is-success {
  background: var(--success-soft);
}

@keyframes pulse-inline {
  0%,
  100% {
    opacity: 0.9;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

.toast-stack {
  position: fixed;
  top: 86px;
  right: 16px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
}

.algolumina-toast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--shell-border);
  box-shadow: var(--shell-shadow);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(14px);
}

.algolumina-toast.is-info {
  border-left: 4px solid #60a5fa;
}

.algolumina-toast.is-success {
  border-left: 4px solid #4ade80;
}

.algolumina-toast.is-warning {
  border-left: 4px solid #fbbf24;
}

.algolumina-toast.is-error {
  border-left: 4px solid #f87171;
}

.toast-copy strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.toast-copy p {
  margin: 0;
  color: rgba(226, 232, 240, 0.88);
  line-height: 1.45;
}

.toast-close {
  min-width: auto;
  padding: 8px 10px;
  align-self: center;
}

.confirm-root.hidden {
  display: none;
}

.confirm-root {
  position: fixed;
  inset: 0;
  z-index: 90;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(6px);
}

.confirm-sheet {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(640px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 20px;
  border-radius: 22px;
  border: 1px solid var(--shell-border);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.96));
  box-shadow: var(--shell-shadow);
}

.confirm-sheet-header {
  margin-bottom: 16px;
}

.confirm-severity-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.confirm-root.is-critical .confirm-severity-pill {
  background: var(--error-soft);
  border: 1px solid rgba(248, 113, 113, 0.24);
}

.confirm-root.is-warning .confirm-severity-pill {
  background: var(--warning-soft);
  border: 1px solid rgba(251, 191, 36, 0.24);
}

.confirm-root.is-info .confirm-severity-pill,
.confirm-root.is-success .confirm-severity-pill {
  background: var(--info-soft);
  border: 1px solid rgba(96, 165, 250, 0.24);
}

.confirm-sheet h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.confirm-sheet-body {
  margin: 0;
  line-height: 1.55;
  color: rgba(226, 232, 240, 0.9);
}

.confirm-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.confirm-detail-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.confirm-detail-label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--shell-text-soft);
}

.confirm-detail-value {
  display: block;
  font-size: 0.98rem;
  line-height: 1.35;
}

.confirm-sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .context-banner-grid,
  .command-bar {
    grid-template-columns: 1fr;
  }

  .command-kpis {
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  .page-shell {
    padding-bottom: 122px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .nav-rail {
    display: none;
  }

  .content-panel {
    position: static;
    top: auto;
  }

  .utility-bar {
    top: 70px;
    padding: 10px 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .utility-left,
  .utility-right {
    justify-content: space-between;
  }

  .utility-right {
    gap: 8px;
  }

  .utility-inline {
    flex: 1 1 auto;
    justify-content: space-between;
  }

  .mobile-tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 60;
    display: flex;
    gap: 8px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid var(--shell-border);
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(14px);
    box-shadow: var(--shell-shadow);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mobile-tabbar::-webkit-scrollbar {
    display: none;
  }

  .mobile-tabbar .nav-button {
    min-width: 108px;
    min-height: 48px;
    justify-content: center;
    font-size: 0.78rem;
    padding: 10px 10px;
    flex: 0 0 auto;
  }

  .command-bar {
    padding: 14px;
  }

  .command-chip {
    min-width: 0;
    flex: 1 1 140px;
  }

  .context-primary h2 {
    font-size: 1.2rem;
  }

  .toast-stack {
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 86px;
    width: auto;
  }

  .confirm-sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    transform: none;
    border-radius: 22px 22px 0 0;
    padding: 18px 16px 20px;
  }

  .confirm-details-grid {
    grid-template-columns: 1fr;
  }

  .confirm-sheet-actions {
    position: sticky;
    bottom: 0;
    padding-top: 12px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0), rgba(17, 24, 39, 0.96) 22%);
  }

  .action-inline-status {
    display: block;
    width: fit-content;
    margin-left: 0;
    margin-top: 8px;
  }

  .workspace-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-bottom: 8px;
  }

  .workspace-footer-copy-soft {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .topbar-meta {
    gap: 8px;
  }

  .command-actions,
  .command-kpis,
  .shell-shortcut {
    gap: 8px;
  }

  .command-chip {
    padding: 10px;
  }

  .context-banner,
  .command-bar,
  .utility-bar {
    border-radius: 16px;
  }

  .algolumina-toast {
    grid-template-columns: 1fr;
  }

  .toast-close {
    justify-self: end;
  }

  .utility-right {
    flex-direction: column;
    align-items: stretch;
  }

  .utility-right .secondary {
    width: 100%;
  }
}
