:root {
  color-scheme: light;
  --bg: #eaf2f2;
  --bg-strong: #d9e6e8;
  --nav: rgba(20, 31, 34, 0.86);
  --nav-soft: rgba(255, 255, 255, 0.1);
  --nav-line: rgba(255, 255, 255, 0.16);
  --surface: rgba(255, 255, 255, 0.62);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --surface-soft: rgba(255, 255, 255, 0.42);
  --surface-muted: rgba(48, 68, 75, 0.08);
  --line: rgba(255, 255, 255, 0.58);
  --line-strong: rgba(67, 91, 99, 0.24);
  --text: #202b31;
  --muted: #65727a;
  --blue: #246bd0;
  --teal: #0f8f86;
  --green: #2f855a;
  --amber: #b7791f;
  --red: #c24135;
  --violet: #6b58c8;
  --glass-blur: blur(18px) saturate(1.25);
  --shadow: 0 18px 46px rgba(30, 47, 55, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(227, 241, 242, 0.95), rgba(249, 245, 235, 0.86) 44%, rgba(229, 244, 235, 0.94)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 280px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.42;
}

button,
textarea,
select {
  font: inherit;
}

button,
select,
textarea {
  border-radius: 8px;
}

button {
  border: 0;
  cursor: pointer;
}

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

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(18, 31, 34, 0.9), rgba(38, 44, 56, 0.78)),
    var(--nav);
  backdrop-filter: var(--glass-blur);
  color: #fff;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: linear-gradient(135deg, rgba(15, 143, 134, 0.92), rgba(36, 107, 208, 0.86));
  color: #fff;
  font-weight: 900;
  font-size: 21px;
}

.brand-block strong,
.brand-block span {
  display: block;
}

.brand-block strong {
  font-size: 16px;
}

.brand-block span {
  color: #aeb9c3;
  font-size: 13px;
}

.side-nav nav {
  display: grid;
  gap: 6px;
}

.side-nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: #d6dfe7;
  font-weight: 800;
}

.side-nav a.active,
.side-nav a:hover {
  background: var(--nav-soft);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.side-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--nav-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: var(--glass-blur);
}

.side-card span,
.side-card strong,
.side-card small {
  display: block;
}

.side-card span,
.side-card small {
  color: #aeb9c3;
  font-size: 12px;
}

.side-card strong {
  margin: 6px 0;
  font-size: 20px;
}

.main-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 2.6vw, 40px);
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p {
  margin: 9px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 20px;
}

h3 {
  margin: 0;
  font-size: 15px;
}

.live-status {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--text);
  box-shadow: 0 12px 26px rgba(31, 40, 50, 0.08);
  backdrop-filter: var(--glass-blur);
  white-space: nowrap;
}

.page-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.page-strip a {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  backdrop-filter: var(--glass-blur);
}

.page-strip a:hover {
  border-color: rgba(15, 143, 134, 0.38);
  background: rgba(255, 255, 255, 0.62);
  color: var(--teal);
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.ok {
  background: var(--green);
}

.status-dot.warn {
  background: var(--amber);
}

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

.command-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.cpi-context-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.executive-panel,
.assistant-card,
.panel,
.data-explorer,
.metric {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.34)),
    radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.62), transparent 32%),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -1px 0 rgba(67, 91, 99, 0.08),
    var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.executive-panel,
.assistant-card {
  min-width: 0;
  padding: 18px;
}

.executive-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.compact-head {
  margin-bottom: 14px;
}

.data-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(47, 133, 90, 0.22);
  border-radius: 6px;
  background: rgba(47, 133, 90, 0.13);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

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

.summary-item {
  position: relative;
  overflow: hidden;
  min-height: 154px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34)),
    rgba(255, 255, 255, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 12px 28px rgba(30, 47, 55, 0.08);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.summary-item::before,
.metric::before,
.panel::before,
.data-explorer::before,
.assistant-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.4), transparent 34%),
    radial-gradient(circle at 86% 12%, rgba(255, 255, 255, 0.34), transparent 28%);
  opacity: 0.78;
}

