:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #17202b;
  --muted: #647386;
  --line: rgba(23, 32, 43, 0.12);
  --blue: #2764a8;
  --teal: #16756d;
  --green: #2f7d4f;
  --amber: #b7791f;
  --red: #a64646;
  --violet: #6852a3;
  --shadow: 0 18px 44px rgba(19, 31, 44, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(247, 249, 251, 0.96) 0%, rgba(238, 242, 245, 0.98) 100%),
    linear-gradient(90deg, rgba(39, 100, 168, 0.05), rgba(22, 117, 109, 0.04));
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", Arial, sans-serif;
}

body.embed-mode {
  min-height: 0;
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

button,
select {
  font: inherit;
}

.demo-shell {
  width: min(1880px, calc(100vw - 28px));
  margin: 14px auto 28px;
}

body.embed-mode .demo-shell {
  width: min(1760px, calc(100vw - 16px));
  margin: 8px auto;
}

.demo-topbar,
.demo-panel,
.metric-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.demo-topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-radius: 8px;
}

.topbar-status {
  display: grid;
  justify-items: end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #e7f4ea;
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(47, 125, 79, 0.36);
  animation: livePulse 1.8s infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 125, 79, 0.36); }
  70% { box-shadow: 0 0 0 12px rgba(47, 125, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 125, 79, 0); }
}

.demo-kicker {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
}

.demo-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-control,
.speed-button,
.dashboard-link,
.demo-controls select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.icon-control {
  width: 44px;
  cursor: pointer;
  font-weight: 800;
}

.speed-group {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7fa;
}

.speed-button {
  min-width: 42px;
  height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.speed-button.active {
  background: var(--ink);
  color: #fff;
}

.demo-controls select {
  min-width: 168px;
  padding: 0 12px;
}

.dashboard-link {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

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

body.embed-mode .metrics-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 8px 0;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 82px;
  display: grid;
  align-content: space-between;
  padding: 14px;
  border-radius: 8px;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--blue);
}

.metric-card:nth-child(2)::before { background: var(--teal); }
.metric-card:nth-child(3)::before { background: var(--amber); }
.metric-card:nth-child(4)::before { background: var(--green); }
.metric-card:nth-child(5)::before { background: var(--violet); }
.metric-card:nth-child(6)::before { background: var(--ink); }

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.visual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 10px;
  margin-bottom: 10px;
}

.visual-panel {
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.visual-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

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

.domain-row,
.channel-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.domain-row-top,
.channel-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.domain-row-top strong,
.channel-row-top strong {
  font-size: 13px;
}

.domain-row-top span,
.channel-row-top span {
  color: var(--muted);
  font-size: 12px;
}

.domain-row p {
  min-height: 34px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.domain-state {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.domain-state span {
  padding: 5px 7px;
  border-radius: 8px;
  background: #eef4fa;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.domain-state span:nth-child(2) {
  background: #eef2f5;
  color: var(--muted);
}

.bar-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8edf2;
}

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

.slim-track {
  height: 6px;
  margin-top: 8px;
}

.channel-chart {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.channel-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
}

.demo-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1.35fr) 420px;
  grid-template-areas:
    "office screen feed"
    "office results feed";
  gap: 10px;
  align-items: start;
}

body.embed-mode .demo-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.7fr);
  grid-template-areas: "screen office";
}

