:root {
  color-scheme: dark;
  --bg: #071323;
  --bg-soft: #0c1e33;
  --panel: rgba(17, 39, 64, 0.78);
  --panel-strong: rgba(21, 49, 80, 0.92);
  --line: rgba(176, 204, 235, 0.18);
  --text: #eef6ff;
  --muted: #9fb4ca;
  --accent: #56b6d8;
  --green: #4dd6a5;
  --red: #ff6b78;
  --yellow: #f6c657;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(86, 182, 216, 0.16), transparent 34rem),
    linear-gradient(145deg, #06101e 0%, #0a1728 48%, #0d2238 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.25rem;
  border-right: 1px solid var(--line);
  background: rgba(5, 16, 30, 0.74);
  backdrop-filter: blur(18px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 4rem;
  margin-bottom: 1.25rem;
}

.brand-mark {
  display: grid;
  width: 2.55rem;
  height: 2.55rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel-strong);
  color: var(--accent);
  font-weight: 800;
}

.brand-block p,
.brand-block strong,
.eyebrow,
.user-copy span,
.metric-card span,
.metric-card p,
.operational-card p,
.hero-status span,
.group-switcher span,
.sidebar-note p {
  margin: 0;
}

.brand-block p,
.eyebrow,
.user-copy span,
.metric-card span,
.operational-card p,
.hero-status span,
.group-switcher span,
.sidebar-note p {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand-block strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.95rem;
}

.nav-list {
  display: grid;
  gap: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.8rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  color: #c9d9ea;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: var(--line);
  background: rgba(86, 182, 216, 0.14);
  color: var(--text);
}

.nav-icon {
  display: grid;
  width: 1.45rem;
  height: 1.45rem;
  place-items: center;
  color: var(--accent);
  font-size: 0.92rem;
}

.sidebar-note {
  position: absolute;
  right: 1.25rem;
  bottom: 1.25rem;
  left: 1.25rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-note span {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--accent);
  font-weight: 800;
}

.main-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 18, 32, 0.64);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0.2rem 0 0;
  font-size: 1.15rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.user-copy {
  text-align: right;
}

.user-copy strong,
.user-copy span {
  display: block;
}

.group-switcher {
  display: grid;
  gap: 0.25rem;
}

.group-switcher select {
  min-height: 2.35rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--bg-soft);
  color: var(--text);
  padding: 0 0.7rem;
}

.page-shell {
  width: min(100%, 82rem);
  margin: 0 auto;
  padding: 1.5rem;
}

.hero-panel,
.panel,
.module-page,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem;
}

.hero-panel h2,
.panel-heading h2,
.module-page h2,
.empty-state h1 {
  margin: 0.25rem 0 0;
  font-size: 1.45rem;
}

.hero-panel p:last-child,
.module-page > p,
.empty-state p {
  max-width: 48rem;
  color: var(--muted);
}

.hero-status {
  align-self: stretch;
  display: grid;
  min-width: 11rem;
  place-content: center;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(86, 182, 216, 0.1);
  text-align: center;
}

.hero-status strong {
  margin-top: 0.25rem;
  color: var(--accent);
  font-size: 1.4rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.metric-card,
.operational-card {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.055);
}

.metric-card {
  padding: 1rem;
}

.metric-card strong {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 1.75rem;
}

.widget-card {
  min-width: 0;
}

.widget-card.is-loading {
  opacity: 0.78;
}

.widget-card.has-error {
  border-color: rgba(255, 107, 120, 0.55);
}

.widget-state {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.widget-error {
  color: var(--red);
}

.widget-trend {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.widget-trend span {
  color: var(--muted);
  font-size: 0.76rem;
}

.widget-trend i {
  display: block;
  max-width: 100%;
  height: 0.25rem;
  border-radius: 999px;
  background: currentColor;
  color: var(--green);
}

.widget-trend[data-trend="down"] i {
  color: var(--red);
}

.widget-trend[data-trend="stable"] i {
  color: var(--accent);
}

.widget-realtime-indicator {
  width: 100%;
  height: 0.25rem;
  margin-top: 0.65rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(86, 182, 216, 0.2), rgba(86, 182, 216, 0.8));
}

.tone-blue strong {
  color: var(--accent);
}

.tone-red strong {
  color: var(--red);
}

.tone-green strong {
  color: var(--green);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.85fr);
  gap: 1rem;
  margin-top: 1rem;
}