.summary-item > *,
.metric > *,
.panel > *,
.data-explorer > *,
.assistant-card > * {
  position: relative;
  z-index: 1;
}

.summary-item .label,
.metric .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric .label {
  min-height: 30px;
  padding-right: 58px;
  line-height: 1.2;
}

.summary-chart,
.metric-chart {
  width: 100%;
  display: block;
  margin-top: 10px;
}

.pillar-grid {
  display: grid;
  gap: 9px;
  max-height: 470px;
  overflow: auto;
  padding-right: 2px;
}

.pillar-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.pillar-main {
  min-width: 0;
}

.pillar-main strong,
.pillar-main span {
  display: block;
}

.pillar-main strong {
  color: var(--text);
  font-size: 13px;
}

.pillar-main span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.pillar-state {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.pillar-progress {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(35, 55, 64, 0.09);
}

.pillar-progress > span {
  display: block;
  height: 100%;
  min-width: 10px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--violet));
}

.summary-item .note,
.metric .note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.chat-header,
.panel-head,
.explorer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.assistant-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: grid;
  justify-items: end;
  gap: 12px;
  pointer-events: none;
}

.assistant-widget > * {
  pointer-events: auto;
}

.assistant-launcher {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 50%;
  background:
    linear-gradient(135deg, rgba(15, 143, 134, 0.96), rgba(36, 107, 208, 0.92)),
    rgba(255, 255, 255, 0.2);
  color: #fff;
  box-shadow: 0 18px 34px rgba(17, 125, 117, 0.3);
}

.assistant-launcher:hover,
.assistant-launcher:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 20px 38px rgba(35, 103, 178, 0.34);
}

.assistant-launcher svg,
.assistant-close svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.assistant-panel {
  width: min(430px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 112px));
  display: grid;
  grid-template-rows: auto auto minmax(150px, 1fr) auto;
  opacity: 0;
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  transform-origin: bottom right;
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 160ms ease;
  visibility: hidden;
}

.assistant-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.assistant-panel .chat-header {
  align-items: center;
}

.assistant-panel .prompt-chips {
  justify-content: flex-start;
  margin-bottom: 10px;
}

.assistant-panel .chat-body {
  max-height: 36vh;
}

.assistant-close {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
  color: var(--text);
}

.assistant-close:hover,
.assistant-close:focus-visible {
  border-color: var(--teal);
  color: var(--teal);
}

.prompt-chips,
.tab-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.prompt-chips button,
.tab-row button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.44);
  color: var(--text);
  font-weight: 800;
}

.prompt-chips button:hover,
.tab-row button.active,
.tab-row button:hover {
  border-color: var(--teal);
  background: rgba(17, 125, 117, 0.09);
  color: var(--teal);
}

.chat-body {
  min-height: 138px;
  max-height: 300px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
  color: var(--text);
  white-space: pre-wrap;
}

.chat-body p {
  margin: 0;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
  margin-top: 10px;
}

.chat-form textarea {
  width: 100%;
  min-height: 72px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  outline: none;
}

.chat-form textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 125, 117, 0.14);
}

.chat-form button {
  min-height: 72px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  font-weight: 900;
}

.chat-form button:hover {
  background: #0d6f68;
}

.chat-form button:disabled {
  opacity: 0.72;
  cursor: progress;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  position: relative;
  min-height: 158px;
  padding: 15px;
  box-shadow: none;
}