.demo-panel {
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.screen-panel {
  border-color: rgba(16, 24, 32, 0.12);
}

.office-panel {
  grid-area: office;
}

.screen-panel {
  grid-area: screen;
}

.feed-panel {
  grid-area: feed;
}

.results-panel {
  grid-area: results;
}

body.embed-mode .feed-panel,
body.embed-mode .results-panel {
  display: none;
}

body.embed-mode .visual-grid {
  display: none;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profile-button,
.ai-team-pill {
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.ai-team-pill {
  display: inline-flex;
  align-items: center;
  background: #e7f4ea;
  color: var(--green);
  cursor: default;
}

.sync-pill,
.channel-pill,
.event-counter,
.review-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 8px;
  background: #eef4fa;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.review-pill {
  color: var(--amber);
  background: #fff7e8;
}

.assistant-list,
.feed-list,
.results-grid,
.task-stack {
  display: grid;
  gap: 10px;
}

body.embed-mode .assistant-list,
body.embed-mode .task-stack {
  gap: 8px;
}

body.embed-mode .assistant-list {
  align-content: start;
}

.assistant-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 14px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

body.embed-mode .assistant-row {
  padding: 10px;
  grid-template-columns: 38px minmax(0, 1fr) 12px;
  gap: 8px;
}

.assistant-row:hover {
  border-color: rgba(39, 100, 168, 0.32);
  background: #f4f8fc;
}

.assistant-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7f0f8;
  color: var(--blue);
  font-weight: 900;
}

.assistant-body {
  min-width: 0;
}

.assistant-head,
.mini-task-bottom,
.result-top,
.result-bottom,
.feed-head,
.screen-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.assistant-head {
  justify-content: flex-start;
}

.assistant-head strong,
.feed-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-head span,
.mini-task span,
.result-top span,
.result-bottom,
.feed-head span,
.screen-meta span {
  color: var(--muted);
  font-size: 12px;
}

.assistant-row p,
.mini-task p,
.result-tile p,
.feed-item p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.progress-track {
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8edf2;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  transition: width 300ms ease;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b8c2cc;
}

.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(47, 125, 79, 0.14);
}

.screen-subtitle {
  max-width: 78ch;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.screen-window {
  min-height: 350px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #101820;
  background: #101820;
  color: #e8eef4;
}

body.embed-mode .screen-window {
  min-height: 320px;
}

.window-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.window-bar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d86956;
}

.window-bar span:nth-child(2) {
  background: #d7a934;
}

.window-bar span:nth-child(3) {
  background: #48a36d;
}

