:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f5f7fb;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee9;
  --nav: #4c5566;
  --blue: #19a7ce;
  --teal: #48c2b7;
  --green: #42c982;
  --amber: #ffb84d;
  --red: #ff5f57;
  --purple: #8067dc;
  --shadow: 0 14px 36px rgba(40, 52, 72, 0.12);
  --radius: 6px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--nav);
  color: #ffffff;
  border-bottom: 1px solid #3e4654;
}

.menu-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 900;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 900;
}

.brand h1,
.brand p,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 0.98rem;
  letter-spacing: 0;
}

.brand p {
  color: #d7dce5;
  font-size: 0.72rem;
}

.status-strip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d7dce5;
  font-size: 0.78rem;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(66, 201, 130, 0.16);
}

.workspace {
  padding: 12px;
}

.demo-note {
  margin: 0 0 10px;
  border: 1px solid #b9e8f2;
  border-left: 5px solid var(--blue);
  border-radius: var(--radius);
  background: #f2fcff;
  color: #385168;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  box-shadow: var(--shadow);
}

.demo-note strong {
  color: var(--ink);
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 96px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  height: 25px;
  background: linear-gradient(90deg, transparent 0 10%, rgba(25, 167, 206, 0.15) 10% 28%, transparent 28% 36%, rgba(72, 194, 183, 0.18) 36% 57%, transparent 57% 64%, rgba(128, 103, 220, 0.16) 64% 82%, transparent 82%);
  clip-path: polygon(0 70%, 12% 38%, 24% 52%, 36% 25%, 48% 64%, 60% 42%, 72% 48%, 84% 22%, 100% 58%, 100% 100%, 0 100%);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.metric-card em {
  display: inline-flex;
  margin-top: 4px;
  color: var(--green);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 800;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(430px, 1.25fr) minmax(300px, 0.9fr);
  gap: 10px;
}

.left-stack,
.center-stack,
.right-stack {
  display: grid;
  align-content: start;
  gap: 10px;
}

.panel {
  padding: 10px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  margin: 2px 0 0;
  font-size: 0.95rem;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

select,
.primary-btn,
.secondary-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 7px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-color: transparent;
  color: #ffffff;
}

.secondary-btn {
  background: #e7f7fb;
  color: #087998;
}

.queue-table {
  display: grid;
  margin-top: 8px;
}

.table-head,
.event-row {
  display: grid;
  grid-template-columns: 78px minmax(150px, 1fr) 76px 52px;
  gap: 8px;
  align-items: center;
  min-height: 39px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
}

.table-head {
  min-height: 34px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.event-row {
  background: #ffffff;
}

.event-row:hover,
.event-row.active {
  background: #eefafd;
}

.event-row.active {
  box-shadow: inset 4px 0 0 var(--blue);
}

.event-row button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  font-weight: 800;
}

.event-row strong,
.event-row .muted {
  display: block;
}

.event-row strong {
  line-height: 1.25;
}

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

.pill {
  justify-self: start;
  border-radius: 999px;
  padding: 4px 7px;
  font-size: 0.68rem;
  font-weight: 900;
}

.critical {
  background: #ffe4e1;
  color: #bc241b;
}

.high {
  background: #fff2d8;
  color: #9a5a00;
}

.medium {
  background: #e9f5ff;
  color: #18729a;
}

.ai-panel {
  min-height: 280px;
  background: linear-gradient(135deg, #ffffff 0%, #f5fbff 100%);
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
}

.risk-pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.risk-pill.critical {
  background: #ff5f57;
  color: #ffffff;
}

.risk-pill.high {
  background: #ffb84d;
  color: #3b2a00;
}

.risk-pill.medium {
  background: #19a7ce;
  color: #ffffff;
}

.ai-summary {
  margin: 12px 0;
  border: 1px solid #b9e8f2;
  border-radius: var(--radius);
  background: #ecfbff;
  padding: 14px;
  font-size: 0.95rem;
  line-height: 1.55;
}

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

.ai-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.ai-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.timeline {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 9px;
  font-size: 0.78rem;
}

.timeline-item strong {
  display: block;
  margin-bottom: 3px;
}

.bar-chart {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.bar-track {
  height: 18px;
  background: #e9edf5;
  border-radius: 999px;
  overflow: hidden;
}

.bar-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--purple));
}

.playbook-list,
.domain-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.api-response {
  overflow: auto;
  max-height: 260px;
  margin: 10px 0 0;
  border: 1px solid #2f3b4d;
  border-radius: var(--radius);
  background: #172033;
  color: #d8f7ff;
  padding: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.playbook-card,
.domain-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.playbook-card strong,
.domain-card strong {
  display: block;
  font-size: 0.86rem;
}

.playbook-card p,
.domain-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.health-meter {
  overflow: hidden;
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: #e4e9f1;
}

.health-meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: #263140;
  color: #ffffff;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px;
  }

  .status-strip {
    width: 100%;
    margin-left: 0;
  }

  .workspace {
    padding: 8px;
  }

  .metric-grid,
  .ai-grid {
    grid-template-columns: 1fr;
  }

  .table-head,
  .event-row {
    grid-template-columns: 68px minmax(0, 1fr) 58px;
  }

  .table-head span:nth-child(4),
  .event-row span:nth-child(4) {
    display: none;
  }
}