.visual-tier {
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.metric:nth-child(1) {
  box-shadow: inset 0 3px 0 rgba(15, 143, 134, 0.68);
}

.metric:nth-child(2) {
  box-shadow: inset 0 3px 0 rgba(183, 121, 31, 0.64);
}

.metric:nth-child(3) {
  box-shadow: inset 0 3px 0 rgba(36, 107, 208, 0.64);
}

.metric:nth-child(4) {
  box-shadow: inset 0 3px 0 rgba(47, 133, 90, 0.64);
}

.metric:nth-child(5) {
  box-shadow: inset 0 3px 0 rgba(107, 88, 200, 0.64);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-wide {
  min-height: 370px;
}

.panel-full {
  grid-column: 1 / -1;
}

select {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.54);
}

canvas {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: 8px;
}

.status-list,
.rank-list,
.stream-list,
.insight-list {
  display: grid;
  gap: 10px;
}

.status-list {
  max-height: 450px;
  overflow: auto;
  padding-right: 2px;
}

.status-item,
.rank-item,
.stream-item,
.insight-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.34)),
    rgba(255, 255, 255, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.68),
    0 10px 24px rgba(30, 47, 55, 0.06);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.status-item::before,
.rank-item::before,
.stream-item::before,
.insight-item::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.44), transparent 38%);
}

.rank-item:hover,
.stream-item:hover,
.insight-item:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 143, 134, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    0 14px 30px rgba(30, 47, 55, 0.09);
}

.status-item,
.rank-item,
.stream-item,
.insight-item {
  padding: 12px;
}

.status-item,
.rank-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.34)),
    rgba(255, 255, 255, 0.44);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.badge.success {
  color: var(--green);
  background: rgba(47, 133, 90, 0.12);
}

.badge.running,
.badge.partial,
.badge.warning,
.badge.attention {
  color: var(--amber);
  background: rgba(183, 121, 31, 0.14);
}

.badge.failed,
.badge.error {
  color: var(--red);
  background: rgba(194, 65, 53, 0.12);
}

.badge.info {
  color: var(--blue);
  background: rgba(35, 103, 178, 0.12);
}

.data-explorer {
  margin-bottom: 16px;
  padding: 16px;
}

.explorer-meta {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.stream-item {
  display: grid;
  gap: 7px;
}

.stream-title {
  color: var(--text);
  font-weight: 900;
}

.stream-title a {
  color: var(--text);
}

.stream-title a:hover {
  color: var(--teal);
}

.stream-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.stream-snippet {
  color: #3b4651;
  font-size: 14px;
}

.compact .stream-snippet {
  display: none;
}

.progress {
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(35, 55, 64, 0.08)),
    rgba(35, 55, 64, 0.08);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.55),
    inset 0 -1px 2px rgba(35, 55, 64, 0.08);
}

.progress > span {
  position: relative;
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--violet));
  box-shadow:
    0 0 14px rgba(36, 107, 208, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.progress > span::after {
  content: "";
  position: absolute;
  inset: 1px 2px auto 2px;
  height: 34%;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.46);
}

.skeleton {
  min-height: 116px;
  border-radius: 8px;
  border: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.74) 50%, rgba(255, 255, 255, 0.32) 100%);
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

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

@media (max-width: 1240px) {
  .command-layout,
  .cpi-context-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .page-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    height: auto;
  }

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

  .side-card {
    display: none;
  }

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

@media (max-width: 720px) {
  .main-shell {
    padding: 14px;
  }

  .side-nav {
    padding: 14px;
  }

  .brand-block {
    margin-bottom: 14px;
  }

  .side-nav nav,
  .page-strip,
  .summary-strip,
  .metric-grid,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .side-nav a {
    min-height: 38px;
  }

  .chat-header,
  .panel-head,
  .explorer-head {
    flex-direction: column;
  }

  .prompt-chips,
  .tab-row {
    width: 100%;
    justify-content: flex-start;
  }

  .live-status {
    width: 100%;
    white-space: normal;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .summary-item,
  .metric {
    min-height: auto;
  }

  .assistant-widget {
    right: 14px;
    bottom: 14px;
  }

  .assistant-launcher {
    width: 58px;
    height: 58px;
  }

  .assistant-panel {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 92px);
  }

  .assistant-panel .chat-header {
    flex-direction: row;
  }

  .assistant-panel .chat-form {
    grid-template-columns: 1fr;
  }

  .assistant-panel .chat-form button {
    min-height: 52px;
  }
}