.screen-meta {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.screen-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-lines {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.screen-line {
  min-height: 38px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #dbe6ef;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.task-stack {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

body.embed-mode .task-stack {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-task,
.result-tile {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.mini-task:hover,
.result-tile:hover,
.feed-item:hover {
  border-color: rgba(39, 100, 168, 0.3);
  background: #f7fbff;
}

.mini-task strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.25;
}

.mini-task-bottom,
.result-bottom {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.feed-list {
  max-height: 830px;
  overflow: auto;
  padding-right: 4px;
}

body.embed-mode .demo-topbar {
  min-height: 68px;
  padding: 12px 16px;
}

body.embed-mode h1 {
  font-size: 22px;
}

body.embed-mode .demo-kicker {
  margin-bottom: 4px;
}

body.embed-mode .visual-panel,
body.embed-mode .demo-panel,
body.embed-mode .metric-card {
  box-shadow: 0 12px 28px rgba(19, 31, 44, 0.07);
}

body.embed-mode .panel-title {
  margin-bottom: 10px;
}

body.embed-mode .panel-actions {
  gap: 6px;
}

body.embed-mode .profile-button {
  display: none;
}

body.embed-mode .assistant-row p,
body.embed-mode .mini-task p,
body.embed-mode .feed-item p,
body.embed-mode .screen-subtitle,
body.embed-mode .domain-row p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.embed-mode .metric-card {
  min-height: 72px;
  padding: 10px 12px 12px;
  gap: 4px;
}

body.embed-mode .metric-card strong {
  font-size: 18px;
}

body.embed-mode .metric-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

body.embed-mode .screen-panel .panel-title h2,
body.embed-mode .office-panel .panel-title h2 {
  font-size: 18px;
}

body.embed-mode .assistant-mark {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

body.embed-mode .assistant-head strong,
body.embed-mode .mini-task strong,
body.embed-mode .screen-meta strong {
  font-size: 13px;
}

body.embed-mode .assistant-row p,
body.embed-mode .mini-task p,
body.embed-mode .screen-line {
  font-size: 12px;
}

body.embed-mode .screen-lines {
  gap: 8px;
  margin-top: 10px;
}

body.embed-mode .screen-line {
  min-height: 34px;
  padding: 9px 10px;
}

body.embed-mode .screen-meta {
  padding: 9px 10px;
}

body.embed-mode .mini-task,
body.embed-mode .result-tile {
  padding: 10px;
}

body.embed-mode .task-stack {
  margin-top: 8px;
}

.feed-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.feed-item.current {
  border-color: rgba(39, 100, 168, 0.38);
  background: #f1f7fd;
}

.channel-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7f0f8;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.channel-mail,
.channel-ml {
  color: var(--blue);
  background: #e7f0f8;
}

.channel-slack,
.channel-sl {
  color: var(--violet);
  background: #eeeafa;
}

.channel-github,
.channel-gh {
  color: #222;
  background: #eceff2;
}

.channel-browser,
.channel-br {
  color: var(--teal);
  background: #e4f3f0;
}

.channel-docs,
.channel-do {
  color: var(--amber);
  background: #fff4d9;
}

.channel-db {
  color: var(--green);
  background: #e7f4ea;
}

.channel-calendar,
.channel-ca,
.channel-lms,
.channel-lm {
  color: var(--red);
  background: #faeaea;
}

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

.result-top strong {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 8px;
  background: #e7f4ea;
  color: var(--green);
  font-size: 13px;
}

.result-tile h3 {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.25;
}

.source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.source-row span {
  max-width: 100%;
  overflow: hidden;
  padding: 5px 7px;
  border-radius: 8px;
  background: #eef2f5;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 23, 34, 0.42);
  backdrop-filter: blur(8px);
}

.modal-backdrop.hidden {
  display: none;
}

.profiles-modal {
  width: min(1120px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 28px 70px rgba(12, 20, 30, 0.24);
}

.profiles-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.modal-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

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

.profile-card {
  min-height: 292px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.profile-top {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.profile-top h3 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.2;
}

.profile-top span,
.profile-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.profile-card p {
  min-height: 56px;
  margin-bottom: 12px;
}

.profile-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.profile-section strong {
  font-size: 13px;
}

.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-tags span {
  padding: 5px 7px;
  border-radius: 8px;
  background: #e7f0f8;
  color: var(--blue);
  font-size: 12px;
}

.profile-tags.muted-tags span {
  background: #eef2f5;
  color: var(--muted);
}

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

  .demo-grid {
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-areas:
      "office screen"
      "feed results";
  }

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

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

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

  .feed-list {
    max-height: 620px;
  }
}

@media (max-width: 980px) {
  .demo-shell {
    width: min(100vw - 16px, 100%);
    margin-top: 8px;
  }

  .demo-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-status {
    justify-items: start;
  }

  .demo-controls {
    justify-content: flex-start;
  }

  .panel-title,
  .panel-actions {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .metrics-strip,
  .visual-grid,
  .domain-chart,
  .channel-chart,
  .demo-grid,
  .task-stack,
  .results-grid,
  .profiles-grid {
    grid-template-columns: 1fr;
  }

  .demo-grid {
    grid-template-areas:
      "office"
      "screen"
      "feed"
      "results";
  }

  .feed-list {
    max-height: none;
  }

  .profiles-modal {
    padding: 14px;
  }
}

@media (max-width: 1360px) {
  body.embed-mode {
    overflow: auto;
  }

  body.embed-mode .demo-topbar {
    align-items: center;
    flex-direction: row;
  }

  body.embed-mode .topbar-status {
    justify-items: end;
  }

  body.embed-mode .metrics-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.embed-mode .demo-grid {
    grid-template-columns: minmax(0, 1fr) 250px;
    grid-template-areas: "screen office";
  }

  body.embed-mode .task-stack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  body.embed-mode .metrics-strip,
  body.embed-mode .demo-grid,
  body.embed-mode .task-stack {
    grid-template-columns: 1fr;
  }

  body.embed-mode .demo-grid {
    grid-template-areas:
      "screen"
      "office";
  }
}