.panel,
.module-page,
.empty-state {
  padding: 1.2rem;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.quick-action {
  display: flex;
  align-items: center;
  min-height: 4.2rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(86, 182, 216, 0.1);
  font-weight: 700;
}

.stack {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.operational-card {
  padding: 0.9rem;
}

.operational-card > div {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.operational-card h3 {
  margin: 0.35rem 0;
  font-size: 1rem;
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--muted);
}

.severity-critical .status-dot {
  background: var(--red);
}

.severity-major .status-dot {
  background: var(--yellow);
}

.severity-minor .status-dot {
  background: var(--accent);
}

.module-placeholder {
  display: grid;
  min-height: 18rem;
  margin-top: 1rem;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.module-placeholder strong,
.module-placeholder span {
  display: block;
}

.module-placeholder strong {
  color: var(--text);
  font-size: 1.35rem;
}

.empty-state {
  margin-top: 2rem;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.fallback-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(12, 30, 51, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.86rem;
}

.fallback-message.tone-warning {
  border-color: rgba(246, 198, 87, 0.55);
}

.fallback-message.tone-error {
  border-color: rgba(255, 107, 120, 0.55);
}

.health-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.health-status-badge.is-ok {
  color: var(--green);
}

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: grid;
  width: min(24rem, calc(100vw - 2rem));
  gap: 0.65rem;
  pointer-events: none;
}

.toast-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-left: 0.25rem solid var(--accent);
  border-radius: 0.55rem;
  background: rgba(12, 30, 51, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  pointer-events: auto;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast-item.is-dismissing {
  opacity: 0;
  transform: translateY(0.35rem);
}

.toast-item p {
  margin: 0;
  color: #dbeafb;
  font-size: 0.88rem;
  line-height: 1.45;
}

.toast-label {
  min-width: 4.2rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.toast-close,
.alert-banner-close {
  display: grid;
  width: 1.8rem;
  height: 1.8rem;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.toast-close:hover,
.alert-banner-close:hover {
  border-color: var(--line);
  color: var(--text);
}

.toast-success,
.alert-success {
  border-left-color: var(--green);
}

.toast-success .toast-label,
.alert-success strong {
  color: var(--green);
}

.toast-warning,
.alert-warning {
  border-left-color: var(--yellow);
}

.toast-warning .toast-label,
.alert-warning strong {
  color: var(--yellow);
}

.toast-error,
.alert-error {
  border-left-color: var(--red);
}

.toast-error .toast-label,
.alert-error strong {
  color: var(--red);
}

.toast-critical,
.alert-critical {
  border-color: rgba(255, 107, 120, 0.72);
  border-left-color: var(--red);
  background: rgba(65, 15, 25, 0.96);
}

.toast-critical .toast-label,
.alert-critical strong {
  color: #ff9ca5;
}

.alert-banner {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: calc(17rem + 1rem);
  z-index: 45;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  min-height: 3.2rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-left: 0.3rem solid var(--accent);
  border-radius: 0.55rem;
  background: rgba(12, 30, 51, 0.97);
  box-shadow: var(--shadow);
}

.alert-banner strong {
  font-size: 0.75rem;
  text-transform: uppercase;
}

.alert-banner span {
  color: #dbeafb;
  font-size: 0.9rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 10, 20, 0.72);
  backdrop-filter: blur(10px);
}

.notification-modal {
  width: min(30rem, 100%);
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-top: 0.25rem solid var(--accent);
  border-radius: 0.65rem;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.notification-modal h2 {
  margin: 0;
  font-size: 1.2rem;
}

.notification-modal p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.modal-error,
.modal-critical {
  border-top-color: var(--red);
}

.modal-warning {
  border-top-color: var(--yellow);
}

.modal-success {
  border-top-color: var(--green);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.1rem;
}

.modal-button {
  min-height: 2.45rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.modal-button-primary {
  background: rgba(86, 182, 216, 0.24);
}

.modal-button-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 1rem;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-note {
    position: static;
    margin-top: 1rem;
  }

  .metric-grid,
  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alert-banner {
    left: 1rem;
  }
}

@media (max-width: 680px) {
  .topbar,
  .hero-panel,
  .app-footer,
  .user-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .user-copy {
    text-align: left;
  }

  .metric-grid,
  .content-grid,
  .quick-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .page-shell {
    padding: 1rem;
  }

  .toast-container {
    right: 0.75rem;
    bottom: 0.75rem;
    width: calc(100vw - 1.5rem);
  }

  .toast-item,
  .alert-banner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .toast-label,
  .alert-banner strong {
    grid-column: 1 / -1;
  }

  .alert-banner {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }
}
